tmf: Update tmf.core unit tests to JUnit4
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core.tests / src / org / eclipse / linuxtools / tmf / core / tests / event / TmfEventFieldTest.java
index cf8f85a9617a657725fe3d72b02dbda0adff90df..750e56184659713aec63cfae0d618387fb8cde0e 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2012 Ericsson
+ * Copyright (c) 2009, 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
@@ -9,20 +9,27 @@
  * Contributors:
  *   Francois Chouinard - Initial API and implementation
  *   Francois Chouinard - Adjusted for new Event Model
+ *   Alexandre Montplaisir - Port to JUnit4
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.core.tests.event;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
 import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
+import org.junit.Test;
 
 /**
  * Test suite for the TmfEventField class.
  */
-@SuppressWarnings("nls")
-public class TmfEventFieldTest extends TestCase {
+@SuppressWarnings({"nls", "javadoc"})
+public class TmfEventFieldTest {
 
     // ------------------------------------------------------------------------
     // Variables
@@ -51,34 +58,11 @@ public class TmfEventFieldTest extends TestCase {
     private final TmfEventField fRootField = new TmfEventField(fRootFieldName,
             new ITmfEventField[] { fField1, fField2 });
 
-    // ------------------------------------------------------------------------
-    // Housekeeping
-    // ------------------------------------------------------------------------
-
-    /**
-     * @param name the test name
-     */
-    public TmfEventFieldTest(final String name) {
-        super(name);
-    }
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-    }
-
     // ------------------------------------------------------------------------
     // Constructors
     // ------------------------------------------------------------------------
 
-    /**
-     *
-     */
+    @Test
     public void testTerminalStructConstructor() {
         assertSame("getName", fFieldName1, fStructTerminalField1.getName());
         assertNull("getValue", fStructTerminalField1.getValue());
@@ -90,9 +74,7 @@ public class TmfEventFieldTest extends TestCase {
         assertNull("getFieldName", fStructTerminalField1.getFieldName(0));
     }
 
-    /**
-     *
-     */
+    @Test
     public void testNonTerminalStructConstructor() {
         assertSame("getName", fStructRootFieldName, fStructRootField.getName());
         assertNull("getValue", fStructRootField.getValue());
@@ -112,9 +94,7 @@ public class TmfEventFieldTest extends TestCase {
         assertNull("getFieldName", fStructRootField.getFieldName(names.length));
     }
 
-    /**
-     *
-     */
+    @Test
     public void testTerminalConstructor() {
         assertSame("getName", fFieldName1, fField1.getName());
         assertSame("getValue", fValue1, fField1.getValue());
@@ -133,9 +113,7 @@ public class TmfEventFieldTest extends TestCase {
         assertNull("getFieldName", fField2.getFieldName(0));
     }
 
-    /**
-     *
-     */
+    @Test
     public void testNonTerminalConstructor() {
         assertSame("getName", fRootFieldName, fRootField.getName());
         assertNull("getValue", fRootField.getValue());
@@ -155,9 +133,7 @@ public class TmfEventFieldTest extends TestCase {
         assertNull("getFieldName", fRootField.getFieldName(names.length));
     }
 
-    /**
-     *
-     */
+    @Test
     public void testConstructorBadArg() {
         try {
             new TmfEventField(null, fValue1, null);
@@ -166,9 +142,7 @@ public class TmfEventFieldTest extends TestCase {
         }
     }
 
-    /**
-     *
-     */
+    @Test
     public void testTerminalCopyConstructor() {
         final TmfEventField copy = new TmfEventField(fField1);
         assertSame("getName", fFieldName1, copy.getName());
@@ -180,9 +154,7 @@ public class TmfEventFieldTest extends TestCase {
         assertNull("getFieldName", copy.getFieldName(0));
     }
 
-    /**
-     *
-     */
+    @Test
     public void testNonTerminalCopyConstructor() {
         assertSame("getName", fRootFieldName, fRootField.getName());
         assertNull("getValue", fRootField.getValue());
@@ -201,9 +173,7 @@ public class TmfEventFieldTest extends TestCase {
         assertNull("getFieldName", fRootField.getFieldName(names.length));
     }
 
-    /**
-     *
-     */
+    @Test
     public void testCopyConstructorBadArg() {
         try {
             new TmfEventField(null);
@@ -216,9 +186,7 @@ public class TmfEventFieldTest extends TestCase {
     // hashCode
     // ------------------------------------------------------------------------
 
-    /**
-     *
-     */
+    @Test
     public void testHashCode() {
         TmfEventField copy = new TmfEventField(fField1);
         assertTrue("hashCode", fField1.hashCode() == copy.hashCode());
@@ -233,9 +201,7 @@ public class TmfEventFieldTest extends TestCase {
     // equals
     // ------------------------------------------------------------------------
 
-    /**
-     *
-     */
+    @Test
     public void testEqualsReflexivity() {
         assertTrue("equals", fField1.equals(fField1));
         assertTrue("equals", fField2.equals(fField2));
@@ -250,9 +216,7 @@ public class TmfEventFieldTest extends TestCase {
         assertFalse("equals", fStructTerminalField2.equals(fStructTerminalField1));
     }
 
-    /**
-     *
-     */
+    @Test
     public void testEqualsSymmetry() {
         final TmfEventField copy0 = new TmfEventField(fField1);
         assertTrue("equals", fField1.equals(copy0));
@@ -263,9 +227,7 @@ public class TmfEventFieldTest extends TestCase {
         assertTrue("equals", copy3.equals(fField2));
     }
 
-    /**
-     *
-     */
+    @Test
     public void testEqualsTransivity() {
         TmfEventField copy1 = new TmfEventField(fField1);
         TmfEventField copy2 = new TmfEventField(copy1);
@@ -280,9 +242,7 @@ public class TmfEventFieldTest extends TestCase {
         assertTrue("equals", fField2.equals(copy2));
     }
 
-    /**
-     *
-     */
+    @Test
     public void testEquals() {
         assertTrue("equals", fStructTerminalField1.equals(fStructTerminalField3));
         assertTrue("equals", fStructTerminalField3.equals(fStructTerminalField1));
@@ -291,25 +251,19 @@ public class TmfEventFieldTest extends TestCase {
         assertFalse("equals", fField3.equals(fStructTerminalField1));
     }
 
-    /**
-     *
-     */
+    @Test
     public void testEqualsNull() {
         assertFalse("equals", fField1.equals(null));
         assertFalse("equals", fField2.equals(null));
     }
 
-    /**
-     *
-     */
+    @Test
     public void testNonEqualClasses() {
         assertFalse("equals", fField1.equals(fStructTerminalField1));
         assertFalse("equals", fField1.equals(fValue1));
     }
 
-    /**
-     *
-     */
+    @Test
     public void testNonEqualValues() {
         final TmfEventField copy1 = new TmfEventField(fFieldName1, fValue1);
         TmfEventField copy2 = new TmfEventField(fFieldName1, fValue1);
@@ -325,9 +279,7 @@ public class TmfEventFieldTest extends TestCase {
         assertFalse("equals", copy2.equals(copy1));
     }
 
-    /**
-     *
-     */
+    @Test
     public void testNonEquals() {
         assertFalse("equals", fField1.equals(fField2));
         assertFalse("equals", fField2.equals(fField1));
@@ -339,9 +291,7 @@ public class TmfEventFieldTest extends TestCase {
     // toString
     // ------------------------------------------------------------------------
 
-    /**
-     *
-     */
+    @Test
     public void testToString() {
         final String expected1 = fFieldName1 + "=" + fValue1.toString();
         TmfEventField field = new TmfEventField(fFieldName1, fValue1, null);
@@ -356,9 +306,7 @@ public class TmfEventFieldTest extends TestCase {
     // makeRoot
     // ------------------------------------------------------------------------
 
-    /**
-     *
-     */
+    @Test
     public void testMakeRoot() {
         ITmfEventField root = TmfEventField.makeRoot(fStructFieldNames);
         String[] names = root.getFieldNames();
This page took 0.026395 seconds and 5 git commands to generate.