tmf: Disable NLS warnings in tests
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui.tests / src / org / eclipse / linuxtools / tmf / ui / tests / statistics / TmfTreeContentProviderTest.java
index 6296b5ff5239c86eafc9787f0b3a19ba60b0e24d..a270edbc49bbd31082144a7971ff5981d4a25794 100755 (executable)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011 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
@@ -9,35 +9,41 @@
  * Contributors:
  *   Mathieu Denis <mathieu.denis@polymtl.ca> - Initial design and implementation
  *   Bernd Hufmann - Fixed warnings
+ *   Alexandre Montplaisir - Port to JUnit4
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.ui.tests.statistics;
 
-import java.util.Arrays;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
-import junit.framework.TestCase;
+import java.util.Arrays;
 
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
 import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
 import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
 import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
-import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.Messages;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTree;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfTreeContentProvider;
+import org.junit.Test;
 
 /**
  * TmfTreeContentProvider Test Cases.
  */
-@SuppressWarnings("nls")
-public class TmfTreeContentProviderTest extends TestCase {
+public class TmfTreeContentProviderTest {
 
     // ------------------------------------------------------------------------
     // Fields
     // ------------------------------------------------------------------------
 
-    private String fTestName = null;
+    private static final String fTestName = "TreeContentProviderTest";
 
     private final String fContext = "UnitTest";
     private final String fTypeId1 = "Some type1";
@@ -57,8 +63,8 @@ public class TmfTreeContentProviderTest extends TestCase {
 
     private final String fReference = "Some reference";
 
-    private final TmfEvent fEvent1;
-    private final TmfEvent fEvent2;
+    private final ITmfEvent fEvent1;
+    private final ITmfEvent fEvent2;
 
     private final TmfEventField fContent1;
     private final TmfEventField fContent2;
@@ -72,14 +78,9 @@ public class TmfTreeContentProviderTest extends TestCase {
     // ------------------------------------------------------------------------
 
     /**
-     * @param name
-     *            of the test
+     * Constructor
      */
-    public TmfTreeContentProviderTest(final String name) {
-        super(name);
-
-        fTestName = name;
-
+    public TmfTreeContentProviderTest() {
         fContent1 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, "Some content");
         fEvent1 = new TmfEvent(null, fTimestamp1, fSource, fType1, fContent1, fReference);
 
@@ -96,7 +97,7 @@ public class TmfTreeContentProviderTest extends TestCase {
     }
 
     // ------------------------------------------------------------------------
-    // GetChildren
+    // Test methods
     // ------------------------------------------------------------------------
 
     /**
@@ -104,8 +105,9 @@ public class TmfTreeContentProviderTest extends TestCase {
      * FIXME this test was quickly adapted when we removed the TmfFixedArray,
      * but it could be rewritten to be much more simple...
      */
+    @Test
     public void testGetChildren() {
-        Object[] objectArray = treeProvider.getChildren(fStatsData.getOrCreate(fTestName, Messages.TmfStatisticsData_EventTypes));
+        Object[] objectArray = treeProvider.getChildren(fStatsData.getOrCreateNode(fTestName, Messages.TmfStatisticsData_EventTypes));
         TmfStatisticsTreeNode[] childrenNode = Arrays.asList(objectArray).toArray(new TmfStatisticsTreeNode[0]);
 
         String[][] childrenExpected = new String[][] {
@@ -143,49 +145,41 @@ public class TmfTreeContentProviderTest extends TestCase {
         return true;
     }
 
-    // ------------------------------------------------------------------------
-    // GetParent
-    // ------------------------------------------------------------------------
-
     /**
      * Test getting of parent.
      */
+    @Test
     public void testGetParent() {
-        TmfStatisticsTreeNode parent = (TmfStatisticsTreeNode) treeProvider.getParent(fStatsData.get(fTestName));
+        TmfStatisticsTreeNode parent = (TmfStatisticsTreeNode) treeProvider.getParent(fStatsData.getNode(fTestName));
 
         assertNotNull("getParent", parent);
-        assertTrue("getParent", parent.getPath().equals(TmfStatisticsTree.ROOT));
+        assertTrue("getParent", parent.getPath().equals(fStatsData.getRootNode().getPath()));
     }
 
-    // ------------------------------------------------------------------------
-    // HasChildren
-    // ------------------------------------------------------------------------
     /**
      * Test checking for children.
      */
+    @Test
     public void testHasChildren() {
-        Boolean hasChildren = treeProvider.hasChildren(fStatsData.getOrCreate(TmfStatisticsTree.ROOT));
+        Boolean hasChildren = treeProvider.hasChildren(fStatsData.getRootNode());
         assertTrue("hasChildren", hasChildren);
 
-        hasChildren = treeProvider.hasChildren(fStatsData.getOrCreate(fTestName));
+        hasChildren = treeProvider.hasChildren(fStatsData.getOrCreateNode(fTestName));
         assertTrue("hasChildren", hasChildren);
 
-        hasChildren = treeProvider.hasChildren(fStatsData.getOrCreate(fTestName, Messages.TmfStatisticsData_EventTypes));
+        hasChildren = treeProvider.hasChildren(fStatsData.getOrCreateNode(fTestName, Messages.TmfStatisticsData_EventTypes));
         assertTrue("hasChildren", hasChildren);
 
-        hasChildren = treeProvider.hasChildren(fStatsData.getOrCreate(fTestName, Messages.TmfStatisticsData_EventTypes, fEvent1.getType().getName()));
+        hasChildren = treeProvider.hasChildren(fStatsData.getOrCreateNode(fTestName, Messages.TmfStatisticsData_EventTypes, fEvent1.getType().getName()));
         assertFalse("hasChildren", hasChildren);
     }
 
-    // ------------------------------------------------------------------------
-    // GetElements
-    // ------------------------------------------------------------------------
-
     /**
      * Test getting of elements.
      */
+    @Test
     public void testGetElements() {
-        Object[] objectElements = treeProvider.getElements(fStatsData.get(TmfStatisticsTree.ROOT));
+        Object[] objectElements = treeProvider.getElements(fStatsData.getRootNode());
         TmfStatisticsTreeNode[] nodeElements = Arrays.asList(objectElements).toArray(new TmfStatisticsTreeNode[0]);
         assertEquals("getElements", 1, nodeElements.length);
         assertTrue("getElements", nodeElements[0].getPath()[0].equals(fTestName));
This page took 0.026191 seconds and 5 git commands to generate.