LTTng: CPU usage analysis from the LTTng kernel trace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core.tests / src / org / eclipse / linuxtools / tmf / core / tests / ctfadaptor / CtfLocationTest.java
index 6f337cb81b394395f3057f0f35c2ced514512ade..739cbc4b8a3ff95a6101571fb408a60ea2516837 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2012 Ericsson
+ * Copyright (c) 2012, 2014 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -17,9 +17,9 @@ 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;
 
@@ -34,44 +34,24 @@ public class CtfLocationTest {
 
     private CtfLocation fixture;
 
-    /**
-     * Launch the test.
-     *
-     * @param args
-     *            the command line arguments
-     */
-    public static void main(String[] args) {
-        new org.junit.runner.JUnitCore().run(CtfLocationTest.class);
-    }
-
     /**
      * Perform pre-test initialization.
      */
     @Before
     public void setUp() {
-        fixture = new CtfLocation(Long.valueOf(1));
-        fixture.setLocation(Long.valueOf(1));
+        fixture = new CtfLocation(new CtfLocationInfo(1, 0));
     }
 
-    /**
-     * Perform post-test clean-up.
-     */
-    @After
-    public void tearDown() {
-        // Add additional tear down code here
-    }
-
-
     /**
      * Run the CtfLocation(Long) constructor test.
      */
     @Test
     public void testCtfLocation_long() {
-        Long location = Long.valueOf(1);
+        CtfLocationInfo location = new CtfLocationInfo(1, 0);
         CtfLocation result = new CtfLocation(location);
 
         assertNotNull(result);
-        assertEquals(Long.valueOf(1), result.getLocation());
+        assertEquals(1L, result.getLocationInfo().getTimestamp());
     }
 
     /**
@@ -83,18 +63,7 @@ public class CtfLocationTest {
         CtfLocation result = new CtfLocation(timestamp);
 
         assertNotNull(result);
-        assertEquals(new Long(0L), result.getLocation());
-    }
-
-    /**
-     * Run the CtfLocation clone() method test.
-     */
-    @Test
-    public void testClone() {
-        CtfLocation result = fixture.clone();
-
-        assertNotNull(result);
-        assertEquals(Long.valueOf(1), result.getLocation());
+        assertEquals(0L, result.getLocationInfo().getTimestamp());
     }
 
     /**
@@ -102,16 +71,9 @@ public class CtfLocationTest {
      */
     @Test
     public void testGetLocation() {
-        Long result = fixture.getLocation();
-
-        assertNotNull(result);
-        assertEquals("1", result.toString()); //$NON-NLS-1$
-        assertEquals((byte) 1, result.byteValue());
-        assertEquals((short) 1, result.shortValue());
-        assertEquals(1, result.intValue());
-        assertEquals(1L, result.longValue());
-        assertEquals(1.0f, result.floatValue(), 1.0f);
-        assertEquals(1.0, result.doubleValue(), 1.0);
+        CtfLocationInfo location = fixture.getLocationInfo();
+        long result = location.getTimestamp();
+        assertEquals(1L, result);
     }
 
     /**
@@ -119,8 +81,8 @@ public class CtfLocationTest {
      */
     @Test
     public void testSetLocation() {
-        Long location = Long.valueOf(1);
-        fixture.setLocation(location);
+        CtfLocationInfo location = new CtfLocationInfo(1337, 7331);
+        fixture = new CtfLocation(location);
     }
 
     /**
@@ -128,8 +90,8 @@ public class CtfLocationTest {
      */
     @Test
     public void testToString_valid(){
-        CtfLocation fixture2 = new CtfLocation(new Long(1337L));
-        assertEquals("CtfLocation: 1337",fixture2.toString()); //$NON-NLS-1$
+        CtfLocation fixture2 = new CtfLocation(new CtfLocationInfo(1337, 7331));
+        assertEquals("CtfLocation [fLocationInfo=Element [1337/7331]]", fixture2.toString());
     }
 
     /**
@@ -137,7 +99,7 @@ public class CtfLocationTest {
      */
     @Test
     public void testToString_invalid(){
-        CtfLocation fixture2 = new CtfLocation(new Long(-1L));
-        assertEquals("CtfLocation: INVALID",fixture2.toString()); //$NON-NLS-1$
+        CtfLocation fixture2 = new CtfLocation(new CtfLocationInfo(-1, -1));
+        assertEquals("CtfLocation [INVALID]", fixture2.toString());
     }
 }
This page took 0.030638 seconds and 5 git commands to generate.