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;
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 {
// ------------------------------------------------------------------------
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();
}
}
+ // ------------------------------------------------------------------------
+ // 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
// ------------------------------------------------------------------------
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
// ------------------------------------------------------------------------