(no commit message)
authorFrancois Chouinard <fchouinard@gmail.com>
Tue, 25 Aug 2009 14:11:32 +0000 (14:11 +0000)
committerFrancois Chouinard <fchouinard@gmail.com>
Tue, 25 Aug 2009 14:11:32 +0000 (14:11 +0000)
22 files changed:
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/AllEventTests.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfEventContentTest.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfEventFormatTest.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfEventTest.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfEventTypeTest.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfTimestampTest.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfTraceEventTest.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/eventlog/AllEventLogTests.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/eventlog/TmfEventLogTest.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/eventlog/TmfEventRequestTest.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/eventlog/TmfEventStreamTest.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/event/AllEventTests.java [deleted file]
org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/event/TmfEventContentTest.java [deleted file]
org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/event/TmfEventFormatTest.java [deleted file]
org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/event/TmfEventTest.java [deleted file]
org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/event/TmfEventTypeTest.java [deleted file]
org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/event/TmfTimestampTest.java [deleted file]
org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/event/TmfTraceEventTest.java [deleted file]
org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/eventlog/AllEventLogTests.java [deleted file]
org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/eventlog/TmfEventLogTest.java [deleted file]
org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/eventlog/TmfEventRequestTest.java [deleted file]
org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/eventlog/TmfEventStreamTest.java [deleted file]

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
new file mode 100644 (file)
index 0000000..11c55f6
--- /dev/null
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * 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 (fchouinard@gmail.com) - 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,
+    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/TmfEventContentTest.java b/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfEventContentTest.java
new file mode 100644 (file)
index 0000000..b2f2beb
--- /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:
+ *   Francois Chouinard (fchouinard@gmail.com) - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.event;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+/**
+ * <b><u>TmfEventContentTest</u></b>
+ * <p>
+ * TODO: Implement me. Please.
+ */
+public class TmfEventContentTest {
+
+       // ========================================================================
+       // 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());
+       }
+
+       // ========================================================================
+       // getField
+       // ========================================================================
+
+       @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());
+       }
+
+       @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());
+       }
+
+}
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
new file mode 100644 (file)
index 0000000..5235172
--- /dev/null
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * 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 (fchouinard@gmail.com) - 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>
+ * TODO: Implement me. Please.
+ */
+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/TmfEventTest.java b/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfEventTest.java
new file mode 100644 (file)
index 0000000..c960ae8
--- /dev/null
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * 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 (fchouinard@gmail.com) - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.event;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+/**
+ * <b><u>TmfEventTest</u></b>
+ * <p>
+ * 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 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());
+    }
+
+}
diff --git a/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfEventTypeTest.java b/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfEventTypeTest.java
new file mode 100644 (file)
index 0000000..5a20449
--- /dev/null
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * 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 (fchouinard@gmail.com) - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.event;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+/**
+ * <b><u>TmfEventTypeTest</u></b>
+ * <p>
+ * TODO: Implement me. Please.
+ */
+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]);
+   }
+
+}
diff --git a/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfTimestampTest.java b/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfTimestampTest.java
new file mode 100644 (file)
index 0000000..9d44366
--- /dev/null
@@ -0,0 +1,332 @@
+/*******************************************************************************
+ * 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 (fchouinard@gmail.com) - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.event;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+/**
+ * <b><u>TmfTimestampTest</u></b>
+ * <p>
+ * 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, (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",     0, ts.getValue());
+        assertEquals("getscale",     0, ts.getScale());
+        assertEquals("getPrecision", 0, ts.getPrecision());
+    }
+
+    @Test
+    public void testCopyConstructorBigCrunch() throws Exception {
+        TmfTimestamp ts = new TmfTimestamp(TmfTimestamp.BigCrunch);
+        assertEquals("getValue", Long.MAX_VALUE, ts.getValue());
+        assertEquals("getscale", Byte.MAX_VALUE, ts.getScale());
+        assertEquals("getPrecision",          0, 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());
+    }
+
+    @Test
+    public void testSynchronizeWithArithmeticException() throws Exception {
+        TmfTimestamp bigBang   = new TmfTimestamp(TmfTimestamp.BigBang);
+        TmfTimestamp bigCrunch = new TmfTimestamp(TmfTimestamp.BigCrunch);
+
+        try {
+            bigCrunch.synchronize(bigBang.getValue(), bigBang.getScale());
+            fail("Exception not thrown");
+        } catch (ArithmeticException e) {          
+        }
+    }
+
+    // ========================================================================
+    // 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);
+    }
+
+    @Test
+    public void testGetAdjustmentDifferentScaleWithException() throws Exception {
+        try {
+            TmfTimestamp.BigBang.getAdjustment(TmfTimestamp.BigCrunch);
+            fail("ArithmeticException not thrown");
+        } catch (ArithmeticException e) {
+        }
+    }
+
+    // ========================================================================
+    // 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);
+    }
+
+}
diff --git a/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfTraceEventTest.java b/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfTraceEventTest.java
new file mode 100644 (file)
index 0000000..3cec8e5
--- /dev/null
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * 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 (fchouinard@gmail.com) - Initial API and implementation
+ *******************************************************************************/
+
+
+package org.eclipse.linuxtools.tmf.event;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+/**
+ * <b><u>TmfTraceEventTest</u></b>
+ * <p>
+ * TODO: Implement me. Please.
+ */
+public class TmfTraceEventTest {
+
+    // ========================================================================
+    // Constructor
+    // ========================================================================
+
+    @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());
+    }
+
+}
diff --git a/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/eventlog/AllEventLogTests.java b/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/eventlog/AllEventLogTests.java
new file mode 100644 (file)
index 0000000..104559e
--- /dev/null
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * 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 (fchouinard@gmail.com) - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.eventlog;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+    TmfEventRequestTest.class,
+    TmfEventStreamTest.class,
+    TmfEventLogTest.class
+})
+
+public class AllEventLogTests {
+
+}
diff --git a/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/eventlog/TmfEventLogTest.java b/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/eventlog/TmfEventLogTest.java
new file mode 100644 (file)
index 0000000..e1a8ab3
--- /dev/null
@@ -0,0 +1,240 @@
+/*******************************************************************************
+ * 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 (fchouinard@gmail.com) - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.eventlog;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Vector;
+
+import org.eclipse.linuxtools.tmf.event.TmfEvent;
+import org.eclipse.linuxtools.tmf.event.TmfTimeWindow;
+import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * <b><u>TmfEventLogTest</u></b>
+ * <p>
+ * TODO: Implement me. Please.
+ */
+public class TmfEventLogTest {
+
+    private static String filename = "Test-10K";
+    private static int fTotalNbEvents = 10000; 
+    private static ITmfEventParser fParser;
+    private static TmfEventStream  fStream;
+
+       @BeforeClass
+       public static void setUpBeforeClass() throws Exception {
+               fParser = new TmfEventParserStub();
+               fStream = new TmfEventStreamStub(filename, fParser);
+       }
+
+    // ========================================================================
+    // Constructor
+    // ========================================================================
+
+       @Test
+       public void testBasicTmfEventLog() {
+               TmfTrace eventLog = new TmfTrace("MyEventLog", fStream);
+
+               assertEquals("GetId", "MyEventLog", eventLog.getId());
+        assertEquals("GetEpoch", TmfTimestamp.BigBang, eventLog.getEpoch());
+        assertEquals("GetNbEvents", fTotalNbEvents, eventLog.getNbEvents());
+
+        TmfTimeWindow timeRange = eventLog.getTimeRange();
+        assertEquals("GetTimeRange", 0, timeRange.getStartTime().getValue());
+        assertEquals("GetTimeRange", fTotalNbEvents - 1, timeRange.getEndTime().getValue());
+       }
+
+       @Test
+       public void testTmfEventLogWithEpoch() {
+               TmfTimestamp epoch = new TmfTimestamp(100, (byte) 0, 0);
+               TmfTrace eventLog = new TmfTrace("MyEventLog", fStream, epoch);
+
+               assertEquals("GetId", "MyEventLog", eventLog.getId());
+        assertEquals("GetEpoch", epoch, eventLog.getEpoch());
+        assertEquals("GetNbEvents", fTotalNbEvents, eventLog.getNbEvents());
+
+        TmfTimeWindow timeRange = eventLog.getTimeRange();
+        assertEquals("GetTimeRange", 0, timeRange.getStartTime().getValue());
+        assertEquals("GetTimeRange", fTotalNbEvents - 1, timeRange.getEndTime().getValue());
+       }
+
+    // ========================================================================
+    // Operators
+    // ========================================================================
+
+    @Test
+    public void testProcessRequestForNbEvents() throws Exception {
+
+        TmfTrace eventLog = new TmfTrace("MyEventLog", fStream);
+
+        final int NB_EVENTS  = 10 * 1000;
+        final int BLOCK_SIZE = 100;
+        final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
+
+        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        final TmfEventRequest request = new TmfEventRequest(range, 0, NB_EVENTS, BLOCK_SIZE) {
+            @Override
+            public void newEvents(Vector<TmfEvent> events) {
+                for (TmfEvent e : events) {
+                    requestedEvents.add(e);
+                }
+            }
+        };
+        eventLog.process(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, requestedEvents.get(i).getTimestamp().getValue());
+        }
+    }
+    
+    @Test
+    public void testProcessRequestForAllEvents() throws Exception {
+
+        TmfTrace eventLog = new TmfTrace("MyEventLog", fStream);
+
+        final int NB_EVENTS  = -1;
+        final int BLOCK_SIZE =  1;
+        final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
+        int nbExpectedEvents = eventLog.getNbEvents();
+
+        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        final TmfEventRequest request = new TmfEventRequest(range, 0, NB_EVENTS, BLOCK_SIZE) {
+            @Override
+            public void newEvents(Vector<TmfEvent> events) {
+                for (TmfEvent e : events) {
+                    requestedEvents.add(e);
+                }
+            }
+        };
+        eventLog.process(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, requestedEvents.get(i).getTimestamp().getValue());
+        }
+    }
+    
+    // @Test
+    public void testProcessRequestWithOffset() throws Exception {
+
+        TmfTrace eventLog = new TmfTrace("MyEventLog", fStream);
+
+        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;
+
+        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        final TmfEventRequest request = new TmfEventRequest(range, OFFSET, NB_EVENTS, BLOCK_SIZE) {
+            @Override
+            public void newEvents(Vector<TmfEvent> events) {
+                for (TmfEvent e : events) {
+                    requestedEvents.add(e);
+                }
+            }
+        };
+        eventLog.process(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 {
+
+        TmfTrace eventLog = new TmfTrace("MyEventLog", fStream);
+
+        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;
+
+        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        final TmfEventRequest request = new TmfEventRequest(range, OFFSET, NB_EVENTS, BLOCK_SIZE) {
+            @Override
+            public void newEvents(Vector<TmfEvent> events) {
+                for (TmfEvent e : events) {
+                    requestedEvents.add(e);
+                }
+            }
+        };
+        eventLog.process(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 {
+
+        TmfTrace eventLog = new TmfTrace("MyEventLog", fStream);
+
+        final int NB_EVENTS  = 10 * 1000;
+        final int BLOCK_SIZE = 100;
+        final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
+
+        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        final TmfEventRequest request = new TmfEventRequest(range, 0, NB_EVENTS, BLOCK_SIZE) {
+            @Override
+            public void newEvents(Vector<TmfEvent> events) {
+                for (TmfEvent e : events) {
+                    requestedEvents.add(e);
+                }
+                // Cancel request after the first chunk is received
+                cancel();
+            }
+        };
+        eventLog.process(request, true);
+
+        assertEquals("nbEvents",  BLOCK_SIZE, requestedEvents.size());
+        assertTrue("isCompleted", request.isCompleted());
+        assertTrue("isCancelled", request.isCancelled());
+    }
+
+}
diff --git a/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/eventlog/TmfEventRequestTest.java b/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/eventlog/TmfEventRequestTest.java
new file mode 100644 (file)
index 0000000..0901611
--- /dev/null
@@ -0,0 +1,241 @@
+/*******************************************************************************
+ * 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 (fchouinard@gmail.com) - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.eventlog;
+
+import static org.junit.Assert.*;
+
+import java.util.Vector;
+
+import org.eclipse.linuxtools.tmf.event.TmfEvent;
+import org.eclipse.linuxtools.tmf.event.TmfTimeWindow;
+import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * <b><u>TmfEventRequestTest</u></b>
+ * <p>
+ * TODO: Implement me. Please.
+ */
+public class TmfEventRequestTest {
+
+    private static ITmfRequestHandler fProcessor = null;
+
+    @BeforeClass
+    public static void setUpBeforeClass() throws Exception {
+        fProcessor = new TmfRequestHandlerStub();
+    }
+
+    // ========================================================================
+    // Constructor
+    // ========================================================================
+
+    @Test
+    public void testConstructorForRange() throws Exception {
+        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        TmfEventRequest request = new TmfEventRequest(range, 0, -1, 1);
+
+        assertEquals("StartTime", TmfTimestamp.BigBang,   request.getRange().getStartTime());
+        assertEquals("EndTime",   TmfTimestamp.BigCrunch, request.getRange().getEndTime());
+        assertEquals("Offset",             0, request.getOffset());
+        assertEquals("NbRequestedEvents", -1, request.getNbRequestedEvents());
+    }
+
+    @Test
+    public void testConstructorForNbEvents() throws Exception {
+        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        TmfEventRequest request = new TmfEventRequest(range, 0, 10, 1);
+
+        assertEquals("StartTime", TmfTimestamp.BigBang,   request.getRange().getStartTime());
+        assertEquals("EndTime",   TmfTimestamp.BigCrunch, request.getRange().getEndTime());
+        assertEquals("Offset",             0, request.getOffset());
+        assertEquals("NbRequestedEvents", 10, request.getNbRequestedEvents());
+    }
+
+    @Test
+    public void testConstructorWithOffset() throws Exception {
+        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        TmfEventRequest request = new TmfEventRequest(range, 5, 10, 1);
+
+        assertEquals("StartTime", TmfTimestamp.BigBang,   request.getRange().getStartTime());
+        assertEquals("EndTime",   TmfTimestamp.BigCrunch, request.getRange().getEndTime());
+        assertEquals("Offset",             5, request.getOffset());
+        assertEquals("NbRequestedEvents", 10, request.getNbRequestedEvents());
+    }
+
+    @Test
+    public void testConstructorWithNegativeOffset() throws Exception {
+        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        TmfEventRequest request = new TmfEventRequest(range, -5, 10, 1);
+
+        assertEquals("StartTime", TmfTimestamp.BigBang,   request.getRange().getStartTime());
+        assertEquals("EndTime",   TmfTimestamp.BigCrunch, request.getRange().getEndTime());
+        assertEquals("Offset",            -5, request.getOffset());
+        assertEquals("NbRequestedEvents", 10, request.getNbRequestedEvents());
+    }
+
+    // ========================================================================
+    // 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>();
+
+        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        final TmfEventRequest request = new TmfEventRequest(range, 0, NB_EVENTS, BLOCK_SIZE) {
+            @Override
+            public void newEvents(Vector<TmfEvent> events) {
+                for (TmfEvent e : events) {
+                    requestedEvents.add(e);
+                }
+            }
+        };
+        fProcessor.process(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, 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;
+
+        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        final TmfEventRequest request = new TmfEventRequest(range, 0, NB_EVENTS, BLOCK_SIZE) {
+            @Override
+            public void newEvents(Vector<TmfEvent> events) {
+                for (TmfEvent e : events) {
+                    requestedEvents.add(e);
+                }
+            }
+        };
+        fProcessor.process(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, 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;
+
+        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        final TmfEventRequest request = new TmfEventRequest(range, OFFSET, NB_EVENTS, BLOCK_SIZE) {
+            @Override
+            public void newEvents(Vector<TmfEvent> events) {
+                for (TmfEvent e : events) {
+                    requestedEvents.add(e);
+                }
+            }
+        };
+        fProcessor.process(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;
+
+        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        final TmfEventRequest request = new TmfEventRequest(range, OFFSET, NB_EVENTS, BLOCK_SIZE) {
+            @Override
+            public void newEvents(Vector<TmfEvent> events) {
+                for (TmfEvent e : events) {
+                    requestedEvents.add(e);
+                }
+            }
+        };
+        fProcessor.process(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>();
+
+        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        final TmfEventRequest request = new TmfEventRequest(range, 0, NB_EVENTS, BLOCK_SIZE) {
+            @Override
+            public void newEvents(Vector<TmfEvent> events) {
+                for (TmfEvent e : events) {
+                    requestedEvents.add(e);
+                }
+                // Cancel request after the first chunk is received
+                cancel();
+            }
+        };
+        fProcessor.process(request, true);
+
+        assertEquals("nbEvents",  BLOCK_SIZE, requestedEvents.size());
+        assertTrue("isCompleted", request.isCompleted());
+        assertTrue("isCancelled", request.isCancelled());
+    }
+
+}
diff --git a/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/eventlog/TmfEventStreamTest.java b/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/eventlog/TmfEventStreamTest.java
new file mode 100644 (file)
index 0000000..33181bf
--- /dev/null
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * 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 (fchouinard@gmail.com) - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.eventlog;
+
+import static org.junit.Assert.*;
+
+import org.eclipse.linuxtools.tmf.event.TmfEvent;
+import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * <b><u>TmfEventStreamTest</u></b>
+ * <p>
+ * TODO: Implement me. Please.
+ */
+public class TmfEventStreamTest {
+
+    private static final String TEST_STREAM = "Test-10K";
+    private static final int NB_EVENTS = 10000;
+    private static TmfEventStreamStub fStream;
+
+    /**
+     * @throws java.lang.Exception
+     */
+    @BeforeClass
+    public static void setUpBeforeClass() throws Exception {
+        TmfEventParserStub parser = new TmfEventParserStub();
+        fStream = new TmfEventStreamStub(TEST_STREAM, parser, 500);
+    }
+
+    // ========================================================================
+    // Constructor
+    // ========================================================================
+
+    @Test
+    public void testDefaultConstructor() throws Exception {
+        TmfEventParserStub parser = new TmfEventParserStub();
+        TmfEventStreamStub stream = new TmfEventStreamStub(TEST_STREAM, parser);
+
+        assertEquals("getCacheSize", TmfEventStream.DEFAULT_CACHE_SIZE, stream.getCacheSize());
+        assertEquals("getTraceSize", NB_EVENTS, stream.getNbEvents());
+        assertEquals("getRange-start", 0, stream.getTimeRange().getStartTime().getValue());
+        assertEquals("getRange-end", NB_EVENTS - 1, stream.getTimeRange().getEndTime().getValue());
+    }
+
+    @Test
+    public void testNormalConstructor() throws Exception {
+        TmfEventParserStub parser = new TmfEventParserStub();
+        TmfEventStreamStub stream = new TmfEventStreamStub(TEST_STREAM, parser, 500);
+
+        assertEquals("getCacheSize",    500, stream.getCacheSize());
+        assertEquals("getTraceSize", NB_EVENTS, stream.getNbEvents());
+        assertEquals("getRange-start",    0, stream.getTimeRange().getStartTime().getValue());
+        assertEquals("getRange-end", NB_EVENTS - 1, stream.getTimeRange().getEndTime().getValue());
+    }
+
+    // ========================================================================
+    // seek
+    // ========================================================================
+
+    @Test
+    public void testSeekOnCacheBoundary() throws Exception {
+        TmfEvent event = fStream.seek(new TmfTimestamp(0, (byte) 0, 0));
+        assertEquals("Event timestamp", 0, event.getTimestamp().getValue());
+
+        event = fStream.seek(new TmfTimestamp(1000, (byte) 0, 0));
+        assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
+
+        event = fStream.seek(new TmfTimestamp(4000, (byte) 0, 0));
+        assertEquals("Event timestamp", 4000, event.getTimestamp().getValue());
+    }
+
+    @Test
+    public void testSeekNotOnCacheBoundary() throws Exception {
+        TmfEvent event = fStream.seek(new TmfTimestamp(1, (byte) 0, 0));
+        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+
+        event = fStream.seek(new TmfTimestamp(999, (byte) 0, 0));
+        assertEquals("Event timestamp", 999, event.getTimestamp().getValue());
+
+        event = fStream.seek(new TmfTimestamp(4499, (byte) 0, 0));
+        assertEquals("Event timestamp", 4499, event.getTimestamp().getValue());
+    }
+
+    @Test
+    public void testSeekForEventOutOfBounds() throws Exception {
+        // On lower bound, returns the first event (ts = 0)
+        TmfEvent event = fStream.seek(new TmfTimestamp(-1, (byte) 0, 0));
+        assertEquals("Event timestamp", 0, event.getTimestamp().getValue());
+
+        // On higher bound, returns null (no event)
+        event = fStream.seek(new TmfTimestamp(NB_EVENTS, (byte) 0, 0));
+        assertEquals("Event timestamp", null, event);
+    }
+
+    // ========================================================================
+    // getNextEvent
+    // ========================================================================
+
+    @Test
+    public void testGetNextEvent() throws Exception {
+        // On lower bound, returns the first event (ts = 0)
+        TmfEvent event = fStream.seek(new TmfTimestamp(0, (byte) 0, 0));
+        assertEquals("Event timestamp", 0, event.getTimestamp().getValue());
+
+        for (int i = 0; i < 10; i++) {
+            event = fStream.getNextEvent();
+            assertEquals("Event timestamp", i + 1, event.getTimestamp().getValue());
+        }
+    }
+
+}
diff --git a/org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/event/AllEventTests.java b/org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/event/AllEventTests.java
deleted file mode 100644 (file)
index 11c55f6..0000000
+++ /dev/null
@@ -1,30 +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 (fchouinard@gmail.com) - 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,
-    TmfEventTypeTest.class,
-    TmfEventFormatTest.class,
-    TmfEventContentTest.class,
-    TmfEventTest.class,
-    TmfTraceEventTest.class
-})
-
-public class AllEventTests {
-
-}
diff --git a/org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/event/TmfEventContentTest.java b/org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/event/TmfEventContentTest.java
deleted file mode 100644 (file)
index d289b01..0000000
+++ /dev/null
@@ -1,64 +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 (fchouinard@gmail.com) - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.event;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-/**
- * <b><u>TmfEventContentTest</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class TmfEventContentTest {
-
-       // ========================================================================
-       // 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());
-       }
-
-       // ========================================================================
-       // getField
-       // ========================================================================
-
-       @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());
-       }
-
-       @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());
-       }
-
-}
diff --git a/org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/event/TmfEventFormatTest.java b/org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/event/TmfEventFormatTest.java
deleted file mode 100644 (file)
index 217ffc3..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 (fchouinard@gmail.com) - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.event;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-/**
- * <b><u>TmfEventFormatTest</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-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/tests/org/eclipse/linuxtools/tmf/event/TmfEventTest.java b/org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/event/TmfEventTest.java
deleted file mode 100644 (file)
index c960ae8..0000000
+++ /dev/null
@@ -1,68 +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 (fchouinard@gmail.com) - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.event;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-/**
- * <b><u>TmfEventTest</u></b>
- * <p>
- * 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 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());
-    }
-
-}
diff --git a/org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/event/TmfEventTypeTest.java b/org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/event/TmfEventTypeTest.java
deleted file mode 100644 (file)
index 5a20449..0000000
+++ /dev/null
@@ -1,45 +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 (fchouinard@gmail.com) - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.event;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-/**
- * <b><u>TmfEventTypeTest</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-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]);
-   }
-
-}
diff --git a/org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/event/TmfTimestampTest.java b/org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/event/TmfTimestampTest.java
deleted file mode 100644 (file)
index 9d44366..0000000
+++ /dev/null
@@ -1,332 +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 (fchouinard@gmail.com) - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.event;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-/**
- * <b><u>TmfTimestampTest</u></b>
- * <p>
- * 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, (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",     0, ts.getValue());
-        assertEquals("getscale",     0, ts.getScale());
-        assertEquals("getPrecision", 0, ts.getPrecision());
-    }
-
-    @Test
-    public void testCopyConstructorBigCrunch() throws Exception {
-        TmfTimestamp ts = new TmfTimestamp(TmfTimestamp.BigCrunch);
-        assertEquals("getValue", Long.MAX_VALUE, ts.getValue());
-        assertEquals("getscale", Byte.MAX_VALUE, ts.getScale());
-        assertEquals("getPrecision",          0, 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());
-    }
-
-    @Test
-    public void testSynchronizeWithArithmeticException() throws Exception {
-        TmfTimestamp bigBang   = new TmfTimestamp(TmfTimestamp.BigBang);
-        TmfTimestamp bigCrunch = new TmfTimestamp(TmfTimestamp.BigCrunch);
-
-        try {
-            bigCrunch.synchronize(bigBang.getValue(), bigBang.getScale());
-            fail("Exception not thrown");
-        } catch (ArithmeticException e) {          
-        }
-    }
-
-    // ========================================================================
-    // 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);
-    }
-
-    @Test
-    public void testGetAdjustmentDifferentScaleWithException() throws Exception {
-        try {
-            TmfTimestamp.BigBang.getAdjustment(TmfTimestamp.BigCrunch);
-            fail("ArithmeticException not thrown");
-        } catch (ArithmeticException e) {
-        }
-    }
-
-    // ========================================================================
-    // 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);
-    }
-
-}
diff --git a/org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/event/TmfTraceEventTest.java b/org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/event/TmfTraceEventTest.java
deleted file mode 100644 (file)
index 3cec8e5..0000000
+++ /dev/null
@@ -1,75 +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 (fchouinard@gmail.com) - Initial API and implementation
- *******************************************************************************/
-
-
-package org.eclipse.linuxtools.tmf.event;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-/**
- * <b><u>TmfTraceEventTest</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class TmfTraceEventTest {
-
-    // ========================================================================
-    // Constructor
-    // ========================================================================
-
-    @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());
-    }
-
-}
diff --git a/org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/eventlog/AllEventLogTests.java b/org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/eventlog/AllEventLogTests.java
deleted file mode 100644 (file)
index 104559e..0000000
+++ /dev/null
@@ -1,27 +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 (fchouinard@gmail.com) - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.eventlog;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
-    TmfEventRequestTest.class,
-    TmfEventStreamTest.class,
-    TmfEventLogTest.class
-})
-
-public class AllEventLogTests {
-
-}
diff --git a/org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/eventlog/TmfEventLogTest.java b/org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/eventlog/TmfEventLogTest.java
deleted file mode 100644 (file)
index e1a8ab3..0000000
+++ /dev/null
@@ -1,240 +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 (fchouinard@gmail.com) - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.eventlog;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Vector;
-
-import org.eclipse.linuxtools.tmf.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.event.TmfTimeWindow;
-import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * <b><u>TmfEventLogTest</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class TmfEventLogTest {
-
-    private static String filename = "Test-10K";
-    private static int fTotalNbEvents = 10000; 
-    private static ITmfEventParser fParser;
-    private static TmfEventStream  fStream;
-
-       @BeforeClass
-       public static void setUpBeforeClass() throws Exception {
-               fParser = new TmfEventParserStub();
-               fStream = new TmfEventStreamStub(filename, fParser);
-       }
-
-    // ========================================================================
-    // Constructor
-    // ========================================================================
-
-       @Test
-       public void testBasicTmfEventLog() {
-               TmfTrace eventLog = new TmfTrace("MyEventLog", fStream);
-
-               assertEquals("GetId", "MyEventLog", eventLog.getId());
-        assertEquals("GetEpoch", TmfTimestamp.BigBang, eventLog.getEpoch());
-        assertEquals("GetNbEvents", fTotalNbEvents, eventLog.getNbEvents());
-
-        TmfTimeWindow timeRange = eventLog.getTimeRange();
-        assertEquals("GetTimeRange", 0, timeRange.getStartTime().getValue());
-        assertEquals("GetTimeRange", fTotalNbEvents - 1, timeRange.getEndTime().getValue());
-       }
-
-       @Test
-       public void testTmfEventLogWithEpoch() {
-               TmfTimestamp epoch = new TmfTimestamp(100, (byte) 0, 0);
-               TmfTrace eventLog = new TmfTrace("MyEventLog", fStream, epoch);
-
-               assertEquals("GetId", "MyEventLog", eventLog.getId());
-        assertEquals("GetEpoch", epoch, eventLog.getEpoch());
-        assertEquals("GetNbEvents", fTotalNbEvents, eventLog.getNbEvents());
-
-        TmfTimeWindow timeRange = eventLog.getTimeRange();
-        assertEquals("GetTimeRange", 0, timeRange.getStartTime().getValue());
-        assertEquals("GetTimeRange", fTotalNbEvents - 1, timeRange.getEndTime().getValue());
-       }
-
-    // ========================================================================
-    // Operators
-    // ========================================================================
-
-    @Test
-    public void testProcessRequestForNbEvents() throws Exception {
-
-        TmfTrace eventLog = new TmfTrace("MyEventLog", fStream);
-
-        final int NB_EVENTS  = 10 * 1000;
-        final int BLOCK_SIZE = 100;
-        final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
-
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        final TmfEventRequest request = new TmfEventRequest(range, 0, NB_EVENTS, BLOCK_SIZE) {
-            @Override
-            public void newEvents(Vector<TmfEvent> events) {
-                for (TmfEvent e : events) {
-                    requestedEvents.add(e);
-                }
-            }
-        };
-        eventLog.process(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, requestedEvents.get(i).getTimestamp().getValue());
-        }
-    }
-    
-    @Test
-    public void testProcessRequestForAllEvents() throws Exception {
-
-        TmfTrace eventLog = new TmfTrace("MyEventLog", fStream);
-
-        final int NB_EVENTS  = -1;
-        final int BLOCK_SIZE =  1;
-        final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
-        int nbExpectedEvents = eventLog.getNbEvents();
-
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        final TmfEventRequest request = new TmfEventRequest(range, 0, NB_EVENTS, BLOCK_SIZE) {
-            @Override
-            public void newEvents(Vector<TmfEvent> events) {
-                for (TmfEvent e : events) {
-                    requestedEvents.add(e);
-                }
-            }
-        };
-        eventLog.process(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, requestedEvents.get(i).getTimestamp().getValue());
-        }
-    }
-    
-    // @Test
-    public void testProcessRequestWithOffset() throws Exception {
-
-        TmfTrace eventLog = new TmfTrace("MyEventLog", fStream);
-
-        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;
-
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        final TmfEventRequest request = new TmfEventRequest(range, OFFSET, NB_EVENTS, BLOCK_SIZE) {
-            @Override
-            public void newEvents(Vector<TmfEvent> events) {
-                for (TmfEvent e : events) {
-                    requestedEvents.add(e);
-                }
-            }
-        };
-        eventLog.process(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 {
-
-        TmfTrace eventLog = new TmfTrace("MyEventLog", fStream);
-
-        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;
-
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        final TmfEventRequest request = new TmfEventRequest(range, OFFSET, NB_EVENTS, BLOCK_SIZE) {
-            @Override
-            public void newEvents(Vector<TmfEvent> events) {
-                for (TmfEvent e : events) {
-                    requestedEvents.add(e);
-                }
-            }
-        };
-        eventLog.process(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 {
-
-        TmfTrace eventLog = new TmfTrace("MyEventLog", fStream);
-
-        final int NB_EVENTS  = 10 * 1000;
-        final int BLOCK_SIZE = 100;
-        final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
-
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        final TmfEventRequest request = new TmfEventRequest(range, 0, NB_EVENTS, BLOCK_SIZE) {
-            @Override
-            public void newEvents(Vector<TmfEvent> events) {
-                for (TmfEvent e : events) {
-                    requestedEvents.add(e);
-                }
-                // Cancel request after the first chunk is received
-                cancel();
-            }
-        };
-        eventLog.process(request, true);
-
-        assertEquals("nbEvents",  BLOCK_SIZE, requestedEvents.size());
-        assertTrue("isCompleted", request.isCompleted());
-        assertTrue("isCancelled", request.isCancelled());
-    }
-
-}
diff --git a/org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/eventlog/TmfEventRequestTest.java b/org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/eventlog/TmfEventRequestTest.java
deleted file mode 100644 (file)
index 0901611..0000000
+++ /dev/null
@@ -1,241 +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 (fchouinard@gmail.com) - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.eventlog;
-
-import static org.junit.Assert.*;
-
-import java.util.Vector;
-
-import org.eclipse.linuxtools.tmf.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.event.TmfTimeWindow;
-import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * <b><u>TmfEventRequestTest</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class TmfEventRequestTest {
-
-    private static ITmfRequestHandler fProcessor = null;
-
-    @BeforeClass
-    public static void setUpBeforeClass() throws Exception {
-        fProcessor = new TmfRequestHandlerStub();
-    }
-
-    // ========================================================================
-    // Constructor
-    // ========================================================================
-
-    @Test
-    public void testConstructorForRange() throws Exception {
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        TmfEventRequest request = new TmfEventRequest(range, 0, -1, 1);
-
-        assertEquals("StartTime", TmfTimestamp.BigBang,   request.getRange().getStartTime());
-        assertEquals("EndTime",   TmfTimestamp.BigCrunch, request.getRange().getEndTime());
-        assertEquals("Offset",             0, request.getOffset());
-        assertEquals("NbRequestedEvents", -1, request.getNbRequestedEvents());
-    }
-
-    @Test
-    public void testConstructorForNbEvents() throws Exception {
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        TmfEventRequest request = new TmfEventRequest(range, 0, 10, 1);
-
-        assertEquals("StartTime", TmfTimestamp.BigBang,   request.getRange().getStartTime());
-        assertEquals("EndTime",   TmfTimestamp.BigCrunch, request.getRange().getEndTime());
-        assertEquals("Offset",             0, request.getOffset());
-        assertEquals("NbRequestedEvents", 10, request.getNbRequestedEvents());
-    }
-
-    @Test
-    public void testConstructorWithOffset() throws Exception {
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        TmfEventRequest request = new TmfEventRequest(range, 5, 10, 1);
-
-        assertEquals("StartTime", TmfTimestamp.BigBang,   request.getRange().getStartTime());
-        assertEquals("EndTime",   TmfTimestamp.BigCrunch, request.getRange().getEndTime());
-        assertEquals("Offset",             5, request.getOffset());
-        assertEquals("NbRequestedEvents", 10, request.getNbRequestedEvents());
-    }
-
-    @Test
-    public void testConstructorWithNegativeOffset() throws Exception {
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        TmfEventRequest request = new TmfEventRequest(range, -5, 10, 1);
-
-        assertEquals("StartTime", TmfTimestamp.BigBang,   request.getRange().getStartTime());
-        assertEquals("EndTime",   TmfTimestamp.BigCrunch, request.getRange().getEndTime());
-        assertEquals("Offset",            -5, request.getOffset());
-        assertEquals("NbRequestedEvents", 10, request.getNbRequestedEvents());
-    }
-
-    // ========================================================================
-    // 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>();
-
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        final TmfEventRequest request = new TmfEventRequest(range, 0, NB_EVENTS, BLOCK_SIZE) {
-            @Override
-            public void newEvents(Vector<TmfEvent> events) {
-                for (TmfEvent e : events) {
-                    requestedEvents.add(e);
-                }
-            }
-        };
-        fProcessor.process(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, 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;
-
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        final TmfEventRequest request = new TmfEventRequest(range, 0, NB_EVENTS, BLOCK_SIZE) {
-            @Override
-            public void newEvents(Vector<TmfEvent> events) {
-                for (TmfEvent e : events) {
-                    requestedEvents.add(e);
-                }
-            }
-        };
-        fProcessor.process(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, 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;
-
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        final TmfEventRequest request = new TmfEventRequest(range, OFFSET, NB_EVENTS, BLOCK_SIZE) {
-            @Override
-            public void newEvents(Vector<TmfEvent> events) {
-                for (TmfEvent e : events) {
-                    requestedEvents.add(e);
-                }
-            }
-        };
-        fProcessor.process(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;
-
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        final TmfEventRequest request = new TmfEventRequest(range, OFFSET, NB_EVENTS, BLOCK_SIZE) {
-            @Override
-            public void newEvents(Vector<TmfEvent> events) {
-                for (TmfEvent e : events) {
-                    requestedEvents.add(e);
-                }
-            }
-        };
-        fProcessor.process(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>();
-
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        final TmfEventRequest request = new TmfEventRequest(range, 0, NB_EVENTS, BLOCK_SIZE) {
-            @Override
-            public void newEvents(Vector<TmfEvent> events) {
-                for (TmfEvent e : events) {
-                    requestedEvents.add(e);
-                }
-                // Cancel request after the first chunk is received
-                cancel();
-            }
-        };
-        fProcessor.process(request, true);
-
-        assertEquals("nbEvents",  BLOCK_SIZE, requestedEvents.size());
-        assertTrue("isCompleted", request.isCompleted());
-        assertTrue("isCancelled", request.isCancelled());
-    }
-
-}
diff --git a/org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/eventlog/TmfEventStreamTest.java b/org.eclipse.linuxtools.tmf.tests/tests/org/eclipse/linuxtools/tmf/eventlog/TmfEventStreamTest.java
deleted file mode 100644 (file)
index 33181bf..0000000
+++ /dev/null
@@ -1,123 +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 (fchouinard@gmail.com) - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.eventlog;
-
-import static org.junit.Assert.*;
-
-import org.eclipse.linuxtools.tmf.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * <b><u>TmfEventStreamTest</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class TmfEventStreamTest {
-
-    private static final String TEST_STREAM = "Test-10K";
-    private static final int NB_EVENTS = 10000;
-    private static TmfEventStreamStub fStream;
-
-    /**
-     * @throws java.lang.Exception
-     */
-    @BeforeClass
-    public static void setUpBeforeClass() throws Exception {
-        TmfEventParserStub parser = new TmfEventParserStub();
-        fStream = new TmfEventStreamStub(TEST_STREAM, parser, 500);
-    }
-
-    // ========================================================================
-    // Constructor
-    // ========================================================================
-
-    @Test
-    public void testDefaultConstructor() throws Exception {
-        TmfEventParserStub parser = new TmfEventParserStub();
-        TmfEventStreamStub stream = new TmfEventStreamStub(TEST_STREAM, parser);
-
-        assertEquals("getCacheSize", TmfEventStream.DEFAULT_CACHE_SIZE, stream.getCacheSize());
-        assertEquals("getTraceSize", NB_EVENTS, stream.getNbEvents());
-        assertEquals("getRange-start", 0, stream.getTimeRange().getStartTime().getValue());
-        assertEquals("getRange-end", NB_EVENTS - 1, stream.getTimeRange().getEndTime().getValue());
-    }
-
-    @Test
-    public void testNormalConstructor() throws Exception {
-        TmfEventParserStub parser = new TmfEventParserStub();
-        TmfEventStreamStub stream = new TmfEventStreamStub(TEST_STREAM, parser, 500);
-
-        assertEquals("getCacheSize",    500, stream.getCacheSize());
-        assertEquals("getTraceSize", NB_EVENTS, stream.getNbEvents());
-        assertEquals("getRange-start",    0, stream.getTimeRange().getStartTime().getValue());
-        assertEquals("getRange-end", NB_EVENTS - 1, stream.getTimeRange().getEndTime().getValue());
-    }
-
-    // ========================================================================
-    // seek
-    // ========================================================================
-
-    @Test
-    public void testSeekOnCacheBoundary() throws Exception {
-        TmfEvent event = fStream.seek(new TmfTimestamp(0, (byte) 0, 0));
-        assertEquals("Event timestamp", 0, event.getTimestamp().getValue());
-
-        event = fStream.seek(new TmfTimestamp(1000, (byte) 0, 0));
-        assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-
-        event = fStream.seek(new TmfTimestamp(4000, (byte) 0, 0));
-        assertEquals("Event timestamp", 4000, event.getTimestamp().getValue());
-    }
-
-    @Test
-    public void testSeekNotOnCacheBoundary() throws Exception {
-        TmfEvent event = fStream.seek(new TmfTimestamp(1, (byte) 0, 0));
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-
-        event = fStream.seek(new TmfTimestamp(999, (byte) 0, 0));
-        assertEquals("Event timestamp", 999, event.getTimestamp().getValue());
-
-        event = fStream.seek(new TmfTimestamp(4499, (byte) 0, 0));
-        assertEquals("Event timestamp", 4499, event.getTimestamp().getValue());
-    }
-
-    @Test
-    public void testSeekForEventOutOfBounds() throws Exception {
-        // On lower bound, returns the first event (ts = 0)
-        TmfEvent event = fStream.seek(new TmfTimestamp(-1, (byte) 0, 0));
-        assertEquals("Event timestamp", 0, event.getTimestamp().getValue());
-
-        // On higher bound, returns null (no event)
-        event = fStream.seek(new TmfTimestamp(NB_EVENTS, (byte) 0, 0));
-        assertEquals("Event timestamp", null, event);
-    }
-
-    // ========================================================================
-    // getNextEvent
-    // ========================================================================
-
-    @Test
-    public void testGetNextEvent() throws Exception {
-        // On lower bound, returns the first event (ts = 0)
-        TmfEvent event = fStream.seek(new TmfTimestamp(0, (byte) 0, 0));
-        assertEquals("Event timestamp", 0, event.getTimestamp().getValue());
-
-        for (int i = 0; i < 10; i++) {
-            event = fStream.getNextEvent();
-            assertEquals("Event timestamp", i + 1, event.getTimestamp().getValue());
-        }
-    }
-
-}
This page took 0.052697 seconds and 5 git commands to generate.