Monster fix: TMF model update + corresponding LTTng adaptations + JUnits
authorFrancois Chouinard <fchouinard@gmail.com>
Tue, 8 Dec 2009 04:17:59 +0000 (04:17 +0000)
committerFrancois Chouinard <fchouinard@gmail.com>
Tue, 8 Dec 2009 04:17:59 +0000 (04:17 +0000)
99 files changed:
org.eclipse.linuxtools.lttng.tests/META-INF/MANIFEST.MF
org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/event/AllLttngTests.java
org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/event/LttngEventContentTest.java
org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/event/LttngEventFieldTest.java
org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/event/LttngEventFormatTest.java [deleted file]
org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/event/LttngEventReferenceTest.java
org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/event/LttngEventTest.java
org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/event/LttngEventTypeTest.java
org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/event/LttngTimestampTest.java
org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/jni/AllJniTests.java
org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/jni/Combinations.java
org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/jni/JniEventTest.java
org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/jni/JniMarkerFieldTest.java
org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/jni/JniMarkerTest.java
org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/jni/JniTraceTest.java
org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/jni/JniTracefileTest.java
org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/state/TestStateManager.java
org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/state/handlers/AbsStateUpdate.java
org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/state/handlers/after/StateAfterUpdateHandlers.java
org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/state/handlers/before/StateBeforeUpdateHandlers.java
org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/trace/LTTngTraceTest.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/model/trange/TimeRangeComposite.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/AbsFlowTRangeUpdate.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeAfterUpdateHandlers.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeBeforeUpdateHandlers.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/model/FlowProcessContainer.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/events/EventsView.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/evProcessor/ResourcesTRangeUpdateFactory.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/model/ResourceContainer.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/AbstractStatsEventHandler.java
org.eclipse.linuxtools.lttng.ui/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngEventParserStub.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEvent.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEventContent.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEventField.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEventFormat.java [deleted file]
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEventReference.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEventSource.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEventType.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngTimestamp.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/jni/JniEvent.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/jni/JniException.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/jni/JniMarker.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/jni/JniMarkerField.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/jni/JniParser.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/jni/JniTime.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/jni/JniTrace.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/jni/JniTracefile.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/jni/Jni_C_Common.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/jni/Jni_C_Pointer.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/StateDataRequest.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/StateManager.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/StateStacksHandler.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/evProcessor/state/AbsStateProcessing.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/evProcessor/state/AbsStateUpdate.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/evProcessor/state/StateUpdateHandlers.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/model/LttngExecutionState.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/model/LttngProcessState.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/model/LttngTraceState.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTrace.java
org.eclipse.linuxtools.tmf.tests/META-INF/MANIFEST.MF
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/AllEventTests.java [deleted file]
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/AllTests.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfEventContentTest.java
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfEventFieldTest.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfEventFormatTest.java [deleted file]
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfEventReferenceTest.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfEventSourceTest.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfEventTest.java
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfEventTypeTest.java
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfTimeRangeTest.java
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfTimestampTest.java
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfTraceEventTest.java
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/request/AllRequestTests.java [deleted file]
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/request/AllTests.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/request/TmfDataRequestTest.java
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/trace/AllTests.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/trace/AllTraceTests.java [deleted file]
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/trace/TmfExperimentTest.java
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/trace/TmfTraceTest.java
org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/CreateTestFiles.java
org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/event/TmfEventContentStub.java
org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/event/TmfEventFormatStub.java [deleted file]
org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/request/TmfRequestHandlerStub.java
org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/trace/TmfEventParserStub.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/TmfEventsView.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/ITmfContentParser.java [deleted file]
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEvent.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEventContent.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEventField.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEventFormat.java [deleted file]
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEventReference.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEventSource.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEventType.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfTimeRange.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfTimestamp.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfTraceEvent.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/request/TmfDataRequest.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfExperiment.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTrace.java

index 81cafb16f2d8c5921fd557cdf7b3b56958261e01..42ef390751031215e727203424b55720228edf03 100644 (file)
@@ -5,6 +5,6 @@ Bundle-SymbolicName: org.eclipse.linuxtools.lttng.tests
 Bundle-Version: 0.0.1
 Bundle-Vendor: Eclipse
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Require-Bundle: org.junit4;bundle-version="4.5.0",
- org.eclipse.linuxtools.lttng;bundle-version="0.0.1",
- org.eclipse.linuxtools.tmf;bundle-version="0.0.1"
+Require-Bundle: org.eclipse.linuxtools.lttng;bundle-version="0.0.1",
+ org.eclipse.linuxtools.tmf;bundle-version="0.0.1",
+ org.junit;bundle-version="3.8.2"
index e45cd78a5243604f8f2443a84324121de0d1edaa..43baa70398af9dbf803794b0f8f6125e2cade778 100644 (file)
@@ -1,20 +1,20 @@
 package org.eclipse.linuxtools.lttng.event;
 
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
-    LttngTimestampTest.class,
-    LttngEventFieldTest.class,
-    LttngEventFormatTest.class,
-    LttngEventContentTest.class,
-    LttngEventReferenceTest.class,
-    LttngEventTypeTest.class,
-    LttngEventTest.class
-})
-
-public class AllLttngTests {
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
 
+public final class AllLttngTests extends TestCase  {
+    public static TestSuite suite() {
+        TestSuite suite = new TestSuite("Testing JNI");
+        
+        suite.addTestSuite(LttngTimestampTest.class);
+        suite.addTestSuite(LttngEventFieldTest.class);
+        suite.addTestSuite(LttngEventContentTest.class);
+        suite.addTestSuite(LttngEventReferenceTest.class);
+        suite.addTestSuite(LttngEventTypeTest.class);
+        suite.addTestSuite(LttngEventTest.class);
+        
+        return suite;
+    }
 }
 
index f66f1ebbbd8b6a43f81dc31e889349ae0914f230..d9e204a236af8fae763e51fda073dd31f626a79f 100644 (file)
@@ -1,12 +1,8 @@
 package org.eclipse.linuxtools.lttng.event;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.fail;
-
 import org.eclipse.linuxtools.lttng.trace.LTTngTrace;
 import org.eclipse.linuxtools.tmf.trace.TmfTraceContext;
-import org.junit.Test;
+import junit.framework.TestCase;
 
 /*
  Functions tested here :
@@ -20,7 +16,7 @@ import org.junit.Test;
     public String toString()
  */
 
-public class LttngEventContentTest {
+public class LttngEventContentTest extends TestCase {
        private final static boolean skipIndexing=true;
        private final static boolean waitForCompletion=true;
     private final static String tracepath1="traceset/trace-618339events-1293lost-1cpu";
@@ -58,18 +54,17 @@ public class LttngEventContentTest {
                return tmpEventContent;
        }
 
-       @Test
        public void testConstructors() {
+               LttngEvent                testEvent = null;
                LttngEventContent testContent   = null;
                @SuppressWarnings("unused")
                LttngEventContent testContent2  = null;
-               LttngEventFormat        testFormat      = new LttngEventFormat(new String[1]); 
         LttngEventField[]      testFields  = new LttngEventField[1];
-        testFields[0] = new LttngEventField("test", "test");
+        testFields[0] = new LttngEventField(testContent2, "test");
         
            // Default construction with good argument
         try {
-               testContent = new LttngEventContent(testFormat);
+               testContent = new LttngEventContent();
         }
         catch( Exception e) { 
                fail("Construction with format failed!");
@@ -77,7 +72,7 @@ public class LttngEventContentTest {
         
         // Construction with good parameters
         try {
-               testContent = new LttngEventContent(testFormat, "test", testFields);
+               testContent = new LttngEventContent(testEvent);
         }
         catch( Exception e) { 
                fail("Construction with format, content and fields failed!");
@@ -85,7 +80,7 @@ public class LttngEventContentTest {
         
         // Copy constructor with correct parameters
         try {
-               testContent = new LttngEventContent(testFormat);
+               testContent = new LttngEventContent(testEvent);
                testContent2 = new LttngEventContent(testContent);
         }
         catch( Exception e) { 
@@ -95,22 +90,12 @@ public class LttngEventContentTest {
        }
        
        
-    @Test
        public void testGetter() {
        LttngEventContent testContent = null;
        LTTngTrace tmpStream = null;
        LttngEvent tmpEvent = null;
        TmfTraceContext tmpContext = null;
        
-       //*** Basic (very bad) interface ***
-       testContent =  prepareToTest();
-       // getFieldS()
-       assertNotSame("getFields() returned null!",null,testContent.getFields().toString());
-       // getField(int)
-       assertEquals("getField(int) returned unexpected result!",firstEventContentFirstField, testContent.getField(0).toString());
-       
-       
-       //*** Upgraded (better) interface ***
        // Require an event
        tmpStream = initializeEventStream();
        tmpContext = new TmfTraceContext(null, null, 0);
@@ -118,9 +103,9 @@ public class LttngEventContentTest {
        
                testContent = prepareToTest();
        // getFieldS()
-       assertNotSame("getFields(event) returned null!",null,testContent.getFields(tmpEvent) );
+       assertNotSame("getFields() returned null!",null,testContent.getFields() );
        // getField(int)
-       assertEquals("getField(int, event) returned unexpected result!",firstEventContentFirstField, testContent.getField(0, tmpEvent).toString());
+       assertEquals("getField(int) returned unexpected result!",firstEventContentFirstField, testContent.getField(0).toString());
        
        
        
@@ -134,23 +119,13 @@ public class LttngEventContentTest {
        // Second event past metadata should have more fields
        tmpEvent = (LttngEvent)tmpStream.parseEvent(tmpContext);
        
-       //*** Basic (very bad) interface ***
-       testContent =  (LttngEventContent)tmpEvent.getContent();
        // getFieldS()
-       assertNotSame("getFields() returned null!",null,testContent.getFields().toString());
+       assertNotSame("getFields() returned null!",null,testContent.getFields() );
        // getField(int)
        assertEquals("getField(int) returned unexpected result!",secondEventContentSecondField, testContent.getField(1).toString());
        
-       
-       //*** Upgraded (better) interface ***
-       // getFieldS()
-       assertNotSame("getFields(event) returned null!",null,testContent.getFields(tmpEvent) );
-       // getField(int)
-       assertEquals("getField(int, event) returned unexpected result!",secondEventContentSecondField, testContent.getField(1, tmpEvent).toString());
-       
     }
     
-    @Test
        public void testToString() {
        LttngEventContent tmpContent = prepareToTest();
        
index ef8082c71c4708df33ace354444f2c5321594d13..a6afa76ac8b404bb78a3d44a5560b35f23684aa6 100644 (file)
@@ -1,12 +1,10 @@
 package org.eclipse.linuxtools.lttng.event;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.fail;
+
 
 import org.eclipse.linuxtools.lttng.trace.LTTngTrace;
 import org.eclipse.linuxtools.tmf.trace.TmfTraceContext;
-import org.junit.Test;
+import junit.framework.TestCase;
 
 /*
  Functions tested here :
@@ -17,7 +15,7 @@ import org.junit.Test;
 
  */
 
-public class LttngEventFieldTest {
+public class LttngEventFieldTest extends TestCase {
        private final static boolean skipIndexing=true;
        private final static boolean waitForCompletion=true;
     private final static String tracepath1="traceset/trace-618339events-1293lost-1cpu";
@@ -53,15 +51,15 @@ public class LttngEventFieldTest {
                return tmpField;
        }
 
-       @Test
        public void testConstructors() {
+               LttngEventContent testContent = null;
                LttngEventField testField       = null;
                @SuppressWarnings("unused")
                LttngEventField testField2      = null;
         
            // Default construction with good argument
         try {
-               testField = new LttngEventField("test", "test");
+               testField = new LttngEventField(testContent, "test", "test");
         }
         catch( Exception e) { 
                fail("Default construction failed!");
@@ -69,7 +67,7 @@ public class LttngEventFieldTest {
         
         // Copy constructor with correct parameters
         try {
-               testField = new LttngEventField("test", "test");
+               testField = new LttngEventField(testContent, "test", "test");
                testField2 = new LttngEventField(testField);
         }
         catch( Exception e) { 
@@ -78,8 +76,6 @@ public class LttngEventFieldTest {
         
        }
        
-       
-    @Test
        public void testGetter() {
        
        // *** To "really" test the field, we will get a real field from LTTngTrace
@@ -88,13 +84,12 @@ public class LttngEventFieldTest {
        LttngEventField testField       = (LttngEventField)tmpStream.parseEvent( new TmfTraceContext(null, null, 0) ).getContent().getField(0);
        assertNotSame("getField is null!",null,testField);
        
-       assertEquals("getName() returned unexpected result!",firstEventName, testField.getName().toString());
-       assertEquals("getValue() returned unexpected result!",firstEventValue, testField.getValue().toString());
+       assertTrue("getName() returned unexpected result!",firstEventName.equals(testField.getId().toString()));
+       assertTrue("getValue() returned unexpected result!",firstEventValue.equals(testField.getValue().toString()));
        
        
     }
     
-    @Test
        public void testToString() {
        LttngEventField tmpField = prepareToTest();
        
diff --git a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/event/LttngEventFormatTest.java b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/event/LttngEventFormatTest.java
deleted file mode 100644 (file)
index a278ace..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-package org.eclipse.linuxtools.lttng.event;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.fail;
-
-import org.eclipse.linuxtools.lttng.trace.LTTngTrace;
-import org.eclipse.linuxtools.tmf.trace.TmfTraceContext;
-import org.junit.Test;
-
-/*
- Functions tested here :
-    public LttngEventFormat() 
-    public String[] getLabels(LttngEvent thisEvent) 
-    public LttngEventField[] parse(LttngEvent thisEvent) 
-    public LttngEventField[] parse(HashMap<String, Object> parsedEvents) 
-    public LttngEventField[] parse(String uselessContent) 
-
- */
-
-public class LttngEventFormatTest {
-       private final static boolean skipIndexing=true;
-       private final static boolean waitForCompletion=true;
-    private final static String tracepath1="traceset/trace-618339events-1293lost-1cpu";
-    
-    private final static long   timestampAfterMetadata                  = 952090116049L;
-    
-    private final static String secondEventFirstField       = "loglevel";
-    private final static String secondEventSecondField              = "string";
-    //private final static String secondEventThirdField             = "ip";
-    
-    private final static String secondEventThirdFieldParsedValue  = "ip:0xc04f402c";
-    
-    
-    private LTTngTrace initializeEventStream() {
-       LTTngTrace tmpStream = null;
-               try {
-                       tmpStream = new LTTngTrace(tracepath1, waitForCompletion, skipIndexing);
-               } 
-               catch (Exception e) {
-                       fail("ERROR : Could not open " + tracepath1 + ". Test failed!" );
-               }
-               
-               return tmpStream;
-    }
-    
-    
-       private LttngEventFormat prepareToTest() {
-               LttngEventFormat tmpEventFormat = null;
-
-               // This trace should be valid
-               try {
-                       LTTngTrace tmpStream = initializeEventStream();
-                       tmpEventFormat = (LttngEventFormat)tmpStream.parseEvent( new TmfTraceContext(null, null, 0) ).getContent().getFormat();
-               } 
-               catch (Exception e) {
-                       fail("ERROR : Failed to get format!");
-               }
-
-               return tmpEventFormat;
-       }
-
-       @Test
-       public void testConstructors() {
-               LttngEventFormat testFormat = null;
-               @SuppressWarnings("unused")
-               LttngEventFormat testFormat2 = null;
-        
-               
-           // Default construction with good argument
-        try {
-               testFormat = new LttngEventFormat(new String[1]);
-        }
-        catch( Exception e) { 
-               fail("Construction failed!");
-        }
-        
-        // Copy constructor
-        try {
-            testFormat = new LttngEventFormat(new String[1]);
-            testFormat2 = new LttngEventFormat(testFormat);
-        }
-        catch( Exception e) { 
-            fail("Copy construction failed!");
-        }
-        
-       }
-       
-       
-    @Test
-       public void testGetter() {
-       LttngEventFormat testFormat = null;
-       LTTngTrace tmpStream = null;
-       LttngEvent tmpEvent = null;
-       TmfTraceContext tmpContext = new TmfTraceContext(null, null, 0);
-       
-       //*** Position ourself to the second event to have something interesting to test with ***
-       
-       tmpStream = initializeEventStream();
-       // Skip first events and seek to events past metadata
-       tmpContext= tmpStream.seekLocation(new LttngTimestamp(timestampAfterMetadata) );
-       // Skip first one
-       tmpEvent = (LttngEvent)tmpStream.parseEvent(tmpContext);
-       // Second event should have more fields
-       tmpEvent = (LttngEvent)tmpStream.parseEvent(tmpContext);
-       // Get a real format from the event
-       testFormat = (LttngEventFormat)tmpEvent.getContent().getFormat();
-       
-       // Test getLabels()
-       assertEquals("Label not as expected!",secondEventFirstField,testFormat.getLabels()[0].toString());
-       assertEquals("Label not as expected!",secondEventSecondField,testFormat.getLabels()[1].toString());
-       
-       
-       // Test different parse()
-       // parse(event)
-       assertNotSame("parse() returned null!",null, testFormat.parse(tmpEvent));
-       assertEquals("Parsed field not as expected!",secondEventThirdFieldParsedValue,testFormat.parse(tmpEvent)[2].toString());
-       
-       // parse(hashmap)
-       assertNotSame("parse() returned null!",null, testFormat.parse(tmpEvent.convertEventTmfToJni().parseAllFields()));
-       assertEquals("Parsed field not as expected!",secondEventThirdFieldParsedValue,testFormat.parse(tmpEvent.convertEventTmfToJni().parseAllFields())[2].toString());
-       
-       
-       // parse(string)
-       System.out.println(tmpEvent.getContent().getContent().toString());
-       assertNotSame("parse() returned null!",null, testFormat.parse(tmpEvent.getContent().getContent().toString()));
-       assertEquals("Parsed field not as expected!",secondEventThirdFieldParsedValue,testFormat.parse(tmpEvent.getContent().getContent())[2].toString());
-    }
-    
-    @Test
-       public void testToString() {
-       LttngEventFormat tmpFormat = prepareToTest();
-       
-               // Just make sure toString() does not return null or the java reference
-               assertNotSame("toString returned null",null, tmpFormat.toString() );
-               assertNotSame("toString is not overridded!", tmpFormat.getClass().getName() + '@' + Integer.toHexString(tmpFormat.hashCode()), tmpFormat.toString() );
-    }
-       
-}
index bdc8118f6e05d98118b9545833bacc1071ba1b77..bf062fc6a63f38ca7fc4aa3cfb4e545ff7decc60 100644 (file)
@@ -1,13 +1,8 @@
 package org.eclipse.linuxtools.lttng.event;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
 import org.eclipse.linuxtools.lttng.trace.LTTngTrace;
 import org.eclipse.linuxtools.tmf.trace.TmfTraceContext;
-import org.junit.Test;
+import junit.framework.TestCase;
 
 /*
  Functions tested here :
@@ -18,7 +13,7 @@ import org.junit.Test;
     public String toString() 
  */
 
-public class LttngEventReferenceTest {
+public class LttngEventReferenceTest extends TestCase {
        private final static boolean skipIndexing=true;
        private final static boolean waitForCompletion=true;
     private final static String tracepath1="traceset/trace-618339events-1293lost-1cpu";
@@ -53,8 +48,7 @@ public class LttngEventReferenceTest {
 
         return tmpEventRef;
     }
-
-    @Test
+    
     public void testConstructors() {
         LttngEventReference testRef = null;
         @SuppressWarnings("unused")
@@ -79,7 +73,6 @@ public class LttngEventReferenceTest {
     }
     
     
-    @Test
     public void testGetter() {
         LttngEventReference tmpRef = prepareToTest();
         
@@ -87,7 +80,6 @@ public class LttngEventReferenceTest {
         assertEquals("Content not what expected!",firstEventReference,tmpRef.getTracepath());
     }
     
-    @Test
     public void testToString() {
         LttngEventReference tmpRef = prepareToTest();
         
index db1e2b7145b99152ae875c1f6d5a09857ac56288..30a0a4e975d63e97a8bdc4699cd52b18ca51041c 100644 (file)
@@ -1,15 +1,10 @@
 package org.eclipse.linuxtools.lttng.event;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
 import org.eclipse.linuxtools.lttng.jni.JniEvent;
 import org.eclipse.linuxtools.lttng.trace.LTTngTrace;
 import org.eclipse.linuxtools.tmf.event.TmfEventSource;
 import org.eclipse.linuxtools.tmf.trace.TmfTraceContext;
-import org.junit.Test;
+import junit.framework.TestCase;
 
 /*
  Functions tested here :
@@ -23,7 +18,7 @@ import org.junit.Test;
 
  */
 
-public class LttngEventTest {
+public class LttngEventTest extends TestCase {
        private final static boolean skipIndexing=true;
        private final static boolean waitForCompletion=true;
     private final static String tracepath1="traceset/trace-618339events-1293lost-1cpu";
@@ -52,7 +47,6 @@ public class LttngEventTest {
                return tmpEvent;
        }
 
-       @Test
        public void testConstructors() {
                
                LTTngTrace testStream1 = null;
@@ -61,23 +55,23 @@ public class LttngEventTest {
                LttngEvent                      testAnotherEvent = null;
         LttngTimestamp         testTime                = null;
         TmfEventSource                 testSource              = null;
-        LttngEventFormat       testFormat              = null;
         LttngEventType         testType                = null;
         LttngEventContent      testContent             = null;
         LttngEventReference testReference      = null;
         JniEvent                       testJniEvent    = null;
-               
+               String[]                        testMarkerFields = null;
+        
         // This need to work if we want to perform tests
         try {
                        // In order to test LttngEvent, we need all these constructors/functions to work.
                // Make sure to run their unit tests first!
+                       testMarkerFields = new String[1];
                        testStream1 = new LTTngTrace(tracepath1, waitForCompletion, skipIndexing);
                 testEvent      = null;
                 testTime       = new LttngTimestamp(0L);
                 testSource     = new TmfEventSource("test");
-                testFormat     = new LttngEventFormat(new String[1]);
-                testType       = new LttngEventType("test", 0, "test", testFormat);
-                testContent    = new LttngEventContent(testFormat);
+                testType       = new LttngEventType("test", 0L, "test", testMarkerFields);
+                testContent    = new LttngEventContent(testEvent);
                 testReference = new LttngEventReference("test", "test");
                 testJniEvent = testStream1.getCurrentJniTrace().findNextEvent();
         }
@@ -164,8 +158,6 @@ public class LttngEventTest {
                
        }
        
-       
-    @Test
        public void testGetter() {
        LttngEvent testEvent = prepareToTest();
        
@@ -177,10 +169,9 @@ public class LttngEventTest {
        assertEquals("CpuId not what expected!",eventCpu,testEvent.getCpuId());
        assertEquals("Marker not what expected!",eventMarker,testEvent.getMarkerName());
        assertEquals("Content not what expected!",eventContent,testEvent.getContent().getContent());
-       assertTrue("Reference not what expected!",((String)testEvent.getReference().getValue()).contains(eventReference) );
+       assertTrue("Reference not what expected!",((String)testEvent.getReference().getReference()).contains(eventReference) );
     }
     
-    @Test
        public void testConversion() {
        JniEvent tmpJniEvent = null;
        LttngEvent testEvent = null;
@@ -199,7 +190,6 @@ public class LttngEventTest {
        
     }
     
-    @Test
        public void testToString() {
        LttngEvent tmpEvent = prepareToTest();
        
index af79497f4f0fb05eda0f0c41e3e87cc013f1e327..4df2dc0d1c9e9280c7c6d20fdd798ceeec39047e 100644 (file)
@@ -1,12 +1,8 @@
 package org.eclipse.linuxtools.lttng.event;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.fail;
-
 import org.eclipse.linuxtools.lttng.trace.LTTngTrace;
 import org.eclipse.linuxtools.tmf.trace.TmfTraceContext;
-import org.junit.Test;
+import junit.framework.TestCase;
 
 /*
  Functions tested here :
@@ -18,7 +14,7 @@ import org.junit.Test;
     public String toString() 
  */
 
-public class LttngEventTypeTest {
+public class LttngEventTypeTest extends TestCase {
        private final static boolean skipIndexing=true;
        private final static boolean waitForCompletion=true;
     private final static String tracepath1="traceset/trace-618339events-1293lost-1cpu";
@@ -54,8 +50,7 @@ public class LttngEventTypeTest {
 
         return tmpEventType;
     }
-
-    @Test
+    
     public void testConstructors() {
         LttngEventType tmpEventType = null;
         @SuppressWarnings("unused")
@@ -63,7 +58,7 @@ public class LttngEventTypeTest {
         
         // Default construction with good argument
         try {
-            tmpEventType = new LttngEventType("test", 0L, "test",  new LttngEventFormat(new String[1]));
+            tmpEventType = new LttngEventType("test", 0L, "test",  new String[1]);
         }
         catch( Exception e) { 
             fail("Construction failed!");
@@ -71,7 +66,7 @@ public class LttngEventTypeTest {
         
         // Copy constructor
         try {
-            tmpEventType = new LttngEventType("test", 0L, "test", new LttngEventFormat(new String[1]));
+            tmpEventType = new LttngEventType("test", 0L, "test", new String[1]);
             tmpEventType2 = new LttngEventType(tmpEventType);
         }
         catch( Exception e) { 
@@ -80,18 +75,16 @@ public class LttngEventTypeTest {
     }
     
     
-    @Test
     public void testGetter() {
         LttngEventType tmpEventType = prepareToTest();
         
-        assertEquals("Channel name not what was expected!",firstEventChannel,(String)tmpEventType.getChannelName() );
-        assertEquals("Cpu Id not what was expected!",firstEventCpu,tmpEventType.getCpuId() );
-        assertEquals("Marker Name not what was expected!",firstEventMarker,(String)tmpEventType.getMarkerName() );
-        // Just test the non-nullity of format
-        assertNotSame("getFormat returned null",null, tmpEventType.getFormat() );
+        assertTrue("Channel name not what was expected!",firstEventChannel.equals((String)tmpEventType.getTracefileName()) );
+        assertTrue("Cpu Id not what was expected!",firstEventCpu == tmpEventType.getCpuId() );
+        assertTrue("Marker Name not what was expected!",firstEventMarker.equals((String)tmpEventType.getMarkerName()) );
+        // Just test the non-nullity of labels
+        assertNotSame("getFormat returned null",null, tmpEventType.getLabels() );
     }
     
-    @Test
     public void testToString() {
         LttngEventType tmpEventType = prepareToTest();
         
index ff623be540028991da28ff082f837d443aedd054..4ca319e5eb685f83ab3ebe0f2e7e9bb03dfca4dc 100644 (file)
@@ -1,12 +1,8 @@
 package org.eclipse.linuxtools.lttng.event;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.fail;
-
 import org.eclipse.linuxtools.lttng.trace.LTTngTrace;
 import org.eclipse.linuxtools.tmf.trace.TmfTraceContext;
-import org.junit.Test;
+import junit.framework.TestCase;
 
 /*
  Functions tested here :
@@ -17,7 +13,7 @@ import org.junit.Test;
     public String toString() 
  */
 
-public class LttngTimestampTest {
+public class LttngTimestampTest extends TestCase {
        private final static boolean skipIndexing=true;
        private final static boolean waitForCompletion=true;
     private final static String tracepath1="traceset/trace-618339events-1293lost-1cpu";
@@ -53,8 +49,7 @@ public class LttngTimestampTest {
 
         return tmpTime;
     }
-
-    @Test
+    
     public void testConstructors() {
         LttngTimestamp tmpTime = null;
         @SuppressWarnings("unused")
@@ -79,7 +74,6 @@ public class LttngTimestampTest {
     }
     
     
-    @Test
     public void testGetter() {
         LttngTimestamp tmpTime = prepareToTest();
         
@@ -90,7 +84,6 @@ public class LttngTimestampTest {
     }
     
     
-    @Test
     public void testToString() {
         LttngTimestamp tmpTime = prepareToTest();
         
index 5097653778d86c57e95f37f1a76d40c70b05dd47..a6365913b2e64770ab9b04af7825fdf4fe11e822 100644 (file)
@@ -1,18 +1,19 @@
 
 package org.eclipse.linuxtools.lttng.jni;
 
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
 
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
-    JniTraceTest.class,
-    JniTracefileTest.class,
-    JniEventTest.class,
-    JniMarkerTest.class,
-    JniMarkerFieldTest.class
-})
-
-public class AllJniTests {
-
-}
+public final class AllJniTests extends TestCase  {
+    public static TestSuite suite() {
+        TestSuite suite = new TestSuite("Testing JNI");
+        
+        suite.addTestSuite(JniTraceTest.class);
+        suite.addTestSuite(JniTracefileTest.class);
+        suite.addTestSuite(JniEventTest.class);
+        suite.addTestSuite(JniMarkerTest.class);
+        suite.addTestSuite(JniMarkerFieldTest.class);
+        
+        return suite;
+    }
+}
\ No newline at end of file
index cfb7bc7022b280d3a4318564410d4c64efc9418b..c54473d6af0c254528f6cc2265e747e56d751055 100644 (file)
@@ -3,22 +3,20 @@
  */
 package org.eclipse.linuxtools.lttng.jni;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
+import junit.framework.TestCase;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import org.junit.Test;
-
 /**
  * @author alvaro
  * 
  */
-public class Combinations {
+public class Combinations extends TestCase {
 
+       private final static boolean printLttDebug = false;
+       
     private final static String tracepath="traceset/trace-618339events-1293lost-1cpu";
        private final static String eventName = "syscall_state";
 
@@ -93,14 +91,13 @@ public class Combinations {
                JniEvent tmpEvent = null;
                // This trace should be valid
                try {
-                       tmpEvent = new JniTrace(tracepath).requestEventByName(eventName);
+                       tmpEvent = new JniTrace(tracepath, printLttDebug).requestEventByName(eventName);
                } catch (JniException e) {
                }
 
                return tmpEvent;
        }
-
-       @Test
+       
        public void testGetSpecEventFields() {
                JniEvent event = prepareEventToTest();
                JniMarker dmarker = event.requestEventMarker();
@@ -111,12 +108,11 @@ public class Combinations {
 
        }
 
-       @Test
        public void testEventsLoop() {
                JniTrace trace = null;
                JniEvent event = null;
                try {
-                       trace = new JniTrace(tracepath);
+                       trace = new JniTrace(tracepath, printLttDebug);
                } catch (JniException e) {
                        e.printStackTrace();
                }
index b9d38dabeb0746db03cf900036bb5d7bfdc0869e..5cffb479c9d0019d2e5130ef0d620ca08cf1e2a7 100644 (file)
 
 package org.eclipse.linuxtools.lttng.jni;
 
-import static org.junit.Assert.*;
-import org.junit.Test;
+import junit.framework.TestCase;
 
-public class JniEventTest
+public class JniEventTest extends TestCase
 {
+               private final static boolean printLttDebug = false;
+       
         private final static String tracepath="traceset/trace-618339events-1293lost-1cpu";
         private final static String eventName="kernel0";
         
@@ -74,7 +75,7 @@ public class JniEventTest
                 
                 // This trace should be valid
                 try {
-                        tmpEvent = new JniTrace(tracepath).requestEventByName(eventName);
+                        tmpEvent = new JniTrace(tracepath, printLttDebug).requestEventByName(eventName);
                 }
                 catch( JniException e) { }
                 
@@ -82,7 +83,6 @@ public class JniEventTest
         }
         
         
-        @Test
         public void testEventConstructors() {
                 JniTracefile testTracefile = null;
                 
@@ -91,7 +91,7 @@ public class JniEventTest
                 
                 // This trace should be valid and will be used in test
                 try {
-                        testTracefile = new JniTrace(tracepath).requestTracefileByName(eventName);
+                        testTracefile = new JniTrace(tracepath, printLttDebug).requestTracefileByName(eventName);
                 }
                 catch( JniException e) { }
                 
@@ -145,7 +145,6 @@ public class JniEventTest
                 
         }
         
-        @Test
         public void testPrintAndToString() {
                 
                 JniEvent testEvent = prepareEventToTest();
@@ -163,7 +162,6 @@ public class JniEventTest
                 
         }
         
-        @Test
         public void testEventDisplacement() {
                 
                 int readValue = -1;
@@ -222,7 +220,6 @@ public class JniEventTest
                 assertEquals("readNextEvent() event timestamp is incoherent (test #2)",timestampToSeekTest1,testEvent.getEventTime().getTime() );
         }
         
-        @Test
         public void testGetSet() {
                 
                 JniEvent testEvent = prepareEventToTest();
@@ -249,7 +246,6 @@ public class JniEventTest
                 assertNotNull("getParentTracefile returned null", testEvent.getParentTracefile() );
         }
         
-        @Test
         public void testRequestFunctions() {
                 
                 JniEvent testEvent = prepareEventToTest();
@@ -268,7 +264,6 @@ public class JniEventTest
                 
         }
         
-        @Test
         public void testParseAllFieldsFunctions() {
                 
                 JniEvent testEvent = prepareEventToTest();
@@ -310,7 +305,6 @@ public class JniEventTest
                 assertNotNull("parseAllFields returned null",testEvent.parseAllFields() );
         }
         
-        @Test
         public void testParseFieldByIdFunctions() {
                 JniEvent testEvent = prepareEventToTest();
                 
index 6220dcb6280e725ef19674d12c6f6520df8fe700..971995f0293b616adedba721682fce9fac7f06cf 100644 (file)
@@ -1,8 +1,7 @@
 
 package org.eclipse.linuxtools.lttng.jni;
 
-import static org.junit.Assert.*;
-import org.junit.Test;
+import junit.framework.TestCase;
 
 /*
  Functions tested here :
@@ -16,8 +15,10 @@ import org.junit.Test;
         public void printMarkerFieldInformation()
 */
 
-public class JniMarkerFieldTest
+public class JniMarkerFieldTest extends TestCase
 {
+               private final static boolean printLttDebug = false;
+       
         private final static String tracepath="traceset/trace-618339events-1293lost-1cpu";
         private final static String eventName="kernel0";
         
@@ -29,7 +30,7 @@ public class JniMarkerFieldTest
                 // This trace should be valid
                 // We will read the first 2 event to have something interesting to test on
                 try {
-                        tmpEvent = new JniTrace(tracepath).requestEventByName(eventName);
+                        tmpEvent = new JniTrace(tracepath, printLttDebug).requestEventByName(eventName);
                         tmpEvent.readNextEvent();
                         tmpEvent.readNextEvent();
                         
@@ -41,8 +42,6 @@ public class JniMarkerFieldTest
                 return tmpMarkerField;
         }
         
-        
-        @Test
         public void testEventConstructors() {
                 
                 JniMarker tmpMarker = null;
@@ -52,7 +51,7 @@ public class JniMarkerFieldTest
                 
                 // This event should be valid and will be used in test
                 try {
-                        tmpMarker = new JniTrace(tracepath).requestEventByName(eventName).requestEventMarker();
+                        tmpMarker = new JniTrace(tracepath, printLttDebug).requestEventByName(eventName).requestEventMarker();
                 }
                 catch( JniException e) { }
                 
@@ -86,7 +85,6 @@ public class JniMarkerFieldTest
                 
         }
         
-        @Test
         public void testGetSet() {
                 
                 JniMarkerField testMarkerField = prepareMarkerFieldToTest();
@@ -97,7 +95,6 @@ public class JniMarkerFieldTest
                 assertNotSame("getMarkerFieldPtr is 0",0,testMarkerField.getMarkerFieldPtr() );
         }
         
-        @Test
         public void testPrintAndToString() {
                 
                 JniMarkerField testMarkerField = prepareMarkerFieldToTest();
index 24f63f6b634e4410acecb423cbd5e333fa75ebbd..2ab420b2e97198f4e36c3447ff89cb3838581815 100644 (file)
@@ -1,8 +1,7 @@
 
 package org.eclipse.linuxtools.lttng.jni;
 
-import static org.junit.Assert.*;
-import org.junit.Test;
+import junit.framework.TestCase;
 
 /*
  Functions tested here :
@@ -19,8 +18,10 @@ import org.junit.Test;
         public void printMarkerInformation()
 */
 
-public class JniMarkerTest
+public class JniMarkerTest extends TestCase
 {
+               private final static boolean printLttDebug = false;
+               
         private final static String tracepath="traceset/trace-618339events-1293lost-1cpu";
         private final static String eventName="kernel0";
         
@@ -34,7 +35,7 @@ public class JniMarkerTest
                 // This trace should be valid
                 // We will read the second event to have something interesting to test on
                 try {
-                        tmpEvent = new JniTrace(tracepath).requestEventByName(eventName);
+                        tmpEvent = new JniTrace(tracepath, printLttDebug).requestEventByName(eventName);
                         tmpEvent.readNextEvent();
                         
                         tmpMarker = tmpEvent.requestEventMarker();
@@ -44,8 +45,6 @@ public class JniMarkerTest
                 return tmpMarker;
         }
         
-        
-        @Test
         public void testEventConstructors() {
                 
                 JniEvent tmpEvent = null;
@@ -55,7 +54,7 @@ public class JniMarkerTest
                 
                 // This event should be valid and will be used in test
                 try {
-                        tmpEvent = new JniTrace(tracepath).requestEventByName(eventName);
+                        tmpEvent = new JniTrace(tracepath, printLttDebug).requestEventByName(eventName);
                 }
                 catch( JniException e) { }
                 
@@ -89,7 +88,6 @@ public class JniMarkerTest
                 
         }
         
-        @Test
         public void testGetSet() {
                 
                 JniMarker testMarker = prepareMarkerToTest();
@@ -105,7 +103,6 @@ public class JniMarkerTest
                 assertNotSame("getMarkerPtr is 0",0,testMarker.getMarkerPtr() );
         }
         
-        @Test
         public void testPrintAndToString() {
                 
                 JniMarker testMarker = prepareMarkerToTest();
index bc3b01417e8ca4b29907a554895f04b1816331e8..b557972dc8ab0d27b32b0cd1baf7963f96bda412 100644 (file)
@@ -1,12 +1,7 @@
 
 package org.eclipse.linuxtools.lttng.jni;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.fail;
-
-import org.junit.Test;
+import junit.framework.TestCase;
 
 /*
  Functions tested here :
@@ -52,8 +47,10 @@ import org.junit.Test;
  */
 
 
-public class JniTraceTest
+public class JniTraceTest extends TestCase
 {
+               private final static boolean printLttDebug = false;
+               
         private final static String tracepath1="traceset/trace-618339events-1293lost-1cpu";
         private final static String tracepath2="traceset/trace-1021events-nolost-1cpu";
         private final static String wrongTracePath="/somewhere/that/does/not/exist";
@@ -92,14 +89,13 @@ public class JniTraceTest
                 
                 // This trace should be valid
                 try {
-                        tmpTrace = new JniTrace(tracepath1);
+                        tmpTrace = new JniTrace(tracepath1, printLttDebug);
                 }
                 catch( JniException e) { }
                 
                 return tmpTrace;
         }
         
-        @Test
         public void testTraceConstructors() {
                 JniTrace testTrace1 = null;
                 @SuppressWarnings("unused")
@@ -107,7 +103,7 @@ public class JniTraceTest
                 
                 // Test constructor with argument on a wrong tracepath
                 try {
-                        testTrace1 = new JniTrace(wrongTracePath);
+                        testTrace1 = new JniTrace(wrongTracePath, printLttDebug);
                         fail("Construction with wrong tracepath should fail!");
                 }
                 catch( JniException e) { 
@@ -115,7 +111,7 @@ public class JniTraceTest
                 
                 // Test constructor with argument on a correct tracepath
                 try {
-                        testTrace1 = new JniTrace(tracepath1);
+                        testTrace1 = new JniTrace(tracepath1, printLttDebug);
                 }
                 catch( JniException e) {
                         fail("Construction with correct tracepath failed!");
@@ -123,7 +119,7 @@ public class JniTraceTest
                 
                 // Test copy constructor that take a pointer with a good pointer
                 try {
-                        testTrace1 = new JniTrace( new Jni_C_Pointer(0) );
+                        testTrace1 = new JniTrace( new Jni_C_Pointer(0), printLttDebug);
                         fail("Construction with wrong pointer should fail!");
                 }
                 catch( JniException e) { 
@@ -131,8 +127,8 @@ public class JniTraceTest
                 
                 // Test copy constructor that take a pointer with a good pointer
                 try {
-                        testTrace1 = new JniTrace(tracepath1); // This trace should be valid
-                        testTrace2 = new JniTrace( testTrace1.getTracePtr() );
+                        testTrace1 = new JniTrace(tracepath1, printLttDebug); // This trace should be valid
+                        testTrace2 = new JniTrace( testTrace1.getTracePtr(), printLttDebug);
                 }
                 catch( JniException e) { 
                         fail("Construction with correct pointer failed!");
@@ -140,7 +136,6 @@ public class JniTraceTest
                 
         }
         
-        @Test
         public void testTraceOpenClose() {
                 
                 JniTrace testTrace = prepareTraceToTest(); // This trace should be valid
@@ -182,7 +177,6 @@ public class JniTraceTest
                 }
         }
         
-        @Test
         public void testGetSet() {
                 
                 JniTrace testTrace = prepareTraceToTest();
@@ -210,7 +204,6 @@ public class JniTraceTest
                 
         }
         
-        @Test
         public void testPrintAndToString() {
                 
                 JniTrace testTrace = prepareTraceToTest();
@@ -227,7 +220,6 @@ public class JniTraceTest
                 assertNotSame("toString returned empty data","",testTrace.toString() );
         }
         
-        @Test
         public void testRequestFunctions() {
         
                 JniTrace testTrace = prepareTraceToTest();
@@ -241,7 +233,6 @@ public class JniTraceTest
                 assertSame("requestEventByName returned content on non existent name",null,testTrace.requestEventByName(wrongTracefileName) );
         }
         
-        @Test
         public void testEventDisplacement() {
         
                 JniEvent testEvent = null; 
@@ -343,7 +334,6 @@ public class JniTraceTest
                 assertEquals("seekToTime(time) timestamp after seek back is incoherent",firstEventTimestamp,testEvent.getEventTime().getTime());
         }
         
-        @Test
         public void testEventDisplacementByTracefile() {
         
                 JniEvent testEvent = null; 
index 93366ff067c0095bb16f69380f2937aedc157cd0..f7c5890bd66602fdcb4f8f416713e9598cacb524 100644 (file)
@@ -1,8 +1,7 @@
 
 package org.eclipse.linuxtools.lttng.jni;
 
-import static org.junit.Assert.*;
-import org.junit.Test;
+import junit.framework.TestCase;
 
 /*
  Functions tested here :
@@ -47,8 +46,10 @@ import org.junit.Test;
         public void printTracefileInformation()
 */
 
-public class JniTracefileTest
+public class JniTracefileTest extends TestCase
 {
+               private final static boolean printLttDebug = false;
+               
         private final static String tracepath1="traceset/trace-618339events-1293lost-1cpu";
         private final static String tracefileName1="kernel0";
         
@@ -70,7 +71,7 @@ public class JniTracefileTest
                 
                 // This trace should be valid
                 try {
-                        tmpTracefile = new JniTrace(tracepath1).requestTracefileByName(tracefileName1);
+                        tmpTracefile = new JniTrace(tracepath1, printLttDebug).requestTracefileByName(tracefileName1);
                         
                 }
                 catch( JniException e) { }
@@ -79,7 +80,6 @@ public class JniTracefileTest
         }
         
         
-        @Test
         public void testTracefileConstructors() {
                 JniTrace testTrace = null;
                 JniTracefile testTracefile1 = null;
@@ -87,7 +87,7 @@ public class JniTracefileTest
                 
                 // This trace should be valid and will be used in test
                 try {
-                        testTrace = new JniTrace(tracepath1);
+                        testTrace = new JniTrace(tracepath1, printLttDebug);
                 }
                 catch( JniException e) { }
                 
@@ -122,7 +122,6 @@ public class JniTracefileTest
                 
         }
         
-        @Test
         public void testGetSet() {
                 
                 JniTracefile testTracefile = prepareTracefileToTest();
@@ -166,7 +165,6 @@ public class JniTracefileTest
                 
         }
         
-        @Test
         public void testPrintAndToString() {
                 
                 JniTracefile testTracefile = prepareTracefileToTest();
@@ -184,7 +182,6 @@ public class JniTracefileTest
                 
         }
         
-        @Test
         public void testEventDisplacement() {
                 
                 int readValue = -1;
index c5348d9b3e778ba094cfd708558ce61703593363..08cc38836b5bd6f817d863f78da87f96f1a4da9b 100644 (file)
@@ -18,36 +18,14 @@ import org.eclipse.linuxtools.lttng.ActivateDebugging;
 import org.eclipse.linuxtools.lttng.TraceDebug;
 import org.eclipse.linuxtools.lttng.trace.LTTngTrace;
 import org.eclipse.linuxtools.tmf.trace.TmfExperiment;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import junit.framework.TestCase;
 
 /**
  * @author alvaro
  * 
  */
-public class TestStateManager {
-
-       @BeforeClass
-       public static void setUpBeforeClass() throws Exception {
-       }
-
-       @AfterClass
-       public static void tearDownAfterClass() throws Exception {
-       }
-
-       @Before
-       public void setUp() throws Exception {
-               ActivateDebugging.activate();
-       }
-
-       @After
-       public void tearDown() throws Exception {
-       }
-
-       @Test
+public class TestStateManager extends TestCase {
+       
        public void testSetTraceSelection() {
                String logName = "traceset/trace1";
                
index 1500fa42a925b29253c78644017c64552a9ba769..1c34ad28f8449d5a7f4186253f073e66bbb29345 100644 (file)
@@ -272,7 +272,7 @@ public abstract class AbsStateUpdate implements IEventProcessing {
                String expectedFieldName = expectedField.getInName();
                for (int i = 0; i < fields.length; i++) {
                        field = (LttngEventField) fields[i];
-                       fieldname = field.getName();
+                       fieldname = field.getId();
                        if (fieldname.equals(expectedFieldName)) {
                                Object fieldObj = field.getValue();
                                if (fieldObj instanceof Long) {
@@ -327,7 +327,7 @@ public abstract class AbsStateUpdate implements IEventProcessing {
                String expectedFieldName = expectedField.getInName();
                for (int i = 0; i < fields.length; i++) {
                        field = (LttngEventField) fields[i];
-                       fieldname = field.getName();
+                       fieldname = field.getId();
                        if (fieldname.equals(expectedFieldName)) {
                                Object fieldObj = field.getValue();
                                if (fieldObj instanceof String) {
@@ -361,7 +361,7 @@ public abstract class AbsStateUpdate implements IEventProcessing {
                sb.append(" number of fields: " + fields.length + "Fields: ");
                for (int i = 0; i < fields.length; i++) {
                        field = (LttngEventField) fields[i];
-                       sb.append(field.getName() + " ");
+                       sb.append(field.getId() + " ");
                }
 
                TraceDebug.debug(sb.toString(), 5);
index a58622cd57428a4b8a8ca96450992e45daa2b73f..6cb870f21b9ca48ee5d3d6674a6e386fbde7dc86 100644 (file)
@@ -72,7 +72,7 @@ class StateAfterUpdateHandlers {
                                                        + ExecutionMode.LTTV_STATE_SYSCALL.getInName());
                                }
 
-                               if (stackState.getEntry_LttTime() != trcEvent.getTimestamp()) {
+                               if (stackState.getEntry_LttTime() != trcEvent.getTimestamp().getValue()) {
                                        TraceDebug.debug("Unexpected Entry time: "
                                                        + trcEvent.getTimestamp() + " Expected: "
                                                        + stackState.getEntry_LttTime());
index 591133cefacea1f2fc390fb0f864b325bdf707cb..d68d5fb6beecd0b8278680788b7ee590d33b3378 100644 (file)
@@ -71,8 +71,8 @@ class StateBeforeUpdateHandlers {
                                exState = new LttngExecutionState();
                                exState.setExec_mode(ExecutionMode.LTTV_STATE_SYSCALL);
                                exState.setExec_submode(submode);
-                               exState.setEntry_Time(trcEvent.getTimestamp());
-                               exState.setChange_Time(trcEvent.getTimestamp());
+                               exState.setEntry_Time(trcEvent.getTimestamp().getValue());
+                               exState.setChange_Time(trcEvent.getTimestamp().getValue());
                                exState.setCum_cpu_time(0L);
 
                                return false;
index 023c79bfb815a28b67bea87b2880f89e425dafdb..9c3039950749da6e1f7e42a26db3bebad2295a88 100644 (file)
@@ -1,14 +1,9 @@
 package org.eclipse.linuxtools.lttng.trace;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
 import org.eclipse.linuxtools.tmf.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
 import org.eclipse.linuxtools.tmf.trace.TmfTraceContext;
-import org.junit.Test;
+import junit.framework.TestCase;
 
 /*
  Functions tested here :
@@ -24,7 +19,7 @@ import org.junit.Test;
 
  */
 
-public class LTTngTraceTest {
+public class LTTngTraceTest extends TestCase {
        
     private final static String tracepath1="traceset/trace-618339events-1293lost-1cpu";
     private final static String wrongTracePath="/somewhere/that/does/not/exist";
@@ -58,8 +53,7 @@ public class LTTngTraceTest {
 
                return tmpStream;
        }
-
-       @Test
+       
        public void testTraceConstructors() {
                @SuppressWarnings("unused")
                LTTngTrace testStream1 = null;
@@ -102,7 +96,6 @@ public class LTTngTraceTest {
         }
        }
        
-       @Test
        public void testParseNextEvent() {
                TmfEvent tmpEvent = null;
                LTTngTrace testStream1 = prepareStreamToTest();
@@ -119,7 +112,6 @@ public class LTTngTraceTest {
                assertEquals("tmpEvent has wrong timestamp after second parseEvent()",secondEventTimestamp,(long)tmpEvent.getTimestamp().getValue() );
        }
        
-       @Test
        public void testSeekLocation() {
                TmfEvent tmpEvent = null;
                TmfTraceContext tmpContext = new TmfTraceContext(null, null, 0);
@@ -131,7 +123,7 @@ public class LTTngTraceTest {
                assertEquals("tmpContext has wrong timestamp after first seekLocation()",contextValueAfterSeekTest1,(long)((TmfTimestamp)tmpContext.getLocation()).getValue() );
                tmpEvent = testStream1.parseEvent(tmpContext);
                assertNotSame("tmpEvent is null after first seekLocation()",null,tmpEvent );
-               assertTrue("tmpEvent has wrong reference after first seekLocation()", ((String)tmpEvent.getReference().getValue()).contains(seek1EventReference) );
+               assertTrue("tmpEvent has wrong reference after first seekLocation()", ((String)tmpEvent.getReference().getReference()).contains(seek1EventReference) );
                
                // Seek to the last timestamp
                tmpContext = testStream1.seekLocation(new TmfTimestamp(timestampToSeekLast));
@@ -139,7 +131,7 @@ public class LTTngTraceTest {
                assertEquals("tmpContext has wrong timestamp after seekLocation() to last",contextValueAfterSeekLast,(long)((TmfTimestamp)tmpContext.getLocation()).getValue() );
                tmpEvent = testStream1.parseEvent(tmpContext);
                assertNotSame("tmpEvent is null after seekLocation() to last ",null,tmpEvent );
-               assertTrue("tmpEvent has wrong reference after seekLocation() to last",((String)tmpEvent.getReference().getValue()).contains(seekLastEventReference) );
+               assertTrue("tmpEvent has wrong reference after seekLocation() to last",((String)tmpEvent.getReference().getReference()).contains(seekLastEventReference) );
                
                // Seek to the first timestamp (startTime)
                tmpContext = testStream1.seekLocation(new TmfTimestamp(firstEventTimestamp));
@@ -147,11 +139,10 @@ public class LTTngTraceTest {
                assertEquals("tmpContext has wrong timestamp after seekLocation() to start",contextValueAfterFirstEvent,(long)((TmfTimestamp)tmpContext.getLocation()).getValue() );
                tmpEvent = testStream1.parseEvent(tmpContext);
                assertNotSame("tmpEvent is null after seekLocation() to start ",null,tmpEvent );
-               assertTrue("tmpEvent has wrong reference after seekLocation() to start",((String)tmpEvent.getReference().getValue()).contains(firstEventReference) );
+               assertTrue("tmpEvent has wrong reference after seekLocation() to start",((String)tmpEvent.getReference().getReference()).contains(firstEventReference) );
        }
        
        
-    @Test
        public void testGetter() {
        TmfEvent tmpEvent = null;
                LTTngTrace testStream1 = prepareStreamToTest();
@@ -167,10 +158,9 @@ public class LTTngTraceTest {
                
                // Test current event
                assertNotSame("tmpEvent is null after first event",null,tmpEvent );
-               assertTrue("tmpEvent has wrong reference after first event",((String)tmpEvent.getReference().getValue()).contains(firstEventReference) );
+               assertTrue("tmpEvent has wrong reference after first event",((String)tmpEvent.getReference().getReference()).contains(firstEventReference) );
     }
     
-    @Test
        public void testToString() {
                LTTngTrace testStream1 = prepareStreamToTest();
                
index b9a728632bf3628eb68907b2f658ab87cd841c24..7cf42f2cd70080653e3d6a1916a9d1b20bd3b9ba 100644 (file)
@@ -51,9 +51,9 @@ ITmfTimeAnalysisEntry {
        protected String groupName = "";
        protected String className = "";
        protected CompositeType contType = CompositeType.UNKNOWN;
-       protected long next_good_time = -1;
+       protected Long next_good_time = -1L;
        /*Time of first event which trigger the creation of this local resource */
-       protected long insertionTime = -1
+       protected Long insertionTime = -1L
 
        // ========================================================================
        // Constructors
index f4879b4fdbbfd2b6c5c3e9f4fa0cb1d83133c979..cdde5bba812dc990898370912af6e81426c09308 100644 (file)
@@ -12,6 +12,7 @@ package org.eclipse.linuxtools.lttng.ui.views.controlflow.evProcessor;
 
 import java.util.Vector;
 
+import org.eclipse.linuxtools.lttng.TraceDebug;
 import org.eclipse.linuxtools.lttng.state.StateStrings.ProcessStatus;
 import org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing;
 import org.eclipse.linuxtools.lttng.state.model.LttngProcessState;
@@ -45,8 +46,10 @@ public abstract class AbsFlowTRangeUpdate extends AbsTRangeUpdate implements IEv
                                procContainer.getUniqueId(), stateProcess.getName(),
                                traceStartTime, traceEndTime, "", stateProcess.getType()
                                                .getInName(), stateProcess.getCpu(), stateProcess
-                                               .getInsertion_time().getValue());
-               localProcess.setCreationTime(stateProcess.getCreation_time().getValue());
+                                               .getInsertion_time());
+               
+               
+               localProcess.setCreationTime(stateProcess.getCreation_time());
                localProcess.setPid(stateProcess.getPid());
                localProcess.setTgid(stateProcess.getTgid());
                localProcess.setPpid(stateProcess.getPpid());
index 8ca30915a0254d6f65a8223862a3732580900149..df7e041f8af97f56e9bcba73798673bb256b31ad 100644 (file)
@@ -60,7 +60,7 @@ class FlowTRangeAfterUpdateHandlers {
                 }
                                
                                //hashed_process_data = processlist_get_process_data(process_list,pid_out,process->cpu,&birth,trace_num);
-                               TimeRangeEventProcess localProcess = procContainer.findProcess(process_in.getPid(), process_in.getCpu(), traceSt.getTraceId(),process_in.getCreation_time().getValue() );
+                               TimeRangeEventProcess localProcess = procContainer.findProcess(process_in.getPid(), process_in.getCpu(), traceSt.getTraceId(),process_in.getCreation_time() );
                                
                                if ( localProcess == null ) {
                                        if ( (pid_in == 0) || (pid_in != process_in.getPpid()) ) {
@@ -139,7 +139,7 @@ class FlowTRangeAfterUpdateHandlers {
                 LttngProcessState process_child = lttv_state_find_process(traceSt, trcEvent.getCpuId(), child_pid );
                            
                            if ( process_child != null ) {
-                               TimeRangeEventProcess localProcess = procContainer.findProcess(process_child.getPid(), process_child.getCpu(), traceSt.getTraceId(), process_child.getCreation_time().getValue() );
+                               TimeRangeEventProcess localProcess = procContainer.findProcess(process_child.getPid(), process_child.getCpu(), traceSt.getTraceId(), process_child.getCreation_time() );
                                
                                if ( localProcess == null ) {
                                    if ( (child_pid == 0) || (child_pid != process_child.getPpid()) ) {            
@@ -198,7 +198,7 @@ class FlowTRangeAfterUpdateHandlers {
                                //   if(likely(process_list->current_hash_data[trace_num][cpu] != NULL) ){
                            //        hashed_process_data = process_list->current_hash_data[trace_num][cpu];
                            //   }
-                               TimeRangeEventProcess localProcess = procContainer.findProcess(process.getPid(), process.getCpu(), traceSt.getTraceId(),  process.getCreation_time().getValue());
+                               TimeRangeEventProcess localProcess = procContainer.findProcess(process.getPid(), process.getCpu(), traceSt.getTraceId(),  process.getCreation_time());
                                
                                if ( localProcess == null ) {
                                    if ( (process.getPid() == 0) || (process.getPid() != process.getPpid()) ) {                                 
@@ -246,7 +246,7 @@ class FlowTRangeAfterUpdateHandlers {
 
                 if ( process != null ) {
                     
-                    TimeRangeEventProcess localProcess = procContainer.findProcess(process.getPid(),  process.getCpu(), traceSt.getTraceId(), process.getCreation_time().getValue());
+                    TimeRangeEventProcess localProcess = procContainer.findProcess(process.getPid(),  process.getCpu(), traceSt.getTraceId(), process.getCreation_time());
                     
                     if ( localProcess == null ) {
                         if ( (process.getPid() == 0) || (process.getPid() != process.getPpid()) ) {
@@ -302,7 +302,7 @@ class FlowTRangeAfterUpdateHandlers {
                     //   if(likely(process_list->current_hash_data[trace_num][cpu] != NULL) ){
                     //        hashed_process_data = process_list->current_hash_data[trace_num][cpu];
                     //   }
-                    TimeRangeEventProcess localProcess = procContainer.findProcess(process.getPid(), process.getCpu(), traceSt.getTraceId(), process.getCreation_time().getValue());
+                    TimeRangeEventProcess localProcess = procContainer.findProcess(process.getPid(), process.getCpu(), traceSt.getTraceId(), process.getCreation_time());
                     
                     if ( localProcess == null ) {
                         if ( (process.getPid() == 0) || (process.getPid() != process.getPpid()) ) {                         
@@ -382,7 +382,7 @@ class FlowTRangeAfterUpdateHandlers {
                                LttngProcessState process_in = lttv_state_find_process(traceSt, trcEvent.getCpuId(), pid_in );
                                
                                if ( process_in != null ) {
-                                   TimeRangeEventProcess localProcess = procContainer.findProcess(process_in.getPid(), process_in.getCpu(), traceSt.getTraceId(), process_in.getCreation_time().getValue());
+                                   TimeRangeEventProcess localProcess = procContainer.findProcess(process_in.getPid(), process_in.getCpu(), traceSt.getTraceId(), process_in.getCreation_time());
                            
                                    if (localProcess == null) {
                                            if ( (process_in.getPid() == 0) || (process_in.getPid() != process_in.getPpid()) ) {
index 20362e3f8a2efaa4806196c51ce09de4a901b4d0..cad26eee4e00370e94a7e1afa0d890a6983ab791 100644 (file)
@@ -63,7 +63,7 @@ class FlowTRangeBeforeUpdateHandlers {
                                        // may change
                                        TimeRangeEventProcess localProcess = procContainer
                                                        .findProcess(stateProcess.getPid(), stateProcess.getCpu(), traceId, stateProcess
-                                    .getCreation_time().getValue());
+                                    .getCreation_time());
 
                                        // Add process to process list if not present
                                        if (localProcess == null) {
@@ -146,7 +146,7 @@ class FlowTRangeBeforeUpdateHandlers {
                                                // processlist_get_process_data(process_list,pid_out,process->cpu,&birth,trace_num);
                                                TimeRangeEventProcess localProcess = procContainer
                                                                .findProcess(process.getPid(), process.getCpu(), traceSt
-                                                                               .getTraceId(), process.getCreation_time().getValue());
+                                                                               .getTraceId(), process.getCreation_time());
 
                                                // Add process to process list if not present
                                                // Replace C Call :
@@ -181,7 +181,7 @@ class FlowTRangeBeforeUpdateHandlers {
                                                // tfs->cpu, &birth, trace_num);
                                                TimeRangeEventProcess localProcess = procContainer
                                                                .findProcess(process.getPid(), process.getCpu(), traceSt
-                                                                               .getTraceId(), process.getCreation_time().getValue());
+                                                                               .getTraceId(), process.getCreation_time());
 
                                                // Add process to process list if not present
                                                // Replace C Call :
@@ -255,7 +255,7 @@ class FlowTRangeBeforeUpdateHandlers {
                                        // process->cpu, &birth,trace_num);
                                        TimeRangeEventProcess localProcess = procContainer
                                                        .findProcess(process.getPid(), process.getCpu(), traceSt
-                                                                       .getTraceId(), process.getCreation_time().getValue());
+                                                                       .getTraceId(), process.getCreation_time());
 
                                        // Add process to process list if not present
                                        // Replace C Call :
@@ -324,7 +324,7 @@ class FlowTRangeBeforeUpdateHandlers {
                                                TimeRangeEventProcess localProcess = procContainer
                                                                .findProcess(process.getPid(), process.getCpu(), traceSt
                                                                                .getTraceId(), process
-                                        .getCreation_time().getValue());
+                                        .getCreation_time());
 
                                                // This is as it was in the C ... ?
                                                if (localProcess == null) {
@@ -395,7 +395,7 @@ class FlowTRangeBeforeUpdateHandlers {
                                        TimeRangeEventProcess localProcess = procContainer
                                                        .findProcess(process.getPid(), process.getCpu(), traceSt
                                                                        .getTraceId(), process
-                                    .getCreation_time().getValue());
+                                    .getCreation_time());
 
                                        // Add process to process list if not present
                                        if (localProcess == null) {
index 64be7332b42517ab07f21ca43c34fa992b5ead83..65e0f369a0e5a99072074e2db9cc00e03d9d01b0 100644 (file)
@@ -73,6 +73,7 @@ public class FlowProcessContainer {
      * @return TimeRangeEventProcess[]
      */
        public TimeRangeEventProcess[] readProcesses() {
+               
            // This allow us to return an Array of the correct type of the exact correct dimension, without looping
                return allProcesses.values().toArray(new TimeRangeEventProcess[allProcesses.size()]);
        }
@@ -138,9 +139,9 @@ public class FlowProcessContainer {
      * @return TimeRangeEventProcess
      */
     public TimeRangeEventProcess findProcess(Long searchedPid, Long searchedCpuId, String searchedTraceID, Long searchedCreationtime) {
-        // Get the TimeRangeEventProcess associated to a key we create here
+       // Get the TimeRangeEventProcess associated to a key we create here
         TimeRangeEventProcess foundProcess = allProcesses.get( new ProcessKey(searchedPid, searchedCpuId, searchedTraceID, searchedCreationtime) );
-        
+        
         return foundProcess;
     }
 }
@@ -251,6 +252,6 @@ class ProcessKey {
             return (valueRef.getPid().toString() + ":" + valueRef.getCpu().toString() + ":" + valueRef.getTraceID().toString() + ":" + valueRef.getCreationTime().toString());
         } 
         
-        return (pid + ":" + cpuId + ":" + traceId + ":" + creationtime);
+        return (pid.toString() + ":" + cpuId.toString() + ":" + traceId.toString() + ":" + creationtime.toString());
     }
 }
index 41c21d57af2c43e026875b7605c9ea5ac37e0667..ae90331ad8c8d9dd270ba62b4f00b8c2ad2d8d42 100644 (file)
@@ -12,6 +12,8 @@
 
 package org.eclipse.linuxtools.lttng.ui.views.events;
 
+import org.eclipse.linuxtools.lttng.event.LttngEvent;
+import org.eclipse.linuxtools.lttng.event.LttngEventContent;
 import org.eclipse.linuxtools.tmf.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.ui.views.TmfEventsView;
 import org.eclipse.swt.SWT;
@@ -106,13 +108,15 @@ public class EventsView extends TmfEventsView {
     @Override
        protected String[] extractItemFields(TmfEvent event) {
         String[] fields = new String[0];
+        
         if (event != null) {
             fields = new String[] {
                     event.getTimestamp().toString(),
                     event.getSource().toString(),
                     event.getType().toString(),
                     event.getReference().toString(),
-                    event.getContent().getContent() };
+                    ((LttngEventContent)event.getContent()).toString() 
+                };
         }
         return fields;
     }
index 58098e8381406d1438a0836fbb2b221799066aa4..14b67caa0f7906f3bf9420cc0eab86033f9554d2 100644 (file)
@@ -30,26 +30,26 @@ import org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing;
  * 
  */
 public class ResourcesTRangeUpdateFactory extends AbsEventProcessorFactory {
-    // ========================================================================
-    // Data
-    // =======================================================================
-    private final Map<String, IEventProcessing> eventNametoBeforeProcessor = new HashMap<String, IEventProcessing>();
-    private final Map<String, IEventProcessing> eventNametoAfterProcessor = new HashMap<String, IEventProcessing>();
+       // ========================================================================
+       // Data
+       // =======================================================================
+       private final Map<String, IEventProcessing> eventNametoBeforeProcessor = new HashMap<String, IEventProcessing>();
+       private final Map<String, IEventProcessing> eventNametoAfterProcessor = new HashMap<String, IEventProcessing>();
        private ResourcesTRangeFinishUpdateHandler finishProcessor = null;
-    private static ResourcesTRangeUpdateFactory instance = null;
-    private ResourcesTRangeBeforeUpdateHandlers instantiateBeforeHandler = new ResourcesTRangeBeforeUpdateHandlers();
-    private ResourcesTRangeAfterUpdateHandlers instantiateAfterHandler = new ResourcesTRangeAfterUpdateHandlers();
-    
-    
+       private static ResourcesTRangeUpdateFactory instance = null;
+       private ResourcesTRangeBeforeUpdateHandlers instantiateBeforeHandler = new ResourcesTRangeBeforeUpdateHandlers();
+       private ResourcesTRangeAfterUpdateHandlers instantiateAfterHandler = new ResourcesTRangeAfterUpdateHandlers();
+
        private ResourcesTRangeUpdateFactory() {
-        // Create one instance of each individual event handler and add the instance to the map
+               // Create one instance of each individual event handler and add the
+               // instance to the map
 
-        // *** BEFORE HOOKS ***
+               // *** BEFORE HOOKS ***
                eventNametoBeforeProcessor.put(
                                StateStrings.Events.LTT_EVENT_SCHED_SCHEDULE.getInName(),
                                instantiateBeforeHandler.getBeforeSchedChangeHandler());
-        
-        eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_TRAP_ENTRY
+
+               eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_TRAP_ENTRY
                                .getInName(), instantiateBeforeHandler
                                .getBeforeExecutionModeTrap());
                eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_TRAP_EXIT
@@ -69,15 +69,15 @@ public class ResourcesTRangeUpdateFactory extends AbsEventProcessorFactory {
                                .put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_NOSEM_EXIT
                                                .getInName(), instantiateBeforeHandler
                                                .getBeforeExecutionModeTrap());
-        
-        eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_IRQ_ENTRY
+
+               eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_IRQ_ENTRY
                                .getInName(), instantiateBeforeHandler
                                .getBeforeExecutionModeIrq());
                eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_IRQ_EXIT
                                .getInName(), instantiateBeforeHandler
                                .getBeforeExecutionModeIrq());
-        
-        eventNametoBeforeProcessor.put(
+
+               eventNametoBeforeProcessor.put(
                                StateStrings.Events.LTT_EVENT_SOFT_IRQ_RAISE.getInName(),
                                instantiateBeforeHandler.getBeforeExecutionModeSoftIrq());
                eventNametoBeforeProcessor.put(
@@ -86,44 +86,41 @@ public class ResourcesTRangeUpdateFactory extends AbsEventProcessorFactory {
                eventNametoBeforeProcessor.put(
                                StateStrings.Events.LTT_EVENT_SOFT_IRQ_EXIT.getInName(),
                                instantiateBeforeHandler.getBeforeExecutionModeSoftIrq());
-        
-        eventNametoBeforeProcessor.put(
+
+               eventNametoBeforeProcessor.put(
                                StateStrings.Events.LTT_EVENT_REQUEST_ISSUE.getInName(),
                                instantiateBeforeHandler.getBeforeBdevEvent());
                eventNametoBeforeProcessor.put(
                                StateStrings.Events.LTT_EVENT_REQUEST_COMPLETE.getInName(),
                                instantiateBeforeHandler.getBeforeBdevEvent());
-        
-        
-        
-        // *** AFTER HOOKS ***
+
+               // *** AFTER HOOKS ***
                eventNametoAfterProcessor.put(
                                StateStrings.Events.LTT_EVENT_SCHED_SCHEDULE.getInName(),
                                instantiateAfterHandler.getAfterSchedChangeHandler());
 
                finishProcessor = new ResourcesTRangeFinishUpdateHandler();
-    }
-    
-    
-    /**
+       }
+
+       /**
      * 
      */
        public static AbsEventProcessorFactory getInstance() {
-        if (instance == null) {
+               if (instance == null) {
                        instance = new ResourcesTRangeUpdateFactory();
-        }
-        return instance;
-    }
-    
-    @Override
-    public IEventProcessing getAfterProcessor(String eventType) {
-        return eventNametoAfterProcessor.get(eventType);
-    }
+               }
+               return instance;
+       }
+
+       @Override
+       public IEventProcessing getAfterProcessor(String eventType) {
+               return eventNametoAfterProcessor.get(eventType);
+       }
 
-    @Override
-    public IEventProcessing getBeforeProcessor(String eventType) {
-        return eventNametoBeforeProcessor.get(eventType);
-    }
+       @Override
+       public IEventProcessing getBeforeProcessor(String eventType) {
+               return eventNametoBeforeProcessor.get(eventType);
+       }
 
        @Override
        public IEventProcessing getfinishProcessor() {
index 23082c920759c5b02ee2b59393195a894db99012..2f9545d1ab222b86007d96f60a78866f33a36b94 100644 (file)
@@ -177,7 +177,7 @@ class ResourceKey {
                else {
                        if ( (  ((ResourceKey)obj).getResourceId().equals(this.resourceId)) &&
                         (  ((ResourceKey)obj).getTraceId().equals(this.traceId)) &&
-                        (  ((ResourceKey)obj).getType().equals(this.traceId)) )
+                        (  ((ResourceKey)obj).getType().equals(this.type)) )
                    {
                        isSame = true;
                    }
index 613cef33483502bcb0b3d50d3c0984529dec54e7..57c99b906b0721af99a3bd5c8beabef0abb67c47 100644 (file)
@@ -152,7 +152,7 @@ abstract class AbstractStatsEventHandler implements IEventProcessing {
                if (process.getState().getProc_status().equals(ProcessStatus.LTTV_STATE_RUN) &&
                                !process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
                        node.getValue().cpuTime += event.getTimestamp().getValue()
-                               - process.getState().getChange_LttTime().getValue();
+                               - process.getState().getChange_LttTime();
                }
        }
        
@@ -168,7 +168,7 @@ abstract class AbstractStatsEventHandler implements IEventProcessing {
                
                if (!process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
                        node.getValue().elapsedTime += event.getTimestamp().getValue()
-                               - process.getState().getEntry_LttTime().getValue();
+                               - process.getState().getEntry_LttTime();
                }
        }
        
@@ -184,14 +184,14 @@ abstract class AbstractStatsEventHandler implements IEventProcessing {
                
                if (!process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
                        long cumulativeCpuTime = process.getState().getCum_cpu_time();
-                       long delta = event.getTimestamp().getValue() - process.getState().getEntry_LttTime().getValue();
+                       long delta = event.getTimestamp().getValue() - process.getState().getEntry_LttTime();
                        process.getState().setCum_cpu_time(cumulativeCpuTime + delta);
                        node.getValue().cumulativeCpuTime += process.getState().getCum_cpu_time();
                }
                else if (process.getState().getProc_status().equals(ProcessStatus.LTTV_STATE_RUN) &&
                                !process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
                        long cumulativeCpuTime = process.getState().getCum_cpu_time();
-                       long delta = event.getTimestamp().getValue() - process.getState().getChange_LttTime().getValue();
+                       long delta = event.getTimestamp().getValue() - process.getState().getChange_LttTime();
                        process.getState().setCum_cpu_time(cumulativeCpuTime + delta);
                        node.getValue().cumulativeCpuTime += process.getState().getCum_cpu_time();
                }
@@ -209,7 +209,7 @@ abstract class AbstractStatsEventHandler implements IEventProcessing {
                if (process.getState().getProc_status().equals(ProcessStatus.LTTV_STATE_RUN) &&
                                !process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
                        long cumulativeCpuTime = process.getState().getCum_cpu_time();
-                       long delta = event.getTimestamp().getValue() - process.getState().getChange_LttTime().getValue();
+                       long delta = event.getTimestamp().getValue() - process.getState().getChange_LttTime();
                        process.getState().setCum_cpu_time(cumulativeCpuTime + delta);
                }
        }
index 2b278095cd56e780058d84bf932048076247c9ff..6902bbdc128915aba2e99b846c6a1b4a41840723 100644 (file)
 
 package org.eclipse.linuxtools.lttng.stubs;
 
-import java.io.EOFException;
 import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.util.Vector;
 
 import org.eclipse.linuxtools.tmf.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.event.TmfEventContent;
-import org.eclipse.linuxtools.tmf.event.TmfEventFormat;
-import org.eclipse.linuxtools.tmf.event.TmfEventReference;
-import org.eclipse.linuxtools.tmf.event.TmfEventSource;
-import org.eclipse.linuxtools.tmf.event.TmfEventType;
 import org.eclipse.linuxtools.tmf.trace.ITmfEventParser;
 import org.eclipse.linuxtools.tmf.trace.ITmfTrace;
 import org.eclipse.linuxtools.tmf.trace.TmfTraceContext;
@@ -34,108 +26,114 @@ import org.eclipse.linuxtools.tmf.trace.TmfTraceContext;
  */
 public class LTTngEventParserStub implements ITmfEventParser {
 
-    // ========================================================================
-    // Attributes
-    // ========================================================================
-
-       private final int NB_FORMATS = 10;
-    private final TmfEventFormat[] fFormats;
-
-    // ========================================================================
-    // Constructors
-    // ========================================================================
-
-    public LTTngEventParserStub() {
-       fFormats = new TmfEventFormat[NB_FORMATS];
-       for (int i = 0; i < NB_FORMATS; i++) {
-               Vector<String> format = new Vector<String>();
-               for (int j = 1; j <= i; j++) {
-                       format.add(new String("Fmt-" + i + "-Fld-" + j));
-               }
-               String[] fields = new String[i];
-               fFormats[i] = new TmfEventFormat(format.toArray(fields));
-       }
-    }
-
-    // ========================================================================
-    // Accessors
-    // ========================================================================
-
-    // ========================================================================
-    // Operators
-    // ========================================================================
-
-    /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventParser#parseNextEvent()
-     */
-    static final String typePrefix = "Type-";
-    public TmfEvent parseNextEvent(ITmfTrace eventStream, TmfTraceContext context) throws IOException {
-
-        if (! (eventStream instanceof LTTngTraceStub)) {
-            return null;
-        }
-
-               // Highly inefficient...
-               RandomAccessFile stream = ((LTTngTraceStub) eventStream).getStream();
-               String name = eventStream.getName();
-               name = name.substring(name.lastIndexOf('/') + 1);
-
-               synchronized(stream) {
-               long location = 0;
-               if (context != null)
-                       location = (Long) (context.getLocation());
-               stream.seek(location);
-
-               try {
-                       // Read the individual fields
-                       long ts       = stream.readLong();
-                       String source = stream.readUTF();
-                       String type   = stream.readUTF();
-                       @SuppressWarnings("unused")
-                       int reference = stream.readInt();
-
-                       // Read the event parts
-                       int typeIndex  = Integer.parseInt(type.substring(typePrefix.length()));
-                       String[] fields = new String[typeIndex];
-                       for (int i = 0; i < typeIndex; i++) {
-                               fields[i] = stream.readUTF();
-                       }
-
-                       // Format the content from the individual fields
-                       String content = "[";
-                       if (typeIndex > 0) {
-                               content += fields[0];
-                       }
-                       for (int i = 1; i < typeIndex; i++) {
-                               content += ", " + fields[i];
-                       }
-                       content += "]";
-
-                       // Update the context
-                       context.setLocation(stream.getFilePointer());
-                       context.incrIndex();
-                               try {
-                                       long ts2 = stream.readLong();
-                               context.setTimestamp(new LTTngTimestampStub(ts2));
-                       } catch (EOFException e) {
-                               context.setTimestamp(null);
-               }
-
-                       // Create the event
-                               TmfEvent event = new TmfEvent(
-                                               new LTTngTimestampStub(ts),
-                                               new TmfEventSource(source),
-                                               new TmfEventType(type, fFormats[typeIndex]),
-                                               new TmfEventContent(content, fFormats[typeIndex]),
-                                               new TmfEventReference(name));
-
-                               return event;
-
-               } catch (EOFException e) {
-                       context.setTimestamp(null);
-               }
-        }
-        return null;
-    }
+       public TmfEvent parseNextEvent(ITmfTrace stream, TmfTraceContext context)
+                       throws IOException {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+//    // ========================================================================
+//    // Attributes
+//    // ========================================================================
+//
+//     private final int NB_FORMATS = 10;
+//    private final TmfEventFormat[] fFormats;
+//
+//    // ========================================================================
+//    // Constructors
+//    // ========================================================================
+//
+//    public LTTngEventParserStub() {
+//     fFormats = new TmfEventFormat[NB_FORMATS];
+//     for (int i = 0; i < NB_FORMATS; i++) {
+//             Vector<String> format = new Vector<String>();
+//             for (int j = 1; j <= i; j++) {
+//                     format.add(new String("Fmt-" + i + "-Fld-" + j));
+//             }
+//             String[] fields = new String[i];
+//             fFormats[i] = new TmfEventFormat(format.toArray(fields));
+//     }
+//    }
+//
+//    // ========================================================================
+//    // Accessors
+//    // ========================================================================
+//
+//    // ========================================================================
+//    // Operators
+//    // ========================================================================
+//
+//    /* (non-Javadoc)
+//     * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventParser#parseNextEvent()
+//     */
+//    static final String typePrefix = "Type-";
+//    public TmfEvent parseNextEvent(ITmfTrace eventStream, TmfTraceContext context) throws IOException {
+//
+//        if (! (eventStream instanceof LTTngTraceStub)) {
+//            return null;
+//        }
+//
+//             // Highly inefficient...
+//             RandomAccessFile stream = ((LTTngTraceStub) eventStream).getStream();
+//             String name = eventStream.getName();
+//             name = name.substring(name.lastIndexOf('/') + 1);
+//
+//             synchronized(stream) {
+//             long location = 0;
+//             if (context != null)
+//                     location = (Long) (context.getLocation());
+//             stream.seek(location);
+//
+//             try {
+//                     // Read the individual fields
+//                     long ts       = stream.readLong();
+//                     String source = stream.readUTF();
+//                     String type   = stream.readUTF();
+//                     @SuppressWarnings("unused")
+//                     int reference = stream.readInt();
+//
+//                     // Read the event parts
+//                     int typeIndex  = Integer.parseInt(type.substring(typePrefix.length()));
+//                     String[] fields = new String[typeIndex];
+//                     for (int i = 0; i < typeIndex; i++) {
+//                             fields[i] = stream.readUTF();
+//                     }
+//
+//                     // Format the content from the individual fields
+//                     String content = "[";
+//                     if (typeIndex > 0) {
+//                             content += fields[0];
+//                     }
+//                     for (int i = 1; i < typeIndex; i++) {
+//                             content += ", " + fields[i];
+//                     }
+//                     content += "]";
+//
+//                     // Update the context
+//                     context.setLocation(stream.getFilePointer());
+//                     context.incrIndex();
+//                             try {
+//                                     long ts2 = stream.readLong();
+//                             context.setTimestamp(new LTTngTimestampStub(ts2));
+//                     } catch (EOFException e) {
+//                             context.setTimestamp(null);
+//             }
+//
+//                     // Create the event
+//                             TmfEvent event = new TmfEvent(
+//                                             new LTTngTimestampStub(ts),
+//                                             new TmfEventSource(source),
+//                                             new TmfEventType(type, fFormats[typeIndex]),
+//                                             new TmfEventContent(content, fFormats[typeIndex]),
+//                                             new TmfEventReference(name));
+//
+//                             return event;
+//
+//             } catch (EOFException e) {
+//                     context.setTimestamp(null);
+//             }
+//        }
+//        return null;
+//    }
 
 }
index a315c635e802fbc2f3e25a7d08f395f5a8247b07..a0f0d4ad4dc20f0da1407c35fb64d09a50aba661 100644 (file)
@@ -3,8 +3,8 @@ package org.eclipse.linuxtools.lttng.event;
 import org.eclipse.linuxtools.tmf.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.event.TmfEventSource;
 import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
-import org.eclipse.linuxtools.lttng.jni.JniEvent;
 import org.eclipse.linuxtools.lttng.LttngException;
+import org.eclipse.linuxtools.lttng.jni.JniEvent;
 
 /**
  * <b><u>LttngEvent</u></b><p>
@@ -17,9 +17,9 @@ import org.eclipse.linuxtools.lttng.LttngException;
 @SuppressWarnings("unused")
 public class LttngEvent extends TmfEvent {
     
-    // Reference to the JNI JniEvent. Should only used INTERNALLY
+    // Reference to the JNI JniEvent. Should only be used INTERNALLY
     private JniEvent jniEventReference = null;
-    
+
     /**
      * Constructor with parameters.<p>
      * 
@@ -35,16 +35,12 @@ public class LttngEvent extends TmfEvent {
      * @see org.eclipse.linuxtools.lttng.event.LttngEventType
      * @see org.eclipse.linuxtools.lttng.event.LttngEventContent
      * @see org.eclipse.linuxtools.lttng.event.LttngEventReference
-     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+     * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent
      */
-    public LttngEvent(LttngTimestamp timestamp, TmfEventSource source, LttngEventType type, LttngEventContent content, LttngEventReference reference, JniEvent lttEvent) throws LttngException { 
-        super(timestamp, source, type, content, reference);
-        
-        // Sanity checks
-        if ( (timestamp == null) || (source == null) || (type == null) || (content == null) || (reference == null) || (lttEvent == null) ) {
-               throw new LttngException("Event creation with null values is forbidden!");
-        }
+    public LttngEvent(LttngTimestamp timestamp, TmfEventSource source, LttngEventType type, LttngEventContent content, LttngEventReference reference, JniEvent lttEvent) { 
+        super(timestamp, source, type, reference);
         
+        fContent = content;
         jniEventReference = lttEvent;
     }
     
@@ -54,7 +50,7 @@ public class LttngEvent extends TmfEvent {
      * @param oldEvent         Event we want to copy from.
      * 
      */
-    public LttngEvent(LttngEvent oldEvent) throws LttngException 
+    public LttngEvent(LttngEvent oldEvent) { 
         this(  (LttngTimestamp)oldEvent.getTimestamp(), 
                        (TmfEventSource)oldEvent.getSource(), 
                        (LttngEventType)oldEvent.getType(), 
@@ -68,48 +64,62 @@ public class LttngEvent extends TmfEvent {
     /**
      * Return the channel name of this event.<p>
      * 
-     * @return The name of the channel for this event
+     * @return Channel (tracefile) for this event
      */
     public String getChannelName() {
-        String returnedValue = "";
+        String returnedChannel = "";
         
-        // This should always be true
-        if ( this.getType() instanceof LttngEventType ) {
-            returnedValue = ( (LttngEventType)this.getType() ).getChannelName();
-        }
-        return returnedValue;
+        return ( (LttngEventType)this.getType() ).getTracefileName();
     }
     
     /**
      * Cpu id number of this event.<p>
      * 
-     * @return The cpu id
+     * @return Cpu id
      */
     public long getCpuId() {
-        long returnedValue =-1;
-        
-        // This should always be true
-        if ( this.getType() instanceof LttngEventType ) {
-            returnedValue = ( (LttngEventType)this.getType() ).getCpuId();
-        }
-        return returnedValue;
+        return ( (LttngEventType)this.getType() ).getCpuId();
     }
     
     /**
      * Marker name of this event.<p>
      * 
-     * @return The marker name
+     * @return Marker name
      */
     public String getMarkerName() {
         String returnedValue = "";
         
-        // This should always be true
-        if ( this.getType() instanceof LttngEventType ) {
-            returnedValue = ( (LttngEventType)this.getType() ).getMarkerName();
-        }
-        return returnedValue;
+        return ( (LttngEventType)this.getType() ).getMarkerName();
     }
     
+    
+    public JniEvent getJniEventReference() {
+        return jniEventReference;
+    }
+    
+    public void setJniEventReference(JniEvent newJniEventReference) {
+        this.jniEventReference = newJniEventReference;
+    }
+    
+    @Override
+    public LttngEventContent getContent() {
+        return (LttngEventContent)fContent;
+    }
+    
+    public void setContent(LttngEventContent newContent) {
+        fContent = newContent;
+    }
+    
+    @Override
+    public LttngEventType getType() {
+        return (LttngEventType)fType;
+    }
+    
+    public void setType(LttngEventType newType) {
+        fType = newType;
+    }
+    
+    
     /**
      * Convert this event into a Jni JniEvent.<p>
      * 
@@ -118,16 +128,22 @@ public class LttngEvent extends TmfEvent {
      * 
      * @return The converted JniEvent
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+     * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent
      */
     public JniEvent convertEventTmfToJni() {
         JniEvent tmpEvent = null;
         
+        // ***TODO***
+        // Should we remove the check to save some time??
+        
         // We don't want to send away events that are outdated as their informations could be invalid
         //  If the timestamp between the event and the trace are not coherent we will not perform the conversion
         if ( jniEventReference.getParentTracefile().getParentTrace().getCurrentEventTimestamp().getTime() == getTimestamp().getValue() ) {
             tmpEvent = jniEventReference;
         }
+        else {
+            System.out.println("WRONG TIMESTAMP : " + getTimestamp().getValue() + " vs " + jniEventReference.getParentTracefile().getParentTrace().getCurrentEventTimestamp().getTime());
+        }
         return tmpEvent;
     }
     
index a614cdd3e660bbc7041c3a747d609a5484340ee9..082dc5b6fcd370302ce7bcee46420cdd48815b8e 100644 (file)
@@ -12,8 +12,9 @@
 
 package org.eclipse.linuxtools.lttng.event;
 
+import java.util.HashMap;
+
 import org.eclipse.linuxtools.tmf.event.TmfEventContent;
-import org.eclipse.linuxtools.tmf.event.TmfEventField;
 
 /**
  * <b><u>LttngEventContent</u></b><p>
@@ -22,27 +23,41 @@ import org.eclipse.linuxtools.tmf.event.TmfEventField;
  */
 public class LttngEventContent extends TmfEventContent {
     
+    // Hash map that contain the (parsed) fields. This is the actual payload of the event.
+    HashMap<String, LttngEventField> fFieldsMap = new HashMap<String, LttngEventField>();
+    
     /**
-     * Constructor with parameters.<p>
+     * Default constructor.<p>
      * 
-     * Content will be empty as no parsed content is given.
      * 
-     * @param thisFormat    The LttngEventFormat relative to the JniEvent
      */
-    public LttngEventContent(LttngEventFormat thisFormat) {
-        super("", thisFormat);
+    public LttngEventContent() {
+        super(null, null);
     }
-
+    
     /**
      * Constructor with parameters.<p>
      * 
-     * @param thisFormat        The LttngEventFormat relative to this JniEvent
-     * @param thisParsedContent The string content of the JniEvent, already parsed
+     * @param thisParent    Parent event for this content.
+     * 
+     * @see org.eclipse.linuxtools.lttng.event.LttngEvent
+     */
+    public LttngEventContent(LttngEvent thisParent) {
+        super(thisParent, null);
+    }
+    
+    /**
+     * Constructor with parameters, with optional content.<p>
+     * 
+     * @param thisParent    Parent event for this content.
+     * @param thisContent   Already parsed content.
+     * 
+     * @see org.eclipse.linuxtools.lttng.event.LttngEvent
      */
-    public LttngEventContent(LttngEventFormat thisFormat, String thisParsedContent, TmfEventField[] thisFields)  {
-        super(thisParsedContent, thisFormat);
+    public LttngEventContent(LttngEvent thisParent, HashMap<String, LttngEventField> thisContent) {
+        super(thisParent, null);
         
-        setFields(thisFields);
+        fFieldsMap = thisContent;
     }
     
     /**
@@ -51,117 +66,177 @@ public class LttngEventContent extends TmfEventContent {
      * @param oldContent  Content to copy from
      */
     public LttngEventContent(LttngEventContent oldContent) {
-        this( (LttngEventFormat)oldContent.getFormat(), oldContent.getContent(), oldContent.getFields() );
+        this((LttngEvent)oldContent.getEvent(), oldContent.getRawContent() );
+    }
+    
+    
+    public LttngEvent getEvent() {
+        return (LttngEvent)fParentEvent;
+    }
+    
+    public void setEvent(LttngEvent newParent) {
+        fParentEvent = newParent;
+    }
+    
+    
+    // *** VERIFY ***
+    // These are not very useful, are they?
+    public LttngEventType getType() {
+        return (LttngEventType)fParentEvent.getType();
+//        return (LttngEventType)fEventType;
+    }
+    public void setType(LttngEventType newType) {
+        ((LttngEvent)fParentEvent).setType(newType);
+//        fEventType = newType;
     }
     
+    
+    // ***TODO***
+    // Find a better way to ensure content is sane!!
+    public void emptyContent() {
+        fFieldsMap.clear();
+    }
+    
+    // ***VERIFY***
+    // A bit weird to return the _currently_parsed fields (unlike all like getFields() )
+    // Should we keep this?
     /**
-     * <b>*DEPRECATED*</b><br>Get all fields of the content.<p>
-     * 
-     * <b><u>DO NOT USE!</b></u> <br>
-     * This function will disapears soon! Use getFields(LttngEvent) instead.<p>
+     * Return currently parsed fields in an object array format.<p>
      * 
-     * If the content was not parsed, format.parse() will get called.<p>
-     * 
-     * @return An array of TmfEventFields
+     * @return  Currently parsed fields.
      */
     @Override
-    public TmfEventField[] getFields() {
-       
-       // Request the field variable from the inherited class
-        TmfEventField[] fields = super.getFields();
+    public Object[] getContent() {
+        Object[] returnedContent = fFieldsMap.values().toArray( new Object[fFieldsMap.size()] );
         
-        // Field may be null if the content hasn't been parse yet
-        // If that's the case, call the parsing function
-        if (fields == null) {
-            fields = ((LttngEventFormat) this.getFormat()).parse(this.getContent());
-            setFields(fields);
-        }
-        return fields;
+        return returnedContent;
     }
-
+    
     /**
-     * <b>*DEPRECATED*</b><br>Get a single field of the content, from its id (position).<p>
+     * Return currently parsed fields in the internal hashmap format.<p>
      * 
-     * <b><u>DO NOT USE!</b></u> <br>
-     * This function will disapears soon! Use getFields(LttngEvent) instead.<p>
+     * @return  Currently parsed fields.
+     */
+    public HashMap<String, LttngEventField> getRawContent() {
+        return fFieldsMap;
+    }
+    
+//    @SuppressWarnings("unchecked")
+//    @Override
+//    public LttngEventField[] getFields() {
+//        LttngEventField tmpField = null;
+//        
+//        // *** TODO ***
+//        // SLOW! SLOW! SLOW! We should prevent the user to use this!!
+//        HashMap<String, Object> parsedContent = parseContent();
+//        
+//        String contentKey = null;
+//        Iterator<String> contentItr = parsedContent.keySet().iterator();
+//        while ( contentItr.hasNext() ) {
+//            contentKey = contentItr.next();
+//            
+//            tmpField = new LttngEventField(this, contentKey, parsedContent.get(contentKey));
+//            ((HashMap<String, LttngEventField>)fFields).put(contentKey, tmpField);
+//        }
+//        
+//        return fFields.values().toArray(new LttngEventField[fFields.size()]);
+//    }
+    
+    /**
+     * Parse all fields and return them as an array of LttngFields.<p>
      * 
-     * If the content was not parsed, format.parse() will get called.<p>
+     * Note : This function is heavy and should only be called if all fields are really needed.
      * 
-     * @param id    The id of the field we want to obtain.
+     * @return  All fields.
      * 
-     * @return A single LttngEventField
+     * @see @see org.eclipse.linuxtools.lttng.event.LttngEventField
      */
     @Override
-    public LttngEventField getField(int id) {
-        LttngEventField returnedField = null;
+    public LttngEventField[] getFields() {
+        LttngEventField tmpField = null;
         
-        if ( (id >= 0) && (id < this.getNbFields()) )
-        {
-            // Call getFields() of this object. Will parse if fields were'nt parse before.
-            TmfEventField[] allFields = this.getFields();
+        LttngEventType tmpType = (LttngEventType)fParentEvent.getType();
+        
+        for ( int pos=0; pos<tmpType.getNbFields(); pos++ ) {
+            String name = tmpType.getLabel(pos);
+            Object newValue = ((LttngEvent)getEvent()).convertEventTmfToJni().parseFieldByName(name);
             
-            if ( allFields != null ) {
-               returnedField = (LttngEventField)allFields[id];
-            }
+            tmpField = new LttngEventField(this, name, newValue );
+            fFieldsMap.put(name, tmpField);
         }
-        return returnedField;
+        return fFieldsMap.values().toArray(new LttngEventField[fFieldsMap.size()]);
     }
     
     /**
-     * Get all fields of the content.<p>
-     * 
-     * If the content was not parsed, format.parse(LttngEvent) will get called.<p>
+     * Parse a single field from its given position.<p>
      * 
-     * @param thisEvent     The event to get the fields from
+     * @return  The parsed field or null.
      * 
-     * @return An array of TmfEventFields
+     * @see @see org.eclipse.linuxtools.lttng.event.LttngEventField
      */
-    public TmfEventField[] getFields(LttngEvent thisEvent) {
-       
-       // Request the field variable from the inherited class
-       TmfEventField[] fields = super.getFields();
+    @Override
+    public LttngEventField getField(int position) {
+        LttngEventField returnedField = null;
+        String label = fParentEvent.getType().getLabel(position);
         
-        // Field may be null if the content hasn't been parse yet
-        // If that's the case, call the parsing function
-        if (fields == null) {
-            fields = ((LttngEventFormat)this.getFormat()).parse(thisEvent);
-            setFields(fields);
+        if ( label != null ) {
+            returnedField = this.getField(label);
         }
-        return fields;
+        
+        return returnedField;
     }
     
     /**
-     * Get a single field of the content, from its id (position).<p>
-     * 
-     * If the content was not parsed, format.parse(LttngEvent) will get called.<p>
+     * Parse a single field from its given name.<p>
      * 
-     * @param thisEvent     The event to get the fields from
-     * @param id    The id of the field we want to obtain.
+     * @return  The parsed field or null.
      * 
-     * @return A single LttngEventField
+     * @see @see org.eclipse.linuxtools.lttng.event.LttngEventField
      */
-    public LttngEventField getField(int id, LttngEvent thisEvent) {
-        LttngEventField returnedField = null;
+    @Override
+    public LttngEventField getField(String name) {
+        // *** VERIFY ***
+        // Should we check if the field exists in LttngType before parsing? 
+        // It could avoid calling parse for non-existent fields but would waste some cpu cycle on check?
+        LttngEventField returnedField = fFieldsMap.get(name);
         
-        if ( (id >= 0) && (id < this.getNbFields()) ) {
-            // Call getFields() of this object. Will parse if fields were'nt parse before.
-            TmfEventField[] allFields = this.getFields(thisEvent);
+        if ( returnedField == null ) {
+            // *** VERIFY ***
+            // Should we really make sure we didn't get null before creating/inserting a field?
+            Object newValue = ((LttngEvent)getEvent()).convertEventTmfToJni().parseFieldByName(name);
             
-            if ( allFields != null ) {
-               returnedField = (LttngEventField)allFields[id];
+            if ( newValue!= null ) {
+                returnedField = new LttngEventField(this, name, newValue);
+                fFieldsMap.put(name, returnedField );
             }
         }
+        
         return returnedField;
     }
     
-
+    // *** VERIFY ***
+    // *** Is this even useful?
+    @Override
+    protected void parseContent() {
+        fFields = getFields();
+    }
+    
     /**
-     * toString() method.
+     * toString() method to print the content
      * 
-     * @return Attributes of the object concatenated in String
+     * Note : this function parse all fields and so is very heavy to use.
      */
     @Override
-       public String toString() {
-        return getContent().toString();
+    public String toString() {
+        String returnedString = "";
+        
+        LttngEventField[] allFields = getFields();
+        
+        for ( int pos=0; pos < allFields.length; pos++) {
+            returnedString +=  allFields[pos].toString() + " ";
+        }
+        
+        return returnedString;
+        
     }
 }
\ No newline at end of file
index 7f28dc8be5a0a66246054456061429c3aef46620..31b15bb2e002d1d6ef051a2e5eefbb863bd1f218 100644 (file)
@@ -12,6 +12,7 @@
 
 package org.eclipse.linuxtools.lttng.event;
 
+import org.eclipse.linuxtools.tmf.event.TmfEventContent;
 import org.eclipse.linuxtools.tmf.event.TmfEventField;
 
 /**
@@ -23,20 +24,26 @@ import org.eclipse.linuxtools.tmf.event.TmfEventField;
  * mean the fields will have a name and a value.
  */
 public class LttngEventField extends TmfEventField {
-       private String fieldName = "";
        
+    /**
+     * Constructor with parameters.<p>
+     * 
+     * @param parent   Parent content for this field
+     * @param id       Name (label) of this field
+     */
+    public LttngEventField(TmfEventContent parent, String id) {
+        super(parent, id, null);
+    }
+    
        /**
-        * Constructor with parameters.<p>
+        * Constructor with parameters with optional value.<p>
         * 
-        * @param name       Name of the field
-        * @param newContent ParsedContent we want to populate the field with.
-        * 
-        * @see org.eclipse.linuxtools.lttng.jni.JniParser
+        * @param parent   Parent content for this field
+        * @param id       Name (label) of this field
+        * @param value    Parsed value (payload) of this field
         */
-       public LttngEventField(String name, Object newContent) {
-               super(newContent);
-               
-               fieldName = name;
+       public LttngEventField(TmfEventContent parent, String id, Object value) {
+               super(parent, id, value);
        }
        
        /**
@@ -45,21 +52,12 @@ public class LttngEventField extends TmfEventField {
         * @param oldField     the field to copy from
         */
        public LttngEventField(LttngEventField oldField) {
-               this(oldField.fieldName, oldField.getValue());
+               this(oldField.getParent(), oldField.getId(), oldField.getValue());
        }
        
-       
-       public String getName() {
-               return fieldName;
-       }
-
-       /**
-        * toString() method.<p>
-        * 
-        * Print both field name and value (i.e. NAME:VALUE ).
-        */
        @Override
        public String toString() {
-               return fieldName + ":" + getValue().toString();
+           return getId().toString() + ":" + getValue().toString();
        }
+       
 }
diff --git a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEventFormat.java b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEventFormat.java
deleted file mode 100644 (file)
index baf13c2..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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:
- *   William Bourque (wbourque@gmail.com) - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.event;
-
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.eclipse.linuxtools.tmf.event.TmfEventFormat;
-
-/**
- * <b><u>LttngEventFormat</u></b><p>
- * 
- * Lttng specific implementation of the TmfEventFormat.<p>
- */
-public class LttngEventFormat extends TmfEventFormat {
-
-    /**
-     * Constructor with parameters.<p>
-     * 
-     * @param labels    The fields labels of the content. 
-     */
-    public LttngEventFormat( String[] labels) {
-        super(labels);
-    }
-    
-    /**
-     * Copy constructor.<p>
-     * 
-     * @param oldFormat     The format to copy from
-     */
-    public LttngEventFormat( LttngEventFormat oldFormat ) {
-        this(oldFormat.getLabels());
-    }
-    
-    /**
-     * Parse the given LttngEvent.<p>
-     * 
-     * @param thisEvent   The LttngEvent to parse
-     * 
-     * @return            An array of LttngEventField that contain the parsed data
-     */
-    public LttngEventField[] parse(LttngEvent thisEvent) {
-        // Obtain the parsed content from the JNI
-        HashMap<String, Object> parsedMap = thisEvent.convertEventTmfToJni().parseAllFields();
-        LttngEventField[] returnedField = new LttngEventField[parsedMap.size()];
-        
-        String fieldName = null;
-        int position = 0;
-        Iterator<String> iterator = parsedMap.keySet().iterator();
-        // Loop to create the LttngEventField from the parsedContent
-        while (iterator.hasNext()) {
-            fieldName = iterator.next();
-            returnedField[position] = new LttngEventField( fieldName, parsedMap.get(fieldName) );
-            position++;
-        }
-        
-        return returnedField;
-    }
-    
-    
-    /**
-     * <b>*FIXME*</b><br>Parse from a HashMap of content.<p>
-     * 
-     * This function will hopefully disapears soon!<br>
-     * We need to parse WHILE CREATING LttngEvent, so we cannot always use parse(LttngEvent).<br>
-     * This function is ugly but should be 100% safe to use.<p>
-     * 
-     * @param  parsedEvents     HashMap of parsed content, as returned by JniParser.parseAllFields()
-     * 
-     * @return An array of TmfEventFields
-     */
-    public LttngEventField[] parse(HashMap<String, Object> parsedEvents) {
-        LttngEventField[] returnedField = new LttngEventField[parsedEvents.size()];
-        
-        String fieldName = null;
-        int position = 0;
-        Iterator<String> iterator = parsedEvents.keySet().iterator();
-        // Loop to create the LttngEventField from the parsedContent in the map
-        while (iterator.hasNext()) {
-            fieldName = iterator.next();
-            returnedField[position] = new LttngEventField( fieldName, parsedEvents.get(fieldName) );
-            position++;
-        }
-        return returnedField;
-    }
-    
-    /**
-     * <b>*DEPRECATED*</b><br>Parse from the content string.<p>
-     * 
-     * <b><u>DO NOT USE!</b></u> <br>
-     * This function will disapears soon! Use parse(LttngEvent) instead.<br>
-     * It is evil to parse content string directly as we <u>do not control the content</u>.<br>
-     * So this would theorically works but it could break at any moment if kernel developpers changes their usual format.<p>
-     * 
-     * This is provided because we need to implement this function since we inherit TmfFormat
-     * 
-     * @param  uselessContent    Content to parse as String
-     * 
-     * @return An array of TmfEventFields
-     */
-    public LttngEventField[] parse(String uselessContent) {
-        
-        // This function is _under commented_ because you should not use it
-        //  (this imply you shouldn't read it as well).
-        
-        // *** Begining of the evil "parse String" function
-        // 
-        // - 1st : Find the number of ":" in the String. This will be the number of fields in the String. 
-        //      Highly unreliable, as we depend on String content that we don't control!
-        int nbFields = 0;
-        for ( int pos = 0; pos < uselessContent.length(); pos++ ) {
-            if ( uselessContent.substring(pos, pos+1).equals(":") ) {
-                nbFields++;
-            }
-        }
-        
-        // - 2nd : Create the fields array
-        LttngEventField[] tmpFields = new LttngEventField[nbFields];
-        
-        // - 3rd : Fill the array
-        //      Content is the NAME:VALUE format with space separators
-        //
-        //      We search for 3 possible case : 
-        //          - Field name
-        //          - Value (AKA payload or parsed content)
-        //          - "Out of range" (EOF found)
-        //
-        //
-        int fieldPosition = 0;
-        int lastFieldnamePos = 0;
-        int lastDoubleDottedPos = 0;
-        int lastSpacePos = 0;
-        boolean isSearchingFieldname = true;
-        
-        String  fieldName   = "";
-        String  fieldValue  = "";
-        
-        int pos = 0;
-        while ( (pos < uselessContent.length()) && (fieldPosition<nbFields) )
-        {
-            // : symbol mean we found the end of "NAME" 
-            if ( uselessContent.substring(pos, pos+1).equals(":") ) {
-              
-              if ( isSearchingFieldname==false ) {
-                  fieldValue = uselessContent.substring(lastDoubleDottedPos+1, lastSpacePos);
-                  tmpFields[fieldPosition] = new LttngEventField( fieldName, fieldValue );
-                  fieldPosition++;
-                  isSearchingFieldname = true;
-              }
-              
-              lastDoubleDottedPos = pos;
-            }
-            // space mean we found the end of VALUE
-            else if ( uselessContent.substring(pos, pos+1).equals(" ") ) {
-                
-                if ( isSearchingFieldname==true ) {
-                    fieldName = uselessContent.substring(lastFieldnamePos, lastDoubleDottedPos);
-                    lastFieldnamePos = pos+1;
-                    isSearchingFieldname = false;
-                }
-                
-                lastSpacePos = pos;
-            }
-            // pos+2 > length mean EOF
-            else if ( pos+2 >= uselessContent.length() ) {
-                fieldName = uselessContent.substring(lastSpacePos+1, lastDoubleDottedPos);
-                fieldValue = uselessContent.substring(lastDoubleDottedPos+1, pos+1);
-                
-                tmpFields[fieldPosition] = new LttngEventField( fieldName, fieldValue );
-                fieldPosition++;
-            }
-            
-            pos++;
-        }
-        
-        return tmpFields;
-    }
-    
-}
index 784bc5861caabb96a379eaafe8ba889201d1023a..9ed06528543ea7cbcde4eecfa41d3ec305a7422b 100644 (file)
@@ -26,8 +26,18 @@ public class LttngEventReference extends TmfEventReference {
     /**
      * Constructor with parameters.<p>
      * 
+     * @param newTraceName      Trace name 
+     */
+    public LttngEventReference(String newTraceName) {
+        super("");
+        tracename = newTraceName;
+    }
+    
+    /**
+     * Constructor with parameters with optional tracefile path.<p>
+     * 
      * @param newTracefilePath  Complete tracefile path
-     * @param newTraceName      The Trace name 
+     * @param newTraceName      Trace name 
      */
     public LttngEventReference(String newTracefilePath, String newTraceName) {
         super(newTracefilePath);
@@ -54,10 +64,19 @@ public class LttngEventReference extends TmfEventReference {
         this.tracename = tracename;
     }
     
+    public String getValue() {
+        return (String)fReference;
+    }
+    
+    public void setValue(String newReference) {
+        fReference = newReference;
+    }
+    
     /**
      * toString() method.<p>
      * 
-     * We return only tracename, as it will be used directly in the eventsView and it gives a better output.
+     * We return only tracename, as it will be used directly in the eventsView.
+     *  Returning only tracename gives a better output.
      * 
      * @return tracename as String
      */
diff --git a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEventSource.java b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEventSource.java
new file mode 100644 (file)
index 0000000..3ba4a2c
--- /dev/null
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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:
+ *   William Bourque (wbourque@gmail.com) - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.lttng.event;
+
+import org.eclipse.linuxtools.tmf.event.*;
+
+/**
+ * <b><u>LttngEventSource</u></b><p>
+ * 
+ * Lttng specific implementation of the TmfEventSource
+ */
+public class LttngEventSource extends TmfEventSource {
+    
+    /**
+     * Default Constructor.<p>
+     * 
+     */
+    public LttngEventSource() {
+        super();
+    }
+    
+    /**
+     * Copy Constructor.<p>
+     * 
+     * @param newSource  Source of the event as string.
+     */
+    public LttngEventSource(String newSource) {
+        super(newSource);
+    }
+    
+    
+    /**
+     * Copy Constructor.<p>
+     * 
+     * @param oldSource  LttngEventSource to copy from.
+     */
+    public LttngEventSource(LttngEventSource oldSource) {
+        this( (String)oldSource.getSourceId() );
+    }
+    
+    
+    public String getSourceId() {
+        return (String)fSourceId;
+    }
+    
+    public void setSourceId(String newSource) {
+        fSourceId = newSource;
+    }
+    
+    public String toString() {
+        return fSourceId.toString();
+    }
+}
index 984ad8d3ba6c0bdbb87e0fefa499fbfa57871106..156cd4e8f4bafec03c581933950622c2c71ffe84 100644 (file)
@@ -22,62 +22,66 @@ import org.eclipse.linuxtools.tmf.event.*;
  * This implementation add some attributes to the basic Tmf object.
  */
 public class LttngEventType extends TmfEventType {
-    private String  channelName = "";
-    private long    cpuId = 0;
-    private String  markerName = "";
+    
+    private String tracefileName    = null;
+    private Long   cpuId            = null;
+    private String markerName       = null;
     
     /**
-     * Constructor with parameters.<p>
+     * Default Constructor.<p>
      * 
-     * @param thisChannelName   Channel name. It is the Tracefile name in LTT
-     * @param thisCpuId         CPU id number from LTT
-     * @param thisMarkerName    JniMarker name. It is the marker_info name in LTT
-     * @param thisFormat        The format relative to the event
+     */
+    public LttngEventType() {
+        super();
+    }
+    
+    /**
+     * Constructor with parameters.<p>
      * 
-     * @see org.eclipse.linuxtools.lttng.event.LttngEventFormat
+     * @param thisTracefileName                Tracefile (channel) name in Ltt
+     * @param thisMarkerName           Marker name in LTT
+     * @param thisMarkerfieldsName  MarkerFields related to this marker        
      */
-    public LttngEventType(String thisChannelName, long thisCpuId, String thisMarkerName, LttngEventFormat thisFormat) {
-        super( thisChannelName + "/" + thisCpuId + "/" + thisMarkerName, thisFormat);
+    public LttngEventType(String thisTracefileName, Long thisCpuId, String thisMarkerName, String[] thisMarkerfieldsName) {
+        super( thisTracefileName + "/" + thisCpuId + "/" + thisMarkerName, thisMarkerfieldsName);
         
-        channelName = thisChannelName;
-        cpuId       = thisCpuId;
-        markerName  = thisMarkerName;
+        tracefileName   = thisTracefileName;
+        cpuId           = thisCpuId;
+        markerName      = thisMarkerName;
     }
 
     /**
      * Copy constructor.<p>
      * 
      * @param oldType   Type we want to copy from
-     * 
-     * @see org.eclipse.linuxtools.lttng.event.LttngEventFormat
      */
     public LttngEventType(LttngEventType oldType) {
-        this(oldType.channelName, oldType.cpuId, oldType.markerName, (LttngEventFormat)oldType.getFormat());
+        this(oldType.tracefileName, oldType.cpuId, oldType.markerName, oldType.getLabels());
     }
     
     
-    public String getChannelName() {
-        return channelName;
+    public String getTracefileName() {
+        return tracefileName;
     }
     
-    
-    public long getCpuId() {
+    public Long getCpuId() {
         return cpuId;
     }
     
-    
     public String getMarkerName() {
         return markerName;
     }
     
-    
     /**
      * toString() method.
      * 
-     * @return TypeId (channel/cpu/marker) of the object
+     * @return TypeId (channel/marker) of the object
      */
     @Override
        public String toString() {
-        return getTypeId();
+        // *** TODO ***
+        // This is used as-it in the events view, so we won't change its format.
+        //  ...but maybe we should?
+        return tracefileName + "/" + cpuId.toString() + "/" + markerName;
     }
 }
index 21c2e05e3686f5c3c2ad3d34f011ca5a5bad36f6..df1da9e42a003d3680f72051f329da0724e912bf 100644 (file)
@@ -25,11 +25,19 @@ public class LttngTimestamp extends TmfTimestamp {
     
     // Required by Serializable
        private static final long serialVersionUID = -7016853105162491273L;
-
+       
+    /**
+     * Default Constructor.<p>
+     * 
+     */
+       public LttngTimestamp() {
+           super(Long.MIN_VALUE, (byte) -9);
+       }
+       
        /**
      * Constructor with parameters.<p>
      * 
-     * @param newEventTime    JniTime as long, unit expected to be nanoseconds
+     * @param newEventTime    Time as long, unit expected to be nanoseconds
      */
     public LttngTimestamp(long newEventTime) {
         super(newEventTime, (byte) -9);
@@ -43,7 +51,16 @@ public class LttngTimestamp extends TmfTimestamp {
     public LttngTimestamp(TmfTimestamp oldEventTime) {
         this(oldEventTime.getValue());
     }
-
+    
+    @Override
+    public long getValue() {
+        return fValue;
+    }
+    
+    public void setValue(long newValue) {
+        fValue = newValue;
+    }
+    
        /**
         * Get the second part in timestamp.<p>
         * 
@@ -65,7 +82,7 @@ public class LttngTimestamp extends TmfTimestamp {
        public String getNanoSeconds() {
                return formatNs(fValue);
        }
-
+       
        /*
         * Use the exponent to format the second in the correct format.
         */
@@ -118,7 +135,7 @@ public class LttngTimestamp extends TmfTimestamp {
     /**
      * toString() method.
      * 
-     * @return Attributes of this object.
+     * @return timestamp, as string
      */
     @Override
        public String toString() {
index aa36ee278d6803ff3c98f012b37f0ee2bceea329..c9acabe9f93ebb28fc5d191e741e6e6e348e07a8 100644 (file)
@@ -1,3 +1,4 @@
+package org.eclipse.linuxtools.lttng.jni;
 /*******************************************************************************
  * Copyright (c) 2009 Ericsson
  * 
@@ -10,7 +11,6 @@
  *   William Bourque (wbourque@gmail.com) - Initial API and implementation
  *******************************************************************************/
 
-package org.eclipse.linuxtools.lttng.jni;
 
 import java.util.HashMap;
 
@@ -47,10 +47,8 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
     // Note that all type have been scaled up as there is no "unsigned" in java
     // This might be a problem about "unsigned long" as there is no equivalent
     // in java
-    private Jni_C_Pointer tracefilePtr = new Jni_C_Pointer();;
-    private int eventMarkerId = 0;
+    private Jni_C_Pointer tracefilePtr = new Jni_C_Pointer();
     private JniTime eventTime = null;
-    private long eventDataSize = 0;
 
     // These methods need a tracefile pointer, instead of a event pointer
     private native int      ltt_readNextEvent(long tracefilePtr);
@@ -68,6 +66,8 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
     @SuppressWarnings("unused")
     private native long     ltt_getTimestamp(long eventPtr);
     private native int      ltt_getEventMarkerId(long eventPtr);
+    private native long     ltt_getNanosencondsTime(long eventPtr);
+    @SuppressWarnings("unused")
     private native void     ltt_feedEventTime(long eventPtr, JniTime eventTime);
     private native long     ltt_getEventDataSize(long eventPtr);
     @SuppressWarnings("unused")
@@ -107,9 +107,7 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
         eventState = oldEvent.eventState;
 
         tracefilePtr = oldEvent.tracefilePtr;
-        eventMarkerId = oldEvent.eventMarkerId;
         eventTime = oldEvent.eventTime;
-        eventDataSize = oldEvent.eventDataSize;
     }
     
     /**
@@ -124,9 +122,9 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
      *            
      * @exception JniException
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
-     * @see org.eclipse.linuxtools.lttng.jni.JniMarker
-     * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniMarker
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
      */
     public JniEvent(Jni_C_Pointer newEventPtr, HashMap<Integer, JniMarker> newMarkersMap, JniTracefile newParentTracefile) throws JniException {
 
@@ -147,10 +145,8 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
         
         // Try to move to the first event
         // If the event is Out of Range (ERANGE) at the first read, 
-        //  this event type will never been usable.
+        //  this event type will never be usable.
         // In that case, throw JniNoSuchEventException to warn the tracefile.
-        //
-        // Position ourself on the first event.
         eventState = positionToFirstEvent();
         if (eventState != EOK)  {
             throw new JniNoSuchEventException("Object not populated, unusable. There is probably no event of that type in the trace. (JniEvent)");
@@ -167,17 +163,16 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
      * 
      * @return LTT read status, as defined in Jni_C_Common.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Common
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Common
      */
      public int readNextEvent() {
         // Ask Ltt to read the next event for this particular tracefile
-        eventState = ltt_readNextEvent(tracefilePtr.getPointer() );
-
+        eventState = ltt_readNextEvent( tracefilePtr.getPointer() );
         // If the event state is sane populate it
         if (eventState == EOK) {
             populateEventInformation();
         }
-
+        
         return eventState;
     }
 
@@ -193,7 +188,7 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
      * 
      * @return LTT read status, as defined in Jni_C_Common
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Common
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Common
      */
     public int seekToTime(JniTime seekTime) {
         // Ask Ltt to read the next event for this particular tracefile
@@ -216,11 +211,11 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
      * 
      * @return LTT read status, as defined in Jni_C_Common
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Common
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Common
      */
     public int seekOrFallBack(JniTime seekTime) {
         // Save the old time
-        JniTime oldTime = eventTime;
+        JniTime oldTime = new JniTime(eventTime);
 
         // Call seek to move ahead
         // Save the state for the return (eventState will be modified if we seek back)
@@ -246,7 +241,7 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
      * 
      * @return LTT read status, as defined in Jni_C_Common
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Common
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Common
      */
     public int positionToFirstEvent() {
         eventState = ltt_positionToFirstEvent(tracefilePtr.getPointer());
@@ -259,10 +254,10 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
      * 
      * @return Reference to the marker for this tracefile's event or null if none.
      *  
-     * @see org.eclipse.linuxtools.lttng.jni.JniMarker
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniMarker
      */
     public JniMarker requestEventMarker() {
-        return markersMap.get(eventMarkerId);
+        return markersMap.get(getEventMarkerId());
     }
 
     /**
@@ -274,9 +269,9 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
      * @return  Bytes array of raw data (contain raw C bytes).
      */
     public byte[] requestEventContent() {
-        byte dataContent[] = new byte[(int) eventDataSize];
+        byte dataContent[] = new byte[(int) getEventDataSize()];
 
-        ltt_getDataContent(thisEventPtr.getPointer(), eventDataSize, dataContent);
+        ltt_getDataContent(thisEventPtr.getPointer(), getEventDataSize(), dataContent);
 
         return dataContent;
     }
@@ -288,7 +283,7 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
      * 
      * @return  Reference to the JniMarker object for this event or null if none. 
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.JniMarker
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniMarker
      */
     public String requestEventSource() {
         // *** TODO ***
@@ -307,6 +302,8 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
      * @param fieldId   Position of the field to parse.
      * 
      * @return Object that contain the parsed payload
+     * 
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniParser
      */
     public Object parseFieldById(int fieldId) {
         return JniParser.parseField(this, fieldId);
@@ -320,6 +317,8 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
      * @param fieldName   Position of the field to parse.
      * 
      * @return Object that contain the parsed payload
+     * 
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniParser
      */
     public Object parseFieldByName(String fieldName) {
         return JniParser.parseField(this, fieldName);
@@ -328,7 +327,9 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
     /**
      * Method to parse all the event payload.<p>
      * 
-     * @return HashMap<String, Object> which is the parsedContent objects and their name as key. 
+     * @return HashMap<String, Object> which is the parsedContent objects and their name as key.
+     * 
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniParser 
      */
     public HashMap<String, Object> parseAllFields() {
         return JniParser.parseAllFields(this);
@@ -337,40 +338,32 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
     /* 
      * This function populates the event data with data from LTT
      * 
+     * NOTE : To get better performance, we copy very few data into memory here
+     * 
      */
     private void populateEventInformation() {
-        if (thisEventPtr.getPointer() == NULL) {
-            printlnC("Pointer is NULL, trace closed? (populateEventInformation)");
-        }
-        else {
-            tracefilePtr = new Jni_C_Pointer( ltt_getTracefilePtr(thisEventPtr.getPointer()) );
-            eventMarkerId = ltt_getEventMarkerId(thisEventPtr.getPointer());
-            
-            // Creation of time is a bit different, we need to pass the object
-            // reference to C
-            ltt_feedEventTime(thisEventPtr.getPointer(), eventTime);
-            
-            eventDataSize = ltt_getEventDataSize(thisEventPtr.getPointer());
-        }
+       // We need to save the time, as it is not a primitive (can't be dynamically called in getter)
+       eventTime.setTime(ltt_getNanosencondsTime(thisEventPtr.getPointer() ));
     }
     
-    public int getEventMarkerId() {
-        return eventMarkerId;
-    }
-
     public JniTime getEventTime() {
         return eventTime;
     }
+    
+    // *** To get better performance, all getter belows call LTT directly ****
+    //     That way, we can avoid copying data into memory
+    public int getEventMarkerId() {
+        return ltt_getEventMarkerId(thisEventPtr.getPointer());
+    }
 
     public long getEventDataSize() {
-        return eventDataSize;
+        return ltt_getEventDataSize(thisEventPtr.getPointer());
     }
 
     public HashMap<Integer, JniMarker> getMarkersMap() {
         return markersMap;
     }
 
-    
     /**
      * Pointer to the parent LTTTracefile C structure.<br>
      * <br>
@@ -379,10 +372,10 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
      * 
      * @return The actual (long converted) pointer or NULL.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
      */
     public Jni_C_Pointer getTracefilePtr() {
-        return tracefilePtr;
+        return new Jni_C_Pointer( ltt_getTracefilePtr(thisEventPtr.getPointer()) );
     }
 
     /**
@@ -393,7 +386,7 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
      * 
      * @return The actual (long converted) pointer or NULL.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
      */
     public Jni_C_Pointer getEventPtr() {
         return thisEventPtr;
@@ -408,7 +401,7 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
      *
      * @return  The parent tracefile 
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
      */
     public JniTracefile getParentTracefile() {
         return parentTracefile;
@@ -422,19 +415,20 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
      * 
      * @return -1 if given event happens before, 0 if equal, 1 if passed event happens after.
      */
-    //@Override
     public int compareTo(JniEvent rightEvent ){
-        JniEvent leftEvent = this;
+       
+       // Note : this = left hand operand
+       
         // By default, we consider the current event to be older.
         int eventComparaison = -1; 
         
         // Test against null before performing anything
         if ( rightEvent != null ) {
             // Compare the timestamp first
-            eventComparaison = leftEvent.getEventTime().compareTo( rightEvent.getEventTime() );
+            eventComparaison = this.getEventTime().compareTo( rightEvent.getEventTime() );
             
             // If timestamp is equal, compare the parent tracefile ("event type")
-            if ( (eventComparaison == 0) && ( !leftEvent.parentTracefile.equals(rightEvent.parentTracefile)) ) {
+            if ( (eventComparaison == 0) && ( !this.parentTracefile.equals(rightEvent.parentTracefile)) ) {
                 eventComparaison = 1;
             }
         }
@@ -472,11 +466,11 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
         String returnData = "";
 
         returnData += "tracefilePtr            : " + tracefilePtr + "\n";
-        returnData += "eventMarkerId           : " + eventMarkerId + "\n";
+        returnData += "eventMarkerId           : " + getEventMarkerId() + "\n";
         returnData += "eventTime               : " + eventTime.getReferenceToString() + "\n";
         returnData += "   seconds              : " + eventTime.getSeconds() + "\n";
         returnData += "   nanoSeconds          : " + eventTime.getNanoSeconds() + "\n";
-        returnData += "eventDataSize           : " + eventDataSize + "\n";
+        returnData += "eventDataSize           : " + getEventDataSize() + "\n";
         returnData += "markersMap              : " + markersMap.keySet() + "\n"; // Hack to avoid ending up with markersMap.toString()
 
         return returnData;
index 1bde48381049f690331e6995b25b667aa7702108..7f8adf6e0db9bc6d61f2231dfd1249b7ce5701ee 100644 (file)
@@ -1,3 +1,4 @@
+package org.eclipse.linuxtools.lttng.jni;
 /*******************************************************************************
  * Copyright (c) 2009 Ericsson
  * 
@@ -10,7 +11,6 @@
  *   William Bourque (wbourque@gmail.com) - Initial API and implementation
  *******************************************************************************/
 
-package org.eclipse.linuxtools.lttng.jni;
 
 /**
  * <b><u>JniException</u></b>
index 213b188e66e250f2b5bdce4be4392f32c1757c46..3990bfc15c7f154948fc47fe8d8fbcbbfb46f255 100644 (file)
@@ -1,3 +1,4 @@
+package org.eclipse.linuxtools.lttng.jni;
 /*******************************************************************************
  * Copyright (c) 2009 Ericsson
  * 
@@ -10,7 +11,6 @@
  *   William Bourque (wbourque@gmail.com) - Initial API and implementation
  *******************************************************************************/
 
-package org.eclipse.linuxtools.lttng.jni;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -174,7 +174,7 @@ public final class JniMarker extends Jni_C_Common
      * 
      * @return The actual (long converted) pointer or NULL
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
      */
     public Jni_C_Pointer getMarkerPtr() {
         return thisMarkerPtr;
index 70e18a733fafbfa6f698ada014a2d049f792f5e5..de2422f2aba4a619dba2fb33d938492c28621888 100644 (file)
@@ -1,3 +1,4 @@
+package org.eclipse.linuxtools.lttng.jni;
 /*******************************************************************************
  * Copyright (c) 2009 Ericsson
  * 
@@ -10,7 +11,6 @@
  *   William Bourque (wbourque@gmail.com) - Initial API and implementation
  *******************************************************************************/
 
-package org.eclipse.linuxtools.lttng.jni;
 
 /**
  * <b><u>JniMarkerField</u></b> <p>
@@ -117,7 +117,7 @@ public final class JniMarkerField extends Jni_C_Common
      * 
      * @return The actual (long converted) pointer or NULL
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
      */
     public Jni_C_Pointer getMarkerFieldPtr() {
         return thisMarkerFieldPtr;
index 3f7e36c1e4e2f993a4ca4bb8a12097d9a51f2c4c..4f1ee63f23ae0a20b56bb53f79b5a36b85839b9a 100644 (file)
@@ -1,3 +1,4 @@
+package org.eclipse.linuxtools.lttng.jni;
 /*******************************************************************************
  * Copyright (c) 2009 Ericsson
  * 
@@ -10,7 +11,6 @@
  *   William Bourque (wbourque@gmail.com) - Initial API and implementation
  *******************************************************************************/
 
-package org.eclipse.linuxtools.lttng.jni;
 
 import java.util.HashMap;
 import java.util.Iterator;
@@ -29,7 +29,14 @@ public class JniParser extends Jni_C_Common
     static {
         System.loadLibrary("lttvtraceread");
     }
-
+    
+    // *** HACK ***
+    // We cannot use "Object" directly as java does not support swapping primitive value
+    //    We either need to create a new object type or to use a "non-primitive" type that have "Setter()" functions
+    //    Another (ugly) hack would be to pass an array to modify the reference's reference.
+    // ***
+    private static ParsedObjectContent parsedData = new ParsedObjectContent();
+    
     /*
      * Default constructor is forbidden
      */
@@ -47,7 +54,7 @@ public class JniParser extends Jni_C_Common
      * 
      * @return                  An Object that contain the JniEvent payload parsed by the C, or null, if if was impossible to parse (i.e., wrong position)
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
      */
     static public Object parseField(JniEvent eventToParse, int fieldPosition) {
         
@@ -56,15 +63,10 @@ public class JniParser extends Jni_C_Common
             return null;
         }
         
-        // *** HACK ***
-        // We cannot use "Object" directly as java does not support swapping primitive value
-        //    We either need to create a new object type or to use a "non-primitive" type that have "Setter()" functions
-        //    Another (ugly) hack would be to pass an array to modify the reference's reference.
-        // ***
-        ParsedObjectContent parsedData = new ParsedObjectContent();
+        JniMarkerField tmpField = eventToParse.requestEventMarker().getMarkerFieldsArrayList().get(fieldPosition);
         
         // Call the parsing function in C. The result will be put in parsedData object
-        ltt_getParsedData(parsedData, eventToParse.getEventPtr().getPointer(), eventToParse.requestEventMarker().getMarkerFieldsArrayList().get(fieldPosition).getMarkerFieldPtr().getPointer() );
+        ltt_getParsedData(parsedData, eventToParse.getEventPtr().getPointer(), tmpField.getMarkerFieldPtr().getPointer() );
         
         return parsedData.getData();
     }
@@ -80,7 +82,7 @@ public class JniParser extends Jni_C_Common
      * 
      * @return                  An Object that contain the JniEvent payload parsed by the C, or null, if if was impossible to parse (i.e., wrong position)
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
      */
     static public Object parseField(JniEvent eventToParse, String fieldName) {
         
@@ -91,13 +93,6 @@ public class JniParser extends Jni_C_Common
             return null;
         }
         
-        // *** HACK ***
-        // We cannot use "Object" directly as java does not support swapping on primitive value
-        //      We either need to create a new object type or to use a "non-primitive" type that have "Setter()" functions
-        //      Another (ugly) hack would be to pass an array to modify the reference's reference.
-        // ***
-        ParsedObjectContent parsedData = new ParsedObjectContent();
-        
         ltt_getParsedData(parsedData, eventToParse.getEventPtr().getPointer(), tmpField.getMarkerFieldPtr().getPointer() );
         
         return parsedData.getData();
@@ -113,7 +108,7 @@ public class JniParser extends Jni_C_Common
      * @param   eventToParse    The jni event we want to parse.  
      * @return                  An HashMap of Object that contain the is the JniEvent's payload parsed by the C
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
      */
     static public HashMap<String, Object> parseAllFields(JniEvent eventToParse) {
         HashMap<String,JniMarkerField> markerFieldData = eventToParse.requestEventMarker().getMarkerFieldsHashMap();
@@ -134,23 +129,17 @@ public class JniParser extends Jni_C_Common
                // Or even safer, use HashMap constructor to do so : 
         HashMap<String, Object> parsedDataMap = new HashMap<String, Object>(markerFieldData);
                 
-               // *** HACK ***
-               // We cannot use "Object" directly as java does not support swapping on primitive value
-               //  We either need to create a new object type or to use a "non-primitive" type that have "Setter()" functions
-               // ***
-        ParsedObjectContent parsedData = new ParsedObjectContent();
-                
-        String              newKey      = null; 
-        JniMarkerField      newValue = null;
-        Iterator<String>    iterator = markerFieldData.keySet().iterator();
+        String              newKey             = null; 
+        JniMarkerField      newMarkerField  = null;
+        Iterator<String>    iterator        = markerFieldData.keySet().iterator();
+        
         while ( iterator.hasNext() ) {
             newKey = iterator.next();
-            newValue = markerFieldData.get(newKey);
+            newMarkerField = markerFieldData.get(newKey);
             // Call the C to parse the data
-            ltt_getParsedData(parsedData, eventToParse.getEventPtr().getPointer(), newValue.getMarkerFieldPtr().getPointer() );
+            ltt_getParsedData(parsedData, eventToParse.getEventPtr().getPointer(), newMarkerField.getMarkerFieldPtr().getPointer() );
             // Save the result into the HashMap
-            parsedDataMap.put(newValue.getField(), parsedData.getData() );
+            parsedDataMap.put(newMarkerField.getField(), parsedData.getData() );
         }
  
         return parsedDataMap;
@@ -170,7 +159,7 @@ public class JniParser extends Jni_C_Common
      * @param formatToAdd   The format of the raw data
      */
     @SuppressWarnings("unused")
-    static private void addStringToParsingFromC(Object contentHolder, String fieldName, String stringToAdd) {
+    static private void addStringToParsingFromC(Object contentHolder, String stringToAdd) {
         ((ParsedObjectContent)contentHolder).setData( stringToAdd);
     }
 
@@ -187,7 +176,7 @@ public class JniParser extends Jni_C_Common
      * @param formatToAdd   The format of the raw data
      */
     @SuppressWarnings("unused")
-    static private void addLongPointerToParsingFromC(Object contentHolder, String fieldName, long pointerToAdd) {
+    static private void addLongPointerToParsingFromC(Object contentHolder, long pointerToAdd) {
         ((ParsedObjectContent)contentHolder).setData( new Jni_C_Pointer((long) pointerToAdd));
     }
 
@@ -204,7 +193,7 @@ public class JniParser extends Jni_C_Common
      * @param formatToAdd   The format of the raw data
      */
     @SuppressWarnings("unused")
-    static private void addIntPointerToParsingFromC(Object contentHolder, String fieldName, long pointerToAdd) {
+    static private void addIntPointerToParsingFromC(Object contentHolder, long pointerToAdd) {
         ((ParsedObjectContent)contentHolder).setData( new Jni_C_Pointer((int) pointerToAdd));
     }
 
@@ -221,7 +210,7 @@ public class JniParser extends Jni_C_Common
      * @param formatToAdd   The format of the raw data
      */
     @SuppressWarnings("unused")
-    static private void addShortToParsingFromC(Object contentHolder, String fieldName, short shortToAdd) {
+    static private void addShortToParsingFromC(Object contentHolder, short shortToAdd) {
         ((ParsedObjectContent)contentHolder).setData( new Short(shortToAdd));
     }
 
@@ -238,7 +227,7 @@ public class JniParser extends Jni_C_Common
      * @param formatToAdd   The format of the raw data
      */
     @SuppressWarnings("unused")
-    static private void addIntegerToParsingFromC(Object contentHolder, String fieldName, int intToAdd) {
+    static private void addIntegerToParsingFromC(Object contentHolder, int intToAdd) {
         ((ParsedObjectContent)contentHolder).setData( new Integer(intToAdd));
     }
 
@@ -255,7 +244,7 @@ public class JniParser extends Jni_C_Common
      * @param formatToAdd   The format of the raw data
      */
     @SuppressWarnings("unused")
-    static private void addLongToParsingFromC(Object contentHolder, String fieldName, long longToAdd) {
+    static private void addLongToParsingFromC(Object contentHolder, long longToAdd) {
         ((ParsedObjectContent)contentHolder).setData( new Long(longToAdd));
     }
 
@@ -272,7 +261,7 @@ public class JniParser extends Jni_C_Common
      * @param formatToAdd   The format of the raw data
      */
     @SuppressWarnings("unused")
-    static private void addFloatToParsingFromC(Object contentHolder, String fieldName, float floatToAdd) {
+    static private void addFloatToParsingFromC(Object contentHolder, float floatToAdd) {
         ((ParsedObjectContent)contentHolder).setData( new Float(floatToAdd));
     }
 
@@ -290,7 +279,7 @@ public class JniParser extends Jni_C_Common
      * @param formatToAdd   The format of the raw data
      */
     @SuppressWarnings("unused")
-    static private void addDoubleToParsingFromC(Object contentHolder, String fieldName, double doubleToAdd) {
+    static private void addDoubleToParsingFromC(Object contentHolder, double doubleToAdd) {
         ((ParsedObjectContent)contentHolder).setData( new Double(doubleToAdd));
     }
     
index e11acb47913ce725f25a962bd309ea45bfd8029b..4559bfb013b51af01930f102d10c389c69db0334 100644 (file)
@@ -1,3 +1,4 @@
+package org.eclipse.linuxtools.lttng.jni;
 /*******************************************************************************
  * Copyright (c) 2009 Ericsson
  * 
@@ -10,7 +11,6 @@
  *   William Bourque (wbourque@gmail.com) - Initial API and implementation
  *******************************************************************************/
 
-package org.eclipse.linuxtools.lttng.jni;
 
 /**
  * <b><u>JniTime</u></b>
@@ -95,7 +95,28 @@ public final class JniTime extends Jni_C_Common implements Comparable<JniTime>
     public long getTime() {
         return time;
     }
-     
+    
+    /**
+     * Changes the current time for this object<p>
+     * 
+     * @param newTime  New time to set, in nanoseconds.
+     */
+    public void setTime(long newTime) {
+        time = newTime;
+    }
+    
+    /* 
+     * Populate this time object
+     * 
+     * Note: This function is called from C side.
+     * 
+     * @param newTime The time we want to populate
+     */
+    @SuppressWarnings("unused")
+    private void setTimeFromC(long newTime) {
+        time = newTime;
+    }
+    
     /**
      * Comparaison operator smaller or equal than "<=" .<p>
      * 
@@ -123,31 +144,19 @@ public final class JniTime extends Jni_C_Common implements Comparable<JniTime>
      * @return int of value -1, 0 or 1, as the pased argument is bigger, equal or smaller than this time
      */
     public int compareTo(JniTime right) {
+        long leftTime = this.getTime();
+        long rightTime = right.getTime();
         
-        JniTime left = this;
-        
-        if ( left.getTime() < right.getTime() ) {
+        if ( leftTime < rightTime ) { 
             return -1;
         }
-        else if ( left.getTime() > right.getTime() ) {
-            return 1;
+        else if ( leftTime > rightTime ) {
+            return  1;
         }
         else {
             return 0;
         }
     }
-
-    /* 
-     * Populate this time object
-     * 
-     * Note: This function is called from C side.
-     * 
-     * @param newTime The time we want to populate
-     */
-    @SuppressWarnings("unused")
-    private void setTimeFromC(long newTime) {
-        time = newTime;
-    }
     
     /**
      * toString() method.
index 391a506217bb9c3d8a1629059f03bd87aea010b0..91d35297e4b9e203b6bab860c16bea2aa34b9eef 100644 (file)
@@ -1,3 +1,4 @@
+package org.eclipse.linuxtools.lttng.jni;
 /*******************************************************************************
  * Copyright (c) 2009 Ericsson
  * 
@@ -10,7 +11,6 @@
  *   William Bourque (wbourque@gmail.com) - Initial API and implementation
  *******************************************************************************/
 
-package org.eclipse.linuxtools.lttng.jni;
 
 import java.util.HashMap;
 import java.util.Iterator;
@@ -29,7 +29,9 @@ import java.util.PriorityQueue;
  * </ul>
  */
 public class JniTrace extends Jni_C_Common {
-        
+    
+    private final static boolean DEFAULT_LTT_DEBUG = false;
+    
     // Internal C pointer of the JniTrace used in LTT
     private Jni_C_Pointer thisTracePtr = new Jni_C_Pointer();
 
@@ -61,8 +63,11 @@ public class JniTrace extends Jni_C_Common {
     // This variable will hold the content of the "last" event we read
     private JniEvent currentEvent = null;  
     
+    // Should we print debug in the C library or not?
+    private boolean printLttDebug = DEFAULT_LTT_DEBUG;
+    
     // Open/close native functions
-    private native long ltt_openTrace(String pathname);
+    private native long ltt_openTrace(String pathname, boolean printDebug);
     private native void ltt_closeTrace(long tracePtr);
 
     // Native access functions
@@ -78,10 +83,10 @@ public class JniTrace extends Jni_C_Common {
     private native long   ltt_getStartFreq(long tracePtr);
     private native long   ltt_getStartTimestampCurrentCounter(long tracePtr);
     private native long   ltt_getStartMonotonic(long tracePtr);
-
+    
     // Native function to fill out startTime
     private native void ltt_feedStartTime(long tracePtr, JniTime startTime);
-
+    
     // Native function to fill out startTimeFromTimestampCurrentCounter
     private native void ltt_feedStartTimeFromTimestampCurrentCounter(long tracePtr, JniTime startTime);
 
@@ -108,12 +113,14 @@ public class JniTrace extends Jni_C_Common {
      * This constructor also opens the trace.
      * 
      * @param newpath The <b>directory</b> of the trace to be opened
+     * @param newPrintDebug Should the debug information be printed in the LTT C library
      * 
      * @exception JniException
      */
-    public JniTrace(String newpath) throws JniException {
+    public JniTrace(String newpath, boolean newPrintDebug) throws JniException {
         tracepath = newpath;
         thisTracePtr = new Jni_C_Pointer();
+        printLttDebug = newPrintDebug;
         
         openTrace(newpath);
     }
@@ -146,19 +153,23 @@ public class JniTrace extends Jni_C_Common {
         
         eventsHeap = new PriorityQueue<JniEvent>( oldTrace.eventsHeap.size());
         eventsHeap = oldTrace.eventsHeap;
+        
+        printLttDebug = oldTrace.printLttDebug;
     }        
         
     /**
      * Constructor, using C pointer.<p>
      * 
      * @param newPtr The pointer to an already opened LttTrace C structure.
+     * @param newPrintDebug Should the debug information be printed in the LTT C library
      *            
      * @exception JniException
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
      */
-    public JniTrace(Jni_C_Pointer newPtr) throws JniException {
+    public JniTrace(Jni_C_Pointer newPtr, boolean newPrintDebug) throws JniException {
         thisTracePtr = newPtr;
+        printLttDebug = newPrintDebug;
         
         // Populate our trace
         populateTraceInformation();
@@ -205,7 +216,7 @@ public class JniTrace extends Jni_C_Common {
         }
 
         // Call the LTT to open the trace
-        long newPtr = ltt_openTrace(tracepath);
+        long newPtr = ltt_openTrace(tracepath, printLttDebug);
         if (newPtr == NULL) {
             throw new JniOpenTraceFailedException("Error while opening trace. Is the tracepath correct? (openTrace)");
         }
@@ -328,7 +339,7 @@ public class JniTrace extends Jni_C_Common {
         //    the tracefile fill itself with LTT data while being constructed
         try {
             newTracefile = new JniTracefile( new Jni_C_Pointer(tracefilePtr), this );
-            tracefilesMap.put(tracefileName + newTracefile.getCpuNumber(), newTracefile);
+            tracefilesMap.put( (tracefileName + newTracefile.getCpuNumber()), newTracefile);
         }
         catch(JniTracefileWithoutEventException e) {
             printlnC("JniTracefile " + tracefileName + " has no event (addTracefileFromC). Ignoring.");
@@ -337,7 +348,7 @@ public class JniTrace extends Jni_C_Common {
             printlnC("Failed to add tracefile " + tracefileName + " to tracefilesMap!(addTracefileFromC)\n\tException raised : " + e.toString() );
         }
     }
-        
+    
     /**
      * Return the top event in the events stack, determined by timestamp, in the trace (all the tracefiles).<p>
      * 
@@ -345,7 +356,7 @@ public class JniTrace extends Jni_C_Common {
      * 
      * @return The top event in the stack or null if no event is available.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
      */
     public JniEvent findNextEvent() {
         return eventsHeap.peek();
@@ -356,7 +367,7 @@ public class JniTrace extends Jni_C_Common {
      * 
      * @return The next event in the trace or null if no event is available.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
      */
     public JniEvent readNextEvent() {
         // Get the "next" event on the top of the heap but DO NOT remove it
@@ -405,8 +416,8 @@ public class JniTrace extends Jni_C_Common {
      * 
      * @return The next event in the tracefile or null if no event is available.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
-     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
      */
     public JniEvent readNextEvent(JniTracefile targetTracefile) {
         JniEvent returnedEvent = null;
@@ -447,7 +458,7 @@ public class JniTrace extends Jni_C_Common {
     * 
     * @param seekTime     The time where we want to seek to
     * 
-    * @see org.eclipse.linuxtools.lttng.jni.JniTime
+    * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTime
     */
     public void seekToTime(JniTime seekTime) {
         
@@ -474,15 +485,15 @@ public class JniTrace extends Jni_C_Common {
     * @param targetTracefile   The tracefile object to read from
     * @param seekTime                  The time where we want to seek to
     * 
-    * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
-    * @see org.eclipse.linuxtools.lttng.jni.JniTime
+    * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
+    * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTime
     */
     public void seekToTime(JniTime seekTime, JniTracefile targetTracefile) {
         // Invalidate the current read event
         currentEvent = null;
         
         // Remove from the event related to this tracefile from the event heap, if it exists.
-        // WARNING : This only safe as long getCurrentEvent() never return "null" in any case.
+        // WARNING : This is only safe as long getCurrentEvent() never return "null" in any case.
         eventsHeap.remove(targetTracefile.getCurrentEvent() );
         
         // Perform the actual seek on the tracefile
@@ -502,8 +513,8 @@ public class JniTrace extends Jni_C_Common {
     * 
     * @return The event just after the seeked time or null if none available.
     * 
-    * @see org.eclipse.linuxtools.lttng.jni.JniEvent
-    * @see org.eclipse.linuxtools.lttng.jni.JniTime
+    * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
+    * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTime
     */
     public JniEvent seekAndRead(JniTime seekTime) { 
          JniEvent returnedEvent = null;
@@ -527,9 +538,9 @@ public class JniTrace extends Jni_C_Common {
     * 
     * @return The event just after the seeked time or null if none available.
     * 
-    * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
-    * @see org.eclipse.linuxtools.lttng.jni.JniTime
-    * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+    * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
+    * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTime
+    * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
     */
     public JniEvent seekAndRead(JniTime seekTime, JniTracefile targetTracefile) { 
         seekToTime(seekTime, targetTracefile);
@@ -543,7 +554,7 @@ public class JniTrace extends Jni_C_Common {
      * 
      * @return The tracefile found or null if none.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
      */
     public JniTracefile requestTracefileByName(String tracefileName) {
         return tracefilesMap.get(tracefileName);
@@ -556,7 +567,7 @@ public class JniTrace extends Jni_C_Common {
      * 
      * @return Event of the tracefile or null if none found.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
      */
     public JniEvent requestEventByName(String tracefileName) {
         JniEvent returnValue = null;
@@ -640,7 +651,7 @@ public class JniTrace extends Jni_C_Common {
      * 
      * @return Time of the last event read
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.JniTime
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTime
      */
     public JniTime getCurrentEventTimestamp() {
         JniTime returnedTime = null;
@@ -664,12 +675,23 @@ public class JniTrace extends Jni_C_Common {
      * 
      * @return The actual (long converted) pointer or NULL.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
      */
     public Jni_C_Pointer getTracePtr() {
         return thisTracePtr;
     }        
-        
+    
+    /**
+     * Return boolean value saying if the debug is enabled in LTT or not.<p>
+     * 
+     * Note : this need to be set at construction.
+     * 
+     * @return If the debug is set or not
+     */
+    public boolean isPrintingLttDebug() {
+        return printLttDebug;
+    }
+    
     /**
      * Print information for all the tracefiles associated with this trace.
      * <u>Intended to debug</u><p>
@@ -677,7 +699,7 @@ public class JniTrace extends Jni_C_Common {
      * This function will call Ltt to print, so information printed will be the
      * one from the C structure, not the one populated in java.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
      */
     public void printAllTracefilesInformation() {
         JniTracefile tracefile = null;
index c541e5776d8be38e7083789b52800f1976ead880..4ce1b91aeced11001dfc7f879abdb8d76c837d2f 100644 (file)
@@ -1,3 +1,4 @@
+package org.eclipse.linuxtools.lttng.jni;
 /*******************************************************************************
  * Copyright (c) 2009 Ericsson
  * 
@@ -10,7 +11,6 @@
  *   William Bourque (wbourque@gmail.com) - Initial API and implementation
  *******************************************************************************/
 
-package org.eclipse.linuxtools.lttng.jni;
 
 import java.util.HashMap;
 
@@ -161,8 +161,8 @@ public final class JniTracefile extends Jni_C_Common {
      * 
      * @exception JniException
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.JniTrace
-     * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTrace
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
      */
     public JniTracefile(Jni_C_Pointer newPtr, JniTrace newParentTrace) throws JniException {
         thisTracefilePtr = newPtr;
@@ -185,7 +185,7 @@ public final class JniTracefile extends Jni_C_Common {
      *      
      * @return LTT read status, as defined in Jni_C_Common
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Common
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Common
      */
     public int readNextEvent() {
         return currentEvent.readNextEvent();
@@ -200,7 +200,7 @@ public final class JniTracefile extends Jni_C_Common {
      * 
      * @return LTT read status, as defined in Jni_C_Common
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Common
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Common
      */
     public int seekToTime(JniTime seekTime) {
         return currentEvent.seekToTime(seekTime);
@@ -382,7 +382,7 @@ public final class JniTracefile extends Jni_C_Common {
      *
      * @return The parent trace
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.JniTrace
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTrace
      */
     public JniTrace getParentTrace() {
         return parentTrace;
@@ -396,7 +396,7 @@ public final class JniTracefile extends Jni_C_Common {
      * 
      * @return The actual (long converted) pointer or NULL.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
      */
     public Jni_C_Pointer getTracefilePtr() {
         return thisTracefilePtr;
index 8803123c5baaa06aef4bbf164276b22ae9f31b9b..23904606db322ce3a657316215c9230d5b472880 100644 (file)
@@ -1,3 +1,4 @@
+package org.eclipse.linuxtools.lttng.jni;
 /*******************************************************************************
  * Copyright (c) 2009 Ericsson
  * 
@@ -10,7 +11,6 @@
  *   William Bourque (wbourque@gmail.com) - Initial API and implementation
  *******************************************************************************/
 
-package org.eclipse.linuxtools.lttng.jni;
 
 /**
  * <b><u>Jni_C_Common</u></b>
index d1c40388469eaf488fd967f8882995c748bccc0d..7cfec13078ad121c7ef4ba5ad2ec9a9dae64c5e5 100644 (file)
@@ -1,5 +1,6 @@
 package org.eclipse.linuxtools.lttng.jni;
 
+
 /**
  * <b><u>Jni_C_Pointer</u></b>
  * <p>
index b4318fb107418b2227a1682729a13416c3a98158..62eb5be5bfa558fe77ec23440d203219de9095c7 100644 (file)
@@ -49,8 +49,9 @@ public class StateDataRequest extends TmfDataRequest<TmfEvent> {
        public StateDataRequest(TmfTimeRange range, long offset, int nbEvents,
                        int maxBlockSize, IStateDataRequestListener listener,
                        StateManager manager) {
-
-               super(range, offset, nbEvents, maxBlockSize);
+               
+               super(range, nbEvents, maxBlockSize);
+               //super(0, nbEvents, maxBlockSize);
                this.manager = manager;
                if (listener != null && !listeners.contains(listener)) {
                        listeners.add(listener);
index 5cd47bf380cbbab3c14630a95b589a256dba58c7..9a0ec870da68270de13720296033da555cefd82a 100644 (file)
@@ -44,7 +44,7 @@ import org.eclipse.linuxtools.tmf.trace.TmfTraceCheckpoint;
  */
 public class StateManager extends Observable {
 
-       private static final long LTTNG_STATE_SAVE_INTERVAL = 50000L;
+       private static final long LTTNG_STATE_SAVE_INTERVAL = 5000000L;
 
        // These are used in the building of the data request.
        private static final long DEFAULT_OFFSET = 0L;
@@ -308,13 +308,13 @@ public class StateManager extends Observable {
                                || (eventTime.getValue() > logRange.getEndTime().getValue())) {
                        return null;
                }
-
+               
                // The GUI can have time limits lower than this log, since GUI can
                // handle multiple logs
                if ((eventTime.getValue() < logRange.getStartTime().getValue())) {
                        eventTime = logRange.getStartTime();
                }
-
+               
                // Sort the checkpoints, required before the binary search
                Collections.sort(timestampCheckpointsList);
                // Initiate the compare with a checkpoint containing the target time
@@ -482,7 +482,7 @@ public class StateManager extends Observable {
                        @Override
                        public void handleData() {
                                TmfEvent[] result = getData();
-
+                               
                                evt[0] = (result.length > 0) ? result[0] : null;
                                // Dispatch information for Event processing
                                stateIn.processEvent(evt[0]);
index 354f3a76b91c7f38f84a9db0df2e1766240ed81d..5001dc8ca7a2cffdc3fc70bf97d6091dfe42153f 100644 (file)
@@ -17,6 +17,8 @@ import java.util.Vector;
 
 import org.eclipse.linuxtools.lttng.TraceDebug;
 import org.eclipse.linuxtools.lttng.event.LttngEvent;
+import org.eclipse.linuxtools.lttng.event.LttngEventContent;
+import org.eclipse.linuxtools.lttng.event.LttngEventField;
 import org.eclipse.linuxtools.lttng.jni.JniTrace;
 import org.eclipse.linuxtools.lttng.state.evProcessor.AbsEventProcessorFactory;
 import org.eclipse.linuxtools.lttng.state.evProcessor.EventProcessorProxy;
@@ -81,9 +83,9 @@ public class StateStacksHandler {
                }
 
                LttngEvent trcEvent = (LttngEvent) tmfEvent;
-               TmfEventField[] fields = trcEvent.getContent().getFields();
+//             LttngEventField[] fields = ((LttngEventContent)trcEvent.getContent()).getFields();
 
-               if (fields != null) {
+               if (trcEvent != null) {
                        String inEventName = trcEvent.getMarkerName();
                        // String inChannel = trcEvent.getChannelName();
                        // TraceDebug.debug("Event: " + inEventName);
index b6cb14ecf47c6d64955dbd1f939e4029442f1253..8d23f4d1aefb1f49724d29dd8549f299f8e64238 100644 (file)
@@ -30,9 +30,30 @@ public abstract class AbsStateProcessing {
         * @param expectedNumFields
         * @return
         */
-       protected Long getAFieldLong(LttngEvent trcEvent, LttngTraceState traceSt,
-                       Fields expectedField) {
+       protected Long getAFieldLong(LttngEvent trcEvent, LttngTraceState traceSt, Fields expectedField) {
                Long fieldVal = null;
+               
+        String fieldname = expectedField.getInName();
+               LttngEventField field = ((LttngEventContent) trcEvent.getContent()).getField(fieldname);
+               
+//             if ( field == null ) {
+//                 System.out.println("****************** JOIE : " + fieldname);
+//                 System.out.println("***************** CONTENT : " + ((LttngEventContent) trcEvent.getContent()).toString());
+//             }
+//             else {
+            Object fieldObj = field.getValue();
+            if ( (fieldObj instanceof Long) || (fieldObj instanceof Integer) ) {
+                // Expected numeric value found
+                fieldVal = (Long) field.getValue();
+            } 
+            else {
+                if (TraceDebug.isDEBUG()) {
+                    TraceDebug.debug("Unexpected field Type. Expected: Long, Received: "+ fieldObj.getClass().getSimpleName());
+                }
+            }
+//             }
+               
+               /*
                // TmfEventField[] fields = trcEvent.getContent().getFields();
                TmfEventField[] fields = ((LttngEventContent) trcEvent.getContent())
                                .getFields(trcEvent);
@@ -69,12 +90,13 @@ public abstract class AbsStateProcessing {
                                }
                        }
                }
+               */
        
-               if (fieldVal == null) {
-                       if (TraceDebug.isDEBUG()) {
-                               sendNoFieldFoundMsg(fields, expectedFieldName);
-                       }
-               }
+//             if (fieldVal == null) {
+//                     if (TraceDebug.isDEBUG()) {
+//                             sendNoFieldFoundMsg(((LttngEventContent) trcEvent.getContent()).getFields(), fieldname);
+//                     }
+//             }
                return fieldVal;
        }
 
@@ -90,6 +112,22 @@ public abstract class AbsStateProcessing {
        protected String getAFieldString(LttngEvent trcEvent,
                        LttngTraceState traceSt, Fields expectedField) {
                String fieldVal = null;
+               
+               String fieldname = expectedField.getInName();
+        LttngEventField field = ((LttngEventContent) trcEvent.getContent()).getField(fieldname);
+        
+        Object fieldObj = field.getValue();
+        if (fieldObj instanceof String) {
+            // Expected numeric value found
+            fieldVal = (String) field.getValue();
+        } 
+        else {
+            if (TraceDebug.isDEBUG()) {
+                TraceDebug.debug("Unexpected field Type. Expected: String, Received: "+ fieldObj.getClass().getSimpleName());
+            }
+        }
+               
+               /*
                // TmfEventField[] fields = trcEvent.getContent().getFields();
                TmfEventField[] fields = ((LttngEventContent) trcEvent.getContent())
                                .getFields(trcEvent);
@@ -123,12 +161,13 @@ public abstract class AbsStateProcessing {
                                }
                        }
                }
-       
-               if (fieldVal == null) {
-                       if (TraceDebug.isDEBUG()) {
-                               sendNoFieldFoundMsg(fields, expectedFieldName);
-                       }
-               }
+           */
+           
+//        if (fieldVal == null) {
+//            if (TraceDebug.isDEBUG()) {
+//                sendNoFieldFoundMsg(((LttngEventContent) trcEvent.getContent()).getFields(), fieldname);
+//            }
+//        }
                return fieldVal;
        }
 
@@ -157,7 +196,7 @@ public abstract class AbsStateProcessing {
                sb.append(" number of fields: " + fields.length + "Fields: ");
                for (int i = 0; i < fields.length; i++) {
                        field = (LttngEventField) fields[i];
-                       sb.append(field.getName() + " ");
+                       sb.append(field.getId() + " ");
                }
        
                TraceDebug.debug(sb.toString(), 5);
index f2a63403257e0391bc2ddd6833507369893b5f41..bf82ff2e75c05c9dfc5aa1eb4bef8e70f1ca6219 100644 (file)
@@ -45,8 +45,8 @@ public abstract class AbsStateUpdate extends AbsStateProcessing implements
                LttngExecutionState exe_state = new LttngExecutionState();
                exe_state.setExec_mode(execMode);
                exe_state.setExec_submode(submode);
-               exe_state.setEntry_Time(eventTime);
-               exe_state.setChange_Time(eventTime);
+               exe_state.setEntry_Time(eventTime.getValue());
+               exe_state.setChange_Time(eventTime.getValue());
                exe_state.setCum_cpu_time(0L);
                exe_state.setProc_status(process.getState().getProc_status());
                process.pushToExecutionStack(exe_state);
@@ -68,7 +68,7 @@ public abstract class AbsStateUpdate extends AbsStateProcessing implements
 
                //The process state is updated within the pop method
                process.popFromExecutionStack();
-               process.getState().setChange_Time(eventTime);
+               process.getState().setChange_Time(eventTime.getValue());
        }
 
        protected void irq_push_mode(LttngIRQState irqst, IRQMode state) {
@@ -217,7 +217,7 @@ public abstract class AbsStateUpdate extends AbsStateProcessing implements
                        Long cpu, Long pid, Long tgid, String name,
                        final TmfTimestamp timestamp) {
                LttngProcessState process;
-               process = new LttngProcessState(cpu, pid, tgid, name, timestamp, traceSt.getTraceId());
+               process = new LttngProcessState(cpu, pid, tgid, name, timestamp.getValue(), traceSt.getTraceId());
                traceSt.addProcessState(process);
                return process;
        }
index f5297cfb9d1a28173e85e4de6ecfdcd43c203f61..48292b86b6fa3af03d81382c577e152f4475f774 100644 (file)
@@ -902,16 +902,16 @@ class StateUpdateHandlers {
                                                        process.getState().setProc_status(
                                                                        ProcessStatus.LTTV_STATE_WAIT);
                                                        process.getState().setChange_Time(
-                                                                       trcEvent.getTimestamp());
+                                                                       trcEvent.getTimestamp().getValue());
                                                        process.getState().setEntry_Time(
-                                                                       trcEvent.getTimestamp());
+                                                                       trcEvent.getTimestamp().getValue());
                                                }
                                        } else {
                                                if (process.getState().getProc_status() == ProcessStatus.LTTV_STATE_EXIT) {
                                                        process.getState().setProc_status(
                                                                        ProcessStatus.LTTV_STATE_ZOMBIE);
                                                        process.getState().setChange_Time(
-                                                                       trcEvent.getTimestamp());
+                                                                       trcEvent.getTimestamp().getValue());
                                                } else {
                                                        if ((state_out != null)
                                                                        && (state_out.longValue() == 0L)) {
@@ -923,7 +923,7 @@ class StateUpdateHandlers {
                                                        }
 
                                                        process.getState().setChange_Time(
-                                                                       trcEvent.getTimestamp());
+                                                                       trcEvent.getTimestamp().getValue());
                                                }
 
                                                if ((state_out != null)
@@ -937,7 +937,7 @@ class StateUpdateHandlers {
                                                                process.getState().setProc_status(
                                                                                ProcessStatus.LTTV_STATE_DEAD);
                                                                process.getState().setChange_Time(
-                                                                               trcEvent.getTimestamp());
+                                                                               trcEvent.getTimestamp().getValue());
                                                        }
                                                }
                                        }
@@ -948,7 +948,7 @@ class StateUpdateHandlers {
                                traceSt.getRunning_process().put(cpu, process);
 
                                process.getState().setProc_status(ProcessStatus.LTTV_STATE_RUN);
-                               process.getState().setChange_Time(eventTime);
+                               process.getState().setChange_Time(eventTime.getValue());
                                process.setCpu(cpu);
                                // process->state->s = LTTV_STATE_RUN;
                                // if(process->usertrace)
@@ -1073,7 +1073,7 @@ class StateUpdateHandlers {
                                if (child_process == null) {
                                        child_process = create_process(traceSt, cpu, child_pid,
                                                        child_tgid, timeStamp);
-                                       child_process.setPpid(process.getPid(), timeStamp);
+                                       child_process.setPpid(process.getPid(), timeStamp.getValue());
                                } else {
                                        /*
                                         * The process has already been created : due to time
@@ -1452,8 +1452,8 @@ class StateUpdateHandlers {
                                                es
                                                                .setExec_submode(ExecutionSubMode.LTTV_STATE_SUBMODE_NONE
                                                                                .getInName());
-                                               es.setEntry_Time(timestamp);
-                                               es.setChange_Time(timestamp);
+                                               es.setEntry_Time(timestamp.getValue());
+                                               es.setChange_Time(timestamp.getValue());
                                                es.setCum_cpu_time(0L);
                                                if (es.getProc_status() == ProcessStatus.LTTV_STATE_UNNAMED) {
                                                        es.setProc_status(ProcessStatus.LTTV_STATE_WAIT);
@@ -1466,8 +1466,8 @@ class StateUpdateHandlers {
                                                es
                                                                .setExec_submode(ExecutionSubMode.LTTV_STATE_SUBMODE_NONE
                                                                                .getInName());
-                                               es.setEntry_Time(timestamp);
-                                               es.setChange_Time(timestamp);
+                                               es.setEntry_Time(timestamp.getValue());
+                                               es.setChange_Time(timestamp.getValue());
                                                es.setCum_cpu_time(0L);
                                                if (es.getProc_status() == ProcessStatus.LTTV_STATE_UNNAMED) {
                                                        es.setProc_status(ProcessStatus.LTTV_STATE_RUN);
@@ -1494,8 +1494,8 @@ class StateUpdateHandlers {
                                                        es
                                                                        .setExec_submode(ExecutionSubMode.LTTV_STATE_SUBMODE_NONE
                                                                                        .getInName());
-                                                       es.setEntry_Time(timestamp);
-                                                       es.setChange_Time(timestamp);
+                                                       es.setEntry_Time(timestamp.getValue());
+                                                       es.setChange_Time(timestamp.getValue());
                                                        es.setCum_cpu_time(0L);
                                                        es.setProc_status(ProcessStatus.LTTV_STATE_WAIT);
 
@@ -1534,13 +1534,14 @@ class StateUpdateHandlers {
                                Long tgid;
                                String command;
                                Long cpu = trcEvent.getCpuId();
+                               
                                LttngProcessState process = traceSt.getRunning_process().get(
                                                cpu);
                                LttngProcessState parent_process;
                                String type;
                                // String mode, submode, status;
                                LttngExecutionState es;
-
+                               
                                /* PID */
                                pid = getAFieldLong(trcEvent, traceSt, Fields.LTT_FIELD_PID);
 
@@ -1607,7 +1608,7 @@ class StateUpdateHandlers {
                                                process = create_process(traceSt, cpu, pid, tgid,
                                                                command, eventTime);
                                                if (parent_process != null) {
-                                                       process.setPpid(parent_process.getPid(), eventTime);
+                                                       process.setPpid(parent_process.getPid(), eventTime.getValue());
                                                }
 
                                                /* Keep the stack bottom : a running user mode */
index ee0b09418103cbe39a13d16622bbc6d20e43fb1b..4a19227466fc05c99c99cf1887305848497f856b 100644 (file)
@@ -12,7 +12,6 @@
 package org.eclipse.linuxtools.lttng.state.model;
 
 import org.eclipse.linuxtools.lttng.state.StateStrings;
-import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
 
 /**
  * <b><u>LttngExecutionState</u></b>
@@ -23,8 +22,8 @@ public class LttngExecutionState implements Cloneable {
        // ========================================================================
        // Data
        // =======================================================================
-       private TmfTimestamp entry_LttTime = null;
-       private TmfTimestamp change_LttTime = null;
+       private Long entry_LttTime = null;
+       private Long change_LttTime = null;
        private Long cum_cpu_time_Timens = null;
        
        private StateStrings.ProcessStatus proc_status = StateStrings.ProcessStatus.LTTV_STATE_UNNAMED;
@@ -48,16 +47,8 @@ public class LttngExecutionState implements Cloneable {
             // ProcessStatus and ExecutionMode are enum, and so shouldn't be a problem to use their reference
             newState.proc_status = this.proc_status;
             newState.exec_mode = this.exec_mode;
-            
-            // No clonable implemented in TMF, we will use copy constructor
-            // NOTE : we GOT to check for null to avoid crashing on null pointer here!
-            if ( this.entry_LttTime != null ) {
-                newState.entry_LttTime = new TmfTimestamp(this.entry_LttTime);
-            }
-            
-            if ( this.change_LttTime != null ) {
-                newState.change_LttTime = new TmfTimestamp(this.change_LttTime);
-            }
+            newState.entry_LttTime = this.entry_LttTime;
+            newState.change_LttTime = this.change_LttTime;
         }
         catch ( CloneNotSupportedException e ) {
             System.out.println("Cloning failed with : " + e.getMessage() );
@@ -72,7 +63,7 @@ public class LttngExecutionState implements Cloneable {
        /**
         * @return the entry_LttTime
         */
-       public TmfTimestamp getEntry_LttTime() {
+       public Long getEntry_LttTime() {
                return entry_LttTime;
        }
 
@@ -80,14 +71,14 @@ public class LttngExecutionState implements Cloneable {
         * @param entryLttTime
         *            the entry_LttTime to set
         */
-       public void setEntry_Time(TmfTimestamp entryLttTime) {
+       public void setEntry_Time(Long entryLttTime) {
                entry_LttTime = entryLttTime;
        }
 
        /**
         * @return the change_LttTime
         */
-       public TmfTimestamp getChange_LttTime() {
+       public Long getChange_LttTime() {
                return change_LttTime;
        }
 
@@ -95,7 +86,7 @@ public class LttngExecutionState implements Cloneable {
         * @param changeLttTime
         *            the change_LttTime to set
         */
-       public void setChange_Time(TmfTimestamp changeLttTime) {
+       public void setChange_Time(Long changeLttTime) {
                change_LttTime = changeLttTime;
        }
 
index d0a556ee85c5aa407149bdc917a2c8b99e22f9bb..63451594dead2038efb990a751698d7fe3aa4143 100644 (file)
@@ -18,7 +18,6 @@ import org.eclipse.linuxtools.lttng.state.StateStrings;
 import org.eclipse.linuxtools.lttng.state.StateStrings.ExecutionMode;
 import org.eclipse.linuxtools.lttng.state.StateStrings.ExecutionSubMode;
 import org.eclipse.linuxtools.lttng.state.StateStrings.ProcessStatus;
-import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
 
 /**
  * <b>LttngProcessState</b>
@@ -34,12 +33,12 @@ public class LttngProcessState implements Cloneable {
        private Long pid = null;
        private Long tgid = null;
        private String name = null;
-       private TmfTimestamp creation_time = null;
+       private Long creation_time = null;
        private String brand = null;
        private StateStrings.ProcessType type = null;
        private Long current_function = null;
        private Long ppid = null;
-       private TmfTimestamp insertion_time = null;
+       private Long insertion_time = null;
        private String pid_time = null;
        private Long free_events = null;
        private LttngExecutionState state = null; // top of stack
@@ -53,7 +52,7 @@ public class LttngProcessState implements Cloneable {
        // ========================================================================
        // Constructor
        // =======================================================================
-       public LttngProcessState(TmfTimestamp startTime) {
+       public LttngProcessState(Long startTime, String traceId) {
                this.cpu = 0L;
                this.pid = 0L;
                this.tgid = 0L;
@@ -64,7 +63,7 @@ public class LttngProcessState implements Cloneable {
        }
 
        public LttngProcessState(Long cpu, Long pid, Long tgid,
-                       String name, TmfTimestamp startTime, String traceId) {
+                       String name, Long startTime, String traceId) {
                this.cpu = cpu;
                this.pid = pid;
                this.tgid = tgid;
@@ -82,9 +81,7 @@ public class LttngProcessState implements Cloneable {
                this.type = StateStrings.ProcessType.LTTV_STATE_USER_THREAD;
                this.current_function = 0L;
                this.ppid = 0L;
-               // creation time defined when parent pid is known
-               // calling the setCreation_time method adjust the pid_time string
-               setCreation_time(new TmfTimestamp());
+               this.creation_time = 0L;
                this.free_events = 0L;
 
                // Initialise stack
@@ -138,16 +135,8 @@ public class LttngProcessState implements Cloneable {
             newState.userTrace = this.userTrace;
             newState.target_pid = this.target_pid;
             newState.trace_id = this.trace_id;
-            
-                       // No clonable implemented in TMF, we will use copy constructor
-            // NOTE : we GOT to check for null to avoid crashing on null pointer here!
-            if ( this.creation_time != null ) {
-                newState.creation_time = new TmfTimestamp(this.creation_time);
-            }
-            
-            if ( this.creation_time != null ) {
-                newState.insertion_time = new TmfTimestamp(this.insertion_time);
-            }
+            newState.creation_time = this.creation_time;
+            newState.insertion_time = this.insertion_time;
             
             // Call clone on our own object is safe as Long it implements Clonable
             newState.state = (LttngExecutionState)this.state.clone();
@@ -242,7 +231,7 @@ public class LttngProcessState implements Cloneable {
         * @param ppid
         *            the ppid to set
         */
-       public void setPpid(Long ppid, TmfTimestamp creationTime) {
+       public void setPpid(Long ppid, Long creationTime) {
                if (ppid != null) {
                        this.ppid = ppid;
                }
@@ -255,7 +244,7 @@ public class LttngProcessState implements Cloneable {
        /**
         * @return the creation_time
         */
-       public TmfTimestamp getCreation_time() {
+       public Long getCreation_time() {
                return creation_time;
        }
 
@@ -263,7 +252,7 @@ public class LttngProcessState implements Cloneable {
         * @param creationTime
         *            the creation_time to set
         */
-       public void setCreation_time(TmfTimestamp creationTime) {
+       public void setCreation_time(Long creationTime) {
                if ( (creationTime != null) && (pid != null) ) {
                        creation_time = creationTime;
                        StringBuilder sb = new StringBuilder(this.pid.toString() + "-"
@@ -275,7 +264,7 @@ public class LttngProcessState implements Cloneable {
        /**
         * @return the insertion_time
         */
-       public TmfTimestamp getInsertion_time() {
+       public Long getInsertion_time() {
                return insertion_time;
        }
 
@@ -283,7 +272,7 @@ public class LttngProcessState implements Cloneable {
         * @param insertionTime
         *            the insertion_time to set
         */
-       public void setInsertion_time(TmfTimestamp insertionTime) {
+       public void setInsertion_time(Long insertionTime) {
                insertion_time = insertionTime;
        }
 
index ca2cece64087ef859f27009eeab143d62affc3fa..4d0ff321e55c80e8afa8ebcb8a3c1eedbfc57dd0 100644 (file)
@@ -23,7 +23,6 @@ import org.eclipse.linuxtools.lttng.state.StateStrings.ExecutionSubMode;
 import org.eclipse.linuxtools.lttng.state.StateStrings.IRQMode;
 import org.eclipse.linuxtools.lttng.state.StateStrings.ProcessStatus;
 import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
 
 /**
  * <b><u>LttngTraceState</u></b>
@@ -41,7 +40,7 @@ public class LttngTraceState implements Cloneable {
     
        private Long save_interval = null;
 
-       private TmfTimestamp max_time_state_recomputed_in_seek = null;
+       private Long max_time_state_recomputed_in_seek = null;
        private boolean has_precomputed_states = false;
 
        private HashMap<ProcessStateKey, LttngProcessState> processes = new HashMap<ProcessStateKey, LttngProcessState>();
@@ -121,14 +120,7 @@ public class LttngTraceState implements Cloneable {
                        // Basic value only need to be assigned while cloning
                        newState.has_precomputed_states = this.has_precomputed_states;
                        newState.nb_events = this.nb_events;
-
-                       // No clonable implemented in TMF, we will use copy constructor
-                       // NOTE : we GOT to check for null to avoid crashing on null pointer
-                       // here!
-                       if (this.max_time_state_recomputed_in_seek != null) {
-                               newState.max_time_state_recomputed_in_seek = new TmfTimestamp(
-                                               this.max_time_state_recomputed_in_seek);
-                       }
+                       newState.max_time_state_recomputed_in_seek = this.max_time_state_recomputed_in_seek;
 
                        // Clone should work correctly for all stack object that contain
                        // basic java object (String, Long, etc...)
@@ -228,7 +220,7 @@ public class LttngTraceState implements Cloneable {
                traceId = inputDataRef.getTraceId();
 
                // max time
-               setMax_time_state_recomputed_in_seek(new TmfTimestamp());
+               max_time_state_recomputed_in_seek = 0L;
 
                // reset cpu_states
                cpu_states.clear();
@@ -260,13 +252,7 @@ public class LttngTraceState implements Cloneable {
 
                // bdev states
                bdev_states.clear();
-
-               // JniTrace State
-               init_state(numCpus);
-
-       }
-
-       public void init_state(int numCpus) {
+               
                processes.clear();
 
                nb_events = 0;
@@ -274,8 +260,7 @@ public class LttngTraceState implements Cloneable {
 
                /* Put the per cpu running_process to beginning state : process 0. */
                for (Long i = 0L; i < numCpus; i++) {
-                       LttngProcessState process = new LttngProcessState(timeWin
-                                       .getStartTime());
+                       LttngProcessState process = new LttngProcessState(timeWin.getStartTime().getValue(), traceId );
 
                        /*
                         * We are not sure is it's a kernel thread or normal thread, put the
@@ -353,12 +338,12 @@ public class LttngTraceState implements Cloneable {
                return inputDataRef;
        }
 
-       public TmfTimestamp getMax_time_state_recomputed_in_seek() {
+       public Long getMax_time_state_recomputed_in_seek() {
                return max_time_state_recomputed_in_seek;
        }
 
        public void setMax_time_state_recomputed_in_seek(
-                       TmfTimestamp maxTimeStateRecomputedInSeek) {
+                       Long maxTimeStateRecomputedInSeek) {
                max_time_state_recomputed_in_seek = maxTimeStateRecomputedInSeek;
        }
 
index 583e8f7aeb7a83dd72f678e1bea1abd015a1bd57..1a9031e2f6d57a461cfedcd5b83d09b4b9f84575 100644 (file)
 
 package org.eclipse.linuxtools.lttng.trace;
 
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Vector;
+
 import org.eclipse.linuxtools.lttng.LttngException;
 import org.eclipse.linuxtools.lttng.event.LttngEvent;
 import org.eclipse.linuxtools.lttng.event.LttngEventContent;
-import org.eclipse.linuxtools.lttng.event.LttngEventField;
-import org.eclipse.linuxtools.lttng.event.LttngEventFormat;
 import org.eclipse.linuxtools.lttng.event.LttngEventReference;
+import org.eclipse.linuxtools.lttng.event.LttngEventSource;
 import org.eclipse.linuxtools.lttng.event.LttngEventType;
 import org.eclipse.linuxtools.lttng.event.LttngTimestamp;
 import org.eclipse.linuxtools.lttng.jni.JniEvent;
+import org.eclipse.linuxtools.lttng.jni.JniMarker;
 import org.eclipse.linuxtools.lttng.jni.JniTime;
 import org.eclipse.linuxtools.lttng.jni.JniTrace;
-import org.eclipse.linuxtools.tmf.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.event.TmfEventSource;
+import org.eclipse.linuxtools.lttng.jni.JniTracefile;
 import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
 import org.eclipse.linuxtools.tmf.trace.TmfTrace;
@@ -46,24 +49,35 @@ class LTTngTraceException extends LttngException {
  * (seeking, reading and parsing) through the JNI component.
  */
 public class LTTngTrace extends TmfTrace {
-
-       private final static boolean IS_PARSING_NEEDED_DEFAULT = true;
-       private final static int     CHECKPOINT_PAGE_SIZE = 1000;
-       
-    // Reference to the current LttngEvent
-    private LttngEvent currentLttngEvent = null;
+    private final static boolean SHOW_LTT_DEBUG_DEFAULT = false;
+       private final static boolean IS_PARSING_NEEDED_DEFAULT = false;
+       private final static int     CHECKPOINT_PAGE_SIZE      = 1;
     
     // Reference to our JNI trace
     private JniTrace currentJniTrace = null;
     
+    // *** HACK ***
+    // To save time, we will declare all component of the LttngEvent during the construction of the trace
+    //  Then, while reading the trace, we will just SET the values instead of declaring new object
+    LttngTimestamp                  eventTimestamp   = null;
+    LttngEventSource                eventSource      = null;
+    LttngEventType                  eventType        = null;
+    LttngEventContent               eventContent     = null;
+    LttngEventReference             eventReference   = null;
+    // The actual event
+    LttngEvent                      currentLttngEvent = null;             
+    
+    // Hashmap of the possible types of events (Tracefile/CPU/Marker in the JNI)
+    HashMap<String, LttngEventType> traceTypes       = null;
+    // This vector will be used to quickly find a marker name from a position 
+    Vector<String>                  traceTypeNames   = null;
+    
     /**
      * Default Constructor.<p>
      * 
      * @param path  Path to a <b>directory</b> that contain an LTTng trace.
      * 
      * @exception Exception (most likely LTTngTraceException or FileNotFoundException)
-     * 
-     * @see org.eclipse.linuxtools.lttng.jni.JniTrace
      */
     public LTTngTrace(String path) throws Exception {
         // Call with "wait for completion" true and "skip indexing" false
@@ -77,11 +91,9 @@ public class LTTngTrace extends TmfTrace {
      * @param waitForCompletion     Should we wait for indexign to complete before moving on.
      * 
      * @exception Exception (most likely LTTngTraceException or FileNotFoundException)
-     * 
-     * @see org.eclipse.linuxtools.lttng.jni.JniTrace
      */
     public LTTngTrace(String path, boolean waitForCompletion) throws Exception {
-     // Call with "skip indexing" false
+        // Call with "skip indexing" false
         this(path, waitForCompletion, false);
     }
     
@@ -94,19 +106,39 @@ public class LTTngTrace extends TmfTrace {
      * 
      * @exception Exception (most likely LTTngTraceException or FileNotFoundException)
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.JniTrace
      */
     public LTTngTrace(String path, boolean waitForCompletion, boolean bypassIndexing) throws Exception {
         super(path, CHECKPOINT_PAGE_SIZE, true);
         try {
-               currentJniTrace = new JniTrace(path);
+               currentJniTrace = new JniTrace(path, SHOW_LTT_DEBUG_DEFAULT);
         }
         catch (Exception e) {
             throw new LTTngTraceException(e.getMessage());
         }
-        TmfTimestamp startTime = new LttngTimestamp(currentJniTrace.getStartTimeFromTimestampCurrentCounter().getTime());
+        
+        // Set the start time of the trace
+        LttngTimestamp startTime = new LttngTimestamp(currentJniTrace.getStartTimeFromTimestampCurrentCounter().getTime());
         setTimeRange(new TmfTimeRange(startTime, startTime));
         
+        // Export all the event types from the JNI side 
+        traceTypes      = new HashMap<String, LttngEventType>();
+        traceTypeNames  = new Vector<String>();
+        initialiseEventTypes(currentJniTrace);
+        
+        // *** VERIFY ***
+        // Verify that all those "default constructor" are safe to use
+        eventTimestamp        = new LttngTimestamp();
+        eventSource           = new LttngEventSource();
+        eventType             = new LttngEventType();
+        eventContent          = new LttngEventContent(currentLttngEvent);
+        eventReference        = new LttngEventReference(this.getName());
+        
+        // Create the skeleton event
+        currentLttngEvent = new LttngEvent(eventTimestamp, eventSource, eventType, eventContent, eventReference, null);
+        
+        // Set the currentEvent to the eventContent
+        eventContent.setEvent(currentLttngEvent);
+        
         // Bypass indexing if asked
         if ( bypassIndexing == false ) {
             indexStream();
@@ -125,19 +157,70 @@ public class LTTngTrace extends TmfTrace {
        throw new Exception("Copy constructor should never be use with a LTTngTrace!");
     }
     
+    /*
+     * Fill out the HashMap with "Type" (Tracefile/Marker)
+     * 
+     * This should be called at construction once the trace is open
+     */
+    private void initialiseEventTypes(JniTrace trace) {
+        // Work variables
+        LttngEventType  tmpType             = null;
+        String[]        markerFieldsLabels  = null;
+        
+        String          newTracefileKey     = null;
+        Integer         newMarkerKey        = null;
+        
+        JniTracefile    newTracefile    = null;
+        JniMarker       newMarker       = null;
+        
+        // First, obtain an iterator on TRACEFILES of owned by the TRACE
+        Iterator<String>    tracefileItr = trace.getTracefilesMap().keySet().iterator();
+        while ( tracefileItr.hasNext() ) {
+            newTracefileKey = tracefileItr.next();
+            newTracefile    = trace.getTracefilesMap().get(newTracefileKey);
+            
+            // From the TRACEFILE read, obtain its MARKER
+            Iterator<Integer> markerItr = newTracefile.getTracefileMarkersMap().keySet().iterator();
+            while ( markerItr.hasNext() ) {
+                newMarkerKey = markerItr.next();
+                newMarker = newTracefile.getTracefileMarkersMap().get(newMarkerKey);
+                
+                // From the MARKER we can obtain the MARKERFIELDS keys (i.e. labels)
+                markerFieldsLabels = newMarker.getMarkerFieldsHashMap().keySet().toArray( new String[newMarker.getMarkerFieldsHashMap().size()] );
+                tmpType = new LttngEventType(newTracefile.getTracefileName(), newTracefile.getCpuNumber(), newMarker.getName(), markerFieldsLabels );
+                
+                // Add the type to the map/vector
+                addEventTypeToMap(tmpType);
+            }
+        }
+    }
+    
+    /*
+     * Add a new type to the HashMap
+     * 
+     * As the hashmap use a key format that is a bit dangerous to use, we should always add using this function.
+     */
+    private void addEventTypeToMap(LttngEventType newEventType) {
+        String newTypeKey = EventTypeKey.getEventTypeKey(newEventType);
+        
+        this.traceTypes.put(newTypeKey, newEventType);
+        this.traceTypeNames.add(newTypeKey);
+    }
+    
     /** 
-     * Parse the next event in the trace.<p>
+     * Return the next event in the trace.<p>
      * 
      * @param context   The actual context of the trace
      * 
-     * @return The parsed event, or null if none available
+     * @return The next event, or null if none available
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.JniTrace
+     * @see org.eclipse.linuxtools.lttng.event.LttngEvent
      */ 
     @Override
-       public TmfEvent parseEvent(TmfTraceContext context) {
+       public LttngEvent parseEvent(TmfTraceContext context) {
                JniEvent jniEvent;
                LttngTimestamp timestamp = null;
+               LttngEvent returnedEvent = null;
                
        synchronized (currentJniTrace) {
            // Seek to the context's location
@@ -145,7 +228,12 @@ public class LTTngTrace extends TmfTrace {
                
                // Read an event from the JNI and convert it into a LttngEvent
                jniEvent = currentJniTrace.readNextEvent();
-               currentLttngEvent = (jniEvent != null) ? convertJniEventToTmf(jniEvent, true) : null;
+               
+               //currentLttngEvent = (jniEvent != null) ? convertJniEventToTmf(jniEvent, true) : null;
+               if ( jniEvent != null ) {
+                   currentLttngEvent = convertJniEventToTmf(jniEvent);
+                   returnedEvent = currentLttngEvent;
+               }
                
                // Save timestamp
                timestamp = (LttngTimestamp) getCurrentLocation();
@@ -153,8 +241,8 @@ public class LTTngTrace extends TmfTrace {
                context.setLocation(timestamp);
                context.setTimestamp(timestamp);
                context.incrIndex();
-
-               return currentLttngEvent;
+               
+               return returnedEvent;
     }
     
     /**
@@ -165,66 +253,58 @@ public class LTTngTrace extends TmfTrace {
      * 
      * @param   newEvent     The JniEvent to convert into LttngEvent
      * 
-     * @return  The converted event
+     * @return  The converted LttngEvent
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+     * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent
+     * @see org.eclipse.linuxtools.lttng.event.LttngEvent
      */
        public LttngEvent convertJniEventToTmf(JniEvent newEvent) {
-       LttngEvent event = null;
-       if (newEvent != null)
-               event = convertJniEventToTmf(newEvent, IS_PARSING_NEEDED_DEFAULT);
-       return event;
+           currentLttngEvent = convertJniEventToTmf(newEvent, IS_PARSING_NEEDED_DEFAULT);
+           
+           return currentLttngEvent;
     }
     
     /**
-     * Method tp convert a JniEvent into a LttngEvent
+     * Method to convert a JniEvent into a LttngEvent
      * 
      * @param   jniEvent        The JniEvent to convert into LttngEvent
      * @param   isParsingNeeded A boolean value telling if the event should be parsed or not.
      * 
-     * @return  The converted event
+     * @return  The converted LttngEvent
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+     * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent
+     * @see org.eclipse.linuxtools.lttng.event.LttngEvent
      */
     public LttngEvent convertJniEventToTmf(JniEvent jniEvent, boolean isParsingNeeded) {
-       
-       // *** FIXME ***
-       // Format seems weird to me... we need to revisit Format/Fields/Content to find a better ways
-       //
-       // Generate fields
-       String[] labels = new String[jniEvent.requestEventMarker().getMarkerFieldsHashMap().size()];
-       labels = jniEvent.requestEventMarker().getMarkerFieldsHashMap().keySet().toArray( labels );
-       
-       // We need a format for content and fields
-        LttngEventFormat eventFormat = new LttngEventFormat(labels);
-        String content = "";
-        LttngEventField[] fields = null;
-
-        if (isParsingNeeded == true) {
-            fields = eventFormat.parse(jniEvent.parseAllFields());
-            for (int y = 0; y < fields.length; y++) {
-                content += fields[y].toString() + " ";
-            }
-        }
+        // *** HACK *** 
+        // To save time here, we only set value instead of allocating new object
+        // This give an HUGE performance improvement
+        // all allocation done in the LttngTrace constructor
         
-        LttngEvent event = null;
-        try {
-               event = new LttngEvent(
-                                       new LttngTimestamp(jniEvent.getEventTime().getTime()),
-                                       new TmfEventSource(jniEvent.requestEventSource() ), 
-                                       new LttngEventType(jniEvent.getParentTracefile().getTracefileName(),
-                                              jniEvent.getParentTracefile().getCpuNumber(),
-                                              jniEvent.requestEventMarker().getName(),
-                                              eventFormat),
-                           new LttngEventContent(eventFormat, content, fields), 
-                           new LttngEventReference(jniEvent.getParentTracefile().getTracefilePath(), this.getName()),
-                           jniEvent);
-        }
-        catch (LttngException e) {
-               System.out.println("ERROR : Event creation returned :" + e.getMessage() );
+        eventTimestamp.setValue(jniEvent.getEventTime().getTime());
+        eventSource.setSourceId(jniEvent.requestEventSource());
+        
+        eventType = traceTypes.get( EventTypeKey.getEventTypeKey(jniEvent) );
+        
+        eventReference.setValue(jniEvent.getParentTracefile().getTracefilePath());
+        eventReference.setTracepath(this.getName());
+        
+//        eventContent.setEvent(currentLttngEvent);
+//        eventContent.setType(eventType);
+        eventContent.emptyContent();
+        
+//        currentLttngEvent.setContent(eventContent);
+        currentLttngEvent.setType(eventType);
+        // Save the jni reference
+        currentLttngEvent.setJniEventReference(jniEvent);
+        
+        // Parse now if was asked
+        // Warning : THIS IS SLOW
+        if (isParsingNeeded == true ) {
+            eventContent.getFields();
         }
         
-        return event;
+        return currentLttngEvent;
     }
     
     /**
@@ -294,7 +374,7 @@ public class LTTngTrace extends TmfTrace {
      * 
      * @return Reference to the current LttngTrace 
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.JniTrace
+     * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniTrace
      */
     public JniTrace getCurrentJniTrace() {
         return currentJniTrace;
@@ -323,5 +403,29 @@ public class LTTngTrace extends TmfTrace {
        
        return returnedData;
     }
+}
+
+/*
+ * EventTypeKey inner class
+ * 
+ * This class is used to make the process of generating the HashMap key more transparent and so less error prone to use
+ * 
+ */
+class EventTypeKey {
+    //*** WARNING ***
+    // These two getEventTypeKey() functions should ALWAYS construct the key the same ways! 
+    // Otherwise, every type search will fail!
+    
+    static public String getEventTypeKey(LttngEventType newEventType) {
+        String key = newEventType.getTracefileName() + "/" + newEventType.getCpuId().toString() + "/" + newEventType.getMarkerName();
+        
+        return key;
+    }
     
-}
\ No newline at end of file
+    static public String getEventTypeKey(JniEvent newEvent) {
+        String key = newEvent.getParentTracefile().getTracefileName() + "/" + newEvent.getParentTracefile().getCpuNumber() + "/" + newEvent.requestEventMarker().getName();
+        
+        return key;
+    }
+    
+}
index ff905a6e93badfb7d1b3e0319af750e3a5230fe2..703cff9331186728215531e2289e4d452ab9cbaa 100644 (file)
@@ -1,9 +1,9 @@
 Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
-Bundle-Name: Test
+Bundle-Name: TMF Unit Test Suite
 Bundle-SymbolicName: org.eclipse.linuxtools.tmf.tests
-Bundle-Version: 0.0.1
+Bundle-Version: 0.1.0.qualifier
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Bundle-Vendor: Eclipse
-Require-Bundle: org.junit4;bundle-version="4.5.0",
+Require-Bundle: org.junit;bundle-version="3.8.2",
  org.eclipse.linuxtools.tmf;bundle-version="0.0.1"
diff --git a/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/AllEventTests.java b/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/AllEventTests.java
deleted file mode 100644 (file)
index 373579f..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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:
- *   Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.event;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
-    TmfTimestampTest.class,
-    TmfTimeRangeTest.class,
-    TmfEventTypeTest.class,
-    TmfEventFormatTest.class,
-    TmfEventContentTest.class,
-    TmfEventTest.class,
-    TmfTraceEventTest.class
-})
-
-public class AllEventTests {
-
-}
diff --git a/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/AllTests.java b/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/AllTests.java
new file mode 100644 (file)
index 0000000..307d3d9
--- /dev/null
@@ -0,0 +1,24 @@
+package org.eclipse.linuxtools.tmf.event;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+       public static Test suite() {
+               TestSuite suite = new TestSuite(AllTests.class.getName());
+               //$JUnit-BEGIN$
+               suite.addTestSuite(TmfEventFieldTest.class);
+               suite.addTestSuite(TmfEventContentTest.class);
+               suite.addTestSuite(TmfEventTypeTest.class);
+               suite.addTestSuite(TmfEventSourceTest.class);
+               suite.addTestSuite(TmfTraceEventTest.class);
+               suite.addTestSuite(TmfEventReferenceTest.class);
+               suite.addTestSuite(TmfTimestampTest.class);
+               suite.addTestSuite(TmfTimeRangeTest.class);
+               suite.addTestSuite(TmfEventTest.class);
+               //$JUnit-END$
+               return suite;
+       }
+
+}
index 4e36cd7137a04568b26752dfa1a1537f9584c3ff..60ffe558ff16e5f24dfd6796e7b08dcfafc25ab9 100644 (file)
 
 package org.eclipse.linuxtools.tmf.event;
 
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
+import junit.framework.TestCase;
 
 /**
  * <b><u>TmfEventContentTest</u></b>
  * <p>
- * JUnit test suite for the TmfEventContent class.
+ * TODO: Implement me. Please.
  */
-public class TmfEventContentTest {
+public class TmfEventContentTest extends TestCase {
+
+       private final TmfTimestamp      fTimestamp;
+       private final TmfEventSource    fEventSource;
+       private final TmfEventType      fEventType;
+       private final TmfEventTypeStub  fEventTypeStub;
+       private final TmfEventReference fReference;
+       private final TmfEvent          fEvent;
+       private final TmfEvent          fEventStub;
+
+       private final Object fRawContent = new String("Some content");
+
+       private final TmfEventContent     fBasicContent;
+       private final TmfEventContentStub fStubContent;
+
+       /**
+        * @param name
+        */
+       public TmfEventContentTest(String name) {
+               super(name);
+               fTimestamp     = new TmfTimestamp();
+               fEventSource   = new TmfEventSource();
+               fEventType     = new TmfEventType();
+               fEventTypeStub = new TmfEventTypeStub();
+               fReference     = new TmfEventReference();
+
+               fEvent        = new TmfEvent(fTimestamp, fEventSource, fEventType, fReference);
+               fBasicContent = new TmfEventContent(fEvent, fRawContent);
+
+               fEventStub    = new TmfEvent(fTimestamp, fEventSource, fEventTypeStub, fReference);
+               fStubContent  = new TmfEventContentStub(fEventStub, fRawContent);
+       }
+
+       @Override
+       protected void setUp() throws Exception {
+               super.setUp();
+       }
+
+       @Override
+       protected void tearDown() throws Exception {
+               super.tearDown();
+       }
 
        // ========================================================================
        // Constructors
        // ========================================================================
 
-       @Test
        public void testTmfEventContent() {
-               TmfEventContent content = new TmfEventContent("Some content", new TmfEventFormat());
-               assertEquals("getFormat", 1, content.getFormat().getLabels().length);
-               assertEquals("getLabels", "Content", content.getFormat().getLabels()[0]);
-               assertEquals("getContent", "Some content", content.getContent());
+               assertSame("getLabels",  fEvent,      fBasicContent.getEvent());
+               assertSame("getType",    fEventType,  fBasicContent.getType());
+               assertSame("getContent", fRawContent, fBasicContent.getContent());
+       }
+
+       public void testTmfEventContentCopy() {
+               TmfEventContent content  = new TmfEventContent(fBasicContent);
+               assertSame("getLabels",  fEvent,      content.getEvent());
+               assertSame("getType",    fEventType,  content.getType());
+               assertSame("getContent", fRawContent, content.getContent());
+       }
+
+       public void testCloneShallowCopy() {
+               TmfEventContent content  = fBasicContent.clone();
+               assertSame("getLabels",  fEvent,      content.getEvent());
+               assertSame("getType",    fEventType,  content.getType());
+               assertSame("getContent", fRawContent, content.getContent());
+       }
+
+       public void testCloneDeepCopy() {
+               TmfEventContent content  = fStubContent.clone();
+               assertSame   ("getEvent",   fEventStub,     content.getEvent());
+               assertSame   ("getType",    fEventTypeStub, content.getType());
+               assertNotSame("getContent", fRawContent,    content.getContent());
+               assertEquals ("getContent", fRawContent,    content.getContent());
+       }
+
+       // ========================================================================
+       // Basic content parsing
+       // ========================================================================
+
+       public void testGetFields() {
+               Object[] fields = fBasicContent.getFields(); 
+               assertEquals("getFields", 1, fields.length);
+               assertEquals("getFields", fRawContent, fields[0].toString());
+       }
+
+       public void testGetFieldFromId() {
+               Object field;
+               try {
+                       field = fBasicContent.getField("Content");
+                       assertEquals("getField", fRawContent, field.toString());
+               } catch (TmfNoSuchFieldException e) {
+                       fail("Field not found");
+               } 
+       }
+
+       public void testGetFieldFromIdFailed() {
+               try {
+                       fBasicContent.getField("Dummy");
+                       fail("Found an inexisting field...");
+               } catch (TmfNoSuchFieldException e) {
+                       // Success
+               } 
+       }
+
+       public void testGetFieldFromPos() {
+               Object field = fBasicContent.getField(0);
+               assertEquals("getField", fRawContent, field.toString());
        }
 
        // ========================================================================
-       // getField
+       // Standard content parsing
        // ========================================================================
 
-       @Test
-       public void testBasicGetField() {
-               TmfEventContent content = new TmfEventContent("Some content", new TmfEventFormat());
-               assertEquals("getField", 1, content.getFields().length);
-               assertEquals("getField", "Some content", content.getField(0).toString());
+       public void testGetFields2() {
+               Object[] fields = fStubContent.getFields(); 
+               assertEquals("getFields", 5, fields.length);
        }
 
-       @Test
-       public void testExtendedGetField() {
-               TmfEventContent content = new TmfEventContent("", new TmfEventFormatStub());
-               assertEquals("getField", 5, content.getFields().length);
-               assertEquals("getField", "1", content.getField(0).toString());
-               assertEquals("getField", "-10", content.getField(1).toString());
-               assertEquals("getField", "true", content.getField(2).toString());
-               assertEquals("getField", "some string", content.getField(3).toString());
-               assertEquals("getField", "[TmfTimestamp:1,2,3]", content.getField(4).toString());
+       public void testGetFieldFromId2() {
+               Object field;
+               try {
+                       field = fStubContent.getField("Field1");
+                       assertEquals("getField", new Integer(1), field);
+
+                       field = fStubContent.getField("Field2");
+                       assertEquals("getField", new Integer(-10), field);
+
+                       field = fStubContent.getField("Field3");
+                       assertEquals("getField", new Boolean(true), field);
+
+                       field = fStubContent.getField("Field4");
+                       assertEquals("getField", new String("some string"), field);
+
+                       field = fStubContent.getField("Field5");
+                       assertEquals("getField", new TmfTimestamp(1, (byte) 2, 3), field);
+
+               } catch (TmfNoSuchFieldException e) {
+                       fail("Field not found");
+               } 
+       }
+
+       public void testGetFieldFromPos2() {
+               TmfEventContentStub content = new TmfEventContentStub(fEvent, fRawContent);
+
+               Object field = content.getField(0);
+               assertEquals("getField", new Integer(1), field);
+
+               field = content.getField(1);
+               assertEquals("getField", new Integer(-10), field);
+
+               field = content.getField(2);
+               assertEquals("getField", new Boolean(true), field);
+
+               field = content.getField(3);
+               assertEquals("getField", new String("some string"), field);
+
+               field = content.getField(4);
+               assertEquals("getField", new TmfTimestamp(1, (byte) 2, 3), field);
+       }
+
+       // ========================================================================
+       // Operators
+       // ========================================================================
+
+       public void testToString() {
+               String expected = "[TmfEventContent(" + fRawContent + ",)]";
+               TmfEventContent content = new TmfEventContent(fEvent, fRawContent);
+               assertEquals("toString", expected, content.toString());
        }
 
 }
diff --git a/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfEventFieldTest.java b/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfEventFieldTest.java
new file mode 100644 (file)
index 0000000..a94faca
--- /dev/null
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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:
+ *   Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.event;
+
+import junit.framework.TestCase;
+
+/**
+ * <b><u>TmfEventFieldTest</u></b>
+ * <p>
+ * TODO: Implement me. Please.
+ */
+public class TmfEventFieldTest extends TestCase {
+
+       private final TmfEventContent fContent;
+       private final String fFieldId = "Field";
+       private final Object fValue1  = new String("Value"); 
+       private final Object fValue2  = new Integer(10); 
+
+       // ========================================================================
+       // Housekeeping
+       // ========================================================================
+
+       public TmfEventFieldTest(String name) {
+               super(name);
+               TmfTimestamp      fTimestamp   = new TmfTimestamp();
+               TmfEventSource    fEventSource = new TmfEventSource();
+               TmfEventType      fEventType   = new TmfEventTypeStub();
+               TmfEventReference fReference   = new TmfEventReference();
+               TmfEvent          fEvent       = new TmfEvent(fTimestamp, fEventSource, fEventType, fReference);
+
+               fContent = new TmfEventContent(fEvent, "Some content");
+       }
+
+       @Override
+       protected void setUp() throws Exception {
+               super.setUp();
+       }
+
+       @Override
+       protected void tearDown() throws Exception {
+               super.tearDown();
+       }
+
+       // ========================================================================
+       // Constructors
+       // ========================================================================
+
+       public void testTmfEventField() {
+               TmfEventField field = new TmfEventField(fContent, fFieldId, fValue1);
+               assertSame("getParent", fContent, field.getParent());
+               assertSame("getId",     fFieldId, field.getId());
+               assertSame("getValue",  fValue1,  field.getValue());
+       }
+
+       public void testTmfEventFieldCopy() {
+               TmfEventField original = new TmfEventField(fContent, fFieldId, fValue1);
+               TmfEventField field = new TmfEventField(original);
+               assertSame("getParent", fContent, field.getParent());
+               assertSame("getId",     fFieldId, field.getId());
+               assertSame("getValue",  fValue1,  field.getValue());
+       }
+
+       public void testCloneShallowCopy() {
+               TmfEventField original = new TmfEventField(fContent, fFieldId, fValue1);
+               TmfEventField field = original.clone();
+               assertSame("getParent", fContent, field.getParent());
+               assertSame("getId",     fFieldId, field.getId());
+               assertSame("getValue",  fValue1,  field.getValue());
+       }
+
+//     public void testCloneDeepCopy() {
+//             TmfEventField original = new TmfEventField(fContent, fFieldId, fValue1);
+//             TmfEventField field = original.clone();
+//             assertNotSame("getParent", fContent, field.getParent());
+//             assertNotSame("getId",     fFieldId, field.getId());
+//             assertNotSame("getValue",  fValue1,  field.getValue());
+//             assertEquals ("getParent", fContent, field.getParent());
+//             assertEquals ("getId",     fFieldId, field.getId());
+//             assertEquals ("getValue",  fValue1,  field.getValue());
+//     }
+
+       // ========================================================================
+       // Operators
+       // ========================================================================
+
+       public void testToString() {
+               String expected1 = "[TmfEventField(" + fFieldId + ":" + fValue1.toString() + ")]";
+               TmfEventField field = new TmfEventField(fContent, fFieldId, fValue1);
+               assertEquals("toString", expected1, field.toString());
+
+               String expected2 = "[TmfEventField(" + fFieldId + ":" + fValue2.toString() + ")]";
+               field = new TmfEventField(fContent, fFieldId, fValue2);
+               assertEquals("toString", expected2, field.toString());
+       }
+
+}
diff --git a/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfEventFormatTest.java b/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfEventFormatTest.java
deleted file mode 100644 (file)
index 6c89085..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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:
- *   Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.event;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-/**
- * <b><u>TmfEventFormatTest</u></b>
- * <p>
- * JUnit test suite for the TmfEventFormat class.
- */
-public class TmfEventFormatTest {
-
-    // ========================================================================
-    // Constructors
-    // ========================================================================
-
-    @Test
-    public void testBasicTmfEventFormat() {
-        TmfEventFormat format = new TmfEventFormat();
-        assertEquals("getLabels", 1, format.getLabels().length);
-        assertEquals("getValue", "Content", format.getLabels()[0]);
-    }
-
-    @Test
-    public void testEmptyConstructor() {
-        TmfEventFormat format = new TmfEventFormat(new String[] {});
-        assertEquals("getLabels", 0, format.getLabels().length);
-    }
-
-    @Test
-    public void testNormalConstructor() {
-        TmfEventFormat format = new TmfEventFormat(new String[] { "field1", "field2", "field3" });
-        assertEquals("getLabels", 3, format.getLabels().length);
-        assertEquals("getLabels", "field1", format.getLabels()[0]);
-        assertEquals("getLabels", "field2", format.getLabels()[1]);
-        assertEquals("getLabels", "field3", format.getLabels()[2]);
-    }
-
-    @Test
-    public void testExtendedConstructor() {
-        TmfEventFormatStub format = new TmfEventFormatStub();
-        assertEquals("getLabels", 5, format.getLabels().length);
-        assertEquals("getLabels", "Field1", format.getLabels()[0]);
-        assertEquals("getLabels", "Field2", format.getLabels()[1]);
-        assertEquals("getLabels", "Field3", format.getLabels()[2]);
-        assertEquals("getLabels", "Field4", format.getLabels()[3]);
-        assertEquals("getLabels", "Field5", format.getLabels()[4]);
-    }
-
-    // ========================================================================
-    // parse
-    // ========================================================================
-
-    @Test
-    public void testBasicParse() {
-        TmfEventFormat format = new TmfEventFormat();
-        TmfEventField[] content = format.parse(new TmfTimestamp());
-        assertEquals("length", 1, content.length);
-        assertEquals("getValue", "[TmfTimestamp:0,0,0]", content[0].toString());
-    }
-
-    @Test
-    public void testExtendedParse() {
-        TmfEventFormatStub format = new TmfEventFormatStub();
-        TmfEventField[] content = format.parse(new TmfTimestamp());
-        assertEquals("length", 5, content.length);
-        assertEquals("getValue", "1",                    content[0].toString());
-        assertEquals("getValue", "-10",                  content[1].toString());
-        assertEquals("getValue", "true",                 content[2].toString());
-        assertEquals("getValue", "some string",          content[3].toString());
-        assertEquals("getValue", "[TmfTimestamp:1,2,3]", content[4].toString());
-    }
-
-}
diff --git a/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfEventReferenceTest.java b/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfEventReferenceTest.java
new file mode 100644 (file)
index 0000000..875f73f
--- /dev/null
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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:
+ *   Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.event;
+
+import junit.framework.TestCase;
+
+/**
+ * <b><u>TmfEventReferenceTest</u></b>
+ * <p>
+ * TODO: Implement me. Please.
+ */
+public class TmfEventReferenceTest extends TestCase {
+
+       private final Object fReference = new String("Some reference");
+
+       // ========================================================================
+       // Housekeeping
+       // ========================================================================
+
+       public TmfEventReferenceTest(String name) {
+               super(name);
+       }
+
+       @Override
+       protected void setUp() throws Exception {
+               super.setUp();
+       }
+
+       @Override
+       protected void tearDown() throws Exception {
+               super.tearDown();
+       }
+
+       // ========================================================================
+       // Constructors
+       // ========================================================================
+
+       public void testTmfEventReferenceDefault() {
+               TmfEventReference reference = new TmfEventReference();
+               assertEquals("getReference", null, reference.getReference());
+       }
+
+       public void testTmfEventReference() {
+               TmfEventReference reference = new TmfEventReference(fReference);
+               assertSame("getReference", fReference, reference.getReference());
+       }
+
+       public void testTmfEventReferenceCopy() {
+               TmfEventReference original = new TmfEventReference(fReference);
+               TmfEventReference reference = new TmfEventReference(original);
+               assertSame("getReference", fReference, reference.getReference());
+       }
+
+       public void testCloneShallowCopy() {
+               TmfEventReference original = new TmfEventReference(fReference);
+               TmfEventReference reference = original.clone();
+               assertSame("getReference", fReference, reference.getReference());
+       }
+
+//     public void testCloneDeepCopy() {
+//             TmfEventReference original = new TmfEventReference(fReference);
+//             TmfEventReference reference = original.clone();
+//             assertNotSame("getReference", fReference, reference.getReference());
+//             assertEquals ("getReference", fReference, reference.getReference());
+//     }
+
+       // ========================================================================
+       // Operators
+       // ========================================================================
+
+       public void testToString() {
+               String expected1 = "[TmfEventReference(" + "null" + ")]";
+               TmfEventReference reference1 = new TmfEventReference();
+               assertEquals("toString", expected1, reference1.toString());
+
+               String expected2 = "[TmfEventReference(" + fReference.toString() + ")]";
+               TmfEventReference reference2 = new TmfEventReference(fReference);
+               assertEquals("toString", expected2, reference2.toString());
+       }
+
+}
diff --git a/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfEventSourceTest.java b/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfEventSourceTest.java
new file mode 100644 (file)
index 0000000..d3de8de
--- /dev/null
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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:
+ *   Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.event;
+
+import junit.framework.TestCase;
+
+/**
+ * <b><u>TmfEventSourceTest</u></b>
+ * <p>
+ * TODO: Implement me. Please.
+ */
+public class TmfEventSourceTest extends TestCase {
+
+       private final Object fSource = new String("Some source");
+
+       // ========================================================================
+       // Housekeeping
+       // ========================================================================
+
+       public TmfEventSourceTest(String name) {
+               super(name);
+       }
+
+       @Override
+       protected void setUp() throws Exception {
+               super.setUp();
+       }
+
+       @Override
+       protected void tearDown() throws Exception {
+               super.tearDown();
+       }
+
+       // ========================================================================
+       // Constructors
+       // ========================================================================
+
+       public void testTmfEventSourceDefault() {
+               TmfEventSource source = new TmfEventSource();
+               assertEquals("getSourceId", null, source.getSourceId());
+       }
+
+       public void testTmfEventSource() {
+               TmfEventSource source = new TmfEventSource(fSource);
+               assertSame("getSourceId", fSource, source.getSourceId());
+       }
+
+       public void testTmfEventSourceCopy() {
+               TmfEventSource original = new TmfEventSource(fSource);
+               TmfEventSource source = new TmfEventSource(original);
+               assertSame("getSourceId", fSource, source.getSourceId());
+       }
+
+       public void testCloneShallowCopy() {
+               TmfEventSource original = new TmfEventSource(fSource);
+               TmfEventSource source = original.clone();
+               assertSame("getSourceId", fSource, source.getSourceId());
+       }
+
+//     public void testCloneDeepCopy() {
+//             TmfEventSource original = new TmfEventSource(fSource);
+//             TmfEventSource source = original.clone();
+//             assertNotSame("getSourceId", fSource, source.getSourceId());
+//             assertEquals ("getSourceId", fSource, source.getSourceId());
+//     }
+
+       // ========================================================================
+       // Operators
+       // ========================================================================
+
+       public void testToString() {
+               String expected1 = "[TmfEventSource(" + "null" + ")]";
+               TmfEventSource source1 = new TmfEventSource();
+               assertEquals("toString", expected1, source1.toString());
+
+               String expected2 = "[TmfEventSource(" + fSource.toString() + ")]";
+               TmfEventSource source2 = new TmfEventSource(fSource);
+               assertEquals("toString", expected2, source2.toString());
+       }
+
+}
index c6e880ff5f5170fdd85b365360a8b24ff7004f23..133746b9b5103def81e251eb75c8f2ce4e4cf69c 100644 (file)
 
 package org.eclipse.linuxtools.tmf.event;
 
-import static org.junit.Assert.*;
-
-import org.junit.Test;
+import junit.framework.TestCase;
 
 /**
  * <b><u>TmfEventTest</u></b>
  * <p>
- * JUNit test suite for the TmfEvent class.
+ * TODO: Implement me. Please.
  */
-public class TmfEventTest {
-
-    // ========================================================================
-    // Constructor
-    // ========================================================================
-    
-    @Test
-    public void testTmfEvent() {
-        TmfTimestamp      timestamp = new TmfTimestamp(12345, (byte) 2, 5);
-        TmfEventSource    source    = new TmfEventSource("Source");
-        TmfEventFormat    format    = new TmfEventFormat(new String[] { "field1", "field2" });
-        TmfEventType      type      = new TmfEventType("Type", format);
-        TmfEventContent   content   = new TmfEventContent("Some content", format);
-        TmfEventReference reference = new TmfEventReference("Reference");
-
-        // Create the event
-        TmfEvent event = new TmfEvent(timestamp, source, type, content, reference);
-
-        // Check the event timestamp
-        TmfTimestamp ts = event.getTimestamp();
-        assertEquals("getValue", 12345, ts.getValue());
-        assertEquals("getscale",     2, ts.getScale());
-        assertEquals("getPrecision", 5, ts.getPrecision());
-
-        // Check the original event timestamp
-        ts = event.getOriginalTimestamp();
-        assertEquals("getValue", 12345, ts.getValue());
-        assertEquals("getscale",     2, ts.getScale());
-        assertEquals("getPrecision", 5, ts.getPrecision());
-
-        // Check the event source
-        TmfEventSource src = event.getSource();
-        assertEquals("getValue", "Source", src.getSourceId());
-
-        // Check the event type
-        TmfEventType tp = event.getType();
-        assertEquals("getValue", "Type", tp.getTypeId());
-        assertEquals("getFormat", "field1", tp.getFormat().getLabels()[0]);
-        assertEquals("getFormat", "field2", tp.getFormat().getLabels()[1]);
-
-        // Check the event content
-        TmfEventContent cnt = event.getContent();
-        assertEquals("getField", 1, cnt.getFields().length);
-        assertEquals("getField", "Some content", cnt.getField(0).toString());
-
-        // Check the event reference
-        TmfEventReference ref = event.getReference();
-        assertEquals("getValue", "Reference", ref.getValue());
-    }
-
-    @Test
-    public void testTmfEvent2() {
-        TmfTimestamp      original  = new TmfTimestamp(12345, (byte) 2, 5);
-        TmfTimestamp      effective = new TmfTimestamp(12350, (byte) 2, 5);
-        TmfEventSource    source    = new TmfEventSource("Source");
-        TmfEventFormat    format    = new TmfEventFormat(new String[] { "field1", "field2" });
-        TmfEventType      type      = new TmfEventType("Type", format);
-        TmfEventContent   content   = new TmfEventContent("Some content", format);
-        TmfEventReference reference = new TmfEventReference("Reference");
-
-        // Create the event
-        TmfEvent event = new TmfEvent(original, effective, source, type, content, reference);
-
-        // Check the event timestamp
-        TmfTimestamp ts = event.getTimestamp();
-        assertEquals("getValue", 12350, ts.getValue());
-        assertEquals("getscale",     2, ts.getScale());
-        assertEquals("getPrecision", 5, ts.getPrecision());
-
-        // Check the original event timestamp
-        ts = event.getOriginalTimestamp();
-        assertEquals("getValue", 12345, ts.getValue());
-        assertEquals("getscale",     2, ts.getScale());
-        assertEquals("getPrecision", 5, ts.getPrecision());
-
-        // Check the event source
-        TmfEventSource src = event.getSource();
-        assertEquals("getValue", "Source", src.getSourceId());
-
-        // Check the event type
-        TmfEventType tp = event.getType();
-        assertEquals("getValue", "Type", tp.getTypeId());
-        assertEquals("getFormat", "field1", tp.getFormat().getLabels()[0]);
-        assertEquals("getFormat", "field2", tp.getFormat().getLabels()[1]);
-
-        // Check the event content
-        TmfEventContent cnt = event.getContent();
-        assertEquals("getField", 1, cnt.getFields().length);
-        assertEquals("getField", "Some content", cnt.getField(0).toString());
-
-        // Check the event reference
-        TmfEventReference ref = event.getReference();
-        assertEquals("getValue", "Reference", ref.getValue());
-    }
+public class TmfEventTest extends TestCase {
+
+       private final String   fTypeId = "Some type";
+       private final String   fLabel0 = "label1";
+       private final String   fLabel1 = "label2";
+       private final String[] fLabels = new String[] { fLabel0, fLabel1 };
+
+       private final TmfTimestamp      fTimestamp1 = new TmfTimestamp(12345, (byte) 2, 5);
+       private final TmfTimestamp      fTimestamp2 = new TmfTimestamp(12350, (byte) 2, 5);
+       private final TmfEventSource    fSource     = new TmfEventSource("Source");
+       private final TmfEventType      fType       = new TmfEventType(fTypeId, fLabels);
+       private final TmfEventReference fReference  = new TmfEventReference("Some reference");
+
+       private final TmfEvent fEvent1;
+       private final TmfEvent fEvent2;
+
+       private final TmfEventContent fContent1;
+       private final TmfEventContent fContent2;
+       
+       // ========================================================================
+       // Housekeeping
+       // ========================================================================
+
+       public TmfEventTest(String name) {
+               super(name);
+
+               fEvent1 = new TmfEvent(fTimestamp1, fSource, fType, fReference);
+               fContent1 = new TmfEventContent(fEvent1, "Some content");
+               fEvent1.setContent(fContent1);
+
+               fEvent2 = new TmfEvent(fTimestamp1, fTimestamp2, fSource, fType, fReference);
+               fContent2 = new TmfEventContent(fEvent2, "Some other content");
+               fEvent2.setContent(fContent2);
+       }
+
+       @Override
+       protected void setUp() throws Exception {
+               super.setUp();
+       }
+
+       @Override
+       protected void tearDown() throws Exception {
+               super.tearDown();
+       }
+
+       // ========================================================================
+       // Constructors
+       // ========================================================================
+
+       public void testTmfEvent() {
+               assertEquals("getTimestamp",         fTimestamp1, fEvent1.getTimestamp());
+               assertEquals("getOriginalTimestamp", fTimestamp1, fEvent1.getOriginalTimestamp());
+               assertEquals("getSource",            fSource,     fEvent1.getSource());
+               assertEquals("getType",              fType,       fEvent1.getType());
+               assertEquals("getContent",           fContent1,   fEvent1.getContent());
+               assertEquals("getReference",         fReference,  fEvent1.getReference());
+       }
+
+       public void testTmfEvent2() {
+               assertEquals("getTimestamp",         fTimestamp2, fEvent2.getTimestamp());
+               assertEquals("getOriginalTimestamp", fTimestamp1, fEvent2.getOriginalTimestamp());
+               assertEquals("getSource",            fSource,     fEvent2.getSource());
+               assertEquals("getType",              fType,       fEvent2.getType());
+               assertEquals("getContent",           fContent2,   fEvent2.getContent());
+               assertEquals("getReference",         fReference,  fEvent2.getReference());
+       }
+
+       public void testTmfEventCopy() {
+               TmfEvent event = new TmfEvent(fEvent1);
+               assertEquals("getTimestamp",         fTimestamp1, event.getTimestamp());
+               assertEquals("getOriginalTimestamp", fTimestamp1, event.getOriginalTimestamp());
+               assertEquals("getSource",            fSource,     event.getSource());
+               assertEquals("getType",              fType,       event.getType());
+               assertEquals("getContent",           fContent1,   event.getContent());
+               assertEquals("getReference",         fReference,  event.getReference());
+       }
+
+//     public void testTmfEventCloneShallowCopy() {
+//             TmfEvent event = fEvent1.clone();
+//             assertEquals("getTimestamp",         fTimestamp1, event.getTimestamp());
+//             assertEquals("getOriginalTimestamp", fTimestamp1, event.getOriginalTimestamp());
+//             assertEquals("getSource",            fSource,     event.getSource());
+//             assertEquals("getType",              fType,       event.getType());
+//             assertEquals("getContent",           fContent1,   event.getContent());
+//             assertEquals("getReference",         fReference,  event.getReference());
+//     }
+
+//     public void testTmfEventCloneDeepCopy() {
+//             TmfEvent event = fEvent1.clone();
+//             assertEquals("getTimestamp",         fTimestamp1, event.getTimestamp());
+//             assertEquals("getOriginalTimestamp", fTimestamp1, event.getOriginalTimestamp());
+//             assertEquals("getSource",            fSource,     event.getSource());
+//             assertEquals("getType",              fType,       event.getType());
+//             assertEquals("getContent",           fContent1,   event.getContent());
+//             assertEquals("getReference",         fReference,  event.getReference());
+//     }
+
+       // ========================================================================
+       // Operators
+       // ========================================================================
+
+//     public void testToString() {
+//             String expected1 = "[TmfEventType:" + TmfEventType.DEFAULT_TYPE_ID + "]";
+//             assertEquals("toString", expected1, fEvent1.toString());
+//
+//             String expected2 = "[TmfEventType:" + fTypeId + "]";
+//             assertEquals("toString", expected2, fEvent2.toString());
+//     }
 
 }
index e90a9fa1e3fe82e18d5bc2eb49416403671685a3..2683dcc4d5fd87b389b77897dd88c6a4bf83726f 100644 (file)
 
 package org.eclipse.linuxtools.tmf.event;
 
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
+import junit.framework.TestCase;
 
 /**
  * <b><u>TmfEventTypeTest</u></b>
  * <p>
  * JUnit test suite for the TmfEventType class.
  */
-public class TmfEventTypeTest {
-
-    // ========================================================================
-    // Constructor
-    // ========================================================================
-
-    @Test
-    public void testEmptyConstructor() {
-        TmfEventType type = new TmfEventType("", null);
-        assertEquals("getValue", "", type.getTypeId());
-        assertEquals("getFormat", null, type.getFormat());
-   }
-
-    @Test
-    public void testNormalConstructor() {
-        TmfEventType type = new TmfEventType("Type", new TmfEventFormat(new String[] { "field1", "field2" }));
-        assertEquals("getValue", "Type", type.getTypeId());
-        assertEquals("getFormat", "field1", type.getFormat().getLabels()[0]);
-        assertEquals("getFormat", "field2", type.getFormat().getLabels()[1]);
-   }
+public class TmfEventTypeTest extends TestCase {
+
+       private final String   fTypeId = "Some type";
+       private final String   fLabel0 = "label1";
+       private final String   fLabel1 = "label2";
+       private final String[] fLabels = new String[] { fLabel0, fLabel1 };
+
+       // ========================================================================
+       // Housekeeping
+       // ========================================================================
+
+       public TmfEventTypeTest(String name) {
+               super(name);
+       }
+
+       @Override
+       protected void setUp() throws Exception {
+               super.setUp();
+       }
+
+       @Override
+       protected void tearDown() throws Exception {
+               super.tearDown();
+       }
+
+       // ========================================================================
+       // Constructors
+       // ========================================================================
+
+       public void testTmfEventTypeDefault() {
+               TmfEventType type = new TmfEventType();
+               try {
+                       assertEquals("getTypeId",     TmfEventType.DEFAULT_TYPE_ID, type.getTypeId());
+                       assertEquals("getNbFields",   1, type.getNbFields());
+                       assertEquals("getFieldIndex", 0, type.getFieldIndex(TmfEventType.DEFAULT_LABELS[0]));
+                       assertEquals("getLabels",     TmfEventType.DEFAULT_LABELS, type.getLabels());
+                       assertEquals("getLabel",      TmfEventType.DEFAULT_LABELS[0], type.getLabel(0));
+               } catch (TmfNoSuchFieldException e) {
+                       fail("getFieldIndex: no such field");
+               }
+       }
+
+       public void testTmfEventType() {
+               TmfEventType type = new TmfEventType(fTypeId, fLabels);
+               try {
+                       assertEquals("getTypeId",     fTypeId, type.getTypeId());
+                       assertEquals("getNbFields",   fLabels.length, type.getNbFields());
+                       assertEquals("getFieldIndex", 0, type.getFieldIndex(fLabel0));
+                       assertEquals("getFieldIndex", 1, type.getFieldIndex(fLabel1));
+                       assertEquals("getLabels",     fLabels, type.getLabels());
+                       assertEquals("getLabel",      fLabel0, type.getLabel(0));
+                       assertEquals("getLabel",      fLabel1, type.getLabel(1));
+               } catch (TmfNoSuchFieldException e) {
+                       fail("getFieldIndex: no such field");
+               }
+
+               try {
+                       assertEquals("getFieldIndex", 0, type.getFieldIndex("Dummy"));
+                       fail("getFieldIndex: inexistant field");
+               } catch (TmfNoSuchFieldException e) {
+                       // Success
+               }
+       }
+
+       public void testTmfEventTypeCopy() {
+               TmfEventType original = new TmfEventType(fTypeId, fLabels);
+               TmfEventType type = new TmfEventType(original);
+               assertEquals("getTypeId",     fTypeId, type.getTypeId());
+               assertEquals("getNbFields",   fLabels.length, type.getNbFields());
+               assertEquals("getLabels",     fLabels, type.getLabels());
+       }
+
+       public void testCloneShallowCopy() {
+               TmfEventType original = new TmfEventType(fTypeId, fLabels);
+               TmfEventType type = original.clone();
+               assertEquals("getTypeId",     fTypeId, type.getTypeId());
+               assertEquals("getNbFields",   fLabels.length, type.getNbFields());
+               assertEquals("getLabels",     fLabels, type.getLabels());
+       }
+
+//     public void testCloneDeepCopy() {
+//             fail("Not yet implemented");
+//     }
+
+       // ========================================================================
+       // Operators
+       // ========================================================================
+
+       public void testToString() {
+               String expected1 = "[TmfEventType:" + TmfEventType.DEFAULT_TYPE_ID + "]";
+               TmfEventType type1 = new TmfEventType();
+               assertEquals("toString", expected1, type1.toString());
+
+               String expected2 = "[TmfEventType:" + fTypeId + "]";
+               TmfEventType type2 = new TmfEventType(fTypeId, fLabels);
+               assertEquals("toString", expected2, type2.toString());
+       }
 
 }
index a2f752444c8453fba6e6f2c3a023f6f67987187d..1d93fd585905c9d6cd78044afdaff3dd1e26f3a4 100644 (file)
 
 package org.eclipse.linuxtools.tmf.event;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-
-import org.junit.Test;
+import junit.framework.TestCase;
 
 /**
  * <b><u>TmfTimeRangeTest</u></b>
  * <p>
- * JUnit test suite for the TmfTimeRange class.
+ * TODO: Implement me. Please.
  */
-public class TmfTimeRangeTest {
-
-    // ========================================================================
-    // Constructors
-    // ========================================================================
-
-    @Test
-    public void testConstructor() throws Exception {
-        TmfTimestamp ts1   = new TmfTimestamp(12345);
-        TmfTimestamp ts2   = new TmfTimestamp(12350);
-        TmfTimeRange range = new TmfTimeRange(ts1, ts2);
-        assertEquals("startTime", ts1, range.getStartTime());
-        assertEquals("endTime",   ts2, range.getEndTime());
-    }
-
-    @Test
-    public void testOpenRange1() throws Exception {
-        TmfTimestamp ts2    = new TmfTimestamp(12350);
-        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, ts2);
-        assertEquals("startTime", TmfTimestamp.BigBang, range.getStartTime());
-        assertEquals("endTime",   ts2, range.getEndTime());
-    }
-
-    @Test
-    public void testOpenRange2() throws Exception {
-        TmfTimestamp ts1   = new TmfTimestamp(12345);
-        TmfTimeRange range = new TmfTimeRange(ts1, TmfTimestamp.BigCrunch);
-        assertEquals("startTime", ts1, range.getStartTime());
-        assertEquals("endTime",   TmfTimestamp.BigCrunch, range.getEndTime());
-    }
-
-    @Test
-    public void testOpenRange3() throws Exception {
-        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        assertEquals("startTime", TmfTimestamp.BigBang,   range.getStartTime());
-        assertEquals("endTime",   TmfTimestamp.BigCrunch, range.getEndTime());
-    }
-
-    // ========================================================================
-    // Constructors
-    // ========================================================================
-
-    @Test
-    public void testContains() throws Exception {
-        TmfTimestamp ts1   = new TmfTimestamp(12345);
-        TmfTimestamp ts2   = new TmfTimestamp(12350);
-        TmfTimeRange range = new TmfTimeRange(ts1, ts2);
-
-        assertTrue("contains (lower bound)",   range.contains(new TmfTimestamp(12345)));
-        assertTrue("contains (higher bound)",  range.contains(new TmfTimestamp(12350)));
-        assertTrue("contains (within bounds)", range.contains(new TmfTimestamp(12346)));
-
-        assertFalse("contains (low value)",   range.contains(new TmfTimestamp(12340)));
-        assertFalse("contains (high value)",  range.contains(new TmfTimestamp(12351)));
-    }
+public class TmfTimeRangeTest extends TestCase {
+
+       // ========================================================================
+       // Housekeeping
+       // ========================================================================
+
+       public TmfTimeRangeTest(String name) {
+               super(name);
+       }
+
+       @Override
+       protected void setUp() throws Exception {
+               super.setUp();
+       }
+
+       @Override
+       protected void tearDown() throws Exception {
+               super.tearDown();
+       }
+
+       // ========================================================================
+       // Constructors
+       // ========================================================================
+
+       public void testConstructor() throws Exception {
+               TmfTimestamp ts1 = new TmfTimestamp(12345);
+               TmfTimestamp ts2 = new TmfTimestamp(12350);
+               TmfTimeRange range = new TmfTimeRange(ts1, ts2);
+               assertEquals("startTime", ts1, range.getStartTime());
+               assertEquals("endTime", ts2, range.getEndTime());
+       }
+
+       public void testOpenRange1() throws Exception {
+               TmfTimestamp ts2 = new TmfTimestamp(12350);
+               TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, ts2);
+               assertEquals("startTime", TmfTimestamp.BigBang, range.getStartTime());
+               assertEquals("endTime", ts2, range.getEndTime());
+       }
+
+       public void testOpenRange2() throws Exception {
+               TmfTimestamp ts1 = new TmfTimestamp(12345);
+               TmfTimeRange range = new TmfTimeRange(ts1, TmfTimestamp.BigCrunch);
+               assertEquals("startTime", ts1, range.getStartTime());
+               assertEquals("endTime", TmfTimestamp.BigCrunch, range.getEndTime());
+       }
+
+       public void testOpenRange3() throws Exception {
+               TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang,     TmfTimestamp.BigCrunch);
+               assertEquals("startTime", TmfTimestamp.BigBang, range.getStartTime());
+               assertEquals("endTime", TmfTimestamp.BigCrunch, range.getEndTime());
+       }
+       
+       // ========================================================================
+       // contains
+       // ========================================================================
+
+       public void testContains() throws Exception {
+               TmfTimestamp ts1 = new TmfTimestamp(12345);
+               TmfTimestamp ts2 = new TmfTimestamp(12350);
+               TmfTimeRange range = new TmfTimeRange(ts1, ts2);
+
+               assertTrue("contains (lower bound)", range.contains(new TmfTimestamp(12345)));
+               assertTrue("contains (higher bound)", range.contains(new TmfTimestamp(12350)));
+               assertTrue("contains (within bounds)", range.contains(new TmfTimestamp(12346)));
+
+               assertFalse("contains (low value)", range.contains(new TmfTimestamp(12340)));
+               assertFalse("contains (high value)", range.contains(new TmfTimestamp(12351)));
+       }
+
+       // ========================================================================
+       // toString
+       // ========================================================================
+
+       public void testToString() throws Exception {
+               TmfTimestamp ts1 = new TmfTimestamp(12345);
+               TmfTimestamp ts2 = new TmfTimestamp(12350);
+               TmfTimeRange range = new TmfTimeRange(ts1, ts2);
 
+               String expected = "[TmfTimeRange(" + ts1.toString() + ":" + ts2.toString() + ")]";
+               assertEquals("toString", expected, range.toString());
+       }
+       
 }
index 833e10efa8e2c2ff14818f6176bf2a46d7d93a8c..66d5e95e7cd12d15d148624e806d42f0f02ab628 100644 (file)
 
 package org.eclipse.linuxtools.tmf.event;
 
-import static org.junit.Assert.*;
-
-import org.junit.Test;
+import junit.framework.TestCase;
 
 /**
  * <b><u>TmfTimestampTest</u></b>
  * <p>
- * JUnit test suite for the TmfTimestamp class.
+ * TODO: Implement me. Please.
  */
-public class TmfTimestampTest {
-
-    // ========================================================================
-    // Constructors
-    // ========================================================================
-
-    @Test
-    public void testDefaultConstructor() throws Exception {
-        TmfTimestamp ts = new TmfTimestamp();
-        assertEquals("getValue",     0, ts.getValue());
-        assertEquals("getscale",     0, ts.getScale());
-        assertEquals("getPrecision", 0, ts.getPrecision());
-    }
-
-    @Test
-    public void testSimpleConstructor() throws Exception {
-        TmfTimestamp ts = new TmfTimestamp(12345);
-        assertEquals("getValue", 12345, ts.getValue());
-        assertEquals("getscale",     0, ts.getScale());
-        assertEquals("getPrecision", 0, ts.getPrecision());
-    }
-
-    @Test
-    public void testSimpleConstructor2() throws Exception {
-        TmfTimestamp ts = new TmfTimestamp(12345, (byte) -1);
-        assertEquals("getValue", 12345, ts.getValue());
-        assertEquals("getscale",    -1, ts.getScale());
-        assertEquals("getPrecision", 0, ts.getPrecision());
-    }
-
-    @Test
-    public void testFullConstructor() throws Exception {
-        TmfTimestamp ts = new TmfTimestamp(12345, (byte) 2, 5);
-        assertEquals("getValue", 12345, ts.getValue());
-        assertEquals("getscale",     2, ts.getScale());
-        assertEquals("getPrecision", 5, ts.getPrecision());
-    }
-
-    @Test
-    public void testCopyConstructor() throws Exception {
-        TmfTimestamp ts0 = new TmfTimestamp(12345, (byte) 2, 5);
-        TmfTimestamp ts  = new TmfTimestamp(ts0);
-        assertEquals("getValue", 12345, ts.getValue());
-        assertEquals("getscale",     2, ts.getScale());
-        assertEquals("getPrecision", 5, ts.getPrecision());
-    }
-
-    // ========================================================================
-    // BigBang, BigCrunch
-    // ========================================================================
-
-    @Test
-    public void testCopyConstructorBigBang() throws Exception {
-        TmfTimestamp ts = new TmfTimestamp(TmfTimestamp.BigBang);
-        assertEquals("getValue",     TmfTimestamp.BigBang.getValue(), ts.getValue());
-        assertEquals("getscale",     TmfTimestamp.BigBang.getScale(), ts.getScale());
-        assertEquals("getPrecision", TmfTimestamp.BigBang.getPrecision(), ts.getPrecision());
-    }
-
-    @Test
-    public void testCopyConstructorBigCrunch() throws Exception {
-        TmfTimestamp ts = new TmfTimestamp(TmfTimestamp.BigCrunch);
-        assertEquals("getValue",     TmfTimestamp.BigCrunch.getValue(), ts.getValue());
-        assertEquals("getscale",     TmfTimestamp.BigCrunch.getScale(), ts.getScale());
-        assertEquals("getPrecision", TmfTimestamp.BigCrunch.getPrecision(), ts.getPrecision());
-    }
-
-    // ========================================================================
-    // toString
-    // ========================================================================
-
-    @Test
-    public void testToString() throws Exception {
-        TmfTimestamp ts1 = new TmfTimestamp();
-        TmfTimestamp ts2  = new TmfTimestamp(1234,  (byte)  2);
-        TmfTimestamp ts3  = new TmfTimestamp(1234,  (byte)  2, 1);
-        TmfTimestamp ts4  = new TmfTimestamp(-1234, (byte) -1, 4);
-
-        assertEquals("toString", "[TmfTimestamp:0,0,0]",      ts1.toString());
-        assertEquals("toString", "[TmfTimestamp:1234,2,0]",   ts2.toString());
-        assertEquals("toString", "[TmfTimestamp:1234,2,1]",   ts3.toString());
-        assertEquals("toString", "[TmfTimestamp:-1234,-1,4]", ts4.toString());
-    }
-
-    // ========================================================================
-    // synchronize
-    // ========================================================================
-
-    @Test
-    public void testSynchronizeOffset() throws Exception {
-        TmfTimestamp ts0 = new TmfTimestamp(1234, (byte) 0, 1);
-        TmfTimestamp ts  = new TmfTimestamp();
-
-        ts = ts0.synchronize(0, (byte) 0);
-        assertEquals("getValue",  1234, ts.getValue());
-        assertEquals("getscale",     0, ts.getScale());
-        assertEquals("getPrecision", 1, ts.getPrecision());
-
-        ts = ts0.synchronize(10, (byte) 0);
-        assertEquals("getValue",  1244, ts.getValue());
-        assertEquals("getscale",     0, ts.getScale());
-        assertEquals("getPrecision", 1, ts.getPrecision());
-
-        ts = ts0.synchronize(-10, (byte) 0);
-        assertEquals("getValue",  1224, ts.getValue());
-        assertEquals("getscale",     0, ts.getScale());
-        assertEquals("getPrecision", 1, ts.getPrecision());
-    }
-
-    @Test
-    public void testSynchronizeScale() throws Exception {
-        TmfTimestamp ts0 = new TmfTimestamp(1234, (byte) 0, 12);
-        TmfTimestamp ts  = new TmfTimestamp();
-
-        ts = ts0.synchronize(0, (byte) 0);
-        assertEquals("getValue",   1234, ts.getValue());
-        assertEquals("getscale",      0, ts.getScale());
-        assertEquals("getPrecision",  12, ts.getPrecision());
-
-        ts = ts0.synchronize(0, (byte) 1);
-        assertEquals("getValue",   123, ts.getValue());
-        assertEquals("getscale",     1, ts.getScale());
-        assertEquals("getPrecision", 1, ts.getPrecision());
-
-        ts = ts0.synchronize(0, (byte) 2);
-        assertEquals("getValue",    12, ts.getValue());
-        assertEquals("getscale",     2, ts.getScale());
-        assertEquals("getPrecision", 0, ts.getPrecision());
-
-        ts = ts0.synchronize(0, (byte) 4);
-        assertEquals("getValue",     0, ts.getValue());
-        assertEquals("getscale",     4, ts.getScale());
-        assertEquals("getPrecision", 0, ts.getPrecision());
-
-        ts = ts0.synchronize(0, (byte) -2);
-        assertEquals("getValue",   123400, ts.getValue());
-        assertEquals("getscale",       -2, ts.getScale());
-        assertEquals("getPrecision", 1200, ts.getPrecision());
-    }
-
-    @Test
-    public void testSynchronizeOffsetAndScale() throws Exception {
-        TmfTimestamp ts0 = new TmfTimestamp(1234, (byte) 0, 12);
-        TmfTimestamp ts  = new TmfTimestamp();
-
-        ts = ts0.synchronize(10, (byte) 1);
-        assertEquals("getValue",   133, ts.getValue());
-        assertEquals("getscale",     1, ts.getScale());
-        assertEquals("getPrecision", 1, ts.getPrecision());
-
-        ts = ts0.synchronize(-10, (byte) -1);
-        assertEquals("getValue",   12330, ts.getValue());
-        assertEquals("getscale",      -1, ts.getScale());
-        assertEquals("getPrecision", 120, ts.getPrecision());
-    }
-
-    // ========================================================================
-    // getAdjustment
-    // ========================================================================
-
-    @Test
-    public void testGetAdjustmentSameScale() throws Exception {
-        TmfTimestamp ts0 = new TmfTimestamp(12345, (byte) -2);
-        TmfTimestamp ts  = new TmfTimestamp(10000, (byte) -2);
-
-        long delta = ts.getAdjustment(ts0);
-        assertEquals("delta", 2345, delta);
-    }
-
-    @Test
-    public void testGetAdjustmentDifferentScale() throws Exception {
-        TmfTimestamp ts0 = new TmfTimestamp(12345, (byte) -2);
-        TmfTimestamp ts  = new TmfTimestamp(    1, (byte)  2);
-
-        long delta = ts.getAdjustment(ts0);
-        assertEquals("delta", 2345, delta);
-
-        delta = ts0.getAdjustment(ts);
-        assertEquals("delta", 0, delta);
-    }
-
-    // ========================================================================
-    // CompareTo
-    // ========================================================================
-
-    @Test
-    public void testCompareToSameScale() throws Exception {
-        TmfTimestamp ts1 = new TmfTimestamp( 900, (byte) 0, 50);
-        TmfTimestamp ts2 = new TmfTimestamp(1000, (byte) 0, 50);
-        TmfTimestamp ts3 = new TmfTimestamp(1100, (byte) 0, 50);
-        TmfTimestamp ts4 = new TmfTimestamp(1000, (byte) 0, 75);
-
-        assertTrue(ts1.compareTo(ts1, false) == 0);
-
-        assertTrue(ts1.compareTo(ts2, false)  < 0);
-        assertTrue(ts1.compareTo(ts3, false)  < 0);
-        assertTrue(ts1.compareTo(ts4, false)  < 0);
-
-        assertTrue(ts2.compareTo(ts1, false)  > 0);
-        assertTrue(ts2.compareTo(ts3, false)  < 0);
-        assertTrue(ts2.compareTo(ts4, false) == 0);
-
-        assertTrue(ts3.compareTo(ts1, false)  > 0);
-        assertTrue(ts3.compareTo(ts2, false)  > 0);
-        assertTrue(ts3.compareTo(ts4, false)  > 0);
-    }
-
-    @Test
-    public void testCompareToDifferentScale() throws Exception {
-        TmfTimestamp ts1 = new TmfTimestamp(9000, (byte) -1, 50);
-        TmfTimestamp ts2 = new TmfTimestamp(1000, (byte)  0, 50);
-        TmfTimestamp ts3 = new TmfTimestamp( 110, (byte)  1, 50);
-        TmfTimestamp ts4 = new TmfTimestamp(   1, (byte)  3, 75);
-
-        assertTrue(ts1.compareTo(ts1, false) == 0);
-
-        assertTrue(ts1.compareTo(ts2, false)  < 0);
-        assertTrue(ts1.compareTo(ts3, false)  < 0);
-        assertTrue(ts1.compareTo(ts4, false)  < 0);
-
-        assertTrue(ts2.compareTo(ts1, false)  > 0);
-        assertTrue(ts2.compareTo(ts3, false)  < 0);
-        assertTrue(ts2.compareTo(ts4, false) == 0);
-
-        assertTrue(ts3.compareTo(ts1, false)  > 0);
-        assertTrue(ts3.compareTo(ts2, false)  > 0);
-        assertTrue(ts3.compareTo(ts4, false)  > 0);
-    }
-
-    @Test
-    public void testCompareToWithinPrecision() throws Exception {
-        TmfTimestamp ts1 = new TmfTimestamp( 900, (byte) 0, 50);
-        TmfTimestamp ts2 = new TmfTimestamp(1000, (byte) 0, 50);
-        TmfTimestamp ts3 = new TmfTimestamp(1100, (byte) 0, 50);
-        TmfTimestamp ts4 = new TmfTimestamp(1000, (byte) 0, 75);
-
-        assertTrue(ts1.compareTo(ts1, true) == 0);
-
-        assertTrue(ts1.compareTo(ts2, true) == 0);
-        assertTrue(ts1.compareTo(ts3, true)  < 0);
-        assertTrue(ts1.compareTo(ts4, true) == 0);
-
-        assertTrue(ts2.compareTo(ts1, true) == 0);
-        assertTrue(ts2.compareTo(ts3, true) == 0);
-        assertTrue(ts2.compareTo(ts4, true) == 0);
-
-        assertTrue(ts3.compareTo(ts1, true)  > 0);
-        assertTrue(ts3.compareTo(ts2, true) == 0);
-        assertTrue(ts3.compareTo(ts4, true) == 0);
-    }
-
-    @Test
-    public void testCompareToLargeScale() throws Exception {
-        TmfTimestamp ts1 = new TmfTimestamp(   -1, (byte)  100);
-        TmfTimestamp ts2 = new TmfTimestamp(-1000, (byte) -100);
-        TmfTimestamp ts3 = new TmfTimestamp(    1, (byte)  100);
-        TmfTimestamp ts4 = new TmfTimestamp( 1000, (byte) -100);
-
-        assertTrue(ts1.compareTo(ts2, false) < 0);
-        assertTrue(ts1.compareTo(ts3, false) < 0);
-        assertTrue(ts1.compareTo(ts4, false) < 0);
-
-        assertTrue(ts2.compareTo(ts1, false) > 0);
-        assertTrue(ts2.compareTo(ts3, false) < 0);
-        assertTrue(ts2.compareTo(ts4, false) < 0);
-
-        assertTrue(ts3.compareTo(ts1, false) > 0);
-        assertTrue(ts3.compareTo(ts2, false) > 0);
-        assertTrue(ts3.compareTo(ts4, false) > 0);
-
-        assertTrue(ts4.compareTo(ts1, false) > 0);
-        assertTrue(ts4.compareTo(ts2, false) > 0);
-        assertTrue(ts4.compareTo(ts3, false) < 0);
-    }
-
-    @Test
-    public void testCompareToBigGuys() throws Exception {
-        TmfTimestamp ts1 = new TmfTimestamp(-1, Byte.MAX_VALUE);
-        TmfTimestamp ts2 = new TmfTimestamp(-1, Byte.MIN_VALUE);
-        TmfTimestamp ts3 = new TmfTimestamp( 1, Byte.MAX_VALUE);
-        TmfTimestamp ts4 = new TmfTimestamp( 1, Byte.MIN_VALUE);
-
-        assertTrue(ts1.compareTo(TmfTimestamp.BigBang,   false) > 0);
-        assertTrue(ts1.compareTo(TmfTimestamp.BigCrunch, false) < 0);
-
-        assertTrue(ts2.compareTo(TmfTimestamp.BigBang,   false) > 0);
-        assertTrue(ts2.compareTo(TmfTimestamp.BigCrunch, false) < 0);
-
-        assertTrue(ts3.compareTo(TmfTimestamp.BigBang,   false) > 0);
-        assertTrue(ts3.compareTo(TmfTimestamp.BigCrunch, false) < 0);
-
-        assertTrue(ts4.compareTo(TmfTimestamp.BigBang,   false) > 0);
-        assertTrue(ts4.compareTo(TmfTimestamp.BigCrunch, false) < 0);
-    }
+public class TmfTimestampTest extends TestCase {
+
+       // ========================================================================
+       // Housekeeping
+       // ========================================================================
+
+       public TmfTimestampTest(String name) {
+               super(name);
+       }
+
+       @Override
+       protected void setUp() throws Exception {
+               super.setUp();
+       }
+
+       @Override
+       protected void tearDown() throws Exception {
+               super.tearDown();
+       }
+
+       // ========================================================================
+       // Constructors
+       // ========================================================================
+
+       public void testDefaultConstructor() throws Exception {
+               TmfTimestamp ts = new TmfTimestamp();
+               assertEquals("getValue", 0, ts.getValue());
+               assertEquals("getscale", 0, ts.getScale());
+               assertEquals("getPrecision", 0, ts.getPrecision());
+       }
+
+       public void testSimpleConstructor() throws Exception {
+               TmfTimestamp ts = new TmfTimestamp(12345);
+               assertEquals("getValue", 12345, ts.getValue());
+               assertEquals("getscale", 0, ts.getScale());
+               assertEquals("getPrecision", 0, ts.getPrecision());
+       }
+
+       public void testSimpleConstructor2() throws Exception {
+               TmfTimestamp ts = new TmfTimestamp(12345, (byte) -1);
+               assertEquals("getValue", 12345, ts.getValue());
+               assertEquals("getscale", -1, ts.getScale());
+               assertEquals("getPrecision", 0, ts.getPrecision());
+       }
+
+       public void testFullConstructor() throws Exception {
+               TmfTimestamp ts = new TmfTimestamp(12345, (byte) 2, 5);
+               assertEquals("getValue", 12345, ts.getValue());
+               assertEquals("getscale", 2, ts.getScale());
+               assertEquals("getPrecision", 5, ts.getPrecision());
+       }
+
+       public void testCopyConstructor() throws Exception {
+               TmfTimestamp ts0 = new TmfTimestamp(12345, (byte) 2, 5);
+               TmfTimestamp ts = new TmfTimestamp(ts0);
+               assertEquals("getValue", 12345, ts.getValue());
+               assertEquals("getscale", 2, ts.getScale());
+               assertEquals("getPrecision", 5, ts.getPrecision());
+       }
+
+       // ========================================================================
+       // BigBang, BigCrunch
+       // ========================================================================
+
+       public void testCopyConstructorBigBang() throws Exception {
+               TmfTimestamp ts = new TmfTimestamp(TmfTimestamp.BigBang);
+               assertEquals("getValue", TmfTimestamp.BigBang.getValue(), ts.getValue());
+               assertEquals("getscale", TmfTimestamp.BigBang.getScale(), ts.getScale());
+               assertEquals("getPrecision", TmfTimestamp.BigBang.getPrecision(), ts.getPrecision());
+       }
+
+       public void testCopyConstructorBigCrunch() throws Exception {
+               TmfTimestamp ts = new TmfTimestamp(TmfTimestamp.BigCrunch);
+               assertEquals("getValue", TmfTimestamp.BigCrunch.getValue(), ts.getValue());
+               assertEquals("getscale", TmfTimestamp.BigCrunch.getScale(), ts.getScale());
+               assertEquals("getPrecision", TmfTimestamp.BigCrunch.getPrecision(), ts.getPrecision());
+       }
+
+       // ========================================================================
+       // toString
+       // ========================================================================
+
+       public void testToString() throws Exception {
+               TmfTimestamp ts1 = new TmfTimestamp();
+               TmfTimestamp ts2 = new TmfTimestamp(1234, (byte) 2);
+               TmfTimestamp ts3 = new TmfTimestamp(1234, (byte) 2, 1);
+               TmfTimestamp ts4 = new TmfTimestamp(-1234, (byte) -1, 4);
+
+               assertEquals("toString", "[TmfTimestamp(0,0,0)]", ts1.toString());
+               assertEquals("toString", "[TmfTimestamp(1234,2,0)]", ts2.toString());
+               assertEquals("toString", "[TmfTimestamp(1234,2,1)]", ts3.toString());
+               assertEquals("toString", "[TmfTimestamp(-1234,-1,4)]", ts4.toString());
+       }
+       
+       // ========================================================================
+       // synchronize
+       // ========================================================================
+
+       public void testSynchronizeOffset() throws Exception {
+               TmfTimestamp ts0 = new TmfTimestamp(1234, (byte) 0, 1);
+               TmfTimestamp ts = new TmfTimestamp();
+
+               ts = ts0.synchronize(0, (byte) 0);
+               assertEquals("getValue", 1234, ts.getValue());
+               assertEquals("getscale", 0, ts.getScale());
+               assertEquals("getPrecision", 1, ts.getPrecision());
+
+               ts = ts0.synchronize(10, (byte) 0);
+               assertEquals("getValue", 1244, ts.getValue());
+               assertEquals("getscale", 0, ts.getScale());
+               assertEquals("getPrecision", 1, ts.getPrecision());
+
+               ts = ts0.synchronize(-10, (byte) 0);
+               assertEquals("getValue", 1224, ts.getValue());
+               assertEquals("getscale", 0, ts.getScale());
+               assertEquals("getPrecision", 1, ts.getPrecision());
+       }
+
+       public void testSynchronizeScale() throws Exception {
+               TmfTimestamp ts0 = new TmfTimestamp(1234, (byte) 0, 12);
+               TmfTimestamp ts = new TmfTimestamp();
+
+               ts = ts0.synchronize(0, (byte) 0);
+               assertEquals("getValue", 1234, ts.getValue());
+               assertEquals("getscale", 0, ts.getScale());
+               assertEquals("getPrecision", 12, ts.getPrecision());
+
+               ts = ts0.synchronize(0, (byte) 1);
+               assertEquals("getValue", 123, ts.getValue());
+               assertEquals("getscale", 1, ts.getScale());
+               assertEquals("getPrecision", 1, ts.getPrecision());
+
+               ts = ts0.synchronize(0, (byte) 2);
+               assertEquals("getValue", 12, ts.getValue());
+               assertEquals("getscale", 2, ts.getScale());
+               assertEquals("getPrecision", 0, ts.getPrecision());
+
+               ts = ts0.synchronize(0, (byte) 4);
+               assertEquals("getValue", 0, ts.getValue());
+               assertEquals("getscale", 4, ts.getScale());
+               assertEquals("getPrecision", 0, ts.getPrecision());
+
+               ts = ts0.synchronize(0, (byte) -2);
+               assertEquals("getValue", 123400, ts.getValue());
+               assertEquals("getscale", -2, ts.getScale());
+               assertEquals("getPrecision", 1200, ts.getPrecision());
+       }
+
+       public void testSynchronizeOffsetAndScale() throws Exception {
+               TmfTimestamp ts0 = new TmfTimestamp(1234, (byte) 0, 12);
+               TmfTimestamp ts = new TmfTimestamp();
+
+               ts = ts0.synchronize(10, (byte) 1);
+               assertEquals("getValue", 133, ts.getValue());
+               assertEquals("getscale", 1, ts.getScale());
+               assertEquals("getPrecision", 1, ts.getPrecision());
+
+               ts = ts0.synchronize(-10, (byte) -1);
+               assertEquals("getValue", 12330, ts.getValue());
+               assertEquals("getscale", -1, ts.getScale());
+               assertEquals("getPrecision", 120, ts.getPrecision());
+       }       
+       
+       // ========================================================================
+       // getAdjustment
+       // ========================================================================
+
+       public void testGetAdjustmentSameScale() throws Exception {
+               TmfTimestamp ts0 = new TmfTimestamp(12345, (byte) -2);
+               TmfTimestamp ts = new TmfTimestamp(10000, (byte) -2);
+
+               long delta = ts.getAdjustment(ts0);
+               assertEquals("delta", 2345, delta);
+       }
+
+       public void testGetAdjustmentDifferentScale() throws Exception {
+               TmfTimestamp ts0 = new TmfTimestamp(12345, (byte) -2);
+               TmfTimestamp ts = new TmfTimestamp(1, (byte) 2);
+
+               long delta = ts.getAdjustment(ts0);
+               assertEquals("delta", 2345, delta);
+
+               delta = ts0.getAdjustment(ts);
+               assertEquals("delta", 0, delta);
+       }
+
+       // ========================================================================
+       // CompareTo
+       // ========================================================================
+
+       public void testCompareToSameScale() throws Exception {
+               TmfTimestamp ts1 = new TmfTimestamp(900, (byte) 0, 50);
+               TmfTimestamp ts2 = new TmfTimestamp(1000, (byte) 0, 50);
+               TmfTimestamp ts3 = new TmfTimestamp(1100, (byte) 0, 50);
+               TmfTimestamp ts4 = new TmfTimestamp(1000, (byte) 0, 75);
+
+               assertTrue(ts1.compareTo(ts1, false) == 0);
+
+               assertTrue(ts1.compareTo(ts2, false) < 0);
+               assertTrue(ts1.compareTo(ts3, false) < 0);
+               assertTrue(ts1.compareTo(ts4, false) < 0);
+
+               assertTrue(ts2.compareTo(ts1, false) > 0);
+               assertTrue(ts2.compareTo(ts3, false) < 0);
+               assertTrue(ts2.compareTo(ts4, false) == 0);
+
+               assertTrue(ts3.compareTo(ts1, false) > 0);
+               assertTrue(ts3.compareTo(ts2, false) > 0);
+               assertTrue(ts3.compareTo(ts4, false) > 0);
+       }
+
+       public void testCompareToDifferentScale() throws Exception {
+               TmfTimestamp ts1 = new TmfTimestamp(9000, (byte) -1, 50);
+               TmfTimestamp ts2 = new TmfTimestamp(1000, (byte) 0, 50);
+               TmfTimestamp ts3 = new TmfTimestamp(110, (byte) 1, 50);
+               TmfTimestamp ts4 = new TmfTimestamp(1, (byte) 3, 75);
+
+               assertTrue(ts1.compareTo(ts1, false) == 0);
+
+               assertTrue(ts1.compareTo(ts2, false) < 0);
+               assertTrue(ts1.compareTo(ts3, false) < 0);
+               assertTrue(ts1.compareTo(ts4, false) < 0);
+
+               assertTrue(ts2.compareTo(ts1, false) > 0);
+               assertTrue(ts2.compareTo(ts3, false) < 0);
+               assertTrue(ts2.compareTo(ts4, false) == 0);
+
+               assertTrue(ts3.compareTo(ts1, false) > 0);
+               assertTrue(ts3.compareTo(ts2, false) > 0);
+               assertTrue(ts3.compareTo(ts4, false) > 0);
+       }
+
+       public void testCompareToWithinPrecision() throws Exception {
+               TmfTimestamp ts1 = new TmfTimestamp(900, (byte) 0, 50);
+               TmfTimestamp ts2 = new TmfTimestamp(1000, (byte) 0, 50);
+               TmfTimestamp ts3 = new TmfTimestamp(1100, (byte) 0, 50);
+               TmfTimestamp ts4 = new TmfTimestamp(1000, (byte) 0, 75);
+
+               assertTrue(ts1.compareTo(ts1, true) == 0);
+
+               assertTrue(ts1.compareTo(ts2, true) == 0);
+               assertTrue(ts1.compareTo(ts3, true) < 0);
+               assertTrue(ts1.compareTo(ts4, true) == 0);
+
+               assertTrue(ts2.compareTo(ts1, true) == 0);
+               assertTrue(ts2.compareTo(ts3, true) == 0);
+               assertTrue(ts2.compareTo(ts4, true) == 0);
+
+               assertTrue(ts3.compareTo(ts1, true) > 0);
+               assertTrue(ts3.compareTo(ts2, true) == 0);
+               assertTrue(ts3.compareTo(ts4, true) == 0);
+       }
+
+       public void testCompareToLargeScale() throws Exception {
+               TmfTimestamp ts1 = new TmfTimestamp(-1, (byte) 100);
+               TmfTimestamp ts2 = new TmfTimestamp(-1000, (byte) -100);
+               TmfTimestamp ts3 = new TmfTimestamp(1, (byte) 100);
+               TmfTimestamp ts4 = new TmfTimestamp(1000, (byte) -100);
+
+               assertTrue(ts1.compareTo(ts2, false) < 0);
+               assertTrue(ts1.compareTo(ts3, false) < 0);
+               assertTrue(ts1.compareTo(ts4, false) < 0);
+
+               assertTrue(ts2.compareTo(ts1, false) > 0);
+               assertTrue(ts2.compareTo(ts3, false) < 0);
+               assertTrue(ts2.compareTo(ts4, false) < 0);
+
+               assertTrue(ts3.compareTo(ts1, false) > 0);
+               assertTrue(ts3.compareTo(ts2, false) > 0);
+               assertTrue(ts3.compareTo(ts4, false) > 0);
+
+               assertTrue(ts4.compareTo(ts1, false) > 0);
+               assertTrue(ts4.compareTo(ts2, false) > 0);
+               assertTrue(ts4.compareTo(ts3, false) < 0);
+       }
+
+       public void testCompareToBigGuys() throws Exception {
+               TmfTimestamp ts1 = new TmfTimestamp(-1, Byte.MAX_VALUE);
+               TmfTimestamp ts2 = new TmfTimestamp(-1, Byte.MIN_VALUE);
+               TmfTimestamp ts3 = new TmfTimestamp(1, Byte.MAX_VALUE);
+               TmfTimestamp ts4 = new TmfTimestamp(1, Byte.MIN_VALUE);
+
+               assertTrue(ts1.compareTo(TmfTimestamp.BigBang, false) > 0);
+               assertTrue(ts1.compareTo(TmfTimestamp.BigCrunch, false) < 0);
+
+               assertTrue(ts2.compareTo(TmfTimestamp.BigBang, false) > 0);
+               assertTrue(ts2.compareTo(TmfTimestamp.BigCrunch, false) < 0);
+
+               assertTrue(ts3.compareTo(TmfTimestamp.BigBang, false) > 0);
+               assertTrue(ts3.compareTo(TmfTimestamp.BigCrunch, false) < 0);
+
+               assertTrue(ts4.compareTo(TmfTimestamp.BigBang, false) > 0);
+               assertTrue(ts4.compareTo(TmfTimestamp.BigCrunch, false) < 0);
+       }
 
 }
index dee1fba659462fd1c0192d43e39a6c5da5071960..3d48563bc41c053096f25a99b948d02ec102b770 100644 (file)
 
 package org.eclipse.linuxtools.tmf.event;
 
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
+import junit.framework.TestCase;
 
 /**
  * <b><u>TmfTraceEventTest</u></b>
  * <p>
- * JUnit test suite for the TmfTraceEvent class.
+ * TODO: Implement me. Please.
  */
-public class TmfTraceEventTest {
+public class TmfTraceEventTest extends TestCase {
+
+       private final String   fTypeId = "Some type";
+       private final String   fLabel0 = "label1";
+       private final String   fLabel1 = "label2";
+       private final String[] fLabels = new String[] { fLabel0, fLabel1 };
+
+       private final TmfTimestamp      fTimestamp1 = new TmfTimestamp(12345, (byte) 2, 5);
+       private final TmfTimestamp      fTimestamp2 = new TmfTimestamp(12350, (byte) 2, 5);
+       private final TmfEventSource    fSource     = new TmfEventSource("Source");
+       private final TmfEventType      fType       = new TmfEventType(fTypeId, fLabels);
+       private final TmfEventReference fReference  = new TmfEventReference("Some reference");
+
+       private final TmfTraceEvent fEvent1;
+       private final TmfTraceEvent fEvent2;
+
+       private final TmfEventContent fContent1;
+       private final TmfEventContent fContent2;
+
+       private final String fPath = "/some/path/";
+       private final String fFile = "filename";
+       private final int    fLine = 10;
+
+       // ========================================================================
+       // Housekeeping
+       // ========================================================================
+
+       public TmfTraceEventTest(String name) {
+               super(name);
+
+               fEvent1 = new TmfTraceEvent(fTimestamp1, fSource, fType, fReference, fPath, fFile, fLine);
+               fContent1 = new TmfEventContent(fEvent1, "Some content");
+               fEvent1.setContent(fContent1);
 
-    // ========================================================================
-    // Constructor
-    // ========================================================================
+               fEvent2 = new TmfTraceEvent(fTimestamp1, fTimestamp2, fSource, fType, fReference, fPath, fFile, fLine);
+               fContent2 = new TmfEventContent(fEvent2, "Some other content");
+               fEvent2.setContent(fContent2);
+       }
+
+       @Override
+       protected void setUp() throws Exception {
+               super.setUp();
+       }
+
+       @Override
+       protected void tearDown() throws Exception {
+               super.tearDown();
+       }
+
+       // ========================================================================
+       // Constructors
+       // ========================================================================
 
-    @Test
     public void testTmfTraceEvent() throws Exception {
-        TmfTimestamp      timestamp = new TmfTimestamp(12345, (byte) 2, 5);
-        TmfEventSource    source    = new TmfEventSource("Source");
-        TmfEventFormat    format    = new TmfEventFormat(new String[] { "field1", "field2" });
-        TmfEventType      type      = new TmfEventType("Type", format);
-        TmfEventContent   content   = new TmfEventContent("Some content", format);
-        TmfEventReference reference = new TmfEventReference("Reference");
-
-        // Create the trace event
-        TmfTraceEvent event = 
-            new TmfTraceEvent(timestamp, source, type, content, reference, "path", "filename", 10);
-
-        // Check the event timestamp
-        TmfTimestamp evTS = event.getTimestamp();
-        assertEquals("getValue", 12345, evTS.getValue());
-        assertEquals("getscale",     2, evTS.getScale());
-        assertEquals("getPrecision", 5, evTS.getPrecision());
-
-        // Check the event source
-        TmfEventSource evSrc = event.getSource();
-        assertEquals("getValue", "Source", evSrc.getSourceId());
-
-        // Check the event type
-        TmfEventType evType = event.getType();
-        assertEquals("getValue", "Type", evType.getTypeId());
-        assertEquals("getFormat", "field1", evType.getFormat().getLabels()[0]);
-        assertEquals("getFormat", "field2", evType.getFormat().getLabels()[1]);
-
-        // Check the event content
-        TmfEventContent evContent = event.getContent();
-        assertEquals("getField", 1, evContent.getFields().length);
-        assertEquals("getField", "Some content", evContent.getField(0).toString());
-
-        // Check the event reference
-        TmfEventReference evRef = event.getReference();
-        assertEquals("getValue", "Reference", evRef.getValue());
-
-        // Check the event file reference
-        assertEquals("getPath", "path", event.getSourcePath());
-        assertEquals("getFile", "filename", event.getFileName());
-        assertEquals("getLineNumber", 10, event.getLineNumber());
+               assertEquals("getTimestamp",         fTimestamp1, fEvent1.getTimestamp());
+               assertEquals("getOriginalTimestamp", fTimestamp1, fEvent1.getOriginalTimestamp());
+               assertEquals("getSource",            fSource,     fEvent1.getSource());
+               assertEquals("getType",              fType,       fEvent1.getType());
+               assertEquals("getContent",           fContent1,   fEvent1.getContent());
+               assertEquals("getReference",         fReference,  fEvent1.getReference());
+               assertEquals("getSourcePath",        fPath,       fEvent1.getSourcePath());
+               assertEquals("getFileName",          fFile,       fEvent1.getFileName());
+               assertEquals("getLineNumber",        fLine,       fEvent1.getLineNumber());
+    }
+
+    public void testTmfTraceEvent2() throws Exception {
+               assertEquals("getTimestamp",         fTimestamp2, fEvent2.getTimestamp());
+               assertEquals("getOriginalTimestamp", fTimestamp1, fEvent2.getOriginalTimestamp());
+               assertEquals("getSource",            fSource,     fEvent2.getSource());
+               assertEquals("getType",              fType,       fEvent2.getType());
+               assertEquals("getContent",           fContent2,   fEvent2.getContent());
+               assertEquals("getReference",         fReference,  fEvent2.getReference());
+               assertEquals("getSourcePath",        fPath,       fEvent2.getSourcePath());
+               assertEquals("getFileName",          fFile,       fEvent2.getFileName());
+               assertEquals("getLineNumber",        fLine,       fEvent2.getLineNumber());
+    }
+
+    public void testTmfTraceEventCopy() throws Exception {
+       TmfTraceEvent event = new TmfTraceEvent(fEvent2);
+               assertEquals("getTimestamp",         fTimestamp2, event.getTimestamp());
+               assertEquals("getOriginalTimestamp", fTimestamp1, event.getOriginalTimestamp());
+               assertEquals("getSource",            fSource,     event.getSource());
+               assertEquals("getType",              fType,       event.getType());
+               assertEquals("getContent",           fContent2,   event.getContent());
+               assertEquals("getReference",         fReference,  event.getReference());
+               assertEquals("getSourcePath",        fPath,       event.getSourcePath());
+               assertEquals("getFileName",          fFile,       event.getFileName());
+               assertEquals("getLineNumber",        fLine,       event.getLineNumber());
     }
 
 }
+
diff --git a/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/request/AllRequestTests.java b/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/request/AllRequestTests.java
deleted file mode 100644 (file)
index 1769cd1..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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:
- *   Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.request;
-
-import org.eclipse.linuxtools.tmf.request.TmfDataRequestTest;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
-    TmfDataRequestTest.class,
-})
-
-public class AllRequestTests {
-
-}
diff --git a/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/request/AllTests.java b/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/request/AllTests.java
new file mode 100644 (file)
index 0000000..c898085
--- /dev/null
@@ -0,0 +1,16 @@
+package org.eclipse.linuxtools.tmf.request;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+       public static Test suite() {
+               TestSuite suite = new TestSuite(AllTests.class.getName());
+               //$JUnit-BEGIN$
+               suite.addTestSuite(TmfDataRequestTest.class);
+               //$JUnit-END$
+               return suite;
+       }
+
+}
index bbdcdc40b71c395681c54cb3a38dbde1f5aa333e..eb11231d09b938b4ec2e2433009251a6ea09dc82 100644 (file)
 
 package org.eclipse.linuxtools.tmf.request;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Vector;
+import junit.framework.TestCase;
 
 import org.eclipse.linuxtools.tmf.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.request.ITmfRequestHandler;
-import org.eclipse.linuxtools.tmf.request.TmfDataRequest;
-import org.junit.BeforeClass;
-import org.junit.Test;
 
 /**
  * <b><u>TmfDataRequestTest</u></b>
  * <p>
  * TODO: Implement me. Please.
  */
-public class TmfDataRequestTest {
+public class TmfDataRequestTest extends TestCase {
 
-    private static ITmfRequestHandler<TmfEvent> fProcessor = null;
+       // ========================================================================
+       // Housekeeping
+       // ========================================================================
 
-    @BeforeClass
-    public static void setUpBeforeClass() throws Exception {
-        fProcessor = new TmfRequestHandlerStub();
-    }
+       public TmfDataRequestTest(String name) {
+               super(name);
+       }
 
-    // ========================================================================
-    // Constructor
-    // ========================================================================
+       @Override
+       protected void setUp() throws Exception {
+               super.setUp();
+       }
 
-    @Test
-    public void testConstructorForRange() throws Exception {
-        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, -1, 1);
+       @Override
+       protected void tearDown() throws Exception {
+               super.tearDown();
+       }
 
-        assertEquals("StartTime", TmfTimestamp.BigBang,   request.getRange().getStartTime());
-        assertEquals("EndTime",   TmfTimestamp.BigCrunch, request.getRange().getEndTime());
-        assertEquals("Offset",             0, request.getOffset());
-        assertEquals("NbRequestedEvents", -1, request.getNbRequestedItems());
-    }
+       // ========================================================================
+       // Constructors
+       // ========================================================================
 
-    @Test
-    public void testConstructorForNbEvents() throws Exception {
-        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, 10, 1);
+       public void testTmfDataRequestIndexNbEvents() {
+        TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(10, 100);
 
-        assertEquals("StartTime", TmfTimestamp.BigBang,   request.getRange().getStartTime());
-        assertEquals("EndTime",   TmfTimestamp.BigCrunch, request.getRange().getEndTime());
-        assertEquals("Offset",             0, request.getOffset());
-        assertEquals("NbRequestedEvents", 10, request.getNbRequestedItems());
-    }
+        assertEquals("getRange",            null, request.getRange());
+        assertEquals("getIndex",              10, request.getIndex());
+        assertEquals("getNbRequestedEvents", 100, request.getNbRequestedEvents());
+        assertEquals("getBlockize", TmfDataRequest.DEFAULT_BLOCK_SIZE, request.getBlockize());
+       }
 
-    @Test
-    public void testConstructorWithOffset() throws Exception {
-        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 5, 10, 1);
+       public void testTmfDataRequestIndexNbEventsBlocksize() {
+        TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(10, 100, 200);
 
-        assertEquals("StartTime", TmfTimestamp.BigBang,   request.getRange().getStartTime());
-        assertEquals("EndTime",   TmfTimestamp.BigCrunch, request.getRange().getEndTime());
-        assertEquals("Offset",             5, request.getOffset());
-        assertEquals("NbRequestedEvents", 10, request.getNbRequestedItems());
-    }
+        assertEquals("getRange",            null, request.getRange());
+        assertEquals("getIndex",              10, request.getIndex());
+        assertEquals("getNbRequestedEvents", 100, request.getNbRequestedEvents());
+        assertEquals("getBlockize",          200, request.getBlockize());
+       }
 
-    @Test
-    public void testConstructorWithNegativeOffset() throws Exception {
+       public void testTmfDataRequestTimeRange() {
         TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, -5, 10, 1);
+        TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range);
 
         assertEquals("StartTime", TmfTimestamp.BigBang,   request.getRange().getStartTime());
         assertEquals("EndTime",   TmfTimestamp.BigCrunch, request.getRange().getEndTime());
-        assertEquals("Offset",            -5, request.getOffset());
-        assertEquals("NbRequestedEvents", 10, request.getNbRequestedItems());
-    }
-
-    // ========================================================================
-    // process
-    // ========================================================================
-
-    @Test
-    public void testProcessRequestForNbEvents() throws Exception {
-
-        final int NB_EVENTS  = 10 * 1000;
-        final int BLOCK_SIZE = 100;
-        final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
+        assertEquals("getIndex",              0, request.getIndex());
+        assertEquals("getNbRequestedEvents", -1, request.getNbRequestedEvents());
+        assertEquals("getBlockize", TmfDataRequest.DEFAULT_BLOCK_SIZE, request.getBlockize());
+       }
 
+       public void testTmfDataRequestTimeRangeNbEvents() {
         TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, NB_EVENTS, BLOCK_SIZE) {
-            @Override
-            public void handleData() {
-               TmfEvent[] events = getData();
-                for (TmfEvent e : events) {
-                    requestedEvents.add(e);
-                }
-            }
-        };
-        fProcessor.processRequest(request, true);
-
-        assertEquals("nbEvents", NB_EVENTS, requestedEvents.size());
-        assertTrue("isCompleted",  request.isCompleted());
-        assertFalse("isCancelled", request.isCancelled());
-
-        // Ensure that we have distinct events.
-        // Don't go overboard: we are not validating the stub! 
-        for (int i = 0; i < NB_EVENTS; i++) {
-            assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue());
-        }
-    }
-    
-    @Test
-    public void testProcessRequestForAllEvents() throws Exception {
-
-        final int NB_EVENTS  = -1;
-        final int BLOCK_SIZE =  1;
-        final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
-        int nbExpectedEvents = TmfRequestHandlerStub.MAX_GENERATED_EVENTS;
+        TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 10);
 
-        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, NB_EVENTS, BLOCK_SIZE) {
-            @Override
-            public void handleData() {
-               TmfEvent[] events = getData();
-                for (TmfEvent e : events) {
-                    requestedEvents.add(e);
-                }
-            }
-        };
-        fProcessor.processRequest(request, true);
-
-        assertEquals("nbEvents", nbExpectedEvents, requestedEvents.size());
-        assertTrue("isCompleted",  request.isCompleted());
-        assertFalse("isCancelled", request.isCancelled());
-
-        // Ensure that we have distinct events.
-        // Don't go overboard: we are not validating the stub! 
-        for (int i = 0; i < nbExpectedEvents; i++) {
-            assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue());
-        }
-    }
-    
-    // @Test
-    public void testProcessRequestWithOffset() throws Exception {
-
-        final int NB_EVENTS  = -1;
-        final int BLOCK_SIZE =  1;
-        final int OFFSET = 5;
-        final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
-        int nbExpectedEvents = TmfRequestHandlerStub.MAX_GENERATED_EVENTS;
-
-        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, OFFSET, NB_EVENTS, BLOCK_SIZE) {
-            @Override
-            public void handleData() {
-               TmfEvent[] events = getData();
-                for (TmfEvent e : events) {
-                    requestedEvents.add(e);
-                }
-            }
-        };
-        fProcessor.processRequest(request, true);
-
-        assertEquals("nbEvents", nbExpectedEvents, requestedEvents.size());
-        assertTrue("isCompleted",  request.isCompleted());
-        assertFalse("isCancelled", request.isCancelled());
-
-        // Ensure that we have distinct events.
-        // Don't go overboard: we are not validating the stub! 
-        for (int i = 0; i < nbExpectedEvents; i++) {
-            assertEquals("Distinct events", i + OFFSET, requestedEvents.get(i).getTimestamp().getValue());
-        }
-    }
-    
-    // l@Test
-    public void testProcessRequestWithNegativeOffset() throws Exception {
-
-        final int NB_EVENTS  = -1;
-        final int BLOCK_SIZE =  1;
-        final int OFFSET = -5;
-        final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
-        int nbExpectedEvents = TmfRequestHandlerStub.MAX_GENERATED_EVENTS;
+        assertEquals("StartTime", TmfTimestamp.BigBang,   request.getRange().getStartTime());
+        assertEquals("EndTime",   TmfTimestamp.BigCrunch, request.getRange().getEndTime());
+        assertEquals("getIndex",              0, request.getIndex());
+        assertEquals("getNbRequestedEvents", 10, request.getNbRequestedEvents());
+        assertEquals("getBlockize", TmfDataRequest.DEFAULT_BLOCK_SIZE, request.getBlockize());
+       }
 
+       public void testTmfDataRequestTimeRangeNbEventsBlockSize() {
         TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, OFFSET, NB_EVENTS, BLOCK_SIZE) {
-            @Override
-            public void handleData() {
-               TmfEvent[] events = getData();
-                for (TmfEvent e : events) {
-                    requestedEvents.add(e);
-                }
-            }
-        };
-        fProcessor.processRequest(request, true);
-
-        assertEquals("nbEvents", nbExpectedEvents, requestedEvents.size());
-        assertTrue("isCompleted",  request.isCompleted());
-        assertFalse("isCancelled", request.isCancelled());
-
-        // Ensure that we have distinct events.
-        // Don't go overboard: we are not validating the stub! 
-        for (int i = 0; i < nbExpectedEvents; i++) {
-            assertEquals("Distinct events", i + OFFSET, requestedEvents.get(i).getTimestamp().getValue());
-        }
-    }
-    
-    // ========================================================================
-    // cancel
-    // ========================================================================
-
-    @Test
-    public void testCancel() throws Exception {
-
-        final int NB_EVENTS  = 10 * 1000;
-        final int BLOCK_SIZE = 100;
-        final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
+        TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 10, 100);
 
-        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, NB_EVENTS, BLOCK_SIZE) {
-            @Override
-            public void handleData() {
-               TmfEvent[] events = getData();
-                for (TmfEvent e : events) {
-                    requestedEvents.add(e);
-                }
-                // Cancel request after the first chunk is received
-                cancel();
-            }
-        };
-        fProcessor.processRequest(request, true);
-
-        assertEquals("nbEvents",  BLOCK_SIZE, requestedEvents.size());
-        assertTrue("isCompleted", request.isCompleted());
-        assertTrue("isCancelled", request.isCancelled());
-    }
+        assertEquals("StartTime", TmfTimestamp.BigBang,   request.getRange().getStartTime());
+        assertEquals("EndTime",   TmfTimestamp.BigCrunch, request.getRange().getEndTime());
+        assertEquals("getIndex",              0, request.getIndex());
+        assertEquals("getNbRequestedEvents", 10, request.getNbRequestedEvents());
+        assertEquals("getBlockize",         100, request.getBlockize());
+       }
 
 }
diff --git a/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/trace/AllTests.java b/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/trace/AllTests.java
new file mode 100644 (file)
index 0000000..dc87e23
--- /dev/null
@@ -0,0 +1,17 @@
+package org.eclipse.linuxtools.tmf.trace;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+       public static Test suite() {
+               TestSuite suite = new TestSuite(AllTests.class.getName());
+               //$JUnit-BEGIN$
+               suite.addTestSuite(TmfTraceTest.class);
+               suite.addTestSuite(TmfExperimentTest.class);
+               //$JUnit-END$
+               return suite;
+       }
+
+}
diff --git a/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/trace/AllTraceTests.java b/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/trace/AllTraceTests.java
deleted file mode 100644 (file)
index f7bfe96..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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:
- *   Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.trace;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
-       TmfTraceTest.class,
-    TmfExperimentTest.class
-})
-
-public class AllTraceTests {
-
-}
index cbb5ca18b246d0bc696c7e3039b5bf6e737b62a2..0c3f89918e660a6cef531f21ec6f708025a91120 100644 (file)
 
 package org.eclipse.linuxtools.tmf.trace;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
 import java.io.File;
 import java.util.Vector;
 
@@ -23,15 +19,15 @@ import org.eclipse.linuxtools.tmf.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
 import org.eclipse.linuxtools.tmf.request.TmfDataRequest;
-import org.junit.BeforeClass;
-import org.junit.Test;
+
+import junit.framework.TestCase;
 
 /**
- * <b><u>TmfEventLogTest</u></b>
+ * <b><u>TmfExperimentTest</u></b>
  * <p>
  * TODO: Implement me. Please.
  */
-public class TmfExperimentTest {
+public class TmfExperimentTest extends TestCase {
 
     private static final String DIRECTORY   = "testfiles";
     private static final String TEST_STREAM = "M-Test-10K";
@@ -43,8 +39,12 @@ public class TmfExperimentTest {
     private static ITmfTrace fStream;
     private static TmfExperiment fExperiment;
 
-    @BeforeClass
-       public static void setUpBeforeClass() throws Exception {
+    // ========================================================================
+    // Housekeeping
+    // ========================================================================
+
+       public TmfExperimentTest(String name) throws Exception {
+               super(name);
        String directory = new File(".").getCanonicalPath() + File.separator + DIRECTORY;
        testfile = directory + File.separator + TEST_STREAM;
 
@@ -52,11 +52,20 @@ public class TmfExperimentTest {
         fExperiment = new TmfExperiment(EXPERIMENT, new ITmfTrace[] { fStream }, true);
        }
 
+       @Override
+       protected void setUp() throws Exception {
+               super.setUp();
+       }
+
+       @Override
+       protected void tearDown() throws Exception {
+               super.tearDown();
+       }
+
     // ========================================================================
     // Constructor
     // ========================================================================
 
-       @Test
        public void testBasicTmfTrace() {
                assertEquals("GetId", EXPERIMENT, fExperiment.getExperimentId());
         assertEquals("GetEpoch", TmfTimestamp.BigBang, fExperiment.getEpoch());
@@ -71,14 +80,13 @@ public class TmfExperimentTest {
     // processRequest
     // ========================================================================
 
-    @Test
     public void testProcessRequestForNbEvents() throws Exception {
         final int blockSize = 100;
         final int nbEvents = 1000;
         final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
 
         TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, nbEvents, blockSize) {
+        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, nbEvents, blockSize) {
             @Override
             public void handleData() {
                TmfEvent[] events = getData();
@@ -100,14 +108,13 @@ public class TmfExperimentTest {
         }
     }
     
-    @Test
     public void testProcessRequestForNbEvents2() throws Exception {
         final int blockSize = 2 * NB_EVENTS;
         final int nbEvents = 1000;
         final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
 
         TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, nbEvents, blockSize) {
+        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, nbEvents, blockSize) {
             @Override
             public void handleData() {
                TmfEvent[] events = getData();
@@ -129,7 +136,6 @@ public class TmfExperimentTest {
         }
     }
     
-    @Test
     public void testProcessRequestForAllEvents() throws Exception {
         final int nbEvents  = -1;
         final int blockSize =  1;
@@ -137,7 +143,7 @@ public class TmfExperimentTest {
         int nbExpectedEvents = fExperiment.getNbEvents();
 
         TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, nbEvents, blockSize) {
+        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, nbEvents, blockSize) {
             @Override
             public void handleData() {
                TmfEvent[] events = getData();
@@ -163,14 +169,13 @@ public class TmfExperimentTest {
     // cancel
     // ========================================================================
 
-    @Test
     public void testCancel() throws Exception {
         final int nbEvents  = NB_EVENTS;
         final int blockSize =  fDefaultBlockSize;
         final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
 
         TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, nbEvents, blockSize) {
+        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, nbEvents, blockSize) {
             @Override
             public void handleData() {
                TmfEvent[] events = getData();
@@ -187,5 +192,4 @@ public class TmfExperimentTest {
         assertTrue("isCompleted", request.isCompleted());
         assertTrue("isCancelled", request.isCancelled());
     }
-
 }
index 421c6b6152c7423490e31e40b58848334afc5b79..b1f20f46b522dc65a55daf158e8ca8e6e2bb841a 100644 (file)
 
 package org.eclipse.linuxtools.tmf.trace;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
 import java.io.File;
 import java.util.Vector;
 
@@ -23,15 +19,15 @@ import org.eclipse.linuxtools.tmf.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
 import org.eclipse.linuxtools.tmf.request.TmfDataRequest;
-import org.junit.BeforeClass;
-import org.junit.Test;
+
+import junit.framework.TestCase;
 
 /**
- * <b><u>TmfEventStreamTest</u></b>
+ * <b><u>TmfTraceTest</u></b>
  * <p>
  * TODO: Implement me. Please.
  */
-public class TmfTraceTest {
+public class TmfTraceTest extends TestCase {
 
     private static final String DIRECTORY   = "testfiles";
     private static final String TEST_STREAM = "M-Test-10K";
@@ -41,43 +37,51 @@ public class TmfTraceTest {
 
     private static byte SCALE = (byte) -3;
 
-    /**
-     * @throws java.lang.Exception
-     */
-    @BeforeClass
-    public static void setUpBeforeClass() throws Exception {
+    // ========================================================================
+    // Housekeeping
+    // ========================================================================
+
+       public TmfTraceTest(String name) throws Exception {
+               super(name);
        String directory = new File(".").getCanonicalPath() + File.separator + DIRECTORY;
        testfile = directory + File.separator + TEST_STREAM;
         fTrace = new TmfTraceStub(testfile, 500, true);
-    }
+       }
+
+       @Override
+       protected void setUp() throws Exception {
+               super.setUp();
+       }
+
+       @Override
+       protected void tearDown() throws Exception {
+               super.tearDown();
+       }
 
     // ========================================================================
-    // Constructor
+    // Constructors
     // ========================================================================
 
-    @Test
-    public void testDefaultConstructor() throws Exception {
+    public void testTmfTraceDefault() throws Exception {
         TmfTraceStub trace = new TmfTraceStub(testfile, true);
 
         assertEquals("getCacheSize", TmfTraceStub.DEFAULT_CACHE_SIZE, trace.getCacheSize());
-        assertEquals("getTraceSize", NB_EVENTS, trace.getNbEvents());
-        assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue());
-        assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue());
+        assertEquals("getTraceSize",   0, trace.getNbEvents());
+        assertEquals("getRange-start", 0, trace.getTimeRange().getStartTime().getValue());
+        assertEquals("getRange-end",   0, trace.getTimeRange().getEndTime().getValue());
     }
 
-    @Test
-    public void testNormalConstructor() throws Exception {
-        assertEquals("getCacheSize",    500,    fTrace.getCacheSize());
-        assertEquals("getTraceSize", NB_EVENTS, fTrace.getNbEvents());
-        assertEquals("getRange-start",    1,    fTrace.getTimeRange().getStartTime().getValue());
-        assertEquals("getRange-end", NB_EVENTS, fTrace.getTimeRange().getEndTime().getValue());
+    public void testTmfTrace() throws Exception {
+        assertEquals("getCacheSize", 500, fTrace.getCacheSize());
+        assertEquals("getTraceSize",   0, fTrace.getNbEvents());
+        assertEquals("getRange-start", 0, fTrace.getTimeRange().getStartTime().getValue());
+        assertEquals("getRange-end",   0, fTrace.getTimeRange().getEndTime().getValue());
     }
 
     // ========================================================================
     // seek
     // ========================================================================
 
-    @Test
     public void testSeekOnCacheBoundary() throws Exception {
        TmfTraceContext context = fTrace.seekLocation(null);
 
@@ -94,7 +98,6 @@ public class TmfTraceTest {
         assertEquals("Event timestamp", 4000, event.getTimestamp().getValue());
     }
 
-    @Test
     public void testSeekNotOnCacheBoundary() throws Exception {
        TmfTraceContext context = fTrace.seekLocation(null);
 
@@ -111,7 +114,6 @@ public class TmfTraceTest {
         assertEquals("Event timestamp", 4499, event.getTimestamp().getValue());
     }
 
-    @Test
     public void testSeekForEventOutOfBounds() throws Exception {
        TmfTraceContext context = fTrace.seekLocation(null);
 
@@ -130,7 +132,6 @@ public class TmfTraceTest {
     // getNextEvent
     // ========================================================================
 
-    @Test
     public void testGetNextEvent() throws Exception {
        TmfTraceContext context = fTrace.seekLocation(null);
 
@@ -149,14 +150,13 @@ public class TmfTraceTest {
     // processRequest
     // ========================================================================
 
-    @Test
     public void testProcessRequestForNbEvents() throws Exception {
         final int BLOCK_SIZE = 100;
         final int NB_EVENTS  = 1000;
         final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
 
         TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, NB_EVENTS, BLOCK_SIZE) {
+        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, NB_EVENTS, BLOCK_SIZE) {
             @Override
             public void handleData() {
                TmfEvent[] events = getData();
@@ -178,15 +178,13 @@ public class TmfTraceTest {
         }
     }
     
-    @Test
     public void testProcessRequestForAllEvents() throws Exception {
-        final int NB_EVENTS  = -1;
         final int BLOCK_SIZE =  1;
         final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
-        long nbExpectedEvents = fTrace.getNbEvents();
+        long nbExpectedEvents = NB_EVENTS;
 
         TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, NB_EVENTS, BLOCK_SIZE) {
+        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, NB_EVENTS, BLOCK_SIZE) {
             @Override
             public void handleData() {
                TmfEvent[] events = getData();
@@ -197,13 +195,13 @@ public class TmfTraceTest {
         };
         fTrace.processRequest(request, true);
 
-        assertEquals("nbEvents", nbExpectedEvents, requestedEvents.size());
+        assertEquals("nbEvents", NB_EVENTS, requestedEvents.size());
         assertTrue("isCompleted",  request.isCompleted());
         assertFalse("isCancelled", request.isCancelled());
 
         // Ensure that we have distinct events.
         // Don't go overboard: we are not validating the stub! 
-        for (int i = 0; i < nbExpectedEvents; i++) {
+        for (int i = 0; i < NB_EVENTS; i++) {
             assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue());
         }
     }
@@ -212,12 +210,11 @@ public class TmfTraceTest {
     // cancel
     // ========================================================================
 
-    @Test
     public void testCancel() throws Exception {
         final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
 
         TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, NB_EVENTS, NB_EVENTS) {
+        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, NB_EVENTS, NB_EVENTS) {
             @Override
             public void handleData() {
                TmfEvent[] events = getData();
@@ -234,5 +231,4 @@ public class TmfTraceTest {
         assertTrue("isCompleted", request.isCompleted());
         assertTrue("isCancelled", request.isCancelled());
     }
-
 }
index 9e91fc6f427e5134e14524c56881c4a9cdf0f46f..db6ea3a09b4246e90dc1038f6e535c9ad207d862 100644 (file)
@@ -39,8 +39,8 @@ public class CreateTestFiles {
     // ========================================================================
 
        private static final String DIRECTORY = "testfiles";
-       private static final String FILE_NAMES[] = { "Test-10", "Test-1K", "Test-10K", "Test-100K", "Test-1M",  "Test-10M" };
-    private static final int    FILE_SIZES[] = {       10 ,     1000 ,     10000 ,     100000 ,  1000000 ,   10000000  };
+       private static final String FILE_NAMES[] = { "Test-10", "Test-1K", "Test-10K", "Test-100K" };
+    private static final int    FILE_SIZES[] = {       10 ,     1000 ,     10000 ,     100000  };
 
     private static final int NB_SOURCES = 15;  
     private static final int NB_TYPES   =  7;  
index 91dc38af1c2345e601ffccaed9a9aec3a5ffcb69..b56485bbc64c056776b24aa0efac3e9675edb01b 100644 (file)
@@ -45,15 +45,15 @@ public class TmfEventContentStub extends TmfEventContent {
                return content;
     }
 
-//    @Override
-//     public String toString() {
-//     Object[] fields = getFields();
-//     StringBuilder result = new StringBuilder("[TmfEventContent(");
-//     for (int i = 0; i < fields.length; i++) {
-//             if (i > 0) result.append(",");
-//             result.append(fields[i]);
-//     }
-//     result.append(")]");
-//     return result.toString();
-//    }
+    @Override
+       public String toString() {
+       Object[] fields = getFields();
+       String result = "[TmfEventContentStub(";
+       for (int i = 0; i < fields.length; i++) {
+               result += fields[i].toString() + ",";
+       }
+       result += ")]";
+
+       return result;
+    }
 }
diff --git a/org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/event/TmfEventFormatStub.java b/org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/event/TmfEventFormatStub.java
deleted file mode 100644 (file)
index e144343..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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:
- *   Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.event;
-
-/**
- * <b><u>TmfEventFormatStub</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class TmfEventFormatStub extends TmfEventFormat {
-
-    // ========================================================================
-    // Attributes
-    // ========================================================================
-
-    // ========================================================================
-    // Constructors
-    // ========================================================================
-
-   public TmfEventFormatStub() {
-        super(new String[] { "Field1", "Field2", "Field3", "Field4", "Field5" });
-    }
-
-   // ========================================================================
-   // Accessors
-   // ========================================================================
-
-   // ========================================================================
-   // Operators
-   // ========================================================================
-
-    /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.event.TmfEventFormat#parse(java.lang.Object)
-     */
-    @Override
-    public TmfEventField[] parse(Object content) {
-        TmfEventField field1 = new TmfEventField(1);
-        TmfEventField field2 = new TmfEventField(-10);
-        TmfEventField field3 = new TmfEventField(true);
-        TmfEventField field4 = new TmfEventField("some string");
-        TmfEventField field5 = new TmfEventField(new TmfTimestamp(1, (byte) 2, 3));
-        return new TmfEventField[] { field1, field2, field3, field4, field5 };
-    }
-
-    // ========================================================================
-    // Helper functions
-    // ========================================================================
-
-}
index 281c93fa4954693acb86f95e01585d9e66ee82a5..2d56c1fae9f75c3c3bc4f2e6ced48e2e1dadb9ac 100644 (file)
@@ -54,7 +54,7 @@ public class TmfRequestHandlerStub implements ITmfRequestHandler<TmfEvent> {
                 TmfTimestamp endTime   = request.getRange().getEndTime();
                 int blockSize = request.getBlockize();
 
-                int nbRequestedEvents = request.getNbRequestedItems();
+                int nbRequestedEvents = request.getNbRequestedEvents();
                 if (nbRequestedEvents <= 0) {
                     nbRequestedEvents = MAX_GENERATED_EVENTS;
                 }
index 1b739ca466a500757a3ebd90d7bf95f17902c20a..0196766d3fd761862302107f1691264b5de6364c 100644 (file)
@@ -19,7 +19,6 @@ import java.util.Vector;
 
 import org.eclipse.linuxtools.tmf.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.event.TmfEventContent;
-import org.eclipse.linuxtools.tmf.event.TmfEventFormat;
 import org.eclipse.linuxtools.tmf.event.TmfEventReference;
 import org.eclipse.linuxtools.tmf.event.TmfEventSource;
 import org.eclipse.linuxtools.tmf.event.TmfEventType;
@@ -36,22 +35,22 @@ public class TmfEventParserStub implements ITmfEventParser {
     // Attributes
     // ========================================================================
 
-       private final int NB_FORMATS = 10;
-    private final TmfEventFormat[] fFormats;
+       private final int NB_TYPES = 10;
+    private final TmfEventType[] fTypes;
 
     // ========================================================================
     // Constructors
     // ========================================================================
 
     public TmfEventParserStub() {
-       fFormats = new TmfEventFormat[NB_FORMATS];
-       for (int i = 0; i < NB_FORMATS; i++) {
+       fTypes = new TmfEventType[NB_TYPES];
+       for (int i = 0; i < NB_TYPES; i++) {
                Vector<String> format = new Vector<String>();
                for (int j = 1; j <= i; j++) {
                        format.add(new String("Fmt-" + i + "-Fld-" + j));
                }
                String[] fields = new String[i];
-               fFormats[i] = new TmfEventFormat(format.toArray(fields));
+               fTypes[i] = new TmfEventType("Type-" + i, format.toArray(fields));
        }
     }
 
@@ -59,9 +58,6 @@ public class TmfEventParserStub implements ITmfEventParser {
     // Operators
     // ========================================================================
 
-    /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventParser#parseNextEvent()
-     */
     static final String typePrefix = "Type-";
     public TmfEvent parseNextEvent(ITmfTrace eventStream, TmfTraceContext context) throws IOException {
 
@@ -108,10 +104,11 @@ public class TmfEventParserStub implements ITmfEventParser {
                        TmfEvent event = new TmfEvent(
                                        new TmfTimestamp(ts, (byte) -3, 0),     // millisecs
                                        new TmfEventSource(source),
-                                       new TmfEventType(type, fFormats[typeIndex]),
-                                       new TmfEventContent(content, fFormats[typeIndex]),
+                                       fTypes[typeIndex],
                                        new TmfEventReference(name));
-                       return event;
+                               TmfEventContent cnt = new TmfEventContent(event, content);
+                               event.setContent(cnt);
+                               return event;
                } catch (EOFException e) {
                }
         }
index 6767043666613b745acf4f51cd95f6f705b915b9..62ba8f598a3b3abb47a1b898310c4c0a73c5e6d8 100644 (file)
@@ -141,17 +141,36 @@ public class TmfEventsView extends TmfView {
                                        item.setText(extractItemFields(cache[index - cacheStartIndex]));
                                        return;
                                }
-                               TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(index, 0, CACHE_SIZE) {
+                               
+                               // *** TODO ***
+                               // This is broken!
+                               // 
+                               // This one fails to return any result : 
+                               //              TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(fExperiment.getTimeRange(), index, 1) {
+                               // All these will return THE SAME RESULT!
+                               //              TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(index, 1) {
+                               //              TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(index+10, 1) {
+                               //              TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(null, 1) {
+                               //              
+                               // THIS IS ONLY A TEMPORARY FIX! 
+                               
+                               TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(index, 1) {
                                        @Override
                                        public void handleData() {
-                                               // No need to synchronize because the request is synchronous
-                                               cache = getData();
-                                               cacheStartIndex = index;
-                                               cacheEndIndex = index + cache.length; 
+                                               TmfEvent[] tmpEvent = getData();
+                                               if ( (tmpEvent != null) && (tmpEvent.length > 0) ) {
+                                                       cache = tmpEvent;
+                                               }
+//                                             cacheStartIndex = index;
+//                                             cacheEndIndex = index + cache.length; 
                                        }
                                };
                                fExperiment.processRequest(request, true);
-                               item.setText(extractItemFields(cache[0]));
+                               
+                               if (cache[0] != null) {
+                                       item.setText(extractItemFields(cache[0]));
+                               }
+                               
                        }
         });
 
@@ -166,7 +185,7 @@ public class TmfEventsView extends TmfView {
     }
 
     // Events cache - temporary stuff
-    private final int CACHE_SIZE = 100;
+    private final int CACHE_SIZE = 1;
     private TmfEvent[] cache;
     private int cacheStartIndex = 0;
     private int cacheEndIndex = 0;
@@ -214,8 +233,8 @@ public class TmfEventsView extends TmfView {
                                new Long(event.getTimestamp().getValue()).toString(),           
                                event.getSource().getSourceId().toString(),
                                event.getType().getTypeId().toString(),
-                               event.getReference().getValue().toString(),
-                               event.getContent().getContent()
+                               event.getReference().getReference().toString(),
+                               event.getContent().toString()
             };
                }
                return fields;
@@ -249,7 +268,7 @@ public class TmfEventsView extends TmfView {
         // Perform the updates on the UI thread
         fTable.getDisplay().asyncExec(new Runnable() {
                public void run() {
-                       // TODO: Potentially long operation. Add some feedback for the user
+//                     // TODO: Potentially long operation. Add some feedback for the user
                        fTable.setSelection(0);
                fTable.clearAll();
                fTable.setItemCount(fExperiment.getNbEvents());        
@@ -292,4 +311,4 @@ public class TmfEventsView extends TmfView {
        }
     }
 
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/ITmfContentParser.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/ITmfContentParser.java
deleted file mode 100644 (file)
index 0128da4..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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:
- *   Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.event;
-
-/**
- * <b><u>ITmfContentParser</u></b>
- * <p>
- * Event content parser.
- */
-public interface ITmfContentParser {
-
-    public TmfEventField[] parse(Object content);
-}
index 51143ee2208cee0d3764d5595735e25a1520666d..934d42e642540764cb33ddc30e3a1dd88a050bbe 100644 (file)
@@ -25,61 +25,76 @@ package org.eclipse.linuxtools.tmf.event;
  * For convenience, a free-form reference field is also provided. It could be
  * used as e.g. a location marker in the event stream to distinguish between
  * otherwise identical events.
+ * 
+ * Notice that for performance reasons TmfEvent is NOT immutable. If a copy
+ * of the event is needed, use clone().
  */
-public class TmfEvent extends TmfData {
+public class TmfEvent extends TmfData implements Cloneable {
 
     // ========================================================================
     // Attributes
     // ========================================================================
 
-       private final TmfTimestamp fEffectiveTimestamp;
-       private final TmfTimestamp fOriginalTimestamp;
-       private final TmfEventSource fSource;
-       private final TmfEventType fType;
-       private final TmfEventContent fContent;
-       private final TmfEventReference fReference;
+       protected TmfTimestamp      fEffectiveTimestamp;
+       protected TmfTimestamp      fOriginalTimestamp;
+       protected TmfEventSource    fSource;
+       protected TmfEventType      fType;
+       protected TmfEventReference fReference;
 
-    // ========================================================================
+       // Content requires a reference to the parent event so it is initialized
+       // using setContent()
+       protected TmfEventContent   fContent;
+
+       // ========================================================================
     // Constructors
     // ========================================================================
 
        /**
-        * @param timestamp
+        * @param originalTS
+        * @param effectiveTS
         * @param source
         * @param type
-        * @param content
         * @param reference
         */
-       public TmfEvent(TmfTimestamp originalTS, TmfTimestamp effectiveTS, TmfEventSource source,
-                       TmfEventType type, TmfEventContent content, TmfEventReference reference)
+       public TmfEvent(TmfTimestamp originalTS, TmfTimestamp effectiveTS,
+                       TmfEventSource source, TmfEventType type, TmfEventReference reference)
        {
-               fOriginalTimestamp = originalTS;
+               fOriginalTimestamp  = originalTS;
                fEffectiveTimestamp = effectiveTS;
-               fSource = source;
-               fType = type;
-               fContent = content;
-               fReference = reference;
+               fSource             = source;
+               fType               = type;
+               fReference          = reference;
        }
 
        /**
         * @param timestamp
         * @param source
         * @param type
-        * @param content
         * @param reference
         */
        public TmfEvent(TmfTimestamp timestamp, TmfEventSource source,
-                       TmfEventType type, TmfEventContent content, TmfEventReference reference)
+                       TmfEventType type, TmfEventReference reference)
        {
-               this(timestamp, timestamp, source, type, content, reference);
+               this(timestamp, timestamp, source, type, reference);
        }
 
        /**
+        * Copy constructor (shallow)
+        * 
+        * @param other
         */
-       public TmfEvent(TmfEvent other)
-       {
-               this(other.fOriginalTimestamp, other.fEffectiveTimestamp, other.fSource,
-                        other.fType, other.fContent, other.fReference);
+       public TmfEvent(TmfEvent other) {
+               assert(other != null);
+               fOriginalTimestamp  = other.fOriginalTimestamp;
+               fEffectiveTimestamp = other.fEffectiveTimestamp;
+               fSource                         = other.fSource;
+               fType                           = other.fType;
+               fContent                        = other.fContent;
+               fReference                      = other.fReference;
+       }
+
+       @SuppressWarnings("unused")
+       private TmfEvent() {
        }
 
     // ========================================================================
@@ -114,6 +129,13 @@ public class TmfEvent extends TmfData {
                return fType;
        }
 
+       /**
+        * @return
+        */
+       public void setContent(TmfEventContent content) {
+               fContent = content;
+       }
+
        /**
         * @return
         */
@@ -128,6 +150,23 @@ public class TmfEvent extends TmfData {
                return fReference;
        }
 
+    // ========================================================================
+    // Operators
+    // ========================================================================
+
+       @Override
+       public TmfEvent clone() {
+               TmfEvent event = new TmfEvent(
+                       fOriginalTimestamp.clone(),
+                       fEffectiveTimestamp.clone(),
+                   fSource.clone(),
+                   fType.clone(),
+                   fReference.clone());
+               TmfEventContent content = fContent.clone();
+               event.setContent(content);
+               return event;
+       }
+
        // TODO: Design a proper format...
        @Override
        public String toString() {
index 2bfc446aa21c395287e57eb637d1060c4400f829..1a97c6cb524bc77c133685dc195a50c0b5665b5e 100644 (file)
 
 package org.eclipse.linuxtools.tmf.event;
 
+
 /**
  * <b><u>TmfEventContent</u></b>
  * <p>
  * The event content.
  */
-public class TmfEventContent {
+public class TmfEventContent implements Cloneable {
 
     // ========================================================================
     // Attributes
     // ========================================================================
 
-       private final TmfEventFormat fFormat;
-       private final String fContent;
-       private final int fNbFields;
-       private       TmfEventField[] fFields = null;
+       protected TmfEvent fParentEvent = null;
+       protected Object   fRawContent  = null;
+       protected Object[] fFields      = null;
 
     // ========================================================================
     // Constructors
     // ========================================================================
 
        /**
+        * @param parent
         * @param content
-        * @param format
         */
-       public TmfEventContent(Object content, TmfEventFormat format) {
-               fFormat = format;
-               fContent = content.toString();
-               fNbFields = fFormat.getLabels().length;
+       public TmfEventContent(TmfEvent parent, Object content) {
+               fParentEvent = parent;
+               fRawContent  = content;
        }
 
+    /**
+     * @param other
+     */
+    public TmfEventContent(TmfEventContent other) {
+       assert(other != null);
+       fParentEvent = other.fParentEvent;
+               fRawContent  = other.fRawContent;
+               fFields      = other.fFields;
+    }
+
+    @SuppressWarnings("unused")
+       private TmfEventContent() {
+    }
+
     // ========================================================================
     // Accessors
     // ========================================================================
 
        /**
-        * @return
+        * @return the parent (containing) event
         */
-       public String getContent() {
-               return fContent;
+       public TmfEvent getEvent() {
+               return fParentEvent;
        }
 
        /**
-        * @return
+        * @return the event type
         */
-       public TmfEventFormat getFormat() {
-               return fFormat;
+       public TmfEventType getType() {
+               return fParentEvent.getType();
        }
 
-    /**
-     * @return
-     */
-    public int getNbFields() {
-        return fNbFields;
-    }
+       /**
+        * @return the raw content
+        */
+       public Object getContent() {
+               return fRawContent;
+       }
 
        /**
-        * @return
+        * Returns the list of fields in the same order as TmfEventType.getLabels()
+        * 
+        * @return the ordered set of fields (optional fields might be null)
         */
-       public TmfEventField[] getFields() {
-           if (fFields == null) {
-               fFields = fFormat.parse(fContent);
-           }
+       public Object[] getFields() {
+               if (fFields == null) {
+                       parseContent();
+               }
                return fFields;
        }
 
@@ -81,19 +96,56 @@ public class TmfEventContent {
         * @param id
         * @return
         */
-       public TmfEventField getField(int id) {
-        assert id >= 0 && id < fNbFields;
-        if (fFields == null) {
-            fFields = fFormat.parse(fContent);
-        }
-               return fFields[id];
+       public Object getField(String id) throws TmfNoSuchFieldException {
+               if (fFields == null) {
+                       parseContent();
+               }
+               return fFields[getType().getFieldIndex(id)];
        }
 
        /**
+        * @param n
         * @return
         */
-       public void setFields(TmfEventField[] fields) {
-        fFields = fields;
+       public Object getField(int n) {
+               if (fFields == null) {
+                       parseContent();
+               }
+               if (n >= 0 && n < fFields.length)
+                       return fFields[n];
+               return null;
+       }
+
+    // ========================================================================
+    // Operators
+    // ========================================================================
+
+       /**
+        * Should be overridden (all fields are null by default)
+        */
+       protected void parseContent() {
+               fFields = new Object[1];
+               fFields[0] = fRawContent;
        }
+       
+       /**
+        * Clone: shallow copy by default; override for deep copy.
+        */
+    @Override
+    public TmfEventContent clone() {
+               return new TmfEventContent(this);
+    }
+
+    @Override
+       public String toString() {
+       Object[] fields = getFields();
+       String result = "[TmfEventContent(";
+       for (int i = 0; i < fields.length; i++) {
+               result += fields[i].toString() + ",";
+       }
+       result += ")]";
+
+       return result;
+    }
 
 }
index 085311eab0be16ceec3b6a5c2038ed3b59e95318..9cbd789af3e0e965feb53fd63139ac52db0ec245 100644 (file)
@@ -16,30 +16,69 @@ package org.eclipse.linuxtools.tmf.event;
  * <b><u>TmfEventField</u></b>
  * <p>
  * A basic event field.
+ * 
+ * TODO: Add support for field hierarchy.
  */
-public class TmfEventField {
+public class TmfEventField implements Cloneable {
 
     // ========================================================================
     // Attributes
     // ========================================================================
 
-    private final Object fValue;
+       private final TmfEventContent fParent;
+    private final String fFieldId;
+    private       Object fValue;
 
     // ========================================================================
     // Constructors
     // ========================================================================
 
     /**
+     * @param parent
+     * @param id
      * @param value
      */
-    public TmfEventField(Object value) {
-        fValue = value;
+    public TmfEventField(TmfEventContent parent, String id, Object value) {
+       fParent  = parent;
+       fFieldId = id;
+        fValue   = value;
+    }
+
+    /**
+     * @param other
+     */
+    public TmfEventField(TmfEventField other) {
+       assert(other != null);
+       fParent  = other.fParent;
+       fFieldId = other.fFieldId;
+               fValue   = other.fValue;
+    }
+
+    @SuppressWarnings("unused")
+       private TmfEventField() {
+       fParent  = null;
+       fFieldId = null;
+        fValue   = null;
     }
 
     // ========================================================================
     // Accessors
     // ========================================================================
 
+    /**
+     * @return
+     */
+    public TmfEventContent getParent() {
+        return fParent;
+    }
+
+    /**
+     * @return
+     */
+    public String getId() {
+        return fFieldId;
+    }
+
     /**
      * @return
      */
@@ -47,16 +86,28 @@ public class TmfEventField {
         return fValue;
     }
 
+    /**
+     * @param value
+     */
+    protected void setValue(Object value) {
+        fValue = value;
+    }
+
     // ========================================================================
     // Operators
     // ========================================================================
 
-    /* (non-Javadoc)
-     * @see java.lang.Object#toString()
-     */
+       /**
+        * Clone: shallow copy by default; override for deep copy.
+        */
+    @Override
+    public TmfEventField clone() {
+       return new TmfEventField(this);
+    }
+
     @Override
        public String toString() {
-        return fValue.toString();
+        return "[TmfEventField(" + fFieldId + ":" + fValue.toString() + ")]";
     }
 
-}
+}
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEventFormat.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEventFormat.java
deleted file mode 100644 (file)
index 6d26b20..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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:
- *   Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.event;
-
-/**
- * <b><u>TmfEventFormat</u></b>
- * <p>
- * The basic event content format.
- */
-public class TmfEventFormat implements ITmfContentParser {
-
-    // ========================================================================
-    // Attributes
-    // ========================================================================
-
-       private final String[] fLabels;
-
-    // ========================================================================
-    // Constructors
-    // ========================================================================
-
-       /**
-        * 
-        */
-       public TmfEventFormat() {
-           this(new String[] { "Content" });
-       }
-
-    /**
-     * @param labels
-     */
-    public TmfEventFormat(String[] labels) {
-        fLabels = labels;
-    }
-
-    // ========================================================================
-    // Accessors
-    // ========================================================================
-
-       /**
-        * @return
-        */
-       public String[] getLabels() {
-               return fLabels;
-       }
-
-    // ========================================================================
-    // Operators
-    // ========================================================================
-
-       /**
-        * The default content parser: returns a single field containing the whole
-        * content.
-        * 
-        * @param content
-        * @return
-        */
-       public TmfEventField[] parse(Object content) {
-        return new TmfEventField[] { new TmfEventField(content.toString()) };
-    }
-
-}
index e06cccc46551b9ad4f03a1dddd19801d08d3e96e..40a2debec8688e51fa89c0b1ed21f217595be464 100644 (file)
@@ -17,18 +17,25 @@ package org.eclipse.linuxtools.tmf.event;
  * <p>
  * An application-defined event reference.
  */
-public class TmfEventReference {
+public class TmfEventReference implements Cloneable {
 
     // ========================================================================
     // Attributes
     // ========================================================================
 
-       private final Object fReference;
+       protected Object fReference;
 
     // ========================================================================
     // Constructors
     // ========================================================================
 
+       /**
+        * 
+        */
+       public TmfEventReference() {
+               this(null);
+       }
+
        /**
         * @param reference
         */
@@ -36,6 +43,13 @@ public class TmfEventReference {
                fReference = reference;
        }
 
+       /**
+        * @param other
+        */
+       public TmfEventReference(TmfEventReference other) {
+               this((other != null) ? other.fReference : null);
+       }
+
     // ========================================================================
     // Accessors
     // ========================================================================
@@ -43,7 +57,7 @@ public class TmfEventReference {
        /**
         * @return
         */
-       public Object getValue() {
+       public Object getReference() {
                return fReference;
        }
 
@@ -51,9 +65,14 @@ public class TmfEventReference {
     // Operators
     // ========================================================================
 
+    @Override
+    public TmfEventReference clone() {
+       return new TmfEventReference(this);
+    }
+
     @Override
     public String toString() {
-        return fReference.toString();
+        return "[TmfEventReference(" + ((fReference != null) ? fReference.toString() : "null") + ")]";
     }
 
 }
index d827477fbdb891e981483e1993dde85291e2fd8a..4d6cb2437b72e0eb92ab40deeb0685bee4996d73 100644 (file)
@@ -17,13 +17,13 @@ package org.eclipse.linuxtools.tmf.event;
  * <p>
  * The event source.
  */
-public class TmfEventSource {
+public class TmfEventSource implements Cloneable {
 
     // ========================================================================
     // Attributes
     // ========================================================================
 
-       private final Object fSourceId;
+       protected Object fSourceId;
 
     // ========================================================================
     // Constructors
@@ -43,6 +43,13 @@ public class TmfEventSource {
                fSourceId = sourceId;
        }
 
+       /**
+        * @param other
+        */
+       public TmfEventSource(TmfEventSource other) {
+               this((other != null) ? other.fSourceId : null);
+       }
+
     // ========================================================================
     // Accessors
     // ========================================================================
@@ -58,9 +65,14 @@ public class TmfEventSource {
     // Operators
     // ========================================================================
 
-    @Override
+       @Override
+       public TmfEventSource clone() {
+               return new TmfEventSource(this);
+       }
+
+       @Override
     public String toString() {
-        return fSourceId.toString();
+        return "[TmfEventSource(" + ((fSourceId != null) ? fSourceId.toString() : "null") + ")]";
     }
 
 }
index 56a50d103e9b73a4810050ccc50ef91dbe7d2538..467910c76a908f611bca994e83c8098ede0fd33b 100644 (file)
 
 package org.eclipse.linuxtools.tmf.event;
 
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * <b><u>TmfEventType</u></b>
  * <p>
  * The event type.
  */
-public class TmfEventType {
+public class TmfEventType implements Cloneable {
 
+    // ========================================================================
+    // Constants
+    // ========================================================================
+
+       public static final String DEFAULT_TYPE_ID  = "TMF Default Type";
+       public static final String[] DEFAULT_LABELS = new String[] { "Content" };
+       
     // ========================================================================
     // Attributes
     // ========================================================================
 
-       private final String fTypeId;
-    private final TmfEventFormat fFormat;
+       private final String   fTypeId;
+       private final String[] fFieldLabels;
+       private final int      fNbFields;
+       private final Map<String, Integer> fFieldMap;
 
-    // ========================================================================
+       // ========================================================================
     // Constructors
     // ========================================================================
 
+       /**
+        * 
+        */
+       public TmfEventType() {
+               this(DEFAULT_TYPE_ID, DEFAULT_LABELS);
+       }
+
        /**
         * @param type
         * @param format
         */
-       public TmfEventType(String typeID, TmfEventFormat format) {
-               fTypeId = typeID;
-               fFormat = format;
+       public TmfEventType(String typeId, String[] labels) {
+               assert(typeId != null);
+               assert(labels != null);
+               fTypeId      = typeId;
+               fFieldLabels = labels;
+               fNbFields    = fFieldLabels.length;
+               fFieldMap    = new HashMap<String, Integer>();
+               for (int i = 0; i < fNbFields; i++) {
+                       fFieldMap.put(fFieldLabels[i], i);
+               }
+       }
+
+       /**
+        * @param other
+        */
+       public TmfEventType(TmfEventType other) {
+               assert(other != null);
+               fTypeId      = other.fTypeId;
+               fFieldLabels = other.fFieldLabels;
+               fNbFields    = other.fNbFields;
+               fFieldMap    = other.fFieldMap;
        }
 
     // ========================================================================
@@ -50,20 +87,51 @@ public class TmfEventType {
                return fTypeId;
        }
 
-    /**
-     * @return
-     */
-    public TmfEventFormat getFormat() {
-        return fFormat;
-    }
+       /**
+        * @return
+        */
+       public int getNbFields() {
+               return fNbFields;
+       }
+
+       /**
+        * @return
+        */
+       public int getFieldIndex(String id) throws TmfNoSuchFieldException {
+               Integer index = fFieldMap.get(id);
+               if (index == null)
+                       throw(new TmfNoSuchFieldException(id));
+               return index;
+       }
+
+       /**
+        * @return
+        */
+       public String[] getLabels() {
+               return fFieldLabels;
+       }
+
+       /**
+        * @return
+        */
+       public String getLabel(int i) {
+               if (i >= 0 && i < fNbFields)
+                       return fFieldLabels[i];
+               return null;
+       }
 
     // ========================================================================
     // Operators
     // ========================================================================
 
+    @Override
+    public TmfEventType clone() {
+       return new TmfEventType(this);
+    }
+
     @Override
     public String toString() {
-        return fTypeId.toString();
+       return "[TmfEventType:" + fTypeId + "]";
     }
 
-}
+}
\ No newline at end of file
index 67365a58d2965ceba39b4e1e13b728e095b2f2c9..5f90f796ba50ba9aec0d319a456dcf53ae0ec8f3 100644 (file)
@@ -36,6 +36,15 @@ public class TmfTimeRange {
     // Constructors
     // ========================================================================
 
+       /**
+        * 
+        */
+       @SuppressWarnings("unused")
+       private TmfTimeRange() {
+               fStartTime = null;
+               fEndTime   = null;
+       }
+
        /**
         * @param startTime
         * @param endTime
@@ -44,6 +53,15 @@ public class TmfTimeRange {
                fStartTime = startTime;
                fEndTime   = endTime;
        }
+       
+       /**
+        * @param other
+        */
+       public TmfTimeRange(TmfTimeRange other) {
+               assert(other != null);
+               fStartTime = other.fStartTime;
+               fEndTime   = other.fEndTime;
+       }
 
     // ========================================================================
     // Accessors
@@ -83,7 +101,7 @@ public class TmfTimeRange {
         */
        @Override
        public String toString() {
-               return "[TmfTimeRange (" + fStartTime.toString() + ":" + fEndTime.toString() + ")]";
+               return "[TmfTimeRange(" + fStartTime.toString() + ":" + fEndTime.toString() + ")]";
        }
 
 }
index 228399cc35bd3f6f9a0f23af0d73dab79831c982..cefc7a5714ba60c6cb849ea72e9bc2febb688c3f 100644 (file)
@@ -12,7 +12,6 @@
 
 package org.eclipse.linuxtools.tmf.event;
 
-import java.io.Serializable;
 
 /**
  * <b><u>TmfTimestamp</u></b>
@@ -27,29 +26,25 @@ import java.io.Serializable;
  * <li>a precision to indicate the error on the value (useful for comparing
  * timestamps in different scales). Default: 0.
  * </ul>
- * To allow synchronization of timestamps from different reference clocks, there
- * is a possibility to "adjust" the timestamp both by changing its scale (traces
- * of different scale) and by adding an offset to its value (clock drift between
- * traces).
+ * To allow synchronization of timestamps from different reference clocks,
+ * there is a possibility to "adjust" the timestamp both by changing its scale
+ * (traces of different scale) and by adding an offset to its value (clock
+ * drift between traces).
  * <p>
- * Note that the adjusted timestamp value could be negative e.g. for events that
- * occurred before t0 of the reference clock.
- * 
+ * Notice that the adjusted timestamp value could be negative e.g. for events
+ * that occurred before t0 wrt the reference clock.
+ * <p>
+ * Finally, notice that timestamps are immutable.
  */
-public class TmfTimestamp implements Serializable {
-
-    /**
-        * 
-        */
-       private static final long serialVersionUID = -3196421507276821609L;
+public class TmfTimestamp implements Cloneable {
 
        // ========================================================================
     // Attributes
     // ========================================================================
 
-    protected final long fValue; // The timestamp value
-    protected final byte fScale; // The time scale
-    protected final long fPrecision; // The value precision (tolerance)
+    protected long fValue;             // The timestamp value
+    protected byte fScale;             // The time scale
+    protected long fPrecision;         // The value precision (tolerance)
 
     // ========================================================================
     // Constants
@@ -64,21 +59,21 @@ public class TmfTimestamp implements Serializable {
     // ========================================================================
 
     /**
-     * Default constructor.
+     * Default constructor
      */
     public TmfTimestamp() {
         this(0, (byte) 0, 0);
     }
 
     /**
-     * Simple constructor.
+     * Simple constructor with value only
      */
     public TmfTimestamp(long value) {
         this(value, (byte) 0, 0);
     }
 
     /**
-     * Simple constructor with default error value
+     * Simple constructor with value and scale
      * 
      * @param value
      * @param scale
@@ -88,7 +83,7 @@ public class TmfTimestamp implements Serializable {
     }
 
     /**
-     * Constructor with measurement error.
+     * Constructor with value, scale and precision
      * 
      * @param value
      * @param scale
@@ -101,12 +96,15 @@ public class TmfTimestamp implements Serializable {
     }
 
     /**
-     * Copy constructor.
+     * Copy constructor
      * 
      * @param other
      */
     public TmfTimestamp(TmfTimestamp other) {
-        this(other.fValue, other.fScale, other.fPrecision);
+       assert(other != null);
+        fValue = other.fValue;
+        fScale = other.fScale;
+        fPrecision = other.fPrecision;
     }
 
     // ========================================================================
@@ -114,21 +112,21 @@ public class TmfTimestamp implements Serializable {
     // ========================================================================
 
     /**
-     * @return The timestamp value
+     * @return the timestamp value
      */
     public long getValue() {
         return fValue;
     }
 
     /**
-     * @return The timestamp scale
+     * @return the timestamp scale
      */
     public byte getScale() {
         return fScale;
     }
 
     /**
-     * @return The timestamp value precision
+     * @return the timestamp value precision
      */
     public long getPrecision() {
         return fPrecision;
@@ -196,7 +194,7 @@ public class TmfTimestamp implements Serializable {
      * 
      * @param reference
      *            - the reference timestamp to synchronize with
-     * @return The adjustment term in the reference time scale
+     * @return the adjustment term in the reference time scale
      * @throws TmfNumericalException
      */
     public long getAdjustment(TmfTimestamp reference) throws ArithmeticException {
@@ -211,8 +209,9 @@ public class TmfTimestamp implements Serializable {
      *            - the other timestamp
      * @param withinPrecision
      *            - indicates if precision is to be take into consideration
-     * @return <li>-1: this timestamp is lower <li>0: timestamps are equal
-     *         (within precision if requested) <li>1: this timestamp is higher
+     * @return -1: this timestamp is lower
+     *          0: timestamps are equal (within precision if requested)
+     *          1: this timestamp is higher
      * @throws TmfNumericalException
      */
     public int compareTo(final TmfTimestamp other, boolean withinPrecision) {
@@ -254,11 +253,11 @@ public class TmfTimestamp implements Serializable {
         }
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.lang.Object#equals(java.lang.Object)
-     */
+       @Override
+       public TmfTimestamp clone() {
+               return new TmfTimestamp(this);
+       }
+
     @Override
     public boolean equals(Object other) {
         if (other instanceof TmfTimestamp)
@@ -266,12 +265,9 @@ public class TmfTimestamp implements Serializable {
         return super.equals(other);
     }
 
-    /* (non-Javadoc)
-     * @see java.lang.Object#toString()
-     */
     @Override
     public String toString() {
-       return "[TmfTimestamp:" + fValue + "," + fScale + "," + fPrecision + "]";
+       return "[TmfTimestamp(" + fValue + "," + fScale + "," + fPrecision + ")]";
     }
 
 }
\ No newline at end of file
index 90e4ef956999e8cb9813e5e598a01b34d9fce3c1..f030752f892a2008831bf818328051dda8bf07da 100644 (file)
@@ -30,50 +30,61 @@ public class TmfTraceEvent extends TmfEvent {
 
     private final String fSourcePath;
     private final String fFileName;
-    private final int fLineNumber;
+    private final int    fLineNumber;
 
     // ========================================================================
     // Constructors
     // ========================================================================
 
        /**
-        * The constructor.
-        * 
-        * @param timestamp
+        * @param originalTS
+        * @param effectiveTS
         * @param source
         * @param type
         * @param content
         * @param reference
+        * @param path
+        * @param file
+        * @param line
         */
        public TmfTraceEvent(TmfTimestamp originalTS, TmfTimestamp effectiveTS, TmfEventSource source,
-                       TmfEventType type, TmfEventContent content, TmfEventReference reference,
-                       String path, String file, int line)
+                       TmfEventType type, TmfEventReference reference, String path, String file, int line)
        {
-               super(originalTS, effectiveTS, source, type,content, reference);
+               super(originalTS, effectiveTS, source, type, reference);
                fSourcePath = path;
-               fFileName = file;
+               fFileName   = file;
                fLineNumber = line;
        }
 
        /**
-        * The constructor.
-        * 
         * @param timestamp
         * @param source
         * @param type
         * @param content
         * @param reference
+        * @param path
+        * @param file
+        * @param line
         */
        public TmfTraceEvent(TmfTimestamp timestamp, TmfEventSource source, TmfEventType type,
-                       TmfEventContent content, TmfEventReference reference,
-                       String path, String file, int line)
+                       TmfEventReference reference, String path, String file, int line)
        {
-               super(timestamp, source, type,content, reference);
+               super(timestamp, source, type, reference);
                fSourcePath = path;
-               fFileName = file;
+               fFileName   = file;
                fLineNumber = line;
        }
 
+       /**
+        * @param other
+        */
+       public TmfTraceEvent(TmfTraceEvent other) {
+               super(other);
+               fSourcePath = other.fSourcePath;
+               fFileName   = other.fFileName;
+               fLineNumber = other.fLineNumber;
+       }
+
     // ========================================================================
     // Accessors
     // ========================================================================
@@ -99,4 +110,20 @@ public class TmfTraceEvent extends TmfEvent {
         return fLineNumber;
     }
 
+    // ========================================================================
+    // Operators
+    // ========================================================================
+
+    // TODO: Deep copy
+    @Override
+    public TmfTraceEvent clone() {
+       return new TmfTraceEvent(this);
+    }
+
+    // TODO: Proper format
+    @Override
+    public String toString() {
+       return null;
+    }
+
 }
index 08c328587d71bdc5a816ac17c02631e04b3a04d4..7ad4083dcdd7755259e9be922bd4e8a55fda9c91 100644 (file)
@@ -23,7 +23,7 @@ import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
  * continuous streaming.
  * <p>
  * The request is processed asynchronously by an ITmfRequestProcessor and,
- * as blocks of data become available, the callback handlePartialData() is
+ * as blocks of data become available, the callback handleData() is
  * invoked, synchronously, for each block. When returning from the callback,
  * the data instances go out of scope and become eligible for gc. It is
  * is thus the responsibility of the requester to either copy or keep a
@@ -83,10 +83,9 @@ public class TmfDataRequest<V> {
     // Attributes
     // ========================================================================
 
-    private final TmfTimeRange fRange;      // The requested events timestamp range
-    private final int  fIndex;              // The event index to get
-    private final long fOffset;             // The synchronization offset to apply
-    private final int  fNbRequestedItems;   // The number of items to read (-1 == the whole range)
+    private final int  fIndex;              // The index (order) of the requested event
+    private final TmfTimeRange fRange;      // The requested events time range
+    private final int  fNbRequestedEvents;  // The number of events to read (-1 == all in the range)
     private final int  fBlockSize;          // The maximum number of events per chunk
     private       int  fNbEvents;           // The number of events read so far
 
@@ -105,49 +104,62 @@ public class TmfDataRequest<V> {
      * @param index
      * @param nbEvents
      */
-    public TmfDataRequest(int index, long offset, int nbEvents) {
-        this(null, index, offset, nbEvents, DEFAULT_BLOCK_SIZE);
+    public TmfDataRequest(int index, int nbEvents) {
+        this(null, index, nbEvents, DEFAULT_BLOCK_SIZE);
     }
 
+    public TmfDataRequest(int index, int nbEvents, int blockSize) {
+        this(null, index, nbEvents, blockSize);
+    }
+    
     /**
      * @param range
-     * @param offset
-     * @param nbEvents
      */
-    public TmfDataRequest(TmfTimeRange range, long offset, int nbEvents) {
-        this(range, 0, offset, nbEvents, DEFAULT_BLOCK_SIZE);
+    public TmfDataRequest(TmfTimeRange range) {
+        this(range, 0, ALL_EVENTS, DEFAULT_BLOCK_SIZE);
     }
 
     /**
      * @param range
-     * @param offset
-     * @param nbItems
-     * @param maxBlockSize Size of the largest blocks expected
+     * @param nbEvents
+     */
+    public TmfDataRequest(TmfTimeRange range, int nbEvents) {
+        this(range, 0, nbEvents, DEFAULT_BLOCK_SIZE);
+    }
+    /**
+     * @param range
+     * @param nbEvents
+     * @param blockSize Size of the largest blocks expected
      */
-    public TmfDataRequest(TmfTimeRange range, long offset, int nbEvents, int maxBlockSize) {
-        this(range, 0, offset, nbEvents, maxBlockSize);
+    public TmfDataRequest(TmfTimeRange range, int nbEvents, int blockSize) {
+        this(range, 0, nbEvents, blockSize);
     }
 
     /**
      * @param range
      * @param index
-     * @param offset
-     * @param nbItems
-     * @param maxBlockSize Size of the largest blocks expected
+     * @param nbEvents
+     * @param blockSize Size of the largest blocks expected
      */
-    public TmfDataRequest(TmfTimeRange range, int index, long offset, int nbEvents, int maxBlockSize) {
-        fRange = range;
-        fIndex = index;
-        fOffset = offset;
-        fNbRequestedItems = nbEvents;
-        fBlockSize = maxBlockSize;
-        fNbEvents = 0;
+    private TmfDataRequest(TmfTimeRange range, int index, int nbEvents, int blockSize) {
+       fIndex             = index;
+       fRange             = range;
+       fNbRequestedEvents = nbEvents;
+       fBlockSize         = blockSize;
+       fNbEvents          = 0;
     }
 
     // ========================================================================
     // Accessors
     // ========================================================================
 
+       /**
+        * @return the index
+        */
+       public int getIndex() {
+               return fIndex;
+       }
+
     /**
      * @return the requested time range
      */
@@ -155,25 +167,11 @@ public class TmfDataRequest<V> {
         return fRange;
     }
 
-    /**
-     * @return the index
-     */
-    public int getIndex() {
-        return fIndex;
-    }
-
-    /**
-     * @return the offset
-     */
-    public long getOffset() {
-        return fOffset;
-    }
-
     /**
      * @return the number of requested events (-1 = all)
      */
-    public int getNbRequestedItems() {
-        return fNbRequestedItems;
+    public int getNbRequestedEvents() {
+        return fNbRequestedEvents;
     }
 
     /**
index e046703065d326691ab6d2049a307aef674402d0..ddd0bcabd0735c0af2aee4039671aa6695009654 100644 (file)
@@ -275,7 +275,7 @@ public class TmfExperiment extends TmfComponent implements ITmfRequestHandler<Tm
 
                                // Extract the general request information
                                int blockSize = request.getBlockize();
-                               int nbRequestedEvents = request.getNbRequestedItems();
+                               int nbRequestedEvents = request.getNbRequestedEvents();
                                if (nbRequestedEvents == -1) {
                                        nbRequestedEvents = Integer.MAX_VALUE;
                                }
@@ -461,23 +461,29 @@ public class TmfExperiment extends TmfComponent implements ITmfRequestHandler<Tm
 
                job = new IndexingJob(fExperimentId);
                job.schedule();
-               if (fWaitForIndexCompletion) {
-               ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
-               try {
-                               // TODO: Handle cancel!
-                   dialog.run(true, true, new IRunnableWithProgress() {
-                       public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
-                           monitor.beginTask("Indexing " + fExperimentId, IProgressMonitor.UNKNOWN);
-                                       job.join();
-                           monitor.done();
-                       }
-                   });
-               } catch (InvocationTargetException e) {
-                   e.printStackTrace();
-               } catch (InterruptedException e) {
-                   e.printStackTrace();
-               }
+               try {
+                       job.join();
+               } catch (InterruptedException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
                }
+//             if (fWaitForIndexCompletion) {
+//             ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
+//             try {
+//                             // TODO: Handle cancel!
+//                 dialog.run(true, true, new IRunnableWithProgress() {
+//                     public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+//                         monitor.beginTask("Indexing " + fExperimentId, IProgressMonitor.UNKNOWN);
+//                                     job.join();
+//                         monitor.done();
+//                     }
+//                 });
+//             } catch (InvocationTargetException e) {
+//                 e.printStackTrace();
+//             } catch (InterruptedException e) {
+//                 e.printStackTrace();
+//             }
+//             }
        }
 
        private class IndexingJob extends Job {
index 8bf5f03bd55e16da4cd1b1117fb6c12d3df368a3..0a3c29961a378fb409d548cae4410c1272f4b2a8 100644 (file)
@@ -324,7 +324,7 @@ public abstract class TmfTrace extends TmfComponent implements ITmfTrace, ITmfRe
                        public void run() {
                                // Extract the general request information
                                int blockSize = request.getBlockize();
-                               int nbRequestedEvents = request.getNbRequestedItems();
+                               int nbRequestedEvents = request.getNbRequestedEvents();
                                if (nbRequestedEvents == -1) {
                                        nbRequestedEvents = Integer.MAX_VALUE;
                                }
This page took 0.179451 seconds and 5 git commands to generate.