tmf: Port tmf.ui unit tests to JUnit4
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Tue, 29 Jan 2013 18:20:37 +0000 (13:20 -0500)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Tue, 5 Feb 2013 23:06:26 +0000 (18:06 -0500)
Last part of bug 393449.

Split up some Sequence Diagram unit test methods in separate
test cases, now that we can use @BeforeClass.

Change-Id: I7416241ccb82b4825f6c790e655b276b5c1655ef
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/10119
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
IP-Clean: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Hudson CI
22 files changed:
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/AllTmfUITests.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/histogram/AllTests.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/histogram/HistogramDataModelTest.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/AllTests.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseColumnDataTest.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseStatisticsDataTest.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfStatisticsTest.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfStatisticsTreeManagerTest.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfStatisticsTreeNodeTest.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfTreeContentProviderTest.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/dialogs/AllTests.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/dialogs/CriteriaTest.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/load/AllTests.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/load/LoadersManagerTest.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/AllTests.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderExpTest.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderFilterTest.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderFindTest.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderPagesTest.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderSignalTest.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderTimeTest.java

index 2759bf61e68eec1fa8e8e113bfc7b4462604e254..743364d56fd96e6faecab995623e6ace2c8e1c1a 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011, 2012 Ericsson
+ * Copyright (c) 2011-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
  *   Bernd Hufmann - Initial API and implementation
  *   Bernd Hufmann - Add UML2SD tests
  *   Mathieu Denis <mathieu.denis@polymtl.ca> - Add Statistics test
+ *   Alexandre Montplaisir - Port to JUnit4
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.ui.tests;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
 
 /**
- * <b><u>AllTmfUITests</u></b>
- *
  * Master test suite for TMF UI Core.
  */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+    org.eclipse.linuxtools.tmf.ui.tests.histogram.AllTests.class,
+    org.eclipse.linuxtools.tmf.ui.tests.statistics.AllTests.class,
+    org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.dialogs.AllTests.class,
+    org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.load.AllTests.class,
+    org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.loader.AllTests.class
+})
 public class AllTmfUITests {
 
-    /**
-     * @return the TMF UI test suite
-     */
-    public static Test suite() {
-        TestSuite suite = new TestSuite(AllTmfUITests.class.getName());
-        // $JUnit-BEGIN$
-        suite.addTest(org.eclipse.linuxtools.tmf.ui.tests.statistics.AllTests.suite());
-        suite.addTest(org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.dialogs.AllTests.suite());
-        suite.addTest(org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.loader.AllTests.suite());
-        suite.addTest(org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.load.AllTests.suite());
-        suite.addTest(org.eclipse.linuxtools.tmf.ui.tests.histogram.AllTests.suite());
-        // $JUnit-END$
-        return suite;
-    }
 }
index dc5bb9791bff89b1b3fbb01a1352452db0550a5c..c4afae7b79e4f97711392b4f39fc5ff8f2426125 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011 Ericsson
+ * Copyright (c) 2011, 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
@@ -8,27 +8,21 @@
  *
  * Contributors:
  *   Bernd Hufmann - Initial API and implementation
+ *   Alexandre Montplaisir - Port to JUnit4
  *******************************************************************************/
+
 package org.eclipse.linuxtools.tmf.ui.tests.histogram;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
 
 /**
- *
  * Test suite class for histogram tests.
  */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+    HistogramDataModelTest.class
+})
 public class AllTests {
 
-    /**
-     * @return the test suite
-     */
-    public static Test suite() {
-
-        TestSuite suite = new TestSuite(AllTests.class.getName());
-        //$JUnit-BEGIN$
-        suite.addTestSuite(HistogramDataModelTest.class);
-        //$JUnit-END$
-        return suite;
-    }
 }
index 21bdfb76b4cd901b186e7515f69c98f404c6cc78..f0076acf330d074eb4105efcb0c3ed59edd85525 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011 Ericsson
+ * Copyright (c) 2011, 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
@@ -9,47 +9,31 @@
  * Contributors:
  *   Francois Chouinard - Initial API and implementation
  *   Bernd Hufmann - Adapt to junit.framework.TestCase
+ *   Alexandre Montplaisir - Port to JUnit4
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.ui.tests.histogram;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel;
 import org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramScaledData;
 import org.eclipse.linuxtools.tmf.ui.views.histogram.IHistogramModelListener;
+import org.junit.Test;
 
 /**
- *
  * Unit tests for the HistogramDataModel class.
  */
-public class HistogramDataModelTest extends TestCase {
-
-    // ------------------------------------------------------------------------
-    // Test data
-    // ------------------------------------------------------------------------
+public class HistogramDataModelTest {
 
-    // ------------------------------------------------------------------------
-    // Housekeeping
-    // ------------------------------------------------------------------------
-
-    @Override
-    public void setUp() throws Exception {
-    }
-
-    @Override
-    public void tearDown() throws Exception {
-    }
-
-    // ------------------------------------------------------------------------
-    // Tests
-    // ------------------------------------------------------------------------
+    private static final double DELTA = 1e-15;
 
     /**
-     * Test method for
-     * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#HistogramDataModel()}
-     * .
+     * Test method for {@link HistogramDataModel#HistogramDataModel()}.
      */
+    @Test
     public void testHistogramDataModel() {
         HistogramDataModel model = new HistogramDataModel();
         assertTrue(model.getNbBuckets() == HistogramDataModel.DEFAULT_NUMBER_OF_BUCKETS);
@@ -62,10 +46,9 @@ public class HistogramDataModelTest extends TestCase {
     }
 
     /**
-     * Test method for
-     * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#HistogramDataModel(int)}
-     * .
+     * Test method for {@link HistogramDataModel#HistogramDataModel(int)}.
      */
+    @Test
     public void testHistogramDataModelInt() {
         final int nbBuckets = 5 * 1000;
         HistogramDataModel model = new HistogramDataModel(nbBuckets);
@@ -79,10 +62,9 @@ public class HistogramDataModelTest extends TestCase {
     }
 
     /**
-     * Test methods for
-     * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#countEvent(long,long)}
-     * .
+     * Test methods for {@link HistogramDataModel#countEvent(long,long)}.
      */
+    @Test
     public void testClear() {
         final int nbBuckets = 100;
         HistogramDataModel model = new HistogramDataModel(nbBuckets);
@@ -98,10 +80,9 @@ public class HistogramDataModelTest extends TestCase {
     }
 
     /**
-     * Test methods for
-     * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#countEvent(long,long)}
-     * .
+     * Test methods for {@link HistogramDataModel#countEvent(long,long)}.
      */
+    @Test
     public void testCountEvent_0() {
         final int nbBuckets = 100;
         HistogramDataModel model = new HistogramDataModel(nbBuckets);
@@ -117,13 +98,11 @@ public class HistogramDataModelTest extends TestCase {
     }
 
     /**
-     * Test methods for
-     * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#countEvent(long,long)}
-     * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
-     * .
+     * Test methods for {@link HistogramDataModel#countEvent(long,long)} and
+     * {@link HistogramDataModel#scaleTo(int,int,int)}.
      */
+    @Test
     public void testCountEvent_1() {
-
         final int nbBuckets = 100;
         final int maxHeight = 10;
 
@@ -144,11 +123,10 @@ public class HistogramDataModelTest extends TestCase {
     }
 
     /**
-     * Test methods for
-     * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#countEvent(long,long)}
-     * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
-     * .
+     * Test methods for {@link HistogramDataModel#countEvent(long,long)} and
+     * {@link HistogramDataModel#scaleTo(int,int,int)}.
      */
+    @Test
     public void testCountEvent_2() {
         final int nbBuckets = 100;
         final int maxHeight = 10;
@@ -172,11 +150,10 @@ public class HistogramDataModelTest extends TestCase {
     }
 
     /**
-     * Test methods for
-     * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#countEvent(long,long)}
-     * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
-     * .
+     * Test methods for {@link HistogramDataModel#countEvent(long,long)} and
+     * {@link HistogramDataModel#scaleTo(int,int,int)}.
      */
+    @Test
     public void testCountEvent_3() {
         final int nbBuckets = 100;
         final int maxHeight = 10;
@@ -201,11 +178,10 @@ public class HistogramDataModelTest extends TestCase {
     }
 
     /**
-     * Test methods for
-     * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#countEvent(long,long)}
-     * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
-     * .
+     * Test methods for {@link HistogramDataModel#countEvent(long,long)} and
+     * {@link HistogramDataModel#scaleTo(int,int,int)}.
      */
+    @Test
     public void testCountEvent_4() {
         final int nbBuckets = 100;
         final int maxHeight = 10;
@@ -231,11 +207,10 @@ public class HistogramDataModelTest extends TestCase {
     }
 
     /**
-     * Test methods for
-     * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#countEvent(long,long)}
-     * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
-     * .
+     * Test methods for {@link HistogramDataModel#countEvent(long,long)} and
+     * {@link HistogramDataModel#scaleTo(int,int,int)}.
      */
+    @Test
     public void testCountEvent_5() {
         final int nbBuckets = 100;
         final int startTime = 25;
@@ -261,10 +236,9 @@ public class HistogramDataModelTest extends TestCase {
     }
 
     /**
-     * Test method for
-     * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
-     * .
+     * Test method for {@link HistogramDataModel#scaleTo(int,int,int)}.
      */
+    @Test
     public void testScaleTo_0() {
         HistogramDataModel model = new HistogramDataModel(10);
         try {
@@ -283,15 +257,13 @@ public class HistogramDataModelTest extends TestCase {
                 }
             }
         }
-
         fail("Uncaught assertion error"); //$NON-NLS-1$
     }
 
     /**
-     * Test method for
-     * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
-     * .
+     * Test method for {@link HistogramDataModel#scaleTo(int,int,int)}.
      */
+    @Test
     public void testScaleTo_1() {
         final int nbBuckets = 10;
         final int maxHeight = 10;
@@ -318,10 +290,9 @@ public class HistogramDataModelTest extends TestCase {
     }
 
     /**
-     * Test method for
-     * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
-     * .
+     * Test method for {@link HistogramDataModel#scaleTo(int,int,int)}.
      */
+    @Test
     public void testScaleTo_2() {
         final int nbBuckets = 10;
         final int maxHeight = 10;
@@ -348,10 +319,9 @@ public class HistogramDataModelTest extends TestCase {
     }
 
     /**
-     * Test method for
-     * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
-     * .
+     * Test method for {@link HistogramDataModel#scaleTo(int,int,int)}.
      */
+    @Test
     public void testScaleTo_3() {
         final int nbBuckets = 10;
         final int maxHeight = 10;
@@ -378,10 +348,9 @@ public class HistogramDataModelTest extends TestCase {
     }
 
     /**
-     * Test method for
-     * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
-     * .
+     * Test method for {@link HistogramDataModel#scaleTo(int,int,int)}.
      */
+    @Test
     public void testScaleTo_4() {
         final int nbBuckets = 10;
         final int maxHeight = 10;
@@ -408,10 +377,9 @@ public class HistogramDataModelTest extends TestCase {
     }
 
     /**
-     * Test method for
-     * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
-     * .
+     * Test method for {@link HistogramDataModel#scaleTo(int,int,int)}.
      */
+    @Test
     public void testScaleTo_5() {
         final int nbBuckets = 100;
         final int maxHeight = 20;
@@ -437,10 +405,9 @@ public class HistogramDataModelTest extends TestCase {
     }
 
     /**
-     * Test method for
-     * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
-     * .
+     * Test method for {@link HistogramDataModel#scaleTo(int,int,int)}.
      */
+    @Test
     public void testScaleTo_6() {
         final int nbBuckets = 100;
         final int maxHeight = 24;
@@ -467,10 +434,9 @@ public class HistogramDataModelTest extends TestCase {
     }
 
     /**
-     * Test method for
-     * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
-     * .
+     * Test method for {@link HistogramDataModel#scaleTo(int,int,int)}.
      */
+    @Test
     public void testScaleTo_7() {
         // verify scaleTo with barWidth > 1
         final int nbBuckets = 100;
@@ -502,7 +468,7 @@ public class HistogramDataModelTest extends TestCase {
         assertEquals(0, result.fFirstEventTime);
         assertEquals(1, result.fLastBucket);
         assertEquals(104, result.fMaxValue);
-        assertEquals((double)maxHeight/104, result.fScalingFactor);
+        assertEquals((double)maxHeight/104, result.fScalingFactor, DELTA);
         assertEquals(maxHeight, result.fHeight);
         assertEquals(width, result.fWidth);
         assertEquals(barWidth, result.fBarWidth);
@@ -522,10 +488,9 @@ public class HistogramDataModelTest extends TestCase {
     }
 
     /**
-     * Test method for
-     * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
-     * .
+     * Test method for {@link HistogramDataModel#scaleTo(int,int,int)}.
      */
+    @Test
     public void testScaleToReverse_1() {
         final int nbBuckets = 100;
         final int maxHeight = 24;
@@ -554,7 +519,7 @@ public class HistogramDataModelTest extends TestCase {
         assertEquals(0, result.fFirstEventTime);
         assertEquals(9, result.fLastBucket);
         assertEquals(24, result.fMaxValue);
-        assertEquals((double)maxHeight/24, result.fScalingFactor);
+        assertEquals((double)maxHeight/24, result.fScalingFactor, DELTA);
         assertEquals(maxHeight, result.fHeight);
         assertEquals(width, result.fWidth);
         assertEquals(barWidth, result.fBarWidth);
@@ -574,10 +539,9 @@ public class HistogramDataModelTest extends TestCase {
     }
 
     /**
-     * Test method for
-     * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
-     * .
+     * Test method for {@link HistogramDataModel#scaleTo(int,int,int)}.
      */
+    @Test
     public void testScaleToReverse_2() {
         final int nbBuckets = 100;
         final int maxHeight = 24;
@@ -614,7 +578,7 @@ public class HistogramDataModelTest extends TestCase {
         assertEquals(result.fCurrentBucket, revResult.fCurrentBucket);
         assertEquals(result.fFirstBucketTime, revResult.fFirstBucketTime);
         assertEquals(result.fMaxValue, revResult.fMaxValue);
-        assertEquals(result.fScalingFactor, revResult.fScalingFactor);
+        assertEquals(result.fScalingFactor, revResult.fScalingFactor, DELTA);
         assertEquals(result.fLastBucket, revResult.fLastBucket);
         assertEquals(result.getBucketEndTime(0), revResult.getBucketEndTime(0));
         assertEquals(result.getBucketStartTime(0), revResult.getBucketStartTime(0));
@@ -627,6 +591,7 @@ public class HistogramDataModelTest extends TestCase {
     /**
      * Test method for testing model listener.
      */
+    @Test
     public void testModelListener() {
         final int nbBuckets = 2000;
         final int nbEvents = 10 * nbBuckets + 256;
index 4900f6617a5a69d773c8b8e64dd073f6bc233c7f..c1f8a1986ed7990dd3afb415acef7a3ac659250d 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011 Ericsson
+ * Copyright (c) 2011, 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
@@ -9,32 +9,27 @@
  * Contributors:
  *   Mathieu Denis <mathieu.denis@polymtl.ca> - Initial API and Implementation
  *   Bernd Hufmann - Fixed suite name
+ *   Alexandre Montplaisir - Port to JUnit4
  *******************************************************************************/
-package org.eclipse.linuxtools.tmf.ui.tests.statistics;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
+package org.eclipse.linuxtools.tmf.ui.tests.statistics;
 
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
 
 /**
  * Test suite for statistic tests.
  */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+    TmfBaseColumnDataProviderTest.class,
+    TmfBaseColumnDataTest.class,
+    TmfBaseStatisticsDataTest.class,
+    TmfStatisticsTest.class,
+    TmfStatisticsTreeNodeTest.class,
+    TmfStatisticsTreeManagerTest.class,
+    TmfTreeContentProviderTest.class
+})
 public class AllTests {
 
-    /**
-     * @return the test suite
-     */
-    public static Test suite() {
-        TestSuite suite = new TestSuite(AllTests.class.getName());
-        // $JUnit-BEGIN$
-        suite.addTestSuite(TmfBaseColumnDataProviderTest.class);
-        suite.addTestSuite(TmfBaseColumnDataTest.class);
-        suite.addTestSuite(TmfBaseStatisticsDataTest.class);
-        suite.addTestSuite(TmfStatisticsTreeNodeTest.class);
-        suite.addTestSuite(TmfStatisticsTreeManagerTest.class);
-        suite.addTestSuite(TmfTreeContentProviderTest.class);
-        suite.addTestSuite(TmfStatisticsTest.class);
-        // $JUnit-END$
-        return suite;
-    }
 }
index 45a42926b3e54384c6af4b926f9d61a4461e5b48..1719c359ebe04bb40ce5046112d1adb5d8124e4f 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011 Ericsson
+ * Copyright (c) 2011, 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
@@ -9,12 +9,17 @@
  * Contributors:
  *   Mathieu Denis <mathieu.denis@polymtl.ca> - Initial API and Implementation
  *   Bernd Hufmann - Fixed header and warnings
+ *   Alexandre Montplaisir - Port to JUnit4
  *******************************************************************************/
+
 package org.eclipse.linuxtools.tmf.ui.tests.statistics;
 
-import java.util.List;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
-import junit.framework.TestCase;
+import java.util.List;
 
 import org.eclipse.jface.viewers.ColumnLabelProvider;
 import org.eclipse.jface.viewers.ViewerComparator;
@@ -30,22 +35,26 @@ import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfBaseColumnData.
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfBaseColumnDataProvider;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTree;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode;
+import org.junit.Test;
 
 /**
  * TmfBaseColumnDataProvider test cases.
  */
 @SuppressWarnings("nls")
-public class TmfBaseColumnDataProviderTest extends TestCase {
+public class TmfBaseColumnDataProviderTest {
 
     // ------------------------------------------------------------------------
     // Fields
     // ------------------------------------------------------------------------
+
+    private static final double DELTA = 1e-15;
+
     private final static String LEVEL_COLUMN = Messages.TmfStatisticsView_LevelColumn;
     private final static String EVENTS_COUNT_COLUMN = Messages.TmfStatisticsView_NbEventsColumn;
 
     private TmfBaseColumnDataProvider provider;
 
-    private String fTestName;
+    private static final String fTestName = "ColumnDataProviderTest";
 
     private final String fContext = "UnitTest";
 
@@ -85,13 +94,8 @@ public class TmfBaseColumnDataProviderTest extends TestCase {
 
     /**
      * Constructor
-     * @param name trace name to set
      */
-    public TmfBaseColumnDataProviderTest(final String name) {
-        super(name);
-
-        fTestName = name;
-
+    public TmfBaseColumnDataProviderTest() {
         fContent1 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, "Some content");
         fEvent1 = new TmfEvent(null, fTimestamp1, fSource, fType1, fContent1, fReference);
 
@@ -116,9 +120,11 @@ public class TmfBaseColumnDataProviderTest extends TestCase {
     // ------------------------------------------------------------------------
     // Get Column Data
     // ------------------------------------------------------------------------
+
     /**
      * Method with test cases.
      */
+    @Test
     public void testGetColumnData() {
         List<TmfBaseColumnData> columnsData = provider.getColumnData();
         assertNotNull("getColumnData", columnsData);
@@ -159,7 +165,7 @@ public class TmfBaseColumnDataProviderTest extends TestCase {
                 assertNull("getColumnData", percentProvider);
             } else if (columnData.getHeader().compareTo(EVENTS_COUNT_COLUMN) == 0) {
                 double percentage = (double) treeNode1.getValues().getTotal() / parentNode.getValues().getTotal();
-                assertEquals("getColumnData", percentage, percentProvider.getPercentage(treeNode1));
+                assertEquals("getColumnData", percentage, percentProvider.getPercentage(treeNode1), DELTA);
             }
         }
     }
index c333010b94e3a946840161a713358f086da32aec..b9fafc95da04fbbc4d9688e57c7a96c02bb9eaaa 100755 (executable)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011 Ericsson
+ * Copyright (c) 2011, 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
@@ -8,11 +8,13 @@
  *
  * Contributors:
  *   Mathieu Denis <mathieu.denis@polymtl.ca> - Initial design and implementation
+ *   Alexandre Montplaisir - Port to JUnit4
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.ui.tests.statistics;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import org.eclipse.jface.viewers.ColumnLabelProvider;
 import org.eclipse.jface.viewers.Viewer;
@@ -25,12 +27,14 @@ import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.ui.ISharedImages;
 import org.eclipse.ui.PlatformUI;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * TmfBaseColumnData Test Case.
  */
 @SuppressWarnings("nls")
-public class TmfBaseColumnDataTest extends TestCase {
+public class TmfBaseColumnDataTest {
 
     // ------------------------------------------------------------------------
     // Fields
@@ -51,7 +55,11 @@ public class TmfBaseColumnDataTest extends TestCase {
     // Housekeeping
     // ------------------------------------------------------------------------
 
-    private void init() {
+    /**
+     * Pre-test setup
+     */
+    @Before
+    public void init() {
         fHeader = "test Column1";
         fWidth = 300;
         fAlignment = SWT.LEFT;
@@ -98,92 +106,64 @@ public class TmfBaseColumnDataTest extends TestCase {
         fBaseColumnData = new TmfBaseColumnData(fHeader, fWidth, fAlignment, fToolTip, fLabelProvider, fComparator, fPercentageProvider);
     }
 
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
-        init();
-    }
-
-    @Override
-    public void tearDown() throws Exception {
-        super.tearDown();
-    }
-
     // ------------------------------------------------------------------------
-    // getHeader
+    // Test methods
     // ------------------------------------------------------------------------
 
     /**
      * Test get header
      */
+    @Test
     public void testGetHeader() {
         assertEquals("getHeader", 0, fBaseColumnData.getHeader().compareTo(fHeader));
     }
 
-    // ------------------------------------------------------------------------
-    // getWidth
-    // ------------------------------------------------------------------------
-
     /**
      * Test getting of column width.
      */
+    @Test
     public void testGetWidth() {
         assertEquals("getWidth", fWidth, fBaseColumnData.getWidth());
     }
 
-    // ------------------------------------------------------------------------
-    // getAlignment
-    // ------------------------------------------------------------------------
-
     /**
      * Test getting of alignment value
      */
+    @Test
     public void testGetAlignment() {
         assertEquals("getAlignment", fAlignment, fBaseColumnData.getAlignment());
     }
 
-    // ------------------------------------------------------------------------
-    // getToolTip
-    // ------------------------------------------------------------------------
-
     /**
      * Test getting of tooltip.
      */
+    @Test
     public void testGetTooltip() {
         assertEquals("getTooltip", fToolTip, fBaseColumnData.getTooltip());
     }
 
-    // ------------------------------------------------------------------------
-    // getLabelProvider
-    // ------------------------------------------------------------------------
-
     /**
      * Test getting of label provider
      */
+    @Test
     public void testGetLabelProvider() {
         assertEquals("getLabelProvider", 0, fBaseColumnData.getLabelProvider().getText(fTreeNode).compareTo(fLabelProvider.getText(fTreeNode)));
         assertTrue("getLabelProvider", fBaseColumnData.getLabelProvider().getImage(fTreeNode).equals(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT)));
         assertTrue("getLabelProvider", fBaseColumnData.getLabelProvider().equals(fLabelProvider));
     }
 
-    // ------------------------------------------------------------------------
-    // getComparator
-    // ------------------------------------------------------------------------
-
     /**
      * Test getting of comparator.
      */
+    @Test
     public void testGetComparator() {
         assertTrue("getComparator", fBaseColumnData.getComparator().equals(fComparator));
     }
 
-    // ------------------------------------------------------------------------
-    // getPercentageProvider
-    // ------------------------------------------------------------------------
-
     /**
      * Test getting of percentage provider.
      */
+    @Test
     public void testGetPercentageProvider() {
         assertTrue("getPercentageProvider", fBaseColumnData.getPercentageProvider().equals(fPercentageProvider));
     }
index 18ed5bd5967be0d748fecaa90ea7a12f38cb176e..8ab457586ef71ddf0a7fa24fc70c97ef4f1339ce 100755 (executable)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011 Ericsson
+ * Copyright (c) 2011, 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
@@ -9,17 +9,22 @@
  * Contributors:
  *   Mathieu Denis <mathieu.denis@polymtl.ca> - Initial design and implementation
  *   Bernd Hufmann - Fixed warnings
+ *   Alexandre Montplaisir - Port to JUnit4
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.ui.tests.statistics;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.Vector;
 
-import junit.framework.TestCase;
-
 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
 import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
 import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
@@ -29,17 +34,19 @@ import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.Messages;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTree;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode;
+import org.junit.Test;
 
 /**
  * TmfBaseStatistics Test Cases.
  */
 @SuppressWarnings("nls")
-public class TmfBaseStatisticsDataTest extends TestCase {
+public class TmfBaseStatisticsDataTest {
 
     // ------------------------------------------------------------------------
     // Fields
     // ------------------------------------------------------------------------
-    private       String fTestName = null;
+
+    private static final String fTestName = "StatisticsDataTest";
 
     private final String fContext = "UnitTest";
     private final String fTypeId1 = "Some type1";
@@ -77,14 +84,9 @@ public class TmfBaseStatisticsDataTest extends TestCase {
     // ------------------------------------------------------------------------
 
     /**
-     * @param name
-     *            Test name
+     * Constructor
      */
-    public TmfBaseStatisticsDataTest(final String name) {
-        super(name);
-
-        fTestName = name;
-
+    public TmfBaseStatisticsDataTest() {
         fContent1 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, "Some content");
         fEvent1 = new TmfEvent(null, fTimestamp1, fSource, fType1, fContent1, fReference);
 
@@ -103,12 +105,13 @@ public class TmfBaseStatisticsDataTest extends TestCase {
     }
 
     // ------------------------------------------------------------------------
-    // GetChildren
+    // Test methods
     // ------------------------------------------------------------------------
 
     /**
      * Test getting of children.
      */
+    @Test
     public void testGetChildren() {
         // Getting children of the ROOT
         Collection<TmfStatisticsTreeNode> childrenTreeNode = fStatsTree.getRootNode().getChildren();
@@ -146,13 +149,10 @@ public class TmfBaseStatisticsDataTest extends TestCase {
         assertEquals("getChildren", 0, childrenTreeNode.size());
     }
 
-    // ------------------------------------------------------------------------
-    // RegisterEvent
-    // ------------------------------------------------------------------------
-
     /**
      * Test registering of events.
      */
+    @Test
     public void testRegisterEvent() {
         TmfStatisticsTreeNode trace = fStatsTree.getNode(fTestName);
         assertEquals("registerEvent", 3, trace.getValues().getTotal());
@@ -167,13 +167,10 @@ public class TmfBaseStatisticsDataTest extends TestCase {
         }
     }
 
-    // ------------------------------------------------------------------------
-    // Get a node
-    // ------------------------------------------------------------------------
-
     /**
      * Test getter.
      */
+    @Test
     public void testGet() {
         TmfStatisticsTreeNode traceRoot = fStatsTree.getNode(fTestName);
         assertNotNull("get", traceRoot);
@@ -182,13 +179,10 @@ public class TmfBaseStatisticsDataTest extends TestCase {
         assertEquals("get", 1, traceRoot.getNbChildren());
     }
 
-    // ------------------------------------------------------------------------
-    // GetOrCreate
-    // ------------------------------------------------------------------------
-
     /**
      * Test getting or creating of node entries.
      */
+    @Test
     public void testGetOrCreate() {
         String[] newEventType = new String[] { fTestName, Messages.TmfStatisticsData_EventTypes, "Fancy Type" };
         TmfStatisticsTreeNode newEventTypeNode;
@@ -211,13 +205,10 @@ public class TmfBaseStatisticsDataTest extends TestCase {
         assertTrue(Arrays.equals(newEventType, newEventTypeNode.getPath()));
     }
 
-    // ------------------------------------------------------------------------
-    // GetParent
-    // ------------------------------------------------------------------------
-
     /**
      * Test getting of parent node.
      */
+    @Test
     public void testGetParent() {
         TmfStatisticsTreeNode parentNode = fStatsTree.getRootNode().getParent();
         assertNull(parentNode);
@@ -231,13 +222,10 @@ public class TmfBaseStatisticsDataTest extends TestCase {
         assertEquals(parentNode.getPath().toString(), fStatsTree.getNode(fTestName).getPath().toString());
     }
 
-    // ------------------------------------------------------------------------
-    // Reset
-    // ------------------------------------------------------------------------
-
     /**
      * Test reset method
      */
+    @Test
     public void testReset() {
         fStatsTree.getNode(fTestName, Messages.TmfStatisticsData_EventTypes).reset();
 
index 40658acc98ac7a9dc5b0492b21c9854422f2c198..6ab9f57a48467aa8ff5340a0c0a398786ca2ccf0 100644 (file)
@@ -1,39 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *   Alexandre Montplaisir - Port to JUnit4
+ *******************************************************************************/
+
 package org.eclipse.linuxtools.tmf.ui.tests.statistics;
 
-import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsValues;
+import static org.junit.Assert.assertEquals;
 
-import junit.framework.TestCase;
+import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsValues;
+import org.junit.Test;
 
 /**
  * TmfStatistics Test Cases.
  */
-public class TmfStatisticsTest extends TestCase {
+public class TmfStatisticsTest {
 
-    // ------------------------------------------------------------------------
-    // Fields
-    // ------------------------------------------------------------------------
-
-    TmfStatisticsValues stats = new TmfStatisticsValues();
-
-    // ------------------------------------------------------------------------
-    // Checks initial state
-    // ------------------------------------------------------------------------
+    private TmfStatisticsValues stats = new TmfStatisticsValues();
 
     /**
      * Test the initial state of the counters
      */
+    @Test
     public void testInitialState() {
         assertEquals(0, stats.getTotal());
         assertEquals(0, stats.getPartial());
     }
 
-    // ------------------------------------------------------------------------
-    // Increment Total no parameter
-    // ------------------------------------------------------------------------
-
     /**
      * Test incrementing the total counter by an amount
      */
+    @Test
     public void testSetValue() {
         final int i = 100;
 
@@ -60,6 +63,7 @@ public class TmfStatisticsTest extends TestCase {
     /**
      * Test of the reset for the total counter
      */
+    @Test
     public void testResetTotal() {
         stats.setValue(true, 123);
         assertEquals(123, stats.getTotal());
@@ -75,6 +79,7 @@ public class TmfStatisticsTest extends TestCase {
     /**
      * Test of the reset for the partial counter
      */
+    @Test
     public void testResetPartial() {
         stats.setValue(false, 456);
         assertEquals(456, stats.getPartial());
index e7601775ee5509a7918be618e61ac41bf5261e2b..ebfd3d12f1c41fcda00007cf6465142fffa73b06 100755 (executable)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011 Ericsson
+ * Copyright (c) 2011, 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
@@ -9,52 +9,51 @@
  * Contributors:
  *   Mathieu Denis <mathieu.denis@polymtl.ca> - Initial design and implementation
  *   Bernd Hufmann - Fixed warnings
+ *   Alexandre Montplaisir - Port to JUnit4
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.ui.tests.statistics;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTree;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTreeManager;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * TmfStatisticsTreeRootFactory Test Case.
  */
 @SuppressWarnings("nls")
-public class TmfStatisticsTreeManagerTest extends TestCase {
+public class TmfStatisticsTreeManagerTest {
 
     // ------------------------------------------------------------------------
     // Fields
     // ------------------------------------------------------------------------
 
-    TmfStatisticsTree fStatisticsData1;
-    TmfStatisticsTree fStatisticsData2;
-    TmfStatisticsTree fStatisticsData3;
-    String            fDataKey1 = "key1";
-    String            fDataKey2 = "key2";
-    String            fDataKey3 = "key3";
+    private TmfStatisticsTree fStatisticsData1;
+    private TmfStatisticsTree fStatisticsData2;
+    private TmfStatisticsTree fStatisticsData3;
+    private String            fDataKey1 = "key1";
+    private String            fDataKey2 = "key2";
+    private String            fDataKey3 = "key3";
+
 
     // ------------------------------------------------------------------------
     // Housekeeping
     // ------------------------------------------------------------------------
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        addStatsTreeRoot();
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-    }
-
     /**
-     * Adding of statistics tree root.
+     * Initialization
      */
-    public void addStatsTreeRoot() {
+    @Before
+    public void setUp() {
         fStatisticsData1 = new TmfStatisticsTree();
         fStatisticsData2 = new TmfStatisticsTree();
         fStatisticsData3 = new TmfStatisticsTree();
@@ -66,13 +65,14 @@ public class TmfStatisticsTreeManagerTest extends TestCase {
     /**
      * Clean the statistics tree
      */
-    public void removeStatsTreeRoot() {
+    private static void removeStatsTreeRoot() {
         TmfStatisticsTreeManager.removeAll();
     }
 
     /**
      * Test adding of statistics tree root. It should not throw exceptions
      */
+    @Test
     public void testaddStatsTreeRoot() {
         removeStatsTreeRoot();
 
@@ -104,6 +104,7 @@ public class TmfStatisticsTreeManagerTest extends TestCase {
     /**
      * Test getting of statistics tree root.
      */
+    @Test
     public void testGetStatTreeRoot() {
         TmfStatisticsTreeNode value1 = TmfStatisticsTreeManager.getStatTreeRoot(fDataKey1);
         TmfStatisticsTreeNode value2 = TmfStatisticsTreeManager.getStatTreeRoot(fDataKey2);
@@ -117,6 +118,7 @@ public class TmfStatisticsTreeManagerTest extends TestCase {
     /**
      * Test getting statistics tree.
      */
+    @Test
     public void testGetStatTree() {
         TmfStatisticsTree value1 = TmfStatisticsTreeManager.getStatTree(fDataKey1);
         TmfStatisticsTree value2 = TmfStatisticsTreeManager.getStatTree(fDataKey2);
@@ -134,6 +136,7 @@ public class TmfStatisticsTreeManagerTest extends TestCase {
     /**
      * Test checking for tree root existence.
      */
+    @Test
     public void testContainsTreeRoot() {
         assertTrue("containsTreeRoot", TmfStatisticsTreeManager.containsTreeRoot(fDataKey1));
         assertTrue("containsTreeRoot", TmfStatisticsTreeManager.containsTreeRoot(fDataKey2));
@@ -147,6 +150,7 @@ public class TmfStatisticsTreeManagerTest extends TestCase {
     /**
      * Test removal of statistics tree node.
      */
+    @Test
     public void testRemoveStatTreeRoot() {
         TmfStatisticsTreeManager.removeStatTreeRoot(fDataKey1);
         assertNull("removeStatTreeRoot", TmfStatisticsTreeManager.getStatTree(fDataKey1));
@@ -165,6 +169,7 @@ public class TmfStatisticsTreeManagerTest extends TestCase {
     /**
      * Test removal of all root nodes.
      */
+    @Test
     public void testRemoveAll() {
         TmfStatisticsTreeManager.removeAll();
         assertNull("removeAll", TmfStatisticsTreeManager.getStatTreeRoot(fDataKey2));
index 394a85a4ed20d6f7b11634b8f0dad0f9907b4b0a..6551976708732791532d8ee455a584c69daa838a 100755 (executable)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011 Ericsson
+ * Copyright (c) 2011, 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
@@ -9,24 +9,31 @@
  * Contributors:
  *   Mathieu Denis <mathieu.denis@polymtl.ca> - Initial design and implementation
  *   Bernd Hufmann - Fixed warnings
+ *   Alexandre Montplaisir - Port to JUnit4
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.ui.tests.statistics;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.Vector;
 
-import junit.framework.TestCase;
-
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.Messages;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTree;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode;
+import org.junit.Test;
 
 /**
  * TmfStatisticsTreeNode Test Cases.
  */
-public class TmfStatisticsTreeNodeTest extends TestCase {
+public class TmfStatisticsTreeNodeTest {
 
     // ------------------------------------------------------------------------
     // Fields
@@ -38,20 +45,16 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
 
     private final TmfStatisticsTree fStatsTree;
 
-    private String fTestName = null;
+    private static final String fTestName = "StatisticsTreeNodeTest"; //$NON-NLS-1$
 
     // ------------------------------------------------------------------------
     // Housekeeping
     // ------------------------------------------------------------------------
 
     /**
-     * @param name
-     *            Test name
+     * Constructor
      */
-    public TmfStatisticsTreeNodeTest(final String name) {
-        super(name);
-
-        fTestName = name;
+    public TmfStatisticsTreeNodeTest() {
         fStatsTree = new TmfStatisticsTree();
 
         /* Enter some global values */
@@ -67,13 +70,10 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
         fStatsTree.setTypeCount(fTestName, fTypeId3, false, 4);
     }
 
-    // ------------------------------------------------------------------------
-    // ContainsChild
-    // ------------------------------------------------------------------------
-
     /**
      * Test checking for child.
      */
+    @Test
     public void testContainsChild() {
         TmfStatisticsTreeNode rootNode  = fStatsTree.getRootNode();
         TmfStatisticsTreeNode traceNode = fStatsTree.getNode(fTestName);
@@ -93,13 +93,10 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
         assertFalse(catNode.containsChild(null));
     }
 
-    // ------------------------------------------------------------------------
-    // GetChildren
-    // ------------------------------------------------------------------------
-
     /**
      * Test getting of children.
      */
+    @Test
     public void testGetChildren() {
         // Getting children of the ROOT
         Collection<TmfStatisticsTreeNode> childrenTreeNode = fStatsTree.getRootNode().getChildren();
@@ -137,13 +134,10 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
         assertEquals(0, childrenTreeNode.size());
     }
 
-    // ------------------------------------------------------------------------
-    // GetNbChildren
-    // ------------------------------------------------------------------------
-
     /**
      * Test getting of number of children.
      */
+    @Test
     public void testGetNbChildren() {
         TmfStatisticsTreeNode rootNode    = fStatsTree.getRootNode();
         TmfStatisticsTreeNode traceNode   = fStatsTree.getNode(fTestName);
@@ -156,13 +150,10 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
         assertEquals(0, elementNode.getNbChildren());
     }
 
-    // ------------------------------------------------------------------------
-    // HasChildren
-    // ------------------------------------------------------------------------
-
     /**
      * Test checking for children.
      */
+    @Test
     public void testHasChildren() {
         TmfStatisticsTreeNode rootNode    = fStatsTree.getRootNode();
         TmfStatisticsTreeNode traceNode   = fStatsTree.getNode(fTestName);
@@ -175,13 +166,10 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
         assertFalse(elementNode.hasChildren());
     }
 
-    // ------------------------------------------------------------------------
-    // GetParent
-    // ------------------------------------------------------------------------
-
     /**
      * Test getting of parent.
      */
+    @Test
     public void testGetParent() {
         final TmfStatisticsTreeNode rootNode = fStatsTree.getRootNode();
         TmfStatisticsTreeNode parentNode = rootNode.getParent();
@@ -211,13 +199,10 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
         assertTrue(arraysEqual(parentNode.getPath(), fTestName, Messages.TmfStatisticsData_EventTypes));
     }
 
-    // ------------------------------------------------------------------------
-    // GetKey
-    // ------------------------------------------------------------------------
-
     /**
      * Test getting of key.
      */
+    @Test
     public void testgetName() {
         TmfStatisticsTreeNode rootNode    = fStatsTree.getRootNode();
         TmfStatisticsTreeNode traceNode   = fStatsTree.getNode(fTestName);
@@ -230,13 +215,10 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
         assertEquals(0, elementNode.getName().compareTo(fTypeId1));
     }
 
-    // ------------------------------------------------------------------------
-    // GetPath
-    // ------------------------------------------------------------------------
-
     /**
      * Test getting of path to node.
      */
+    @Test
     public void testGetPath() {
         TmfStatisticsTreeNode rootNode    = fStatsTree.getRootNode();
         TmfStatisticsTreeNode traceNode   = fStatsTree.getNode(fTestName);
@@ -251,13 +233,10 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
                 fTestName, Messages.TmfStatisticsData_EventTypes, fTypeId1));
     }
 
-    // ------------------------------------------------------------------------
-    // GetValue
-    // ------------------------------------------------------------------------
-
     /**
      * Test getting statistic value.
      */
+    @Test
     public void testGetValue() {
         TmfStatisticsTreeNode rootNode, traceNode, catNode, elementNode1, elementNode2, elementNode3;
         rootNode     = fStatsTree.getRootNode();
@@ -282,13 +261,10 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
         assertEquals(4, elementNode3.getValues().getPartial());
     }
 
-    // ------------------------------------------------------------------------
-    // Reset
-    // ------------------------------------------------------------------------
-
     /**
      * Test reset of tree.
      */
+    @Test
     public void testReset() {
         TmfStatisticsTreeNode rootNode, traceNode, catNode, elementNode;
         rootNode    = fStatsTree.getRootNode();
@@ -321,6 +297,7 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
      * Test reset global value of the node in the tree. It should only clear
      * the global value without removing any node from the tree.
      */
+    @Test
     public void testResetGlobalValue() {
         TmfStatisticsTreeNode rootNode, traceNode, catNode, eventTypeNode1, eventTypeNode2, eventTypeNode3;
         rootNode       = fStatsTree.getRootNode();
@@ -359,6 +336,7 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
      * Test reset time range value of the node in the tree. It should only clear
      * the time range value without removing any node from the tree.
      */
+    @Test
     public void testResetTimeRangeValue() {
         TmfStatisticsTreeNode rootNode, traceNode, catNode, eventTypeNode1, eventTypeNode2, eventTypeNode3;
         rootNode       = fStatsTree.getRootNode();
index 53e7717d9a6f68aade19deb32e0daef144cbf337..009a81e3fac2ff5ad062554710cad9d276a29aea 100755 (executable)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011 Ericsson
+ * Copyright (c) 2011, 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
@@ -9,13 +9,18 @@
  * Contributors:
  *   Mathieu Denis <mathieu.denis@polymtl.ca> - Initial design and implementation
  *   Bernd Hufmann - Fixed warnings
+ *   Alexandre Montplaisir - Port to JUnit4
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.ui.tests.statistics;
 
-import java.util.Arrays;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
-import junit.framework.TestCase;
+import java.util.Arrays;
 
 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
 import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
@@ -27,18 +32,19 @@ import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.Messages;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTree;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfTreeContentProvider;
+import org.junit.Test;
 
 /**
  * TmfTreeContentProvider Test Cases.
  */
 @SuppressWarnings("nls")
-public class TmfTreeContentProviderTest extends TestCase {
+public class TmfTreeContentProviderTest {
 
     // ------------------------------------------------------------------------
     // Fields
     // ------------------------------------------------------------------------
 
-    private String fTestName = null;
+    private static final String fTestName = "TreeContentProviderTest";
 
     private final String fContext = "UnitTest";
     private final String fTypeId1 = "Some type1";
@@ -73,14 +79,9 @@ public class TmfTreeContentProviderTest extends TestCase {
     // ------------------------------------------------------------------------
 
     /**
-     * @param name
-     *            of the test
+     * Constructor
      */
-    public TmfTreeContentProviderTest(final String name) {
-        super(name);
-
-        fTestName = name;
-
+    public TmfTreeContentProviderTest() {
         fContent1 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, "Some content");
         fEvent1 = new TmfEvent(null, fTimestamp1, fSource, fType1, fContent1, fReference);
 
@@ -97,7 +98,7 @@ public class TmfTreeContentProviderTest extends TestCase {
     }
 
     // ------------------------------------------------------------------------
-    // GetChildren
+    // Test methods
     // ------------------------------------------------------------------------
 
     /**
@@ -105,6 +106,7 @@ public class TmfTreeContentProviderTest extends TestCase {
      * FIXME this test was quickly adapted when we removed the TmfFixedArray,
      * but it could be rewritten to be much more simple...
      */
+    @Test
     public void testGetChildren() {
         Object[] objectArray = treeProvider.getChildren(fStatsData.getOrCreateNode(fTestName, Messages.TmfStatisticsData_EventTypes));
         TmfStatisticsTreeNode[] childrenNode = Arrays.asList(objectArray).toArray(new TmfStatisticsTreeNode[0]);
@@ -144,13 +146,10 @@ public class TmfTreeContentProviderTest extends TestCase {
         return true;
     }
 
-    // ------------------------------------------------------------------------
-    // GetParent
-    // ------------------------------------------------------------------------
-
     /**
      * Test getting of parent.
      */
+    @Test
     public void testGetParent() {
         TmfStatisticsTreeNode parent = (TmfStatisticsTreeNode) treeProvider.getParent(fStatsData.getNode(fTestName));
 
@@ -158,12 +157,10 @@ public class TmfTreeContentProviderTest extends TestCase {
         assertTrue("getParent", parent.getPath().equals(fStatsData.getRootNode().getPath()));
     }
 
-    // ------------------------------------------------------------------------
-    // HasChildren
-    // ------------------------------------------------------------------------
     /**
      * Test checking for children.
      */
+    @Test
     public void testHasChildren() {
         Boolean hasChildren = treeProvider.hasChildren(fStatsData.getRootNode());
         assertTrue("hasChildren", hasChildren);
@@ -178,13 +175,10 @@ public class TmfTreeContentProviderTest extends TestCase {
         assertFalse("hasChildren", hasChildren);
     }
 
-    // ------------------------------------------------------------------------
-    // GetElements
-    // ------------------------------------------------------------------------
-
     /**
      * Test getting of elements.
      */
+    @Test
     public void testGetElements() {
         Object[] objectElements = treeProvider.getElements(fStatsData.getRootNode());
         TmfStatisticsTreeNode[] nodeElements = Arrays.asList(objectElements).toArray(new TmfStatisticsTreeNode[0]);
index ea482eae50edcc56c69e9baad86c15604cc235f4..f20c764c284baf7db7b2b6bff7579cc78865b53e 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011, 2012 Ericsson
+ * Copyright (c) 2011-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
@@ -8,26 +8,21 @@
  *
  * Contributors:
  *   Bernd Hufmann - Initial API and implementation
+ *   Alexandre Montplaisir - Port to JUnit4
  *******************************************************************************/
+
 package org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.dialogs;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
 
 /**
  * Test suite of UML2SD dialog tests.
  */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+    CriteriaTest.class
+})
 public class AllTests {
 
-    /**
-     * @return the test suite of UML2SD dialog tests
-     */
-    public static Test suite() {
-
-        TestSuite suite = new TestSuite(AllTests.class.getName());
-        //$JUnit-BEGIN$
-        suite.addTestSuite(CriteriaTest.class);
-        //$JUnit-END$
-        return suite;
-    }
 }
index 32274fd6fd0ae3a7b9599a937f7705f280d30658..2f03b0c9bc2b8ecba4f26cc3805c68d784972086 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011, 2012 Ericsson
+ * Copyright (c) 2011-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
@@ -8,36 +8,36 @@
  *
  * Contributors:
  *   Bernd Hufmann - Initial API and implementation
+ *   Alexandre Montplaisir - Port to JUnit4
  *******************************************************************************/
+
 package org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.dialogs;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
 import java.util.List;
 import java.util.regex.Pattern;
 
-import junit.framework.TestCase;
-
 import org.eclipse.jface.dialogs.DialogSettings;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.Criteria;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDFilterProvider;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDGraphNodeSupporter;
+import org.junit.Test;
 
 /**
  *  Test cases to test Criteria class.
  */
 @SuppressWarnings("nls")
-public class CriteriaTest extends TestCase {
-
-    @Override
-    public void setUp() throws Exception {
-    }
-
-    @Override
-    public void tearDown() throws Exception {
-    }
+public class CriteriaTest {
 
     /**
      * Test default constructor.
      */
+    @Test
     public void testCriteria() {
         Criteria criteria = new Criteria();
         assertFalse("testCriteria", criteria.isAsyncMessageReturnSelected());
@@ -54,6 +54,7 @@ public class CriteriaTest extends TestCase {
     /**
      * Test copy constructor.
      */
+    @Test
     public void testCriteriaCriteria() {
         Criteria criteria = new Criteria();
         criteria.setExpression("test");
@@ -76,6 +77,7 @@ public class CriteriaTest extends TestCase {
     /**
      * Test accessor methods.
      */
+    @Test
     public void testAccessors() {
         Criteria criteria = new Criteria();
         criteria.setAsyncMessageReturnSelected(true);
@@ -125,6 +127,7 @@ public class CriteriaTest extends TestCase {
     /**
      * Test compartTo method.
      */
+    @Test
     public void testCompareTo() {
         Criteria criteria = new Criteria();
         criteria.setExpression("test");
@@ -158,6 +161,7 @@ public class CriteriaTest extends TestCase {
     /**
      * Test save to disk.
      */
+    @Test
     public void testSave() {
         DialogSettings settings = new DialogSettings("mysettings");
 
@@ -183,6 +187,7 @@ public class CriteriaTest extends TestCase {
     /**
      * Test restore from disk.
      */
+    @Test
     public void testLoad() {
         DialogSettings settings = new DialogSettings("mysettings");
 
@@ -205,6 +210,7 @@ public class CriteriaTest extends TestCase {
     /**
      * Test graph node summary usage.
      */
+    @Test
     public void testGetGraphNodeSummary() {
 
         // Create a dummy provider
@@ -264,6 +270,7 @@ public class CriteriaTest extends TestCase {
     /**
      * Test matches algorithm.
      */
+    @Test
     public void testMatches() {
         Criteria criteria = new Criteria();
         criteria.setExpression("BALL_.*");
index e4e52dc52224d5e26b5a8a343e259591decc87a6..12ba3a7047769887b21e7b0ecdd626d96ef5e02c 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011 Ericsson
+ * Copyright (c) 2011, 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
@@ -8,26 +8,21 @@
  *
  * Contributors:
  *   Bernd Hufmann - Initial API and implementation
+ *   Alexandre Montplaisir - Port to JUnit4
  *******************************************************************************/
+
 package org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.load;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
 
 /**
  *  Test suite for testing loader manager of UML2SD extension point.
  */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+    LoadersManagerTest.class
+})
 public class AllTests {
 
-    /**
-     * @return the test suite.
-     */
-    public static Test suite() {
-
-        TestSuite suite = new TestSuite(AllTests.class.getName());
-        //$JUnit-BEGIN$
-        suite.addTestSuite(LoadersManagerTest.class);
-        //$JUnit-END$
-        return suite;
-    }
 }
index 9edffd403b466ba770e3625ce9e479f115aada50..5db63aa117bf823aa2d66c3d2c28ecb31441ee64 100644 (file)
@@ -1,54 +1,50 @@
 /**********************************************************************
- * Copyright (c) 2011 Ericsson.
+ * Copyright (c) 2011, 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:
- * Bernd Hufmann - Initial API and implementation
+ *   Bernd Hufmann - Initial API and implementation
+ *   Alexandre Montplaisir - Port to JUnit4
  **********************************************************************/
+
 package org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.load;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
 
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.linuxtools.internal.tmf.ui.Activator;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.LoadersManager;
-import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.PlatformUI;
+import org.junit.Test;
 
 /**
  *  Test cases class to test loader manager of UML2SD extension point.
  */
-public class LoadersManagerTest extends TestCase {
-
-    private final static String SDVIEW_WITH_ONE_LOADER = "org.eclipse.linuxtools.tmf.ui.tests.testSDView1Loader"; //$NON-NLS-1$
-    private final static String SDVIEW_WITH_MULTIPLE_LOADER = "org.eclipse.linuxtools.tmf.ui.tests.testSDView2Loaders"; //$NON-NLS-1$
-    private final static String TEST_LOADER_CLASS_NAME = "org.eclipse.linuxtools.tmf.ui.tests.uml2sd.load.TestLoaders"; //$NON-NLS-1$
-    private final static String TMF_UML2SD_LOADER_CLASS_NAME = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.loader.TmfUml2SDSyncLoader"; //$NON-NLS-1$
+@SuppressWarnings("nls")
+public class LoadersManagerTest {
 
-    private static final String LOADER_TAG = "uml2SDLoader"; //$NON-NLS-1$
-    private static final String LOADER_PREFIX = LOADER_TAG + "."; //$NON-NLS-1$
+    private final static String SDVIEW_WITH_ONE_LOADER = "org.eclipse.linuxtools.tmf.ui.tests.testSDView1Loader";
+    private final static String SDVIEW_WITH_MULTIPLE_LOADER = "org.eclipse.linuxtools.tmf.ui.tests.testSDView2Loaders";
+    private final static String TEST_LOADER_CLASS_NAME = "org.eclipse.linuxtools.tmf.ui.tests.uml2sd.load.TestLoaders";
+    private final static String TMF_UML2SD_LOADER_CLASS_NAME = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.loader.TmfUml2SDSyncLoader";
 
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
-    }
-
-    @Override
-    public void tearDown() throws Exception {
-        super.tearDown();
-    }
+    private static final String LOADER_TAG = "uml2SDLoader";
+    private static final String LOADER_PREFIX = LOADER_TAG + ".";
 
     /**
      * Tests of loader manager singleton class.
      */
-    @SuppressWarnings("nls")
+    @Test
     public void testLoaderManager() {
-
         SDView view = null;
         try {
 
@@ -155,26 +151,6 @@ public class LoadersManagerTest extends TestCase {
         }
     }
 
-    @SuppressWarnings("unused")
-    private static void delay(long waitTimeMillis) {
-        Display display = Display.getCurrent();
-        if (display != null) {
-            long endTimeMillis = System.currentTimeMillis() + waitTimeMillis;
-            while(System.currentTimeMillis() < endTimeMillis) {
-                if (!display.readAndDispatch()) {
-                    display.sleep();
-                }
-                display.update();
-            }
-        } else {
-            try {
-                Thread.sleep(waitTimeMillis);
-            } catch (InterruptedException e) {
-                // Ignored
-            }
-        }
-    }
-
     private static String getSavedLoader(String viewId) {
         IPreferenceStore p = Activator.getDefault().getPreferenceStore();
         return p.getString(LOADER_PREFIX + viewId);
index 4283bf75b7ccceaeba3bfdf33d3d1a3a9ef3f03e..903ff5f4e97bc09ddba254484e9ce90f777c5820 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011, 2012 Ericsson
+ * Copyright (c) 2011-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
@@ -8,31 +8,28 @@
  *
  * Contributors:
  *   Bernd Hufmann - Initial API and implementation
+ *   Alexandre Montplaisir - Port to JUnit4
  *******************************************************************************/
+
 package org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.loader;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
 
 /**
  *  Test suite for testing the TmfUml2SDSyncLoader class.
- *  @author Bernd Hufmann
+ *
+ * @author Bernd Hufmann
  */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+    TmfUml2SDSyncLoaderExpTest.class,
+    TmfUml2SDSyncLoaderFilterTest.class,
+    TmfUml2SDSyncLoaderFindTest.class,
+    TmfUml2SDSyncLoaderPagesTest.class,
+    TmfUml2SDSyncLoaderSignalTest.class,
+    TmfUml2SDSyncLoaderTimeTest.class
+})
 public class AllTests {
 
-    /**
-     * @return the test suite.
-     */
-    public static Test suite() {
-        TestSuite suite = new TestSuite(AllTests.class.getName());
-        //$JUnit-BEGIN$
-        suite.addTestSuite(TmfUml2SDSyncLoaderExpTest.class);
-        suite.addTestSuite(TmfUml2SDSyncLoaderPagesTest.class);
-        suite.addTestSuite(TmfUml2SDSyncLoaderTimeTest.class);
-        suite.addTestSuite(TmfUml2SDSyncLoaderSignalTest.class);
-        suite.addTestSuite(TmfUml2SDSyncLoaderFindTest.class);
-        suite.addTestSuite(TmfUml2SDSyncLoaderFilterTest.class);
-        //$JUnit-END$
-        return new Uml2SDTestSetup(suite);
-    }
 }
index 5c3f3fd9c0ffe4f157f5a8c6fdbd6a937814cea8..2d4857b333c085efc53d2a46f731411f144920ea 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011, 2012 Ericsson
+ * Copyright (c) 2011-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
@@ -8,14 +8,18 @@
  *
  * Contributors:
  *   Bernd Hufmann - Initial API and implementation
+ *   Alexandre Montplaisir - Port to JUnit4
  *******************************************************************************/
+
 package org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.loader;
 
-import java.util.List;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import java.util.List;
 
 import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.FilterCriteria;
@@ -23,77 +27,50 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.FilterListDialog;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDAdvancedPagingProvider;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDPagingProvider;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.loader.TmfUml2SDSyncLoader;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
 /**
  * Test cases for Experiment handling.
  *
  * @author Bernd Hufmann
- *
  */
 @SuppressWarnings("nls")
-public class TmfUml2SDSyncLoaderExpTest extends TestCase {
-
-    // ------------------------------------------------------------------------
-    // Attributes
-    // ------------------------------------------------------------------------
-    private Uml2SDTestFacility fFacility;
+public class TmfUml2SDSyncLoaderExpTest {
 
-    // ------------------------------------------------------------------------
-    // Static methods
-    // ------------------------------------------------------------------------
+    private static Uml2SDTestFacility fFacility;
 
     /**
-     * Returns test setup used when executing test case stand-alone.
-     * @return Test setup class
+     * Initialization
      */
-    public static Test suite() {
-        return new Uml2SDTestSetup(new TestSuite(TmfUml2SDSyncLoaderExpTest.class));
-    }
-
-    // ------------------------------------------------------------------------
-    // Constructors
-    // ------------------------------------------------------------------------
-
-    /**
-     * Constructor
-     */
-    public TmfUml2SDSyncLoaderExpTest() {
-    }
-
-    // ------------------------------------------------------------------------
-    // Operations
-    // ------------------------------------------------------------------------
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
+    @BeforeClass
+    public static void setUpClass() {
         fFacility = Uml2SDTestFacility.getInstance();
         // create filter criteria (incl. save)
         fFacility.createFilterCriteria();
         fFacility.selectExperiment();
     }
 
-
-    @Override
-    public void tearDown() throws Exception {
+    /**
+     * Cleanup
+     */
+    @AfterClass
+    public static void tearDownClass() {
+        fFacility.disposeExperiment();
         fFacility = null;
-        super.tearDown();
     }
 
-
     /**
-     * Main method with test cases.
+     * Verify setup
+     *
+     * Verified Methods: loader.getTitleString()
+     *                   view.getPartName()
+     *                   view.getFrame()
+     * Expected result: Title, view name are set properly.
      */
-    public void testExperimentHandling() {
-
-        /*
-         * Test Case: 001
-         * Description: Verify setup
-         * Verified Methods: loader.getTitleString()
-         *                   view.getPartName()
-         *                   view.getFrame()
-         * Expected result: Title, view name are set properly.
-         */
-
+    @Test
+    public void verifySetup() {
         assertEquals("getTitleString", "Component Interactions", fFacility.getLoader().getTitleString());
         assertEquals("getPartName", "Sequence Diagram", fFacility.getSdView().getPartName());
         assertNotNull("getFrame", fFacility.getSdView().getFrame());
@@ -102,17 +79,19 @@ public class TmfUml2SDSyncLoaderExpTest extends TestCase {
 
         fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
         verifyPage(0, 0, false, false, 0);
+    }
 
-        /*
-         * Test Case: 002
-         * Description: Verifies cancellation of ongoing indexing.
-         * Verified Methods: loader.experimentSelected(), loader.experimentDisposed(), loader.nextPage()
-         * Expected result: No exceptions during cancellation and nextPage() operation..
-         *
-         * Note this test is not sufficient to verify the concurrent access of the loader attributes
-         * by multiple threads. Contention might happen but it's not guaranteed.
-         */
-
+    /**
+     * Verify cancellation of ongoing indexing.
+     *
+     * Verified Methods: loader.experimentSelected(), loader.experimentDisposed(), loader.nextPage()
+     * Expected result: No exceptions during cancellation and nextPage() operation.
+     *
+     * Note this test is not sufficient to verify the concurrent access of the loader attributes
+     * by multiple threads. Contention might happen but it's not guaranteed.
+     */
+    @Test
+    public void verifyCancel() {
         for(int i = 0; i < 5; i++) {
             fFacility.selectExperiment(false);
             fFacility.delay(IUml2SDTestConstants.INITIAL_INDEX_DELAY);
@@ -127,19 +106,21 @@ public class TmfUml2SDSyncLoaderExpTest extends TestCase {
                 fail("exp.select/exp.dispose");
             }
         }
+    }
 
-        /*
-         * Test Case: 003
-         * Description: Verifies disposed experiment.
-         * Verified Methods: loader.nextPage(),
-         *                   loader.pagesCount(), loader.hasNextPage(), loader.hasPrevPage(),
-         *                   frame.syncMessagesCount, frame.lifeLinesCount
-         * Expected result: Page values and filter are reset.
-         *
-         * Note this test is not sufficient to verify the concurrent access ofthe loader attributes
-         * by multiple threads. Contention might happen but it's not guaranteed.
-         */
-
+    /**
+     * Verify disposed experiment.
+     *
+     * Verified Methods: loader.nextPage(),
+     *                   loader.pagesCount(), loader.hasNextPage(), loader.hasPrevPage(),
+     *                   frame.syncMessagesCount, frame.lifeLinesCount
+     * Expected result: Page values and filter are reset.
+     *
+     * Note this test is not sufficient to verify the concurrent access of the loader attributes
+     * by multiple threads. Contention might happen but it's not guaranteed.
+     */
+    @Test
+    public void verifyDispose() {
         verifyPage(0, 0, false, false, 0);
 
         // verify that all enable filters are disabled after disposal
@@ -148,13 +129,16 @@ public class TmfUml2SDSyncLoaderExpTest extends TestCase {
         for (FilterCriteria filterCriteria : filter) {
             assertFalse("exp.dispose", filterCriteria.isActive());
         }
+    }
 
-        /*
-         * Test Case: 004
-         * Description: Verifies the disposal of the loader.
-         * Verified Methods: loader.dispose(),
-         * Expected result: All providers are removed from SDView.
-         */
+    /**
+     * Verify the disposal of the loader.
+     *
+     * Verified Methods: loader.dispose()
+     * Expected result: All providers are removed from SDView.
+     */
+    @Test
+    public void verifyLoaderDispose() {
         fFacility.getLoader().dispose();
         assertTrue("loader.dispose", fFacility.getSdView().getSDPagingProvider() == null);
         assertTrue("loader.dispose", fFacility.getSdView().getSDFindProvider() == null);
@@ -164,14 +148,16 @@ public class TmfUml2SDSyncLoaderExpTest extends TestCase {
 
         // Set again loader as signal handler, which was removed by the the dispose above
         TmfSignalManager.register(fFacility.getLoader());
+    }
 
-        /*
-         * Test Case: 005
-         * Description: Verifies setViewer.
-         * Verified Methods: loader.setViewer
-         * Expected result: Paging, find and filter provider are set
-         */
-
+    /**
+     * Verify setViewer.
+     *
+     * Verified Methods: loader.setViewer
+     * Expected result: Paging, find and filter provider are set
+     */
+    @Test
+    public void testSetViewer() {
         fFacility.getLoader().setViewer(fFacility.getSdView());
         ISDPagingProvider pagingProvider = fFacility.getSdView().getSDPagingProvider();
         assertTrue("loader.setViewer", pagingProvider != null);
@@ -187,7 +173,8 @@ public class TmfUml2SDSyncLoaderExpTest extends TestCase {
         assertTrue("loader.setViewer", fFacility.getSdView().getExtendedFilterProvider() == null);
     }
 
-    private void verifyPage(int currentPage, int numMsg, boolean hasNext, boolean hasPrev, int lifelineCount) {
+    private static void verifyPage(int currentPage, int numMsg, boolean hasNext,
+            boolean hasPrev, int lifelineCount) {
         assertEquals("currentPage", currentPage, fFacility.getLoader().currentPage());
         assertEquals("syncMessageCount, ", numMsg, fFacility.getSdView().getFrame().syncMessageCount());
         if (hasNext) {
index cbf737c3cba6c872a65cd421e2f426653cf6be3f..0c470122c6d06b77eea4718b7af84b2acb08243d 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011, 2012 Ericsson
+ * Copyright (c) 2011-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
@@ -8,82 +8,47 @@
  *
  * Contributors:
  *   Bernd Hufmann - Initial API and implementation
+ *   Alexandre Montplaisir - Port to JUnit4
  *******************************************************************************/
+
 package org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.loader;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
 import java.util.ArrayList;
 import java.util.List;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SyncMessage;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.Criteria;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.FilterCriteria;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.loader.TmfSyncMessage;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
 /**
  * Filter test cases.
  *
  * @author Bernd Hufmann
- *
  */
 @SuppressWarnings("nls")
-public class TmfUml2SDSyncLoaderFilterTest extends TestCase {
-
-    // ------------------------------------------------------------------------
-    // Attributes
-    // ------------------------------------------------------------------------
-    private Uml2SDTestFacility fFacility;
+public class TmfUml2SDSyncLoaderFilterTest {
 
-    // ------------------------------------------------------------------------
-    // Static methods
-    // ------------------------------------------------------------------------
+    private static Uml2SDTestFacility fFacility;
+    private static List<FilterCriteria> filterToSave;
 
     /**
-     * Returns test setup used when executing test case stand-alone.
-     * @return Test setup class
+     * Initialization
      */
-    public static Test suite() {
-        return new Uml2SDTestSetup(new TestSuite(TmfUml2SDSyncLoaderFilterTest.class));
-    }
-
-    // ------------------------------------------------------------------------
-    // Constructors
-    // ------------------------------------------------------------------------
-    /**
-     * Constructor
-     */
-    public TmfUml2SDSyncLoaderFilterTest() {
-    }
-
-    // ------------------------------------------------------------------------
-    // Operations
-    // ------------------------------------------------------------------------
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
+    @BeforeClass
+    public static void setUpClass() {
         fFacility = Uml2SDTestFacility.getInstance();
         fFacility.selectExperiment();
-    }
-
-
-    @Override
-    public void tearDown() throws Exception {
-        fFacility.disposeExperiment();
-        fFacility = null;
-        super.tearDown();
-    }
 
-    /**
-     * Main method with test cases.
-     */
-    public void testFilterHandling() {
-
-        // Create Filter Criteria
-        List<FilterCriteria> filterToSave = new ArrayList<FilterCriteria>();
+        /* Create Filter Criteria */
+        filterToSave = new ArrayList<FilterCriteria>();
         Criteria criteria = new Criteria();
         criteria.setLifeLineSelected(true);
         criteria.setExpression(IUml2SDTestConstants.FIRST_PLAYER_NAME);
@@ -98,54 +63,76 @@ public class TmfUml2SDSyncLoaderFilterTest extends TestCase {
         criteria.setSyncMessageSelected(true);
         criteria.setExpression("BALL_.*"); //$NON-NLS-1$
         filterToSave.add(new FilterCriteria(criteria, false, false));
+    }
 
-        /*
-         * Test Case: 001
-         * Description: Verify the filter lifelines (1 out of 2 is hidden)
-         * Verified Methods: loader.filter()
-         * Expected result: Only one lifeline is visible with no messages
-         */
+    /**
+     * Cleanup
+     */
+    @AfterClass
+    public static void tearDownClass() {
+        fFacility.disposeExperiment();
+        fFacility = null;
+    }
+
+    /**
+     * Verify the filter lifelines (1 out of 2 is hidden)
+     *
+     * Verified Methods: loader.filter()
+     * Expected result: Only one lifeline is visible with no messages
+     */
+    @Test
+    public void verifyFilter1of2() {
         fFacility.getLoader().filter(filterToSave);
         fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
 
         assertEquals("filter", 1, fFacility.getSdView().getFrame().lifeLinesCount());
         assertEquals("filter", IUml2SDTestConstants.MASTER_PLAYER_NAME, fFacility.getSdView().getFrame().getLifeline(0).getName());
         assertEquals("filter", 0, fFacility.getSdView().getFrame().syncMessageCount());
+    }
 
 
-        /*
-         * Test Case: 002
-         * Description: Verify the filter lifelines (2 out of 2 are hidden)
-         * Verified Methods: loader.filter(), loader.fillCurrentPage()
-         * Expected result: Neiter liflines nor messages are visible
-         */
+    /**
+     * Verify the filter lifelines (2 out of 2 are hidden)
+     *
+     * Verified Methods: loader.filter(), loader.fillCurrentPage()
+     * Expected result: Neiter liflines nor messages are visible
+     */
+    @Test
+    public void verifyFilter2of2() {
         filterToSave.get(1).setActive(true);
         fFacility.getLoader().filter(filterToSave);
         fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
 
         assertEquals("filter", 0, fFacility.getSdView().getFrame().lifeLinesCount());
         assertEquals("filter", 0, fFacility.getSdView().getFrame().syncMessageCount());
+    }
 
-        /*
-         * Test Case: 003
-         * Description: Verify removal of all filters
-         * Verified Methods: loader.filter(), loader.fillCurrentPage()
-         * Expected result: Everything is shown
-         */
+    /**
+     * Verify removal of all filters
+     *
+     * Verified Methods: loader.filter(), loader.fillCurrentPage()
+     * Expected result: Everything is shown
+     */
+    @Test
+    public void verifyRemoval() {
         filterToSave.get(0).setActive(false);
         filterToSave.get(1).setActive(false);
         fFacility.getLoader().filter(filterToSave);
         fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
 
         assertEquals("filter", 2, fFacility.getSdView().getFrame().lifeLinesCount());
-        assertEquals("filter", IUml2SDTestConstants.MAX_MESSEAGES_PER_PAGE, fFacility.getSdView().getFrame().syncMessageCount());
-
-        /*
-         * Test Case: 004
-         * Description: Verify filter of messages
-         * Verified Methods: loader.filter(), loader.fillCurrentPage()
-         * Expected result: Only particular messages are shown
-         */
+        assertEquals("filter", IUml2SDTestConstants.MAX_MESSEAGES_PER_PAGE,
+                fFacility.getSdView().getFrame().syncMessageCount());
+    }
+
+    /**
+     * Verify filter of messages
+     *
+     * Verified Methods: loader.filter(), loader.fillCurrentPage()
+     * Expected result: Only particular messages are shown
+     */
+    @Test
+    public void verifyMessageFilter() {
         filterToSave.get(2).setActive(true);
         fFacility.getLoader().filter(filterToSave);
         fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
@@ -153,21 +140,25 @@ public class TmfUml2SDSyncLoaderFilterTest extends TestCase {
         assertEquals("filter", 2, fFacility.getSdView().getFrame().lifeLinesCount());
         assertEquals("filter", 6, fFacility.getSdView().getFrame().syncMessageCount());
 
-        String messages[] = { "REGISTER_PLAYER_REQUEST", "REGISTER_PLAYER_REPLY", "GAME_REQUEST", "GAME_REPLY", "START_GAME_REQUEST", "START_GAME_REPLY" };
+        String messages[] = { "REGISTER_PLAYER_REQUEST", "REGISTER_PLAYER_REPLY",
+                "GAME_REQUEST", "GAME_REPLY", "START_GAME_REQUEST", "START_GAME_REPLY" };
 
         for (int i = 0; i < messages.length; i++) {
             SyncMessage msg = fFacility.getSdView().getFrame().getSyncMessage(i);
             assertTrue("filter", msg instanceof TmfSyncMessage);
             assertEquals("filter", messages[i], msg.getName());
         }
+    }
 
-        /*
-         * Test Case: 005
-         * Description: Verify filter lifeline (1 out of three lifelines).
-         *              Note that filter was set during change of page.
-         * Verified Methods: loader.filter(), loader.fillCurrentPage()
-         * Expected result: Only 2 lifelines and their interactions are shown
-         */
+    /**
+     * Verify filter lifeline (1 out of three lifelines). Note that filter was
+     * set during change of page.
+     *
+     * Verified Methods: loader.filter(), loader.fillCurrentPage()
+     * Expected result: Only 2 lifelines and their interactions are shown
+     */
+    @Test
+    public void verifyFilter1of3() {
         filterToSave.get(0).setActive(true);
         filterToSave.get(2).setActive(false);
         fFacility.setPage(IUml2SDTestConstants.PAGE_OF_ALL_LIFELINES);
index dfa6816029048fff64d37deac516b491b0d6016c..d675ffcc433212b2065e9606c8f78de23242dafd 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011, 2012 Ericsson
+ * Copyright (c) 2011-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
@@ -8,14 +8,17 @@
  *
  * Contributors:
  *   Bernd Hufmann - Initial API and implementation
+ *   Alexandre Montplaisir - Port to JUnit4
  *******************************************************************************/
+
 package org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.loader;
 
-import java.util.List;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import java.util.List;
 
 import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
@@ -24,13 +27,17 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.Criteria;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDGraphNodeSupporter;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.loader.TmfSyncMessage;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
 /**
  * Search Test Cases.
  *
  * @author Bernd Hufmann
  */
-public class TmfUml2SDSyncLoaderFindTest extends TestCase {
+@SuppressWarnings("nls")
+public class TmfUml2SDSyncLoaderFindTest {
 
     // ------------------------------------------------------------------------
     // Attributes
@@ -38,7 +45,7 @@ public class TmfUml2SDSyncLoaderFindTest extends TestCase {
 
     // Test case 002 expected values
     final static private Uml2SDTestTimestamp TC_002_TIME_VALUE       = new Uml2SDTestTimestamp(9788642104149L);
-    final static private String              TC_002_MESSAGE_NAME     = "GAME_REQUEST"; //$NON-NLS-1$
+    final static private String              TC_002_MESSAGE_NAME     = "GAME_REQUEST";
     final static private int                 TC_002_PAGE_VALUE       = 0;
     final static private int                 TC_002_START_OCCURRANCE = 3;
     final static private int                 TC_002_END_OCCURRANCE   = TC_002_START_OCCURRANCE;
@@ -47,7 +54,7 @@ public class TmfUml2SDSyncLoaderFindTest extends TestCase {
 
     // Test case 003 expected values
     final static private Uml2SDTestTimestamp TC_003_TIME_VALUE       = new Uml2SDTestTimestamp(9788642113228L);
-    final static private String              TC_003_MESSAGE_NAME     = "GAME_REPLY"; //$NON-NLS-1$
+    final static private String              TC_003_MESSAGE_NAME     = "GAME_REPLY";
     final static private int                 TC_003_PAGE_VALUE       = 0;
     final static private int                 TC_003_START_OCCURRANCE = 4;
     final static private int                 TC_003_END_OCCURRANCE   = TC_003_START_OCCURRANCE;
@@ -56,7 +63,7 @@ public class TmfUml2SDSyncLoaderFindTest extends TestCase {
 
     // Test case 004 expected values
     final static private Uml2SDTestTimestamp TC_004_TIME_VALUE       = new Uml2SDTestTimestamp(9791893030834L);
-    final static private String              TC_004_MESSAGE_NAME     = "GAME_REQUEST"; //$NON-NLS-1$
+    final static private String              TC_004_MESSAGE_NAME     = "GAME_REQUEST";
     final static private int                 TC_004_PAGE_VALUE       = 4;
     final static private int                 TC_004_START_OCCURRANCE = 19;
     final static private int                 TC_004_END_OCCURRANCE   = TC_004_START_OCCURRANCE;
@@ -71,60 +78,47 @@ public class TmfUml2SDSyncLoaderFindTest extends TestCase {
     final static private int                 TC_006_PAGE_VALUE       = 4;
     final static private String              TC_006_LIFELINE_NAME    = IUml2SDTestConstants.SECOND_PLAYER_NAME;
 
-    private Uml2SDTestFacility    fFacility;
-    private Uml2SDSignalValidator fTmfComponent;
+    // Fields used in tests
+    private static Uml2SDTestFacility    fFacility;
+    private static Uml2SDSignalValidator fTmfComponent;
+    private static Criteria criteria;
+    private static List<GraphNode> selection;
+    private static TmfSyncMessage msg;
+    private static Lifeline lifeline;
 
     // ------------------------------------------------------------------------
-    // Static methods
+    // Operations
     // ------------------------------------------------------------------------
 
     /**
-     * Returns test setup used when executing test case stand-alone.
-     * @return Test setup class
-     */
-    public static Test suite() {
-        return new Uml2SDTestSetup(new TestSuite(TmfUml2SDSyncLoaderFindTest.class));
-    }
-
-    // ------------------------------------------------------------------------
-    // Constructors
-    // ------------------------------------------------------------------------
-    /**
-     * Constructor
+     * Initialization
      */
-    public TmfUml2SDSyncLoaderFindTest() {
-    }
-
-    // ------------------------------------------------------------------------
-    // Operations
-    // ------------------------------------------------------------------------
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
+    @BeforeClass
+    public static void setUpClass() {
         fFacility = Uml2SDTestFacility.getInstance();
         fFacility.selectExperiment();
     }
 
-    @Override
-    public void tearDown() throws Exception {
+    /**
+     * Cleanup
+     */
+    @AfterClass
+    public static void tearDownClass() {
         fFacility.disposeExperiment();
         fFacility = null;
-        super.tearDown();
     }
 
     /**
-     * Main method with test cases.
+     * Verify the ISDGraphNodeSupporter implementation.
+     *
+     * Verified Methods: loader.isNodeSupported(), loader.getNodeName()
+     * Expected result: Correct values are returned, i.e. only lifelines and
+     *                  sync. messages are supported.
      */
-    @SuppressWarnings("nls")
-    public void testFindHandling() {
+    @Test
+    public void verifyISDGraphNodeSupporter() {
         fTmfComponent = new Uml2SDSignalValidator();
 
-        /*
-         * Test Case: 001
-         * Description: Verify the ISDGraphNodeSupporter implementation
-         * Verified Methods: loader.isNodeSupported(), loader.getNodeName()
-         * Expected result: Correct values are returned, i.e. only lifelines and sync. messages are supported
-         */
         assertTrue("isNodeSupported", fFacility.getLoader().isNodeSupported(ISDGraphNodeSupporter.LIFELINE));
         assertTrue("isNodeSupported", fFacility.getLoader().isNodeSupported(ISDGraphNodeSupporter.SYNCMESSAGE));
         assertFalse("isNodeSupported", fFacility.getLoader().isNodeSupported(ISDGraphNodeSupporter.SYNCMESSAGERETURN));
@@ -140,14 +134,17 @@ public class TmfUml2SDSyncLoaderFindTest extends TestCase {
         assertEquals("getNodeName", "", fFacility.getLoader().getNodeName(ISDGraphNodeSupporter.STOP, null));
 
         fFacility.getLoader().cancel();
+    }
 
-        /*
-         * Test Case: 002
-         * Description: Verify 1st message find within page
-         * Verified Methods: loader.find(), loader.moveToMessage()
-         * Expected result: Correct message is selected
-         */
-        Criteria criteria = new Criteria();
+    /**
+     * Verify 1st message find within page.
+     *
+     * Verified Methods: loader.find(), loader.moveToMessage()
+     * Expected result: Correct message is selected
+     */
+    @Test
+    public void verifyFirstMessage() {
+        criteria = new Criteria();
         criteria.setSyncMessageSelected(true);
         criteria.setExpression("GAME_.*");
 
@@ -166,24 +163,27 @@ public class TmfUml2SDSyncLoaderFindTest extends TestCase {
         assertFalse("find", fTmfComponent.isSourceError());
 
         assertEquals("find", TC_002_PAGE_VALUE, fFacility.getLoader().currentPage());
-        List<GraphNode> selection = fFacility.getSdView().getSDWidget().getSelection();
+        selection = fFacility.getSdView().getSDWidget().getSelection();
         assertNotNull(selection);
         assertEquals("find", 1, selection.size());
         assertTrue(selection.get(0) instanceof TmfSyncMessage);
-        TmfSyncMessage msg = (TmfSyncMessage) selection.get(0);
+        msg = (TmfSyncMessage) selection.get(0);
         assertEquals("find", TC_002_MESSAGE_NAME, msg.getName());
         assertEquals("find", 0, TC_002_TIME_VALUE.compareTo(msg.getStartTime(), false));
         assertEquals("find", TC_002_START_OCCURRANCE, msg.getStartOccurrence());
         assertEquals("find", TC_002_END_OCCURRANCE, msg.getEndOccurrence());
         assertEquals("find", TC_002_START_LIFELINE, msg.getStartLifeline().getName());
         assertEquals("find", TC_002_END_LIFELINE, msg.getEndLifeline().getName());
+    }
 
-        /*
-         * Test Case: 003
-         * Description: Verify 2nd message find within page
-         * Verified Methods: loader.find(), loader.moveToMessage()
-         * Expected result: Correct message is selected
-         */
+    /**
+     * Verify 2nd message find within page.
+     *
+     * Verified Methods: loader.find(), loader.moveToMessage()
+     * Expected result: Correct message is selected
+     */
+    @Test
+    public void verifySecondMessage() {
         // set expected values
         fTmfComponent.setSource(fFacility.getLoader());
         fTmfComponent.setCurrentTime(TC_003_TIME_VALUE);
@@ -211,13 +211,16 @@ public class TmfUml2SDSyncLoaderFindTest extends TestCase {
         assertEquals("find", TC_003_END_OCCURRANCE, msg.getEndOccurrence());
         assertEquals("find", TC_003_START_LIFELINE, msg.getStartLifeline().getName());
         assertEquals("find", TC_003_END_LIFELINE, msg.getEndLifeline().getName());
+    }
 
-        /*
-         * Test Case: 004
-         * Description: Verify 1st message across page
-         * Verified Methods: loader.find(), loader.moveToPage(), loader.moveToMessage()
-         * Expected result: Correct message is selected
-         */
+    /**
+     * Verify 1st message across page.
+     *
+     * Verified Methods: loader.find(), loader.moveToPage(), loader.moveToMessage()
+     * Expected result: Correct message is selected
+     */
+    @Test
+    public void verifyFirstMesage() {
         // set expected values
         fTmfComponent.setSource(fFacility.getLoader());
         fTmfComponent.setCurrentTime(TC_004_TIME_VALUE);
@@ -253,13 +256,16 @@ public class TmfUml2SDSyncLoaderFindTest extends TestCase {
         // cancel find and go back to first page
         fFacility.getLoader().cancel();
         fFacility.firstPage();
+    }
 
-        /*
-         * Test Case: 005
-         * Description: Verify find of lifeline within page
-         * Verified Methods: loader.find(), loader.moveToPage(), loader.moveToMessage()
-         * Expected result: Correct message is selected
-         */
+    /**
+     * Verify find of lifeline within page.
+     *
+     * Verified Methods: loader.find(), loader.moveToPage(), loader.moveToMessage()
+     * Expected result: Correct message is selected
+     */
+    @Test
+    public void verifyFind() {
         criteria = new Criteria();
         criteria.setLifeLineSelected(true);
         criteria.setExpression(IUml2SDTestConstants.FIRST_PLAYER_NAME);
@@ -272,15 +278,18 @@ public class TmfUml2SDSyncLoaderFindTest extends TestCase {
         assertNotNull(selection);
         assertEquals("find", 1, selection.size());
         assertTrue(selection.get(0) instanceof Lifeline);
-        Lifeline lifeline = (Lifeline) selection.get(0);
+        lifeline = (Lifeline) selection.get(0);
         assertEquals("find", TC_005_LIFELINE_NAME, lifeline.getName());
+    }
 
-        /*
-         * Test Case: 006
-         * Description: Verify lifeline across page
-         * Verified Methods: loader.find(), loader.moveToPage(), loader.moveToMessage()
-         * Expected result: Correct message is selected
-         */
+    /**
+     * Verify lifeline across page.
+     *
+     * Verified Methods: loader.find(), loader.moveToPage(), loader.moveToMessage()
+     * Expected result: Correct message is selected
+     */
+    @Test
+    public void verifyLifeline() {
         criteria = new Criteria();
         criteria.setLifeLineSelected(true);
         criteria.setExpression(IUml2SDTestConstants.SECOND_PLAYER_NAME);
@@ -304,13 +313,16 @@ public class TmfUml2SDSyncLoaderFindTest extends TestCase {
         // cancel find and go back to first page
         fFacility.getLoader().cancel();
         fFacility.firstPage();
+    }
 
-        /*
-         * Test Case: 007
-         * Description: Verify cancel ongoing search job
-         * Verified Methods: loader.find(), loader.find()
-         * Expected result: Cancelled find
-         */
+    /**
+     * Verify cancel ongoing search job.
+     *
+     * Verified Methods: loader.find(), loader.find()
+     * Expected result: Cancelled find
+     */
+    @Test
+    public void verifyCancelSearch() {
         criteria = new Criteria();
         criteria.setLifeLineSelected(true);
         criteria.setExpression(IUml2SDTestConstants.SECOND_PLAYER_NAME);
index c9ef78bb4925b303c9c799ca332c86302f74e32d..06aa9c7e8fc8a91a6f8fb817ecf9774530274b78 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011, 2012 Ericsson
+ * Copyright (c) 2011-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:
  *   Bernd Hufmann - Initial API and implementation
+ *   Alexandre Montplaisir - Port to JUnit4
  *******************************************************************************/
+
 package org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.loader;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+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.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
 /**
  * Test cases for pages handling.
  *
  * @author Bernd Hufmann
- *
  */
-public class TmfUml2SDSyncLoaderPagesTest extends TestCase {
+public class TmfUml2SDSyncLoaderPagesTest {
 
     // ------------------------------------------------------------------------
     // Attributes
     // ------------------------------------------------------------------------
-    private Uml2SDTestFacility fFacility;
 
-    // ------------------------------------------------------------------------
-    // Static methods
-    // ------------------------------------------------------------------------
-
-    /**
-     * Returns test setup used when executing test case stand-alone.
-     * @return Test setup class
-     */
-    public static Test suite() {
-        return new Uml2SDTestSetup(new TestSuite(TmfUml2SDSyncLoaderPagesTest.class));
-    }
+    private static Uml2SDTestFacility fFacility;
 
     // ------------------------------------------------------------------------
-    // Constructors
+    // Operations
     // ------------------------------------------------------------------------
+
     /**
-     * Constructor
+     * Initialization
      */
-    public TmfUml2SDSyncLoaderPagesTest() {
-    }
-
-    // ------------------------------------------------------------------------
-    // Operations
-    // ------------------------------------------------------------------------
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
+    @BeforeClass
+    public static void setUpClass() {
         fFacility = Uml2SDTestFacility.getInstance();
         fFacility.selectExperiment();
     }
 
-
-    @Override
-    public void tearDown() throws Exception {
+    /**
+     * Cleanup
+     */
+    @AfterClass
+    public static void tearDownClass() {
         fFacility.disposeExperiment();
         fFacility = null;
-        super.tearDown();
     }
 
     /**
-     * Main method with test cases.
+     * Test Case: 001
+     * Description: Test number of pages.
+     * Verified Methods: loader.pagesCount().
+     * Expected result: ITestConstants.TOTAL_NUMBER_OF_PAGES of pages
      */
-    public void testPageHandling() {
-
-        verifyPagesCount();
-        verifyNextPage();
-        verifyPrevPage();
-        verifyFirstPage();
-        verifyLastPage();
-        verifyPageNumberChanged();
-
-    }
-
-     private void verifyPagesCount() {
-
-        /*
-         * Test Case: 001
-         * Description: Test number of pages.
-         * Verified Methods: loader.pagesCount().
-         * Expected result: ITestConstants.TOTAL_NUMBER_OF_PAGES of pages
-         */
+    @Test
+     public void verifyPagesCount() {
         assertEquals(IUml2SDTestConstants.TOTAL_NUMBER_OF_PAGES, fFacility.getLoader().pagesCount());
     }
 
-    private void verifyNextPage() {
-        // assuming we are at the first page
-
-        /*
-         * Test Case: 002
-         * Description: Tests next page feature.
-         * Verified Methods: loader.nextPage(), loader.fillCurrentPage(), loader.pagesCount(),
-         *                   loader.hasNextPage(), loader.hasPrevPage(),
-         *                   frame.syncMessagesCount, frame.lifeLinesCount
-         * Expected result: Expected values are return.
-         */
 
+    /**
+     * Test Case: 002
+     * Description: Tests next page feature.
+     * Verified Methods: loader.nextPage(), loader.fillCurrentPage(), loader.pagesCount(),
+     *                   loader.hasNextPage(), loader.hasPrevPage(),
+     *                   frame.syncMessagesCount, frame.lifeLinesCount
+     * Expected result: Expected values are return.
+     */
+    @Test
+    public void verifyNextPage() {
+        // assuming we are at the first page
         for(int i = 0; i < IUml2SDTestConstants.TOTAL_NUMBER_OF_PAGES-2; i++) {
             fFacility.nextPage();
 
@@ -129,19 +105,16 @@ public class TmfUml2SDSyncLoaderPagesTest extends TestCase {
         fFacility.firstPage();
     }
 
-
-    private void verifyPrevPage() {
-        // assuming we are at the first page
-
-        /*
-         * Test Case: 003
-         * Description: Test previous page feature.
-         * Verified Methods: loader.prevPage(), loader.fillCurrentPage(), loader.pagesCount(),
-         *                   loader.hasNextPage(), loader.hasPrevPage(),
-         *                   frame.syncMessagesCount, frame.lifeLinesCount
-         * Expected result: Expected values are return.
-         */
-
+    /**
+     * Test Case: 003
+     * Description: Test previous page feature.
+     * Verified Methods: loader.prevPage(), loader.fillCurrentPage(), loader.pagesCount(),
+     *                   loader.hasNextPage(), loader.hasPrevPage(),
+     *                   frame.syncMessagesCount, frame.lifeLinesCount
+     * Expected result: Expected values are return.
+     */
+    @Test
+    public void verifyPrevPage() {
         // Last Page
         fFacility.lastPage();
         assertEquals(IUml2SDTestConstants.TOTAL_NUMBER_OF_PAGES - 1, fFacility.getLoader().currentPage());
@@ -170,59 +143,62 @@ public class TmfUml2SDSyncLoaderPagesTest extends TestCase {
         }
     }
 
-    private void verifyFirstPage() {
+    /**
+     * Test Case: 004
+     * Description: Test first page feature.
+     * Verified Methods: loader.firstPage(), loader.fillCurrentPage(), loader.pagesCount(),
+     *                   loader.hasNextPage(), loader.hasPrevPage(),
+     *                   frame.syncMessagesCount, frame.lifeLinesCount
+     * Expected result: Expected values are return.
+     */
+    @Test
+    public void verifyFirstPage() {
         fFacility.lastPage();
-        /*
-         * Test Case: 004
-         * Description: Test first page feature.
-         * Verified Methods: loader.firstPage(), loader.fillCurrentPage(), loader.pagesCount(),
-         *                   loader.hasNextPage(), loader.hasPrevPage(),
-         *                   frame.syncMessagesCount, frame.lifeLinesCount
-         * Expected result: Expected values are return.
-         */
 
         // First Page
         fFacility.firstPage();
         verifyPage(0, IUml2SDTestConstants.MAX_MESSEAGES_PER_PAGE, true, false);
     }
 
-
-    private void verifyLastPage() {
-        /*
-         * Test Case: 005
-         * Description: Test last page feature.
-         * Verified Methods: loader.lastPage(), loader.pagesCount(), loader.hasNextPage(), loader.hasPrevPage()
-         *                   frame.syncMessagesCount, frame.lifeLinesCount
-         * Expected result: Expected values are return.
-         */
+    /**
+     * Test Case: 005
+     * Description: Test last page feature.
+     * Verified Methods: loader.lastPage(), loader.pagesCount(), loader.hasNextPage(), loader.hasPrevPage()
+     *                   frame.syncMessagesCount, frame.lifeLinesCount
+     * Expected result: Expected values are return.
+     */
+    @Test
+    public void verifyLastPage() {
         fFacility.lastPage();
         verifyPage(IUml2SDTestConstants.TOTAL_NUMBER_OF_PAGES - 1, IUml2SDTestConstants.NUM_MESSAGES_OF_LAST_PAGE, false, true);
         fFacility.firstPage();
     }
 
-    private void verifyPageNumberChanged() {
-
-        /*
-         * Test Case: 006
-         * Description: Test move to any page feature.
-         * Verified Methods: loader.pageNumberChanged(), loader.fillCurrentPage(), loader.pagesCount(),
-         *                   loader.hasNextPage(), loader.hasPrevPage(),
-         *                   frame.syncMessagesCount, frame.lifeLinesCount
-         * Expected result: Expected values are return.
-         */
-
+    /**
+     * Test Case: 006
+     * Description: Test move to any page feature.
+     * Verified Methods: loader.pageNumberChanged(), loader.fillCurrentPage(), loader.pagesCount(),
+     *                   loader.hasNextPage(), loader.hasPrevPage(),
+     *                   frame.syncMessagesCount, frame.lifeLinesCount
+     * Expected result: Expected values are return.
+     */
+    @Test
+    public void verifyPageNumberChanged() {
         // any page
         fFacility.setPage(IUml2SDTestConstants.PAGE_OF_ALL_LIFELINES);
-        verifyPage(IUml2SDTestConstants.PAGE_OF_ALL_LIFELINES, IUml2SDTestConstants.MAX_MESSEAGES_PER_PAGE, true, true, IUml2SDTestConstants.NUM_OF_ALL_LIFELINES);
+        verifyPage(IUml2SDTestConstants.PAGE_OF_ALL_LIFELINES,
+                IUml2SDTestConstants.MAX_MESSEAGES_PER_PAGE, true, true,
+                IUml2SDTestConstants.NUM_OF_ALL_LIFELINES);
         fFacility.firstPage();
     }
 
-    private void verifyPage(int currentPage, int numMsg, boolean hasNext, boolean hasPrev) {
+    private static void verifyPage(int currentPage, int numMsg, boolean hasNext, boolean hasPrev) {
         verifyPage(currentPage, numMsg, hasNext, hasPrev, IUml2SDTestConstants.DEFAULT_NUM_LIFELINES);
     }
 
     @SuppressWarnings("nls")
-    private void verifyPage(int currentPage, int numMsg, boolean hasNext, boolean hasPrev, int lifelineCount) {
+    private static void verifyPage(int currentPage, int numMsg, boolean hasNext,
+            boolean hasPrev, int lifelineCount) {
         assertEquals("currentPage", currentPage, fFacility.getLoader().currentPage());
         assertEquals("syncMessageCount, ", numMsg, fFacility.getSdView().getFrame().syncMessageCount());
         if (hasNext) {
index c1c0b953886d3d3cb84b8782210c0d72fdae594d..606e7d49d4e5979aea7f5a78ef8650d0b28e1f78 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011, 2012 Ericsson
+ * Copyright (c) 2011-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
@@ -8,92 +8,74 @@
  *
  * Contributors:
  *   Bernd Hufmann - Initial API and implementation
+ *   Alexandre Montplaisir - Port to JUnit4
  *******************************************************************************/
+
 package org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.loader;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
 /**
  * Test cases for signal handling.
  *
  * @author Bernd Hufmann
- *
  */
-public class TmfUml2SDSyncLoaderSignalTest extends TestCase {
+@SuppressWarnings("nls")
+public class TmfUml2SDSyncLoaderSignalTest {
 
-    // ------------------------------------------------------------------------
-    // Attributes
-    // ------------------------------------------------------------------------
-    private Uml2SDTestFacility fFacility;
-    private Uml2SDSignalValidator fTmfComponent;
+    private static Uml2SDTestFacility fFacility;
+    private static Uml2SDSignalValidator fTmfComponent;
 
-    // ------------------------------------------------------------------------
-    // Static methods
-    // ------------------------------------------------------------------------
+    private static TmfTimeRange range;
+    private static TmfTimestamp rangeWindow;
+    private static TmfTimestamp currentTime;
 
     /**
-     * Returns test setup used when executing test case stand-alone.
-     * @return Test setup class
+     * Initialization
      */
-    public static Test suite() {
-        return new Uml2SDTestSetup(new TestSuite(TmfUml2SDSyncLoaderSignalTest.class));
-    }
-
-    // ------------------------------------------------------------------------
-    // Constructors
-    // ------------------------------------------------------------------------
-    /**
-     * Constructor
-     */
-    public TmfUml2SDSyncLoaderSignalTest() {
-    }
-
-    // ------------------------------------------------------------------------
-    // Operations
-    // ------------------------------------------------------------------------
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
+    @BeforeClass
+    public static void setUpClass() {
         fFacility = Uml2SDTestFacility.getInstance();
         fFacility.selectExperiment();
+
+        range = new TmfTimeRange(new Uml2SDTestTimestamp(9789689220871L), new Uml2SDTestTimestamp(9789773881426L));
+        // Get range window for tests below
+        rangeWindow = (TmfTimestamp) range.getEndTime().getDelta(range.getStartTime());
+        currentTime = new Uml2SDTestTimestamp(9789773782043L);
+
+        fFacility.getTrace().broadcast(new TmfRangeSynchSignal(fFacility, range, currentTime));
+        fFacility.delay(IUml2SDTestConstants.BROADCAST_DELAY);
+
+        fTmfComponent = new Uml2SDSignalValidator();
     }
 
-    @Override
-    public void tearDown() throws Exception {
+    /**
+     * Cleanup
+     */
+    @AfterClass
+    public static void tearDownClass() {
         fFacility.disposeExperiment();
         fFacility = null;
-        super.tearDown();
     }
 
     /**
-     * Main method with test cases.
+     * Test Case: 001
+     * Description: Verify that time range signal is send with correct values when going to first page
+     * Verified Methods: broadcast()
+     * Expected result: Time range sync signal is sent with correct range and current time.
      */
-    @SuppressWarnings("nls")
-    public void testSignalHandling() {
-
-        TmfTimeRange range = new TmfTimeRange(new Uml2SDTestTimestamp(9789689220871L), new Uml2SDTestTimestamp(9789773881426L));
-        // Get range window for tests below
-        TmfTimestamp rangeWindow = (TmfTimestamp) range.getEndTime().getDelta(range.getStartTime());
-        TmfTimestamp currentTime = new Uml2SDTestTimestamp(9789773782043L);
-
-        fFacility.getTrace().broadcast(new TmfRangeSynchSignal(this, range, currentTime));
-        fFacility.delay(IUml2SDTestConstants.BROADCAST_DELAY);
-
-        fTmfComponent = new Uml2SDSignalValidator();
-
-        /*
-         * Test Case: 001
-         * Description: Verify that time range signal is send with correct values when going to first page
-         * Verified Methods: broadcast()
-         * Expected result: Time range sync signal is sent with correct range and current time.
-         */
+    @Test
+    public void verifyFirstPageSignal() {
         currentTime = new Uml2SDTestTimestamp(9788641608418L);
         range = new TmfTimeRange(currentTime, new Uml2SDTestTimestamp(currentTime.getValue() + rangeWindow.getValue()));
 
@@ -114,13 +96,16 @@ public class TmfUml2SDSyncLoaderSignalTest extends TestCase {
         assertFalse("TmfRangeSynchSignal", fTmfComponent.isCurrentTimeError());
         assertFalse("TmfRangeSynchSignal", fTmfComponent.isSourceError());
         assertFalse("TmfRangeSynchSignal", fTmfComponent.isRangeError());
+    }
 
-        /*
-         * Test Case: 002
-         * Description: Verify that time sync signal is sent correctly after selection
-         * Verified Methods: loader.broadcast(), testSelectionChanged
-         * Expected result: Time sync signal is sent with correct current time.
-         */
+    /**
+     * Test Case: 002
+     * Description: Verify that time sync signal is sent correctly after selection
+     * Verified Methods: loader.broadcast(), testSelectionChanged
+     * Expected result: Time sync signal is sent with correct current time.
+     */
+    @Test
+    public void verifySelectionSignal() {
         fTmfComponent.setSignalReceived(false);
 
         int count = fFacility.getSdView().getFrame().syncMessageCount();
index bae2f87658c88104ce36f7e1c5e71930bb546f7d..06ad8a1015596844604d54500c0ec49eeb961b39 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011, 2012 Ericsson
+ * Copyright (c) 2011-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
@@ -8,14 +8,16 @@
  *
  * Contributors:
  *   Bernd Hufmann - Initial API and implementation
+ *   Alexandre Montplaisir - Port to JUnit4
  *******************************************************************************/
+
 package org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.loader;
 
-import java.util.List;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import java.util.List;
 
 import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
@@ -23,18 +25,22 @@ import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.loader.TmfSyncMessage;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
 /**
  * Test cases for time synchronization handling.
  *
  * @author Bernd Hufmann
- *
  */
-public class TmfUml2SDSyncLoaderTimeTest extends TestCase {
+@SuppressWarnings("nls")
+public class TmfUml2SDSyncLoaderTimeTest {
 
     // ------------------------------------------------------------------------
     // Attributes
     // ------------------------------------------------------------------------
+
     // Test case 001 expected values
     final static private Uml2SDTestTimestamp TC_001_TIME_VALUE       = new Uml2SDTestTimestamp(9788642228395L);
     final static private String              TC_001_MESSAGE_NAME     = "START_GAME_REPLY"; //$NON-NLS-1$
@@ -87,80 +93,66 @@ public class TmfUml2SDSyncLoaderTimeTest extends TestCase {
     final static private Uml2SDTestTimestamp TC_009_START_TIME_VALUE = TC_009_TIME_VALUE;
     final static private Uml2SDTestTimestamp TC_009_END_TIME_VALUE   = new Uml2SDTestTimestamp(9789773881426L);
 
-    private Uml2SDTestFacility fFacility;
+    // Fields used in tests
+    private static Uml2SDTestFacility fFacility;
+    private static List<GraphNode> selection;
+    private static TmfSyncMessage msg;
 
     // ------------------------------------------------------------------------
-    // Static methods
+    // Operations
     // ------------------------------------------------------------------------
 
     /**
-     * Returns test setup used when executing test case stand-alone.
-     * @return Test setup class
-     */
-    public static Test suite() {
-        return new Uml2SDTestSetup(new TestSuite(TmfUml2SDSyncLoaderTimeTest.class));
-    }
-
-    // ------------------------------------------------------------------------
-    // Constructors
-    // ------------------------------------------------------------------------
-    /**
-     * Constructor
+     * Initialization
      */
-    public TmfUml2SDSyncLoaderTimeTest() {
-    }
-
-    // ------------------------------------------------------------------------
-    // Operations
-    // ------------------------------------------------------------------------
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
+    @BeforeClass
+    public static void setUpClass() {
         fFacility = Uml2SDTestFacility.getInstance();
         fFacility.selectExperiment();
     }
 
-
-    @Override
-    public void tearDown() throws Exception {
+    /**
+     * Cleanup
+     */
+    @AfterClass
+    public static void tearDownClass() {
         fFacility.disposeExperiment();
         fFacility = null;
-        super.tearDown();
     }
 
     /**
-     * Main method with test cases.
+     * Test Case: 001
+     * Description: Verify synchToTime (exact time in page), selection of message in page
+     * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToMessageInPage()
+     * Expected result: Correct message is selected.
      */
-    @SuppressWarnings("nls")
-    public void testTimeHandling() {
-        /*
-         * Test Case: 001
-         * Description: Verify synchToTime (exact time in page), selection of message in page
-         * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToMessageInPage()
-         * Expected result: Correct message is selected.
-         */
+    @Test
+    public void verifySynchToTimeInPage() {
         fFacility.getTrace().broadcast(new TmfTimeSynchSignal(this, TC_001_TIME_VALUE));
         fFacility.getLoader().waitForCompletion();
         fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
         assertEquals("synchToTime", TC_001_PAGE_VALUE, fFacility.getLoader().currentPage());
-        List<GraphNode> selection = fFacility.getSdView().getSDWidget().getSelection();
+        selection = fFacility.getSdView().getSDWidget().getSelection();
         assertNotNull(selection);
         assertEquals("synchToTime", 1, selection.size());
         assertTrue(selection.get(0) instanceof TmfSyncMessage);
-        TmfSyncMessage msg = (TmfSyncMessage) selection.get(0);
+        msg = (TmfSyncMessage) selection.get(0);
         assertEquals("synchToTime", TC_001_MESSAGE_NAME, msg.getName());
         assertEquals("synchToTime", 0, TC_001_TIME_VALUE.compareTo(msg.getStartTime(), false));
         assertEquals("synchToTime", TC_001_START_OCCURRANCE, msg.getStartOccurrence());
         assertEquals("synchToTime", TC_001_END_OCCURRANCE, msg.getEndOccurrence());
         assertEquals("synchToTime", TC_001_START_LIFELINE, msg.getStartLifeline().getName());
         assertEquals("synchToTime", TC_001_END_LIFELINE, msg.getEndLifeline().getName());
+    }
 
-        /*
-         * Test Case: 002
-         * Description: Verify synchToTime (exact time outside of page), selection of message in page
-         * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage()
-         * Expected result: Correct message is selected.
-         */
+    /**
+     * Test Case: 002
+     * Description: Verify synchToTime (exact time outside of page), selection of message in page
+     * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage()
+     * Expected result: Correct message is selected.
+     */
+    @Test
+    public void verifySynchToTimeOutsidePage() {
         fFacility.getTrace().broadcast(new TmfTimeSynchSignal(this, TC_002_TIME_VALUE));
         fFacility.getLoader().waitForCompletion();
         fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
@@ -176,14 +168,17 @@ public class TmfUml2SDSyncLoaderTimeTest extends TestCase {
         assertEquals("synchToTime", TC_002_END_OCCURRANCE, msg.getEndOccurrence());
         assertEquals(TC_002_START_LIFELINE, msg.getStartLifeline().getName());
         assertEquals(TC_002_END_LIFELINE, msg.getEndLifeline().getName());
+    }
 
 
-        /*
-         * Test Case: 003
-         * Description: Verify synchToTime (timestamp doesn't exist in trace), no selection of message in page
-         * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage()
-         * Expected result: Move to correct page, currentTime is updated so that focus on the currentTime, but no selection.
-         */
+    /**
+     * Test Case: 003
+     * Description: Verify synchToTime (timestamp doesn't exist in trace), no selection of message in page
+     * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage()
+     * Expected result: Move to correct page, currentTime is updated so that focus on the currentTime, but no selection.
+     */
+    @Test
+    public void verifySynchToTimeNonExisting() {
         fFacility.getLoader().firstPage();
 
         fFacility.getTrace().broadcast(new TmfTimeSynchSignal(this, TC_003_TIME_VALUE));
@@ -194,13 +189,16 @@ public class TmfUml2SDSyncLoaderTimeTest extends TestCase {
         selection = fFacility.getSdView().getSDWidget().getSelection();
         assertNotNull("synchToTime", selection);
         assertEquals("synchToTime", 0, selection.size());
+    }
 
-        /*
-         * Test Case: 004
-         * Description: Verify synchToTime (timestamp < experiment time range start)
-         * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage()
-         * Expected result: Move to first page, focus on the beginning of the page, but no selection.
-         */
+    /**
+     * Test Case: 004
+     * Description: Verify synchToTime (timestamp < experiment time range start)
+     * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage()
+     * Expected result: Move to first page, focus on the beginning of the page, but no selection.
+     */
+    @Test
+    public void verifySynchToTimeBeforeExpStart() {
         fFacility.getTrace().broadcast(new TmfTimeSynchSignal(this, TmfTimestamp.BIG_BANG));
         fFacility.getLoader().waitForCompletion();
         fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
@@ -208,13 +206,16 @@ public class TmfUml2SDSyncLoaderTimeTest extends TestCase {
         selection = fFacility.getSdView().getSDWidget().getSelection();
         assertNotNull("synchToTime", selection);
         assertEquals("synchToTime", 0, selection.size());
+    }
 
-        /*
-         * Test Case: 005
-         * Description: Verify synchToTime (timestamp > experiment time range end)
-         * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage()
-         * Expected result: Move to last page, focus on the end of the page, but no selection.
-         */
+    /**
+     * Test Case: 005
+     * Description: Verify synchToTime (timestamp > experiment time range end)
+     * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage()
+     * Expected result: Move to last page, focus on the end of the page, but no selection.
+     */
+    @Test
+    public void verifySynchToTimeAfterExpEnd() {
         fFacility.getTrace().broadcast(new TmfTimeSynchSignal(this, TmfTimestamp.BIG_CRUNCH));
         fFacility.getLoader().waitForCompletion();
         fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
@@ -222,13 +223,16 @@ public class TmfUml2SDSyncLoaderTimeTest extends TestCase {
         selection = fFacility.getSdView().getSDWidget().getSelection();
         assertNotNull(selection);
         assertEquals("synchToTime", 0, selection.size());
+    }
 
-        /*
-         * Test Case: 006
-         * Description: Verify synchToTime (timestamp of last message in page)
-         * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage(), loader.moveToMessageInPage()
-         * Expected result: Move to correct page, selection of last message in page.
-         */
+    /**
+     * Test Case: 006
+     * Description: Verify synchToTime (timestamp of last message in page)
+     * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage(), loader.moveToMessageInPage()
+     * Expected result: Move to correct page, selection of last message in page.
+     */
+    @Test
+    public void verifySynchToTimeEqualsLast() {
         fFacility.getTrace().broadcast(new TmfTimeSynchSignal(this, TC_006_TIME_VALUE));
         fFacility.getLoader().waitForCompletion();
         fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
@@ -239,13 +243,16 @@ public class TmfUml2SDSyncLoaderTimeTest extends TestCase {
         msg = (TmfSyncMessage) selection.get(0);
         assertEquals("synchToTime", TC_006_START_OCCURRANCE, msg.getStartOccurrence());
         assertEquals("synchToTime", TC_006_END_OCCURRANCE, msg.getEndOccurrence());
+    }
 
-        /*
-        * Test Case: 007
-        * Description: Verify synchToTime (timestamp of first message in page)
-        * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage()
-        * Expected result: Move to correct page, selection of last message in page.
-        */
+    /**
+     * Test Case: 007
+     * Description: Verify synchToTime (timestamp of first message in page)
+     * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage()
+     * Expected result: Move to correct page, selection of last message in page.
+     */
+    @Test
+    public void verifySynchToTimeFirst() {
         fFacility.getTrace().broadcast(new TmfTimeSynchSignal(this, TC_007_TIME_VALUE));
         fFacility.getLoader().waitForCompletion();
         fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
@@ -256,13 +263,16 @@ public class TmfUml2SDSyncLoaderTimeTest extends TestCase {
         assertEquals("synchToTime", 1, selection.size());
         assertEquals("synchToTime", TC_007_START_OCCURRANCE, msg.getStartOccurrence());
         assertEquals("synchToTime", TC_007_END_OCCURRANCE, msg.getEndOccurrence());
+    }
 
-        /*
-        * Test Case: 008
-        * Description: Verify time range signal (start, end time and current time are in same  page)
-        * Verified Methods: loader.synchToTimeRange(), loader.moveToMessage(), loader.moveToMessageInPage()
-        * Expected result: Move to correct page(=page of start time of range), set focus on start time of range, but no selection of message.
-        */
+    /**
+     * Test Case: 008
+     * Description: Verify time range signal (start, end time and current time are in same  page)
+     * Verified Methods: loader.synchToTimeRange(), loader.moveToMessage(), loader.moveToMessageInPage()
+     * Expected result: Move to correct page(=page of start time of range), set focus on start time of range, but no selection of message.
+     */
+    @Test
+    public void verifyTimeRangeSamePage() {
         // 9788.642228395 (page 0) -> 9789.164833324 (page 0) with selected time 9788.642228395 (page 0)
         fFacility.getLoader().firstPage();
         TmfTimeRange range = new TmfTimeRange(TC_008_START_TIME_VALUE, TC_008_END_TIME_VALUE);
@@ -276,14 +286,17 @@ public class TmfUml2SDSyncLoaderTimeTest extends TestCase {
         // We actually don't want something to be selected!!!
         assertNotNull("synchToTimeRange", selection);
         assertEquals("synchToTimeRange", 0, selection.size());
+    }
 
-        /*
-         * Test Case: 009
-         * Description: Verify time range signal (start and end time are across 2 pages)
-         * Verified Methods: loader.synchToTimeRange(), loader.moveToMessage(), loader.moveToPage()
-         * Expected result: Move to correct page (=page of start time of range), set focus on start time of range, but no selection of message.
-         */
-        range = new TmfTimeRange(TC_009_START_TIME_VALUE, TC_009_END_TIME_VALUE);
+    /**
+     * Test Case: 009
+     * Description: Verify time range signal (start and end time are across 2 pages)
+     * Verified Methods: loader.synchToTimeRange(), loader.moveToMessage(), loader.moveToPage()
+     * Expected result: Move to correct page (=page of start time of range), set focus on start time of range, but no selection of message.
+     */
+    @Test
+    public void verifyTimeRangeDifferentPages() {
+        TmfTimeRange range = new TmfTimeRange(TC_009_START_TIME_VALUE, TC_009_END_TIME_VALUE);
         fFacility.getTrace().broadcast(new TmfRangeSynchSignal(this, range, TC_009_TIME_VALUE));
         fFacility.getLoader().waitForCompletion();
         fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
@@ -294,6 +307,5 @@ public class TmfUml2SDSyncLoaderTimeTest extends TestCase {
         // We actually don't want something to be selected!!!
         assertNotNull("synchToTimeRange", selection);
         assertEquals("synchToTimeRange", 0, selection.size());
-
     }
 }
\ No newline at end of file
This page took 0.069846 seconds and 5 git commands to generate.