Merge branch 'master' into lttng-luna
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core.tests / src / org / eclipse / linuxtools / tmf / core / tests / ctfadaptor / CtfLocationTest.java
index c6343df56368f679508f79cd82ad21bfcec98aba..9ae5053614eddece7f252509fc0a428fab647e7c 100644 (file)
@@ -1,91 +1,80 @@
+/*******************************************************************************
+ * 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
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Matthew Khouzam - Initial generation with CodePro tools
+ *   Alexandre Montplaisir - Clean up, consolidate redundant tests
+ *******************************************************************************/
+
 package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
 import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocation;
-import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
-import org.junit.After;
+import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocationInfo;
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
 import org.junit.Before;
 import org.junit.Test;
 
 /**
- * The class <code>CtfLocationTest</code> contains tests for the class <code>{@link CtfLocation}</code>.
+ * The class <code>CtfLocationTest</code> contains tests for the class
+ * <code>{@link CtfLocation}</code>.
  *
- * @generatedBy CodePro at 03/05/12 2:29 PM
  * @author ematkho
- * @version $Revision: 1.0 $
+ * @version 1.0
  */
 public class CtfLocationTest {
+
+    private CtfLocation fixture;
+
+    /**
+     * Perform pre-test initialization.
+     */
+    @Before
+    public void setUp() {
+        fixture = new CtfLocation(new CtfLocationInfo(1, 0));
+    }
+
     /**
      * Run the CtfLocation(Long) constructor test.
-     *
-     * @generatedBy CodePro at 03/05/12 2:29 PM
      */
-    @SuppressWarnings("static-method")
     @Test
-    public void testCtfLocation_1() {
-        Long location = new Long(1L);
-
+    public void testCtfLocation_long() {
+        CtfLocationInfo location = new CtfLocationInfo(1, 0);
         CtfLocation result = new CtfLocation(location);
 
-        // add additional test code here
         assertNotNull(result);
-        assertEquals(new Long(1L), result.getLocation());
+        assertEquals(Long.valueOf(1), (Long)result.getLocationInfo().getTimestamp());
     }
 
     /**
      * Run the CtfLocation(ITmfTimestamp) constructor test.
-     *
-     * @generatedBy CodePro at 03/05/12 2:29 PM
      */
-    @SuppressWarnings("static-method")
     @Test
-    public void testCtfLocation_2() {
+    public void testCtfLocation_timestamp() {
         ITmfTimestamp timestamp = new TmfTimestamp();
-
         CtfLocation result = new CtfLocation(timestamp);
 
-        // add additional test code here
         assertNotNull(result);
-        assertEquals(new Long(0L), result.getLocation());
-    }
-
-    /**
-     * Run the CtfLocation clone() method test.
-     *
-     * @generatedBy CodePro at 03/05/12 2:29 PM
-     */
-    @SuppressWarnings("static-method")
-    @Test
-    public void testClone_1() {
-        CtfLocation fixture = new CtfLocation(new Long(1L));
-        fixture.setLocation(new Long(1L));
-
-        CtfLocation result = fixture.clone();
-
-        // add additional test code here
-        assertNotNull(result);
-        assertEquals(new Long(1L), result.getLocation());
+        assertEquals(new Long(0L), (Long)result.getLocationInfo().getTimestamp());
     }
 
     /**
      * Run the Long getLocation() method test.
-     *
-     * @generatedBy CodePro at 03/05/12 2:29 PM
      */
-    @SuppressWarnings("static-method")
     @Test
-    public void testGetLocation_1() {
-        CtfLocation fixture = new CtfLocation(new Long(1L));
-        fixture.setLocation(new Long(1L));
-
-        Long result = fixture.getLocation();
-
-        // add additional test code here
+    public void testGetLocation() {
+        CtfLocationInfo location = fixture.getLocationInfo();
+        Long result = location.getTimestamp();
         assertNotNull(result);
-        assertEquals("1", result.toString()); //$NON-NLS-1$
+        assertEquals("1", result.toString());
         assertEquals((byte) 1, result.byteValue());
         assertEquals((short) 1, result.shortValue());
         assertEquals(1, result.intValue());
@@ -96,63 +85,28 @@ public class CtfLocationTest {
 
     /**
      * Run the void setLocation(Long) method test.
-     *
-     * @generatedBy CodePro at 03/05/12 2:29 PM
      */
-    @SuppressWarnings("static-method")
-    @Test
-    public void testSetLocation_1() {
-        CtfLocation fixture = new CtfLocation(new Long(1L));
-        fixture.setLocation(new Long(1L));
-        Long location = new Long(1L);
-
-        fixture.setLocation(location);
-
-        // add additional test code here
-    }
-
-    @SuppressWarnings("static-method")
-    @Test
-    public void testToString1(){
-        CtfLocation fixture = new CtfLocation(new Long(1337L));
-        assertEquals("CtfLocation: 1337",fixture.toString()); //$NON-NLS-1$
-    }
-
-    @SuppressWarnings("static-method")
     @Test
-    public void testToString2(){
-        CtfLocation fixture = new CtfLocation(new Long(-1L));
-        assertEquals("CtfLocation: INVALID",fixture.toString()); //$NON-NLS-1$
-    }
-
-    /**
-     * Perform pre-test initialization.
-     *
-     * @generatedBy CodePro at 03/05/12 2:29 PM
-     */
-    @Before
-    public void setUp() {
-        // add additional set up code here
+    public void testSetLocation() {
+        CtfLocationInfo location = new CtfLocationInfo(1337, 7331);
+        fixture = new CtfLocation(location);
     }
 
     /**
-     * Perform post-test clean-up.
-     *
-     * @generatedBy CodePro at 03/05/12 2:29 PM
+     * Test the toString() method with a valid location.
      */
-    @After
-    public void tearDown() {
-        // Add additional tear down code here
+    @Test
+    public void testToString_valid(){
+        CtfLocation fixture2 = new CtfLocation(new CtfLocationInfo(1337, 7331));
+        assertEquals("CtfLocation [fLocationInfo=Element [1337/7331]]", fixture2.toString());
     }
 
     /**
-     * Launch the test.
-     *
-     * @param args the command line arguments
-     *
-     * @generatedBy CodePro at 03/05/12 2:29 PM
+     * Test the toString() method with an invalid location.
      */
-    public static void main(String[] args) {
-        new org.junit.runner.JUnitCore().run(CtfLocationTest.class);
+    @Test
+    public void testToString_invalid(){
+        CtfLocation fixture2 = new CtfLocation(new CtfLocationInfo(-1, -1));
+        assertEquals("CtfLocation [INVALID]", fixture2.toString());
     }
-}
\ No newline at end of file
+}
This page took 0.0283910000000001 seconds and 5 git commands to generate.