tmf ui: Make UML2SD UI tests independent from each other
authorBernd Hufmann <bhufmann@gmail.com>
Thu, 14 Mar 2013 20:12:40 +0000 (16:12 -0400)
committerBernd Hufmann <bhufmann@gmail.com>
Thu, 14 Mar 2013 22:44:52 +0000 (18:44 -0400)
This fixes the problem introduced when using JUnit version 4.11
where the order of test execution within a file is not the order
in the file.

Change-Id: I49ac3560c2cb5138c3dc606524a9a741d9827a2a
Signed-off-by: Bernd Hufmann <bhufmann@gmail.com>
Reviewed-on: https://git.eclipse.org/r/11171
Tested-by: Hudson CI
Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
IP-Clean: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Tested-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
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/Uml2SDSignalValidator.java

index 0c470122c6d06b77eea4718b7af84b2acb08243d..26aa414d11ff866c0b0642ca36c2d7b0c46534ac 100644 (file)
@@ -24,7 +24,9 @@ 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.After;
 import org.junit.AfterClass;
+import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -52,7 +54,7 @@ public class TmfUml2SDSyncLoaderFilterTest {
         Criteria criteria = new Criteria();
         criteria.setLifeLineSelected(true);
         criteria.setExpression(IUml2SDTestConstants.FIRST_PLAYER_NAME);
-        filterToSave.add(new FilterCriteria(criteria, true, false));
+        filterToSave.add(new FilterCriteria(criteria, false, false));
 
         criteria = new Criteria();
         criteria.setLifeLineSelected(true);
@@ -74,6 +76,27 @@ public class TmfUml2SDSyncLoaderFilterTest {
         fFacility = null;
     }
 
+    /**
+     * Test Case set-up code.
+     */
+    @Before
+    public void beforeTest(){
+        // Make sure we are at the first page
+        fFacility.firstPage();
+    }
+
+    /**
+     * Test case clean-up code.
+     */
+    @After
+    public void afterTest() {
+        filterToSave.get(0).setActive(false);
+        filterToSave.get(1).setActive(false);
+        filterToSave.get(2).setActive(false);
+        fFacility.getLoader().filter(filterToSave);
+        fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
+    }
+
     /**
      * Verify the filter lifelines (1 out of 2 is hidden)
      *
@@ -82,6 +105,9 @@ public class TmfUml2SDSyncLoaderFilterTest {
      */
     @Test
     public void verifyFilter1of2() {
+        // Initialize the filter
+        filterToSave.get(0).setActive(true);
+        // Run the filter
         fFacility.getLoader().filter(filterToSave);
         fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
 
@@ -99,7 +125,10 @@ public class TmfUml2SDSyncLoaderFilterTest {
      */
     @Test
     public void verifyFilter2of2() {
+        // Initialize the filter
+        filterToSave.get(0).setActive(true);
         filterToSave.get(1).setActive(true);
+        // Run the filter
         fFacility.getLoader().filter(filterToSave);
         fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
 
@@ -115,6 +144,13 @@ public class TmfUml2SDSyncLoaderFilterTest {
      */
     @Test
     public void verifyRemoval() {
+        // First set 2 filter
+        filterToSave.get(0).setActive(true);
+        filterToSave.get(1).setActive(true);
+        fFacility.getLoader().filter(filterToSave);
+        fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
+
+        // Remove the filter
         filterToSave.get(0).setActive(false);
         filterToSave.get(1).setActive(false);
         fFacility.getLoader().filter(filterToSave);
@@ -133,7 +169,9 @@ public class TmfUml2SDSyncLoaderFilterTest {
      */
     @Test
     public void verifyMessageFilter() {
+        // Initialize the filter
         filterToSave.get(2).setActive(true);
+        // Run the filter
         fFacility.getLoader().filter(filterToSave);
         fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
 
@@ -160,7 +198,7 @@ public class TmfUml2SDSyncLoaderFilterTest {
     @Test
     public void verifyFilter1of3() {
         filterToSave.get(0).setActive(true);
-        filterToSave.get(2).setActive(false);
+        fFacility.getLoader().filter(filterToSave);
         fFacility.setPage(IUml2SDTestConstants.PAGE_OF_ALL_LIFELINES);
 
         assertEquals("filter", 2, fFacility.getSdView().getFrame().lifeLinesCount());
@@ -172,7 +210,5 @@ public class TmfUml2SDSyncLoaderFilterTest {
         }
 
         assertTrue(fFacility.getSdView().getFrame().syncMessageCount() > 0);
-
-        filterToSave.get(2).setActive(false);
     }
 }
index b66c0df4f51279d4505283ece4de864e57c3c5c6..c3e60a47b94c43f467cdeee9c3d24197d41dcf83 100644 (file)
@@ -97,6 +97,7 @@ public class TmfUml2SDSyncLoaderFindTest {
     public static void setUpClass() {
         fFacility = Uml2SDTestFacility.getInstance();
         fFacility.selectExperiment();
+        fTmfComponent = new Uml2SDSignalValidator();
     }
 
     /**
@@ -104,6 +105,7 @@ public class TmfUml2SDSyncLoaderFindTest {
      */
     @AfterClass
     public static void tearDownClass() {
+        fTmfComponent.dispose();
         fFacility.disposeExperiment();
         fFacility = null;
     }
@@ -117,7 +119,8 @@ public class TmfUml2SDSyncLoaderFindTest {
      */
     @Test
     public void verifyISDGraphNodeSupporter() {
-        fTmfComponent = new Uml2SDSignalValidator();
+
+        fFacility.firstPage();
 
         assertTrue("isNodeSupported", fFacility.getLoader().isNodeSupported(ISDGraphNodeSupporter.LIFELINE));
         assertTrue("isNodeSupported", fFacility.getLoader().isNodeSupported(ISDGraphNodeSupporter.SYNCMESSAGE));
@@ -144,6 +147,8 @@ public class TmfUml2SDSyncLoaderFindTest {
      */
     @Test
     public void verifyFirstMessage() {
+        fFacility.firstPage();
+
         criteria = new Criteria();
         criteria.setSyncMessageSelected(true);
         criteria.setExpression("GAME_.*");
@@ -174,16 +179,14 @@ public class TmfUml2SDSyncLoaderFindTest {
         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());
-    }
 
-    /**
-     * Verify 2nd message find within page.
-     *
-     * Verified Methods: loader.find(), loader.moveToMessage()
-     * Expected result: Correct message is selected
-     */
-    @Test
-    public void verifySecondMessage() {
+        /**
+         * Verify 2nd message find within page.
+         *
+         * Verified Methods: loader.find(), loader.moveToMessage()
+         * Expected result: Correct message is selected
+         */
+
         // set expected values
         fTmfComponent.setSource(fFacility.getLoader());
         fTmfComponent.setCurrentTime(TC_003_TIME_VALUE);
@@ -211,16 +214,13 @@ public class TmfUml2SDSyncLoaderFindTest {
         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());
-    }
 
-    /**
-     * Verify 1st message across page.
-     *
-     * Verified Methods: loader.find(), loader.moveToPage(), loader.moveToMessage()
-     * Expected result: Correct message is selected
-     */
-    @Test
-    public void verifyFirstMesage() {
+        /**
+         * Verify 1st message across page.
+         *
+         * Verified Methods: loader.find(), loader.moveToPage(), loader.moveToMessage()
+         * Expected result: Correct message is selected
+         */
         // set expected values
         fTmfComponent.setSource(fFacility.getLoader());
         fTmfComponent.setCurrentTime(TC_004_TIME_VALUE);
@@ -255,7 +255,6 @@ public class TmfUml2SDSyncLoaderFindTest {
 
         // cancel find and go back to first page
         fFacility.getLoader().cancel();
-        fFacility.firstPage();
     }
 
     /**
@@ -266,6 +265,8 @@ public class TmfUml2SDSyncLoaderFindTest {
      */
     @Test
     public void verifyFind() {
+        fFacility.firstPage();
+
         criteria = new Criteria();
         criteria.setLifeLineSelected(true);
         criteria.setExpression(IUml2SDTestConstants.FIRST_PLAYER_NAME);
@@ -280,16 +281,13 @@ public class TmfUml2SDSyncLoaderFindTest {
         assertTrue(selection.get(0) instanceof Lifeline);
         lifeline = (Lifeline) selection.get(0);
         assertEquals("find", TC_005_LIFELINE_NAME, lifeline.getName());
-    }
 
-    /**
-     * Verify lifeline across page.
-     *
-     * Verified Methods: loader.find(), loader.moveToPage(), loader.moveToMessage()
-     * Expected result: Correct message is selected
-     */
-    @Test
-    public void verifyLifeline() {
+        /**
+         * Verify lifeline across page.
+         *
+         * Verified Methods: loader.find(), loader.moveToPage(), loader.moveToMessage()
+         * Expected result: Correct message is selected
+         */
         criteria = new Criteria();
         criteria.setLifeLineSelected(true);
         criteria.setExpression(IUml2SDTestConstants.SECOND_PLAYER_NAME);
@@ -309,10 +307,8 @@ public class TmfUml2SDSyncLoaderFindTest {
         lifeline = (Lifeline) selection.get(0);
         assertEquals("find", TC_006_LIFELINE_NAME, lifeline.getName());
 
-
         // cancel find and go back to first page
         fFacility.getLoader().cancel();
-        fFacility.firstPage();
     }
 
     /**
@@ -323,6 +319,9 @@ public class TmfUml2SDSyncLoaderFindTest {
      */
     @Test
     public void verifyCancelSearch() {
+
+        fFacility.firstPage();
+
         criteria = new Criteria();
         criteria.setLifeLineSelected(true);
         criteria.setExpression(IUml2SDTestConstants.SECOND_PLAYER_NAME);
@@ -332,6 +331,9 @@ public class TmfUml2SDSyncLoaderFindTest {
         fFacility.getLoader().cancel();
 
         assertEquals("find", 0, fFacility.getLoader().currentPage()); // we are still at the first page
-        fTmfComponent.dispose();
+
+        // cancel find and go back to first page
+        fFacility.getLoader().cancel();
+        fFacility.firstPage();
     }
 }
index 85c591f08fa1148d66736bb446d7cdfbeff577a3..6f6bd8160568872b75a08f25f1f5dff00cb712e0 100644 (file)
@@ -73,9 +73,15 @@ public class Uml2SDSignalValidator extends TmfComponent implements IUml2SdSignal
     public void synchToTimeRange(TmfRangeSynchSignal signal) {
         // Set results so that it can be validated in the test case
         setSignalReceived(true);
-        setSourceError(getSource() != signal.getSource());
-        setCurrentTimeError(!getCurrentTime().equals(signal.getCurrentTime()));
-        setRangeError(!getCurrentRange().equals(signal.getCurrentRange()));
+        if (getSource() != null) {
+            setSourceError(getSource() != signal.getSource());
+        }
+        if (getCurrentTime() != null) {
+            setCurrentTimeError(!getCurrentTime().equals(signal.getCurrentTime()));
+        }
+        if (getCurrentRange() != null) {
+            setRangeError(!getCurrentRange().equals(signal.getCurrentRange()));
+        }
     }
 
     /**
This page took 0.030131 seconds and 5 git commands to generate.