lttng: Port unit tests to JUnit4
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui.tests / src / org / eclipse / linuxtools / lttng2 / ui / tests / control / service / LTTngControlServiceTest.java
index 167dd7ef7f1ee853a2a0d4cfba5e9a34acaf66d7..d13c2ecdb390b9cad7a463cba9faeea0e3da6866 100644 (file)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * Copyright (c) 2012 Ericsson
+ * Copyright (c) 2012, 2013 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -8,9 +8,13 @@
  *
  * Contributors:
  *   Bernd Hufmann - Initial API and implementation
+ *   Alexandre Montplaisir - Port to JUnit4
  **********************************************************************/
+
 package org.eclipse.linuxtools.lttng2.ui.tests.control.service;
 
+import static org.junit.Assert.*;
+
 import java.io.File;
 import java.net.URL;
 import java.util.ArrayList;
@@ -18,8 +22,6 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import junit.framework.TestCase;
-
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.NullProgressMonitor;
@@ -42,12 +44,16 @@ import org.eclipse.linuxtools.internal.lttng2.stubs.shells.LTTngToolsFileShell;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.LTTngControlService;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.LTTngControlServiceFactory;
+import org.junit.Before;
+import org.junit.Test;
 import org.osgi.framework.FrameworkUtil;
+
 /**
- * The class <code>LTTngControlServiceTest</code> contains test for the class <code>{@link  LTTngControlService}</code>.
+ * The class <code>LTTngControlServiceTest</code> contains test for the class
+ * <code>{@link  LTTngControlService}</code>.
  */
 @SuppressWarnings({"nls", "javadoc"})
-public class LTTngControlServiceTest extends TestCase {
+public class LTTngControlServiceTest {
 
     private static final String DIRECTORY   = "testfiles";
     private static final String TEST_STREAM = "LTTngServiceTest.cfg";
@@ -81,28 +87,24 @@ public class LTTngControlServiceTest extends TestCase {
     // ------------------------------------------------------------------------
     // Test data
     // ------------------------------------------------------------------------
+
     private CommandShellFactory fShellFactory;
     private String fTestfile;
     private LTTngToolsFileShell fShell;
     private ILttngControlService fService;
 
-
-   // ------------------------------------------------------------------------
-    // Static methods
-    // ------------------------------------------------------------------------
-
     // ------------------------------------------------------------------------
     // Housekeeping
     // ------------------------------------------------------------------------
+
     /**
      * Perform pre-test initialization.
      *
-     * @throws Exception if the initialization fails for some reason
-     *
+     * @throws Exception
+     *             if the initialization fails for some reason
      */
-    @Override
+    @Before
     public void setUp() throws Exception {
-        super.setUp();
         fShellFactory = CommandShellFactory.getInstance();
 
         URL location = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
@@ -114,20 +116,11 @@ public class LTTngControlServiceTest extends TestCase {
         fService = new LTTngControlService(fShell);
     }
 
-    /**
-     * Perform post-test clean-up.
-     *
-     * @throws Exception if the clean-up fails for some reason
-     *
-     */
-    @Override
-    public void tearDown() throws Exception {
-    }
-
     // ------------------------------------------------------------------------
     // Test Cases
     // ------------------------------------------------------------------------
 
+    @Test
     public void testVersion() {
         try {
             fShell.setScenario(SCEN_LTTNG_VERSION);
@@ -139,6 +132,7 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
+    @Test
     public void testVersionWithPrompt() {
         try {
             fShell.setScenario(SCEN_LTTNG_VERSION_WITH_PROMPT);
@@ -150,6 +144,7 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
+    @Test
     public void testUnsupportedVersion() {
         try {
             fShell.setScenario(SCEN_LTTNG_UNSUPPORTED_VERSION);
@@ -160,6 +155,7 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
+    @Test
     public void testNoVersion() {
         try {
             fShell.setScenario(SCEN_LTTNG_NO_VERSION);
@@ -170,6 +166,7 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
+    @Test
     public void testLttngNotInstalled() {
         try {
             fShell.setScenario(SCEN_LTTNG_NOT_INSTALLED);
@@ -180,6 +177,7 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
+    @Test
     public void testGetSessionNames1() {
         try {
             fShell.setScenario(SCEN_NO_SESSION_AVAILABLE);
@@ -193,6 +191,7 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
+    @Test
     public void testGetSessionNames2() {
         try {
             fShell.setScenario(SCEN_GET_SESSION_NAMES1);
@@ -208,6 +207,7 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
+    @Test
     public void testGetSessionNotExist() {
         try {
             fShell.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST);
@@ -219,6 +219,7 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
+    @Test
     public void testGetSessionNameGarbage() {
         try {
             fShell.setScenario(SCEN_GET_SESSION_GARBAGE_OUT);
@@ -232,6 +233,7 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
+    @Test
     public void testGetSession1() {
         try {
             fShell.setScenario(SCEN_GET_SESSION1);
@@ -379,6 +381,7 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
+    @Test
     public void testGetKernelProviderNoKernel1() {
         try {
             fShell.setScenario(SCEN_LIST_WITH_NO_KERNEL1);
@@ -393,6 +396,7 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
+    @Test
     public void testGetKernelProviderNoKernel2() {
         try {
             fShell.setScenario(SCEN_LIST_WITH_NO_KERNEL2);
@@ -407,7 +411,7 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
-
+    @Test
     public void testGetUstProvider() {
         try {
             fShell.setScenario(SCEN_GET_UST_PROVIDER1);
@@ -462,6 +466,7 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
+    @Test
     public void testUstProvider2() {
         try {
             fShell.setScenario(SCEN_GET_UST_PROVIDER2);
@@ -475,6 +480,7 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
+    @Test
     public void testGetUstProvider3() {
         try {
             fShell.setScenario(SCEN_GET_UST_PROVIDER3);
@@ -551,6 +557,7 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
+    @Test
     public void testCreateSession() {
         try {
             fShell.setScenario(SCEN_CREATE_SESSION1);
@@ -566,6 +573,7 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
+    @Test
     public void testCreateSessionWithPrompt() {
         try {
             // First line has the shell prompt before the command output
@@ -584,7 +592,7 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
-
+    @Test
     public void testCreateSessionVariants() {
 
         fShell.setScenario(SCEN_CREATE_SESSION_VARIANTS);
@@ -635,6 +643,7 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
+    @Test
     public void testDestroySession() {
         try {
             fShell.setScenario(SCEN_DESTROY_SESSION1);
@@ -644,6 +653,7 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
+    @Test
     public void testCreateChannel() {
         try {
 
@@ -682,6 +692,7 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
+    @Test
     public void testDisableChannel() {
         try {
 
@@ -704,6 +715,7 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
+    @Test
     public void testEnableChannel() {
         try {
 
@@ -739,6 +751,7 @@ public class LTTngControlServiceTest extends TestCase {
 //        }
 //    }
 
+    @Test
     public void testEnableEvents() {
         try {
             // 1) session name, channel = null, 3 event names, kernel
@@ -777,6 +790,7 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
+    @Test
     public void testEnableSyscalls() {
         try {
             // 1) session name, channel = null, 3 event names, kernel
@@ -796,6 +810,7 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
+    @Test
     public void testDynamicProbe() {
         try {
             // 1) session name, channel = null, 3 event names, kernel
@@ -819,6 +834,7 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
+    @Test
     public void testEnableLogLevel() {
         try {
             // 1) session name, channel = null, 3 event names, kernel
@@ -842,6 +858,7 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
+    @Test
     public void testAddContext() {
         try {
             // 1) session name, channel = null, 3 event names, kernel
@@ -883,6 +900,7 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
+    @Test
     public void testAddContextFailure() {
 
         // 1) session name, channel = null, 3 event names, kernel
@@ -908,6 +926,7 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
+    @Test
     public void testCalibrate() {
         try {
             fShell.setScenario(SCEN_CALIBRATE_HANDLING);
@@ -918,8 +937,8 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
+    @Test
     public void testCalibrateFailure() {
-
         try {
             fShell.setScenario(SCEN_CALIBRATE_HANDLING);
             fService.calibrate(false, new NullProgressMonitor());
This page took 0.047258 seconds and 5 git commands to generate.