lttng: Port unit tests to JUnit4
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.core.tests / src / org / eclipse / linuxtools / lttng2 / core / tests / control / model / impl / ChannelInfoTest.java
index 2c0d7c0aaf71f39eecfe1233240460ffdd7adba3..dec59c20895cc56ed6c243b18857e6a2b5822bed 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,29 +8,35 @@
  *
  * Contributors:
  *   Bernd Hufmann - Initial API and implementation
+ *   Alexandre Montplaisir - Port to JUnit4
  **********************************************************************/
+
 package org.eclipse.linuxtools.lttng2.core.tests.control.model.impl;
 
+import static org.junit.Assert.*;
+
 import java.util.LinkedList;
 import java.util.List;
 
-import junit.framework.TestCase;
-
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IChannelInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IEventInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEnablement;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.ChannelInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.EventInfo;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
- * The class <code>ChannelInfoTest</code> contains tests for the class <code>{@link ChannelInfo}</code>.
- *
+ * The class <code>ChannelInfoTest</code> contains tests for the class
+ * <code>{@link ChannelInfo}</code>.
  */
-@SuppressWarnings({"nls", "javadoc"})
-public class ChannelInfoTest extends TestCase {
+@SuppressWarnings("nls")
+public class ChannelInfoTest {
+
     // ------------------------------------------------------------------------
     // Test data
     // ------------------------------------------------------------------------
+
     private IChannelInfo fChannelInfo1 = null;
     private IChannelInfo fChannelInfo2 = null;
 
@@ -40,29 +46,14 @@ public class ChannelInfoTest extends TestCase {
 
     /**
      * Perform pre-test initialization.
-     *
-     * @throws Exception
-     *         if the initialization fails for some reason
-     *
      */
-    @Override
+    @Before
     public void setUp() {
         ModelImplFactory factory = new ModelImplFactory();
         fChannelInfo1 = factory.getChannel1();
         fChannelInfo2 = factory.getChannel2();
     }
 
-    /**
-     * Perform post-test clean-up.
-     *
-     * @throws Exception
-     *         if the clean-up fails for some reason
-     *
-     */
-    @Override
-    public void tearDown() {
-    }
-
     // ------------------------------------------------------------------------
     // Tests
     // ------------------------------------------------------------------------
@@ -73,8 +64,8 @@ public class ChannelInfoTest extends TestCase {
 
     /**
      * Run the ChannelInfo() constructor test.
-     *
      */
+    @Test
     public void testChannelInfo() {
         ChannelInfo result = new ChannelInfo("test");
         assertNotNull(result);
@@ -89,6 +80,10 @@ public class ChannelInfoTest extends TestCase {
         assertEquals(0, result.getSwitchTimer());
     }
 
+    /**
+     * Test copy constructor.
+     */
+    @Test
     public void testChannelInfoCopy() {
         ChannelInfo channelInfo = new ChannelInfo((ChannelInfo)fChannelInfo1);
 
@@ -108,6 +103,10 @@ public class ChannelInfoTest extends TestCase {
         }
     }
 
+    /**
+     * Test copy constructor with a null value.
+     */
+    @Test
     public void testChannelCopy2() {
         try {
             ChannelInfo channel = null;
@@ -121,8 +120,8 @@ public class ChannelInfoTest extends TestCase {
 
     /**
      * Run the IEventInfo[] getEvents() method test.
-     *
      */
+    @Test
     public void testAddAndGetEvents_1() {
         ChannelInfo fixture = new ChannelInfo("test");
         fixture.setSwitchTimer(1L);
@@ -148,8 +147,8 @@ public class ChannelInfoTest extends TestCase {
 
     /**
      * Run the long getNumberOfSubBuffers() method test.
-     *
      */
+    @Test
     public void testGetAndSetters() {
         ChannelInfo fixture = new ChannelInfo("test");
         fixture.setSwitchTimer(2L);
@@ -214,8 +213,8 @@ public class ChannelInfoTest extends TestCase {
 
     /**
      * Run the void setEvents(List<IEventInfo>) method test.
-     *
      */
+    @Test
     public void testSetEvents_1() {
         ChannelInfo fixture = new ChannelInfo("test");
         fixture.setSwitchTimer(1L);
@@ -245,6 +244,10 @@ public class ChannelInfoTest extends TestCase {
         }
     }
 
+    /**
+     * Run the String toString() method test.
+     */
+    @Test
     public void testToString_1() {
         ChannelInfo fixture = new ChannelInfo("channel");
         fixture.setSwitchTimer(1L);
@@ -262,9 +265,9 @@ public class ChannelInfoTest extends TestCase {
     }
 
     /**
-     * Run the String toString() method test.
-     *
+     * Run another String toString() method test.
      */
+    @Test
     public void testToString_2() {
         String result = fChannelInfo1.toString();
 
@@ -276,6 +279,10 @@ public class ChannelInfoTest extends TestCase {
     // equals
     // ------------------------------------------------------------------------
 
+    /**
+     * Run the equals() method test.
+     */
+    @Test
     public void testEqualsReflexivity() {
         assertTrue("equals", fChannelInfo1.equals(fChannelInfo1));
         assertTrue("equals", fChannelInfo2.equals(fChannelInfo2));
@@ -284,6 +291,10 @@ public class ChannelInfoTest extends TestCase {
         assertTrue("equals", !fChannelInfo2.equals(fChannelInfo1));
     }
 
+    /**
+     * Run the equals() method test.
+     */
+    @Test
     public void testEqualsSymmetry() {
         ChannelInfo event1 = new ChannelInfo((ChannelInfo)fChannelInfo1);
         ChannelInfo event2 = new ChannelInfo((ChannelInfo)fChannelInfo2);
@@ -295,6 +306,10 @@ public class ChannelInfoTest extends TestCase {
         assertTrue("equals", fChannelInfo2.equals(event2));
     }
 
+    /**
+     * Run the equals() method test.
+     */
+    @Test
     public void testEqualsTransivity() {
         ChannelInfo channel1 = new ChannelInfo((ChannelInfo)fChannelInfo1);
         ChannelInfo channel2 = new ChannelInfo((ChannelInfo)fChannelInfo1);
@@ -305,6 +320,10 @@ public class ChannelInfoTest extends TestCase {
         assertTrue("equals", channel1.equals(channel3));
     }
 
+    /**
+     * Run the equals() method test.
+     */
+    @Test
     public void testEqualsNull() {
         assertTrue("equals", !fChannelInfo1.equals(null));
         assertTrue("equals", !fChannelInfo2.equals(null));
@@ -314,6 +333,10 @@ public class ChannelInfoTest extends TestCase {
     // hashCode
     // ------------------------------------------------------------------------
 
+    /**
+     * Run the hashCode() method test.
+     */
+    @Test
     public void testHashCode() {
         ChannelInfo channel1 = new ChannelInfo((ChannelInfo)fChannelInfo1);
         ChannelInfo channel2 = new ChannelInfo((ChannelInfo)fChannelInfo2);
This page took 0.033461 seconds and 5 git commands to generate.