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 / BaseEventInfoTest.java
index 352a8ffab1c4c0d1a78c3b1d5cc476547d73e595..3004974f064fa573a33929c3fefd8715b18ae6c0 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,30 +8,36 @@
  *
  * 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.IBaseEventInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IFieldInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEventType;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.BaseEventInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.FieldInfo;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
- * The class <code>BaseEventInfoTest</code> contains test for the class <code>{@link BaseEventInfo}</code>.
+ * The class <code>BaseEventInfoTest</code> contains test for the class
+ * <code>{@link BaseEventInfo}</code>.
  */
-@SuppressWarnings({"nls", "javadoc"})
-public class BaseEventInfoTest extends TestCase {
+@SuppressWarnings("nls")
+public class BaseEventInfoTest {
 
     // ------------------------------------------------------------------------
     // Test data
     // ------------------------------------------------------------------------
+
     private IBaseEventInfo fEventInfo1 = null;
     private IBaseEventInfo fEventInfo2 = null;
 
@@ -40,36 +46,22 @@ public class BaseEventInfoTest extends TestCase {
     // ------------------------------------------------------------------------
     /**
      * Perform pre-test initialization.
-     *
-     * @throws Exception if the initialization fails for some reason
-     *
      */
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
+    @Before
+    public void setUp() {
         ModelImplFactory factory = new ModelImplFactory();
         fEventInfo1 = factory.getBaseEventInfo1();
         fEventInfo2 = factory.getBaseEventInfo2();
     }
 
-    /**
-     * Perform post-test clean-up.
-     *
-     * @throws Exception if the clean-up fails for some reason
-     *
-     */
-    @Override
-    public void tearDown() throws Exception {
-    }
-
     // ------------------------------------------------------------------------
     // Tests
     // ------------------------------------------------------------------------
 
     /**
      * Run the BaseEventInfo() constructor test.
-     *
      */
+    @Test
     public void testBaseEventInfo() {
         BaseEventInfo fixture = new BaseEventInfo("event");
         assertNotNull(fixture);
@@ -92,6 +84,7 @@ public class BaseEventInfoTest extends TestCase {
     /**
      * Test Copy Constructor
      */
+    @Test
     public void testEventInfoCopy() {
         BaseEventInfo info = new BaseEventInfo((BaseEventInfo)fEventInfo1);
 
@@ -112,6 +105,7 @@ public class BaseEventInfoTest extends TestCase {
     /**
      * Test Copy Constructor
      */
+    @Test
     public void testEventCopy2() {
         try {
             BaseEventInfo info = null;
@@ -125,10 +119,8 @@ public class BaseEventInfoTest extends TestCase {
 
     /**
      * Run the TraceEventType getEventType() method test.
-     *
-     * @throws Exception
-     *
      */
+    @Test
     public void testGetEventType_1() {
         BaseEventInfo fixture = new BaseEventInfo("event");
         fixture.setEventType("unknown");
@@ -176,8 +168,8 @@ public class BaseEventInfoTest extends TestCase {
 
     /**
      * Run the void setEventType(TraceEventType) method test.
-     *
      */
+    @Test
     public void testSetEventType_2() {
         BaseEventInfo fixture = new BaseEventInfo("event");
         fixture.setEventType(TraceEventType.TRACEPOINT);
@@ -220,8 +212,8 @@ public class BaseEventInfoTest extends TestCase {
     /**
      * Run the void setLogLevel(TraceLogLevel) method test.
      * Run the TraceLogLevel getLogLevel() method test
-     *
      */
+    @Test
     public void testSetLogLevel1() {
         BaseEventInfo fixture = new BaseEventInfo("event");
         fixture.setEventType(TraceEventType.TRACEPOINT);
@@ -248,8 +240,8 @@ public class BaseEventInfoTest extends TestCase {
     /**
      * Run the void setLogLevel(String) method test.
      * Run the TraceLogLevel getLogLevel() method test
-     *
      */
+    @Test
     public void testSetLogLevel2() {
         BaseEventInfo fixture = new BaseEventInfo("event");
         fixture.setEventType(TraceEventType.TRACEPOINT);
@@ -408,6 +400,7 @@ public class BaseEventInfoTest extends TestCase {
     /**
      * test filter expression
      */
+    @Test
      public void testSetFields() {
          BaseEventInfo info = new BaseEventInfo((BaseEventInfo)fEventInfo2);
          info.setFilterExpression("stringfield==test");
@@ -418,6 +411,7 @@ public class BaseEventInfoTest extends TestCase {
    /**
     * test add field
     */
+    @Test
     public void testAddField() {
         BaseEventInfo info = new BaseEventInfo((BaseEventInfo)fEventInfo2);
 
@@ -438,6 +432,7 @@ public class BaseEventInfoTest extends TestCase {
     /**
      * test set fields
      */
+    @Test
     public void testFields() {
         BaseEventInfo info = new BaseEventInfo((BaseEventInfo)fEventInfo2);
 
@@ -466,8 +461,8 @@ public class BaseEventInfoTest extends TestCase {
 
     /**
      * Run the String toString() method test.
-     *
      */
+    @Test
     public void testToString_1() {
         BaseEventInfo fixture = new BaseEventInfo("event");
         fixture.setName("testName");
@@ -484,6 +479,10 @@ public class BaseEventInfoTest extends TestCase {
     // equals
     // ------------------------------------------------------------------------
 
+    /**
+     * Test the .equals() method.
+     */
+    @Test
     public void testEqualsReflexivity() {
         assertTrue("equals", fEventInfo1.equals(fEventInfo1));
         assertTrue("equals", fEventInfo2.equals(fEventInfo2));
@@ -492,6 +491,10 @@ public class BaseEventInfoTest extends TestCase {
         assertTrue("equals", !fEventInfo2.equals(fEventInfo1));
     }
 
+    /**
+     * Test the .equals() method.
+     */
+    @Test
     public void testEqualsSymmetry() {
         BaseEventInfo info1 = new BaseEventInfo((BaseEventInfo)fEventInfo1);
         BaseEventInfo info2 = new BaseEventInfo((BaseEventInfo)fEventInfo2);
@@ -503,6 +506,10 @@ public class BaseEventInfoTest extends TestCase {
         assertTrue("equals", fEventInfo2.equals(info2));
     }
 
+    /**
+     * Test the .equals() method.
+     */
+    @Test
     public void testEqualsTransivity() {
         BaseEventInfo info1 = new BaseEventInfo((BaseEventInfo)fEventInfo1);
         BaseEventInfo info2 = new BaseEventInfo((BaseEventInfo)fEventInfo1);
@@ -513,6 +520,10 @@ public class BaseEventInfoTest extends TestCase {
         assertTrue("equals", info1.equals(info3));
     }
 
+    /**
+     * Test the .equals() method.
+     */
+    @Test
     public void testEqualsNull() {
         assertTrue("equals", !fEventInfo1.equals(null));
         assertTrue("equals", !fEventInfo2.equals(null));
@@ -522,6 +533,10 @@ public class BaseEventInfoTest extends TestCase {
     // hashCode
     // ------------------------------------------------------------------------
 
+    /**
+     * Test the hashCode() method.
+     */
+    @Test
     public void testHashCode() {
         BaseEventInfo info1 = new BaseEventInfo((BaseEventInfo)fEventInfo1);
         BaseEventInfo info2 = new BaseEventInfo((BaseEventInfo)fEventInfo2);
This page took 0.02901 seconds and 5 git commands to generate.