ss: Move plugins to Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core.tests / src / org / eclipse / linuxtools / tmf / core / tests / event / TmfTimeRangeTest.java
index a3e3e390cb196d78ec2a991ffa353b741ffaaea2..ba7a99db46d7f9b2290b9aa4785304c08f44feea 100644 (file)
@@ -1,53 +1,41 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2010, 2012 Ericsson
- * 
+ * Copyright (c) 2009, 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
  * accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
- * 
+ *
  * 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.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
+import org.junit.Test;
 
 /**
  * Test suite for the TmfTimeRange class.
  */
-@SuppressWarnings("nls")
-public class TmfTimeRangeTest extends TestCase {
-
-    // ------------------------------------------------------------------------
-    // Housekeeping
-    // ------------------------------------------------------------------------
-
-    public TmfTimeRangeTest(final String name) {
-        super(name);
-    }
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-    }
+@SuppressWarnings("javadoc")
+public class TmfTimeRangeTest {
 
     // ------------------------------------------------------------------------
     // Constructors
     // ------------------------------------------------------------------------
 
-    public void testConstructor() throws Exception {
+    @Test
+    public void testConstructor() {
         final ITmfTimestamp ts1 = new TmfTimestamp(12345);
         final ITmfTimestamp ts2 = new TmfTimestamp(12350);
         final TmfTimeRange range = new TmfTimeRange(ts1, ts2);
@@ -56,7 +44,8 @@ public class TmfTimeRangeTest extends TestCase {
         assertEquals("endTime", ts2, range.getEndTime());
     }
 
-    public void testBadConstructor() throws Exception {
+    @Test
+    public void testBadConstructor() {
         try {
             new TmfTimeRange(TmfTimestamp.BIG_BANG, null);
             fail("TmfTimeRange: bad end time");
@@ -72,7 +61,8 @@ public class TmfTimeRangeTest extends TestCase {
         }
     }
 
-    public void testOpenRange1() throws Exception {
+    @Test
+    public void testOpenRange1() {
         final ITmfTimestamp ts2 = new TmfTimestamp(12350);
         final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, ts2);
 
@@ -80,7 +70,8 @@ public class TmfTimeRangeTest extends TestCase {
         assertEquals("endTime", ts2, range.getEndTime());
     }
 
-    public void testOpenRange2() throws Exception {
+    @Test
+    public void testOpenRange2() {
         final ITmfTimestamp ts1 = new TmfTimestamp(12345);
         final TmfTimeRange range = new TmfTimeRange(ts1, TmfTimestamp.BIG_CRUNCH);
 
@@ -88,14 +79,16 @@ public class TmfTimeRangeTest extends TestCase {
         assertEquals("endTime", TmfTimestamp.BIG_CRUNCH, range.getEndTime());
     }
 
-    public void testOpenRange3() throws Exception {
+    @Test
+    public void testOpenRange3() {
         final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
 
         assertEquals("startTime", TmfTimestamp.BIG_BANG, range.getStartTime());
         assertEquals("endTime", TmfTimestamp.BIG_CRUNCH, range.getEndTime());
     }
 
-    public void testCopyConstructor() throws Exception {
+    @Test
+    public void testCopyConstructor() {
         final ITmfTimestamp ts1 = new TmfTimestamp(12345);
         final ITmfTimestamp ts2 = new TmfTimestamp(12350);
         final TmfTimeRange range0 = new TmfTimeRange(ts1, ts2);
@@ -111,7 +104,8 @@ public class TmfTimeRangeTest extends TestCase {
         assertEquals("endTime", TmfTimestamp.BIG_CRUNCH, range3.getEndTime());
     }
 
-    public void testCopyConstructor2() throws Exception {
+    @Test
+    public void testCopyConstructor2() {
         try {
             new TmfTimeRange(null);
             fail("TmfTimeRange: null argument");
@@ -120,30 +114,12 @@ public class TmfTimeRangeTest extends TestCase {
         }
     }
 
-    // ------------------------------------------------------------------------
-    // clone
-    // ------------------------------------------------------------------------
-
-    public void testClone() throws Exception {
-        final ITmfTimestamp ts1 = new TmfTimestamp(12345);
-        final ITmfTimestamp ts2 = new TmfTimestamp(12350);
-
-        final TmfTimeRange range = new TmfTimeRange(ts1, ts2);
-        final TmfTimeRange clone = range.clone();
-
-        assertTrue("clone", range.clone().equals(range));
-        assertTrue("clone", clone.clone().equals(clone));
-
-        assertEquals("clone", range, clone);
-        assertEquals("clone", ts1, clone.getStartTime());
-        assertEquals("clone", ts2, clone.getEndTime());
-    }
-
     // ------------------------------------------------------------------------
     // hashCode
     // ------------------------------------------------------------------------
 
-    public void testHashCode() throws Exception {
+    @Test
+    public void testHashCode() {
         final ITmfTimestamp ts1 = new TmfTimestamp(12345);
         final ITmfTimestamp ts2 = new TmfTimestamp(12350);
         final TmfTimeRange range1 = new TmfTimeRange(ts1, ts2);
@@ -161,7 +137,8 @@ public class TmfTimeRangeTest extends TestCase {
     // equals
     // ------------------------------------------------------------------------
 
-    public void testEqualsReflexivity() throws Exception {
+    @Test
+    public void testEqualsReflexivity() {
         final ITmfTimestamp ts1 = new TmfTimestamp(12345);
         final ITmfTimestamp ts2 = new TmfTimestamp(12350);
         final TmfTimeRange range1 = new TmfTimeRange(ts1, ts2);
@@ -174,7 +151,8 @@ public class TmfTimeRangeTest extends TestCase {
         assertTrue("equals", !range2.equals(range1));
     }
 
-    public void testEqualsSymmetry() throws Exception {
+    @Test
+    public void testEqualsSymmetry() {
         final ITmfTimestamp ts1 = new TmfTimestamp(12345);
         final ITmfTimestamp ts2 = new TmfTimestamp(12350);
         final TmfTimeRange range1a = new TmfTimeRange(ts1, ts2);
@@ -190,7 +168,8 @@ public class TmfTimeRangeTest extends TestCase {
         assertTrue("equals", range2b.equals(range2a));
     }
 
-    public void testEqualsTransivity() throws Exception {
+    @Test
+    public void testEqualsTransivity() {
         final ITmfTimestamp ts1 = new TmfTimestamp(12345);
         final ITmfTimestamp ts2 = new TmfTimestamp(12350);
         final TmfTimeRange range1a = new TmfTimeRange(ts1, ts2);
@@ -202,7 +181,8 @@ public class TmfTimeRangeTest extends TestCase {
         assertTrue("equals", range1a.equals(range1c));
     }
 
-    public void testEqualsNull() throws Exception {
+    @Test
+    public void testEqualsNull() {
         final ITmfTimestamp ts1 = new TmfTimestamp(12345);
         final ITmfTimestamp ts2 = new TmfTimestamp(12350);
         final TmfTimeRange range1 = new TmfTimeRange(ts1, ts2);
@@ -210,7 +190,8 @@ public class TmfTimeRangeTest extends TestCase {
         assertTrue("equals", !range1.equals(null));
     }
 
-    public void testEqualsBadType() throws Exception {
+    @Test
+    public void testEqualsBadType() {
         final ITmfTimestamp ts1 = new TmfTimestamp(12345);
         final ITmfTimestamp ts2 = new TmfTimestamp(12350);
         final TmfTimeRange range1 = new TmfTimeRange(ts1, ts2);
@@ -218,7 +199,8 @@ public class TmfTimeRangeTest extends TestCase {
         assertTrue("equals", !range1.equals(ts1));
     }
 
-    public void testEqualStartTime() throws Exception {
+    @Test
+    public void testEqualStartTime() {
         final ITmfTimestamp ts1 = new TmfTimestamp(12345);
         final ITmfTimestamp ts2 = new TmfTimestamp(12350);
         final ITmfTimestamp ts3 = new TmfTimestamp(12355);
@@ -231,7 +213,8 @@ public class TmfTimeRangeTest extends TestCase {
         assertTrue("equals", !range1.equals(range3));
     }
 
-    public void testEqualsEndTime() throws Exception {
+    @Test
+    public void testEqualsEndTime() {
         final ITmfTimestamp ts1 = new TmfTimestamp(12345);
         final ITmfTimestamp ts2 = new TmfTimestamp(12350);
         final ITmfTimestamp ts3 = new TmfTimestamp(12355);
@@ -248,7 +231,8 @@ public class TmfTimeRangeTest extends TestCase {
     // toString
     // ------------------------------------------------------------------------
 
-    public void testToString() throws Exception {
+    @Test
+    public void testToString() {
         final ITmfTimestamp ts1 = new TmfTimestamp(12345);
         final ITmfTimestamp ts2 = new TmfTimestamp(12350);
         final TmfTimeRange range = new TmfTimeRange(ts1, ts2);
@@ -261,7 +245,8 @@ public class TmfTimeRangeTest extends TestCase {
     // contains
     // ------------------------------------------------------------------------
 
-    public void testContainsTimestamp() throws Exception {
+    @Test
+    public void testContainsTimestamp() {
         final ITmfTimestamp ts1 = new TmfTimestamp(12345);
         final ITmfTimestamp ts2 = new TmfTimestamp(12350);
         final TmfTimeRange range = new TmfTimeRange(ts1, ts2);
@@ -272,11 +257,10 @@ public class TmfTimeRangeTest extends TestCase {
 
         assertFalse("contains (low value)", range.contains(new TmfTimestamp(12340)));
         assertFalse("contains (high value)", range.contains(new TmfTimestamp(12351)));
-
-        assertTrue("contains (zero)", range.contains(TmfTimestamp.ZERO));
     }
 
-    public void testContainsRange() throws Exception {
+    @Test
+    public void testContainsRange() {
         final ITmfTimestamp ts1 = new TmfTimestamp(10);
         final ITmfTimestamp ts2 = new TmfTimestamp(20);
         final ITmfTimestamp ts3 = new TmfTimestamp(30);
@@ -329,7 +313,8 @@ public class TmfTimeRangeTest extends TestCase {
     // getIntersection
     // ------------------------------------------------------------------------
 
-    public void testGetIntersection() throws Exception {
+    @Test
+    public void testGetIntersection() {
 
         final ITmfTimestamp ts1a = new TmfTimestamp(1000);
         final ITmfTimestamp ts1b = new TmfTimestamp(2000);
This page took 0.042211 seconds and 5 git commands to generate.