/*******************************************************************************
- * Copyright (c) 2009, 2010, 2012 Ericsson
+ * Copyright (c) 2009, 2010, 2012, 2013 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* Contributors:
* Francois Chouinard - Initial API and implementation
* Francois Chouinard - Adjusted for new Event Model
+ * Alexandre Montplaisir - Port to JUnit4
*******************************************************************************/
package org.eclipse.linuxtools.tmf.core.tests.event;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
+import org.junit.Test;
/**
* Test suite for the TmfTimeRange class.
*/
-@SuppressWarnings("nls")
-public class TmfTimeRangeTest extends TestCase {
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- /**
- * @param name the test name
- */
- public TmfTimeRangeTest(final String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
+@SuppressWarnings({"nls", "javadoc"})
+public class TmfTimeRangeTest {
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
- /**
- *
- */
+ @Test
public void testConstructor() {
final ITmfTimestamp ts1 = new TmfTimestamp(12345);
final ITmfTimestamp ts2 = new TmfTimestamp(12350);
assertEquals("endTime", ts2, range.getEndTime());
}
- /**
- *
- */
+ @Test
public void testBadConstructor() {
try {
new TmfTimeRange(TmfTimestamp.BIG_BANG, null);
}
}
- /**
- *
- */
+ @Test
public void testOpenRange1() {
final ITmfTimestamp ts2 = new TmfTimestamp(12350);
final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, ts2);
assertEquals("endTime", ts2, range.getEndTime());
}
- /**
- *
- */
+ @Test
public void testOpenRange2() {
final ITmfTimestamp ts1 = new TmfTimestamp(12345);
final TmfTimeRange range = new TmfTimeRange(ts1, TmfTimestamp.BIG_CRUNCH);
assertEquals("endTime", TmfTimestamp.BIG_CRUNCH, range.getEndTime());
}
- /**
- *
- */
+ @Test
public void testOpenRange3() {
final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
assertEquals("endTime", TmfTimestamp.BIG_CRUNCH, range.getEndTime());
}
- /**
- *
- */
+ @Test
public void testCopyConstructor() {
final ITmfTimestamp ts1 = new TmfTimestamp(12345);
final ITmfTimestamp ts2 = new TmfTimestamp(12350);
assertEquals("endTime", TmfTimestamp.BIG_CRUNCH, range3.getEndTime());
}
- /**
- *
- */
+ @Test
public void testCopyConstructor2() {
try {
new TmfTimeRange(null);
// hashCode
// ------------------------------------------------------------------------
- /**
- *
- */
+ @Test
public void testHashCode() {
final ITmfTimestamp ts1 = new TmfTimestamp(12345);
final ITmfTimestamp ts2 = new TmfTimestamp(12350);
// equals
// ------------------------------------------------------------------------
- /**
- *
- */
+ @Test
public void testEqualsReflexivity() {
final ITmfTimestamp ts1 = new TmfTimestamp(12345);
final ITmfTimestamp ts2 = new TmfTimestamp(12350);
assertTrue("equals", !range2.equals(range1));
}
- /**
- *
- */
+ @Test
public void testEqualsSymmetry() {
final ITmfTimestamp ts1 = new TmfTimestamp(12345);
final ITmfTimestamp ts2 = new TmfTimestamp(12350);
assertTrue("equals", range2b.equals(range2a));
}
- /**
- *
- */
+ @Test
public void testEqualsTransivity() {
final ITmfTimestamp ts1 = new TmfTimestamp(12345);
final ITmfTimestamp ts2 = new TmfTimestamp(12350);
assertTrue("equals", range1a.equals(range1c));
}
- /**
- *
- */
+ @Test
public void testEqualsNull() {
final ITmfTimestamp ts1 = new TmfTimestamp(12345);
final ITmfTimestamp ts2 = new TmfTimestamp(12350);
assertTrue("equals", !range1.equals(null));
}
- /**
- *
- */
+ @Test
public void testEqualsBadType() {
final ITmfTimestamp ts1 = new TmfTimestamp(12345);
final ITmfTimestamp ts2 = new TmfTimestamp(12350);
assertTrue("equals", !range1.equals(ts1));
}
- /**
- *
- */
+ @Test
public void testEqualStartTime() {
final ITmfTimestamp ts1 = new TmfTimestamp(12345);
final ITmfTimestamp ts2 = new TmfTimestamp(12350);
assertTrue("equals", !range1.equals(range3));
}
- /**
- *
- */
+ @Test
public void testEqualsEndTime() {
final ITmfTimestamp ts1 = new TmfTimestamp(12345);
final ITmfTimestamp ts2 = new TmfTimestamp(12350);
// toString
// ------------------------------------------------------------------------
- /**
- *
- */
+ @Test
public void testToString() {
final ITmfTimestamp ts1 = new TmfTimestamp(12345);
final ITmfTimestamp ts2 = new TmfTimestamp(12350);
// contains
// ------------------------------------------------------------------------
- /**
- *
- */
+ @Test
public void testContainsTimestamp() {
final ITmfTimestamp ts1 = new TmfTimestamp(12345);
final ITmfTimestamp ts2 = new TmfTimestamp(12350);
assertTrue("contains (zero)", range.contains(TmfTimestamp.ZERO));
}
- /**
- *
- */
+ @Test
public void testContainsRange() {
final ITmfTimestamp ts1 = new TmfTimestamp(10);
final ITmfTimestamp ts2 = new TmfTimestamp(20);
// getIntersection
// ------------------------------------------------------------------------
- /**
- *
- */
+ @Test
public void testGetIntersection() {
final ITmfTimestamp ts1a = new TmfTimestamp(1000);