tmf: Port tmf.ui unit tests to JUnit4
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui.tests / src / org / eclipse / linuxtools / tmf / ui / tests / views / uml2sd / loader / TmfUml2SDSyncLoaderFilterTest.java
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);
This page took 0.02753 seconds and 5 git commands to generate.