Rename xxx.lttng to xxx.lttng.core
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.tests / src / org / eclipse / linuxtools / tmf / tests / event / TmfEventContentTest.java
index 39102259034b887f36f5f37febb8028da7afb34a..fbfbf6121c6b4e2e64d13eb7068ba81d6c262183 100644 (file)
@@ -12,6 +12,8 @@
 
 package org.eclipse.linuxtools.tmf.tests.event;
 
+import junit.framework.TestCase;
+
 import org.eclipse.linuxtools.tmf.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.event.TmfEventContent;
 import org.eclipse.linuxtools.tmf.event.TmfEventContentStub;
@@ -22,13 +24,12 @@ import org.eclipse.linuxtools.tmf.event.TmfEventTypeStub;
 import org.eclipse.linuxtools.tmf.event.TmfNoSuchFieldException;
 import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
 
-import junit.framework.TestCase;
-
 /**
  * <b><u>TmfEventContentTest</u></b>
  * <p>
  * Test suite for the TmfEventContent class.
  */
+@SuppressWarnings("nls")
 public class TmfEventContentTest extends TestCase {
 
        // ------------------------------------------------------------------------
@@ -61,7 +62,7 @@ public class TmfEventContentTest extends TestCase {
        public TmfEventContentTest(String name) {
                super(name);
                fTimestamp     = new TmfTimestamp();
-               fEventSource   = new TmfEventSource();
+               fEventSource   = new TmfEventSource(new Object());
                fEventType     = new TmfEventType();
                fEventTypeStub = new TmfEventTypeStub();
                fReference     = new TmfEventReference();
@@ -112,6 +113,23 @@ public class TmfEventContentTest extends TestCase {
                }
        }
 
+       // ------------------------------------------------------------------------
+       // setEvent
+       // ------------------------------------------------------------------------
+
+       public void testSetEvent() {
+               TmfEvent event = new TmfEvent(fTimestamp, fEventSource, fEventType, fReference);
+               TmfEventContent content1 = new TmfEventContent(event, fRawContent0);
+               event.setContent(content1);
+               TmfEventContent content2 = new TmfEventContent(null, fRawContent1);
+
+               content2.setEvent(event);
+
+               assertEquals("setEvent", event, content2.getEvent());
+//             assertEquals("setEvent", content2, event.getContent());
+//             assertEquals("setEvent", null, content1.getEvent());
+       }
+
        // ------------------------------------------------------------------------
        // equals
        // ------------------------------------------------------------------------
@@ -143,19 +161,35 @@ public class TmfEventContentTest extends TestCase {
                assertTrue("equals", fBasicContent0.equals(fBasicContent2));
        }
        
-       public void testEqualsConsistency() throws Exception {
-               assertTrue("equals", fBasicContent0.equals(fBasicContent0));
-               assertTrue("equals", fBasicContent0.equals(fBasicContent0));
-
-               assertTrue("equals", fStubContent.equals(fStubContent));
-               assertTrue("equals", fStubContent.equals(fStubContent));
-       }
-       
        public void testEqualsNull() throws Exception {
                assertTrue("equals", !fBasicContent0.equals(null));
                assertTrue("equals", !fStubContent.equals(null));
        }
        
+       // ------------------------------------------------------------------------
+       // hashCode
+       // ------------------------------------------------------------------------
+
+       public void testHashCode() throws Exception {
+               assertTrue("hashCode", fBasicContent0.hashCode() == fBasicContent2.hashCode());
+               assertTrue("hashCode", fBasicContent0.hashCode() != fStubContent.hashCode());
+       }
+       
+       public void testHashCode2() throws Exception {
+               TmfEventContent basicContent0 = new TmfEventContent(null, fRawContent0);
+               TmfEventContent basicContent1 = new TmfEventContent(fEvent, null);
+               TmfEventContent basicContent2 = new TmfEventContent(null, null);
+
+               assertTrue("hashCode", fBasicContent0.hashCode() != basicContent0.hashCode());
+               assertTrue("hashCode", fBasicContent0.hashCode() != basicContent1.hashCode());
+               assertTrue("hashCode", fBasicContent0.hashCode() != basicContent2.hashCode());
+
+               assertTrue("hashCode", basicContent0.hashCode() != basicContent1.hashCode());
+               assertTrue("hashCode", basicContent0.hashCode() != basicContent2.hashCode());
+
+               assertTrue("hashCode", basicContent1.hashCode() != basicContent2.hashCode());
+       }
+       
        // ------------------------------------------------------------------------
        // toString
        // ------------------------------------------------------------------------
This page took 0.024963 seconds and 5 git commands to generate.