From b4f71e4ab7e1347e6701424b17fec8619f32f58b Mon Sep 17 00:00:00 2001 From: Francois Chouinard Date: Tue, 24 Apr 2012 16:59:20 -0400 Subject: [PATCH] Implement TmfTrace changes - introduce TmfTraceException --- .../tests/event/LttngEventContentTest.java | 12 ++-- .../core/tests/event/LttngEventFieldTest.java | 4 +- .../core/tests/event/LttngEventTest.java | 2 +- .../core/tests/event/LttngEventTypeTest.java | 2 +- .../core/tests/event/LttngTimestampTest.java | 2 +- .../core/tests/headless/LttngTraceTest.java | 4 +- .../core/tests/trace/LTTngTextTraceTest.java | 22 +++--- .../core/tests/trace/LTTngTraceTest.java | 72 +++++++++---------- .../lttng/core/trace/LTTngTextTrace.java | 2 +- .../internal/lttng/core/trace/LTTngTrace.java | 20 +++--- .../internal/lttng/stubs/LTTngTraceStub.java | 11 ++- .../stateprovider/CTFDummyInputTest.java | 5 +- .../CTFKernelStateInputTest.java | 13 ++-- .../tests/stateprovider/CTFTestFiles.java | 5 +- .../tests/ctfadaptor/CtfTmfEventTest.java | 7 +- .../tmf/core/tests/ctfadaptor/TestParams.java | 6 +- .../tests/ctfadaptor/headless/Benchmark.java | 4 +- .../tmf/core/tests/event/TmfEventTest.java | 5 ++ .../tests/experiment/TmfExperimentTest.java | 65 +++++++++-------- .../TmfMultiTraceExperimentTest.java | 65 +++++++++-------- .../request/TmfCoalescedEventRequestTest.java | 5 +- .../tests/trace/TmfCheckpointIndexTest.java | 6 +- .../core/tests/trace/TmfExperimentTest.java | 65 +++++++++-------- .../tmf/core/tests/trace/TmfTraceTest.java | 70 +++++++++--------- .../stubs/component/TmfDataProviderStub.java | 3 + .../stubs/component/TmfEventProviderStub.java | 3 + .../tmf/tests/stubs/trace/TmfTraceStub.java | 59 ++++++++++----- .../META-INF/MANIFEST.MF | 1 + .../tmf/core/ctfadaptor/CtfTmfTrace.java | 9 ++- .../core/exceptions/TmfTraceException.java | 34 +++++++++ .../tmf/core/experiment/TmfExperiment.java | 16 ++--- .../linuxtools/tmf/core/trace/ITmfTrace.java | 21 +++--- .../linuxtools/tmf/core/trace/TmfTrace.java | 35 ++++----- .../views/uml2sd/impl/Uml2SDTestFacility.java | 4 ++ .../tmf/ui/parsers/custom/CustomTxtTrace.java | 7 +- .../tmf/ui/parsers/custom/CustomXmlTrace.java | 7 +- .../CustomTxtParserOutputWizardPage.java | 4 +- .../CustomXmlParserOutputWizardPage.java | 4 +- .../handlers/OpenExperimentHandler.java | 4 +- .../ui/project/handlers/OpenTraceHandler.java | 4 +- .../tmf/ui/editors/EventsViewEditor.java | 8 +-- .../tmf/ui/editors/TmfEventsEditor.java | 10 +-- .../tmf/ui/views/timechart/TimeChartView.java | 4 +- .../tmf/ui/widgets/TmfRawEventViewer.java | 6 +- 44 files changed, 409 insertions(+), 308 deletions(-) create mode 100644 org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/exceptions/TmfTraceException.java diff --git a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventContentTest.java b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventContentTest.java index a11b8c4336..529df0d212 100644 --- a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventContentTest.java +++ b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventContentTest.java @@ -86,7 +86,7 @@ public class LttngEventContentTest extends TestCase { try { testStream = null; final LTTngTextTrace tmpStream = initializeEventStream(); - tmpEventContent = (LttngEventContent)tmpStream.readEvent( new TmfContext(new TmfLocation(0L), 0) ).getContent(); + tmpEventContent = (LttngEventContent)tmpStream.readNextEvent( new TmfContext(new TmfLocation(0L), 0) ).getContent(); } catch (final Exception e) { fail("ERROR : Failed to get content!"); @@ -148,7 +148,7 @@ public class LttngEventContentTest extends TestCase { // Require an event tmpStream = initializeEventStream(); tmpContext = new TmfContext(new TmfLocation(0L), 0); - tmpEvent = (LttngEvent)tmpStream.readEvent(tmpContext); + tmpEvent = (LttngEvent)tmpStream.readNextEvent(tmpContext); testContent = prepareToTest(); // getFieldS() assertNotSame("getFields() returned null!", null, testContent.getFields() ); @@ -177,10 +177,10 @@ public class LttngEventContentTest extends TestCase { // Skip first events and seek to event pass metadata tmpContext= tmpStream.seekEvent(new LttngTimestamp(timestampAfterMetadata) ); // Skip first one - tmpEvent = (LttngEvent)tmpStream.readEvent(tmpContext); + tmpEvent = (LttngEvent)tmpStream.readNextEvent(tmpContext); // Second event past metadata should have more fields - tmpEvent = (LttngEvent)tmpStream.readEvent(tmpContext); + tmpEvent = (LttngEvent)tmpStream.readNextEvent(tmpContext); // Get the content testContent = tmpEvent.getContent(); @@ -211,7 +211,7 @@ public class LttngEventContentTest extends TestCase { // Require an event tmpStream = initializeEventStream(); tmpContext = new TmfContext(new TmfLocation(0L), 0); - tmpEvent = (LttngEvent)tmpStream.readEvent(tmpContext); + tmpEvent = (LttngEvent)tmpStream.readNextEvent(tmpContext); final LttngEventContent tmpContent = prepareToTest(); try { @@ -240,7 +240,7 @@ public class LttngEventContentTest extends TestCase { // Require an event tmpStream = initializeEventStream(); tmpContext = new TmfContext(new TmfLocation(0L), 0); - tmpEvent = (LttngEvent)tmpStream.readEvent(tmpContext); + tmpEvent = (LttngEvent)tmpStream.readNextEvent(tmpContext); // Get the content testContent = tmpEvent.getContent(); // Get all the fields to make sure there is something in the HashMap diff --git a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventFieldTest.java b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventFieldTest.java index 1801b1a966..f92f395e72 100644 --- a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventFieldTest.java +++ b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventFieldTest.java @@ -56,7 +56,7 @@ public class LttngEventFieldTest extends TestCase { // This trace should be valid try { final LTTngTextTrace tmpStream = initializeEventStream(); - tmpField = (LttngEventField)tmpStream.readEvent( new TmfContext(new TmfLocation(0L), 0) ).getContent().getField(0); + tmpField = (LttngEventField)tmpStream.readNextEvent( new TmfContext(new TmfLocation(0L), 0) ).getContent().getField(0); } catch (final Exception e) { fail("ERROR : Failed to get field!"); @@ -94,7 +94,7 @@ public class LttngEventFieldTest extends TestCase { LttngEventField testField = null; // try { - testField = (LttngEventField) tmpStream.readEvent( new TmfContext(new TmfLocation(0L), 0) ).getContent().getField(0); + testField = (LttngEventField) tmpStream.readNextEvent( new TmfContext(new TmfLocation(0L), 0) ).getContent().getField(0); // } catch (TmfNoSuchFieldException e) { // e.printStackTrace(); // } diff --git a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTest.java b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTest.java index 9843ae4df5..f81a634cce 100644 --- a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTest.java +++ b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTest.java @@ -77,7 +77,7 @@ public class LttngEventTest extends TestCase { try { final LTTngTextTrace tmpStream = initializeEventStream(); - tmpEvent = (LttngEvent)tmpStream.readEvent(new TmfContext(new TmfLocation(0L), 0) ); + tmpEvent = (LttngEvent)tmpStream.readNextEvent(new TmfContext(new TmfLocation(0L), 0) ); } catch (final Exception e) { System.out.println("ERROR : Could not open " + tracepath1); diff --git a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTypeTest.java b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTypeTest.java index 515efa5df0..bc5ade03a1 100644 --- a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTypeTest.java +++ b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTypeTest.java @@ -59,7 +59,7 @@ public class LttngEventTypeTest extends TestCase { // This trace should be valid try { final LTTngTextTrace tmpStream = initializeEventStream(); - tmpEventType = (LttngEventType)tmpStream.readEvent( new TmfContext(null, 0) ).getType(); + tmpEventType = (LttngEventType)tmpStream.readNextEvent( new TmfContext(null, 0) ).getType(); } catch (final Exception e) { fail("ERROR : Failed to get reference!"); diff --git a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngTimestampTest.java b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngTimestampTest.java index c5db31ce83..b2257c15f3 100644 --- a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngTimestampTest.java +++ b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngTimestampTest.java @@ -58,7 +58,7 @@ public class LttngTimestampTest extends TestCase { // This trace should be valid try { final LTTngTextTrace tmpStream = initializeEventStream(); - tmpTime = (LttngTimestamp) tmpStream.readEvent(new TmfContext(null, 0)).getTimestamp(); + tmpTime = (LttngTimestamp) tmpStream.readNextEvent(new TmfContext(null, 0)).getTimestamp(); } catch (final Exception e) { fail("ERROR : Failed to get reference!"); } diff --git a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/headless/LttngTraceTest.java b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/headless/LttngTraceTest.java index 6cf8f48dfe..d91049446a 100644 --- a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/headless/LttngTraceTest.java +++ b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/headless/LttngTraceTest.java @@ -67,10 +67,10 @@ public class LttngTraceTest { // Seek to the beginning of the trace tmpContext = tmptrace.seekEvent( tmpTime ); - tmpevent = (LttngEvent)tmptrace.readEvent(tmpContext); + tmpevent = (LttngEvent)tmptrace.readNextEvent(tmpContext); while ( tmpevent != null ) { - tmpevent = (LttngEvent)tmptrace.readEvent(tmpContext); + tmpevent = (LttngEvent)tmptrace.readNextEvent(tmpContext); // Parse the events if it was asked if ( (tmpevent != null) && (PARSE_EVENTS) ) diff --git a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/trace/LTTngTextTraceTest.java b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/trace/LTTngTextTraceTest.java index f9e939e225..9023ef7831 100644 --- a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/trace/LTTngTextTraceTest.java +++ b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/trace/LTTngTextTraceTest.java @@ -116,12 +116,12 @@ public class LTTngTextTraceTest extends TestCase { final TmfContext tmpContext = new TmfContext(null, 0); // We should be at the beginning of the trace, so we will just read the // first event now - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertNotSame("tmpEvent is null after first getNextEvent()", null, tmpEvent); assertEquals("tmpEvent has wrong timestamp after first getNextEvent()", firstEventTimestamp, tmpEvent.getTimestamp().getValue()); // Read the next event as well - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertNotSame("tmpEvent is null after second getNextEvent()", null, tmpEvent); assertEquals("tmpEvent has wrong timestamp after second getNextEvent()", secondEventTimestamp, tmpEvent.getTimestamp().getValue()); } @@ -151,7 +151,7 @@ public class LTTngTextTraceTest extends TestCase { // We should be at the beginning of the trace, we will seek at a certain // timestamp tmpContext = testStream1.seekEvent(new TmfTimestamp(timestampToSeekTest1, (byte) -9, 0)); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertNotSame("tmpContext is null after first seekEvent()", null, tmpContext); assertEquals("tmpContext has wrong timestamp after first seekEvent()", contextValueAfterSeekTest1, tmpEvent.getTimestamp().getValue()); assertNotSame("tmpEvent is null after first seekEvent()", null, tmpEvent); @@ -159,7 +159,7 @@ public class LTTngTextTraceTest extends TestCase { // Seek to the last timestamp tmpContext = testStream1.seekEvent(new TmfTimestamp(timestampToSeekLast, (byte) -9, 0)); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertNotSame("tmpContext is null after seekEvent() to last", null, tmpContext); assertEquals("tmpContext has wrong timestamp after seekEvent() to last", contextValueAfterSeekLast, tmpEvent.getTimestamp().getValue()); assertNotSame("tmpEvent is null after seekEvent() to last ", null, tmpEvent); @@ -167,7 +167,7 @@ public class LTTngTextTraceTest extends TestCase { // Seek to the first timestamp (startTime) tmpContext = testStream1.seekEvent(new TmfTimestamp(firstEventTimestamp, (byte) -9, 0)); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertNotSame("tmpEvent is null after seekEvent() to start ", null, tmpEvent); assertTrue("tmpEvent has wrong reference after seekEvent() to start", firstEventReference.contains(tmpEvent.getReference())); assertNotSame("tmpContext is null after seekEvent() to first", null, tmpContext); @@ -182,7 +182,7 @@ public class LTTngTextTraceTest extends TestCase { // We should be at the beginning of the trace, we will seek at a certain // timestamp tmpContext = testStream1.seekEvent(indexToSeekTest1); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertNotSame("tmpContext is null after first seekEvent()", null, tmpContext); assertEquals("tmpContext has wrong timestamp after first seekEvent()", contextValueAfterSeekTest1, tmpEvent.getTimestamp().getValue()); assertNotSame("tmpEvent is null after first seekEvent()", null, tmpEvent); @@ -190,7 +190,7 @@ public class LTTngTextTraceTest extends TestCase { // Seek to the last timestamp tmpContext = testStream1.seekEvent(indexToSeekLast); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertNotSame("tmpContext is null after first seekEvent()", null, tmpContext); assertEquals("tmpContext has wrong timestamp after first seekEvent()", contextValueAfterSeekLast, tmpEvent.getTimestamp().getValue()); assertNotSame("tmpEvent is null after seekEvent() to last ", null, tmpEvent); @@ -198,7 +198,7 @@ public class LTTngTextTraceTest extends TestCase { // Seek to the first timestamp (startTime) tmpContext = testStream1.seekEvent(indexToSeekFirst); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertNotSame("tmpContext is null after first seekEvent()", null, tmpContext); assertEquals("tmpContext has wrong timestamp after first seekEvent()", contextValueAfterFirstEvent, tmpEvent.getTimestamp().getValue()); assertNotSame("tmpEvent is null after seekEvent() to start ", null, tmpEvent); @@ -213,7 +213,7 @@ public class LTTngTextTraceTest extends TestCase { // We should be at the beginning of the trace, we will seek at a certain // timestamp tmpContext = testStream1.seekEvent(new TmfLocation(locationToSeekTest1)); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertNotSame("tmpContext is null after first seekLocation()", null, tmpContext); assertEquals("tmpContext has wrong timestamp after first seekLocation()", contextValueAfterSeekTest1, tmpEvent.getTimestamp().getValue()); assertNotSame("tmpEvent is null after first seekLocation()", null, tmpEvent); @@ -221,7 +221,7 @@ public class LTTngTextTraceTest extends TestCase { // Seek to the last timestamp tmpContext = testStream1.seekEvent(new TmfLocation(locationToSeekLast)); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertNotSame("tmpContext is null after first seekLocation()", null, tmpContext); assertEquals("tmpContext has wrong timestamp after first seekLocation()", contextValueAfterSeekLast, tmpEvent.getTimestamp().getValue()); assertNotSame("tmpEvent is null after seekLocation() to last ", null, tmpEvent); @@ -229,7 +229,7 @@ public class LTTngTextTraceTest extends TestCase { // Seek to the first timestamp (startTime) tmpContext = testStream1.seekEvent(new TmfLocation(locationToSeekFirst)); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertNotSame("tmpContext is null after first seekLocation()", null, tmpContext); assertEquals("tmpContext has wrong timestamp after first seekLocation()", contextValueAfterFirstEvent, tmpEvent.getTimestamp().getValue()); assertNotSame("tmpEvent is null after seekLocation() to start ", null, tmpEvent); diff --git a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/trace/LTTngTraceTest.java b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/trace/LTTngTraceTest.java index 0982407c91..83f4dbb398 100644 --- a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/trace/LTTngTraceTest.java +++ b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/trace/LTTngTraceTest.java @@ -116,12 +116,12 @@ public class LTTngTraceTest extends TestCase { final TmfContext tmpContext = new TmfContext(null, 0); // We should be at the beginning of the trace, so we will just read the first event now - tmpEvent = testStream1.readEvent(tmpContext ); + tmpEvent = testStream1.readNextEvent(tmpContext ); assertNotSame("tmpEvent is null after first getNextEvent()",null,tmpEvent ); assertEquals("tmpEvent has wrong timestamp after first getNextEvent()",firstEventTimestamp,tmpEvent.getTimestamp().getValue() ); // Read the next event as well - tmpEvent = testStream1.readEvent( tmpContext); + tmpEvent = testStream1.readNextEvent( tmpContext); assertNotSame("tmpEvent is null after second getNextEvent()",null,tmpEvent ); assertEquals("tmpEvent has wrong timestamp after second getNextEvent()",secondEventTimestamp,tmpEvent.getTimestamp().getValue() ); } @@ -149,7 +149,7 @@ public class LTTngTraceTest extends TestCase { // We should be at the beginning of the trace, we will seek at a certain timestamp tmpContext = testStream1.seekEvent(new TmfTimestamp(timestampToSeekTest1, (byte) -9, 0)); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertNotSame("tmpContext is null after first seekEvent()",null,tmpContext ); assertEquals("tmpContext has wrong timestamp after first seekEvent()",contextValueAfterSeekTest1,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() ); assertNotSame("tmpEvent is null after first seekEvent()",null,tmpEvent ); @@ -157,7 +157,7 @@ public class LTTngTraceTest extends TestCase { // Seek to the last timestamp tmpContext = testStream1.seekEvent(new TmfTimestamp(timestampToSeekLast, (byte) -9, 0)); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertNotSame("tmpContext is null after seekEvent() to last",null,tmpContext ); assertEquals("tmpContext has wrong timestamp after seekEvent() to last",contextValueAfterSeekLast,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() ); assertNotSame("tmpEvent is null after seekEvent() to last ",null,tmpEvent ); @@ -165,7 +165,7 @@ public class LTTngTraceTest extends TestCase { // Seek to the first timestamp (startTime) tmpContext = testStream1.seekEvent(new TmfTimestamp(firstEventTimestamp, (byte) -9, 0)); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertNotSame("tmpEvent is null after seekEvent() to start ",null,tmpEvent ); assertTrue("tmpEvent has wrong reference after seekEvent() to start", firstEventReference.contains(tmpEvent.getReference())); assertNotSame("tmpContext is null after seekEvent() to first",null,tmpContext ); @@ -179,7 +179,7 @@ public class LTTngTraceTest extends TestCase { // We should be at the beginning of the trace, we will seek at a certain timestamp tmpContext = testStream1.seekEvent(indexToSeekTest1); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertNotSame("tmpContext is null after first seekEvent()",null,tmpContext ); assertEquals("tmpContext has wrong timestamp after first seekEvent()",contextValueAfterSeekTest1,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() ); assertNotSame("tmpEvent is null after first seekEvent()",null,tmpEvent ); @@ -187,7 +187,7 @@ public class LTTngTraceTest extends TestCase { // Seek to the last timestamp tmpContext = testStream1.seekEvent(indexToSeekLast); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertNotSame("tmpContext is null after first seekEvent()",null,tmpContext ); assertEquals("tmpContext has wrong timestamp after first seekEvent()",contextValueAfterSeekLast,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() ); assertNotSame("tmpEvent is null after seekEvent() to last ",null,tmpEvent ); @@ -195,7 +195,7 @@ public class LTTngTraceTest extends TestCase { // Seek to the first timestamp (startTime) tmpContext = testStream1.seekEvent(indexToSeekFirst); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertNotSame("tmpContext is null after first seekEvent()",null,tmpContext ); assertEquals("tmpContext has wrong timestamp after first seekEvent()",contextValueAfterFirstEvent,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() ); assertNotSame("tmpEvent is null after seekEvent() to start ",null,tmpEvent ); @@ -209,7 +209,7 @@ public class LTTngTraceTest extends TestCase { // We should be at the beginning of the trace, we will seek at a certain timestamp tmpContext = testStream1.seekEvent(new LttngLocation(locationToSeekTest1)); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertNotSame("tmpContext is null after first seekLocation()",null,tmpContext ); assertEquals("tmpContext has wrong timestamp after first seekLocation()",contextValueAfterSeekTest1,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() ); assertNotSame("tmpEvent is null after first seekLocation()",null,tmpEvent ); @@ -217,7 +217,7 @@ public class LTTngTraceTest extends TestCase { // Seek to the last timestamp tmpContext = testStream1.seekEvent(new LttngLocation(locationToSeekLast)); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertNotSame("tmpContext is null after first seekLocation()",null,tmpContext ); assertEquals("tmpContext has wrong timestamp after first seekLocation()",contextValueAfterSeekLast,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() ); assertNotSame("tmpEvent is null after seekLocation() to last ",null,tmpEvent ); @@ -225,7 +225,7 @@ public class LTTngTraceTest extends TestCase { // Seek to the first timestamp (startTime) tmpContext = testStream1.seekEvent(new LttngLocation(locationToSeekFirst)); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertNotSame("tmpContext is null after first seekLocation()",null,tmpContext ); assertEquals("tmpContext has wrong timestamp after first seekLocation()",contextValueAfterFirstEvent,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() ); assertNotSame("tmpEvent is null after seekLocation() to start ",null,tmpEvent ); @@ -243,7 +243,7 @@ public class LTTngTraceTest extends TestCase { assertTrue("location has wrong flag", location.isLastOperationSeek()); assertEquals("location has wrong operation time", seekTimestamp, location.getOperationTimeValue()); tmpContext = testStream1.seekEvent(location); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null); assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue()); @@ -255,19 +255,19 @@ public class LTTngTraceTest extends TestCase { assertTrue("location has wrong flag", location.isLastOperationParse()); assertEquals("location has wrong operation time", seekTimestamp, location.getOperationTimeValue()); tmpContext = testStream1.seekEvent(location); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null); assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue()); // Test LttngLocation after a getNext tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp)); - tmpEvent = testStream.readEvent(tmpContext); + tmpEvent = testStream.readNextEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue()); location = (LttngLocation) tmpContext.getLocation().clone(); assertTrue("location has wrong flag", location.isLastOperationReadNext()); assertEquals("location has wrong operation time", seekTimestamp, location.getOperationTimeValue()); tmpContext = testStream1.seekEvent(location); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null); assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue()); @@ -281,27 +281,27 @@ public class LTTngTraceTest extends TestCase { assertTrue("location has wrong flag", location.isLastOperationParse()); assertEquals("location has wrong operation time", seekTimestamp, location.getOperationTimeValue()); tmpContext = testStream1.seekEvent(location); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null); assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue()); // Test LttngLocation after a getNext and getNext tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp)); - tmpEvent = testStream.readEvent(tmpContext); + tmpEvent = testStream.readNextEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue()); - tmpEvent = testStream.readEvent(tmpContext); + tmpEvent = testStream.readNextEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue()); location = (LttngLocation) tmpContext.getLocation().clone(); assertTrue("location has wrong flag", location.isLastOperationReadNext()); assertEquals("location has wrong operation time", nextEventTimestamp, location.getOperationTimeValue()); tmpContext = testStream1.seekEvent(location); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null); assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp, tmpEvent.getTimestamp().getValue()); // Test LttngLocation after a getNext and parse tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp)); - tmpEvent = testStream.readEvent(tmpContext); + tmpEvent = testStream.readNextEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue()); tmpEvent = testStream.parseEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue()); @@ -309,7 +309,7 @@ public class LTTngTraceTest extends TestCase { assertTrue("location has wrong flag", location.isLastOperationParse()); assertEquals("location has wrong operation time", nextEventTimestamp, location.getOperationTimeValue()); tmpContext = testStream1.seekEvent(location); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null); assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue()); @@ -317,13 +317,13 @@ public class LTTngTraceTest extends TestCase { tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp)); tmpEvent = testStream.parseEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue()); - tmpEvent = testStream.readEvent(tmpContext); + tmpEvent = testStream.readNextEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue()); location = (LttngLocation) tmpContext.getLocation().clone(); assertTrue("location has wrong flag", location.isLastOperationReadNext()); assertEquals("location has wrong operation time", seekTimestamp, location.getOperationTimeValue()); tmpContext = testStream1.seekEvent(location); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null); assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue()); @@ -331,7 +331,7 @@ public class LTTngTraceTest extends TestCase { tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp)); tmpEvent = testStream.parseEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue()); - tmpEvent = testStream.readEvent(tmpContext); + tmpEvent = testStream.readNextEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue()); tmpEvent = testStream.parseEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue()); @@ -339,7 +339,7 @@ public class LTTngTraceTest extends TestCase { assertTrue("location has wrong flag", location.isLastOperationParse()); assertEquals("location has wrong operation time", nextEventTimestamp, location.getOperationTimeValue()); tmpContext = testStream1.seekEvent(location); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null); assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue()); @@ -347,21 +347,21 @@ public class LTTngTraceTest extends TestCase { tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp)); tmpEvent = testStream.parseEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue()); - tmpEvent = testStream.readEvent(tmpContext); + tmpEvent = testStream.readNextEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue()); - tmpEvent = testStream.readEvent(tmpContext); + tmpEvent = testStream.readNextEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue()); location = (LttngLocation) tmpContext.getLocation().clone(); assertTrue("location has wrong flag", location.isLastOperationReadNext()); assertEquals("location has wrong operation time", nextEventTimestamp, location.getOperationTimeValue()); tmpContext = testStream1.seekEvent(location); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null); assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp, tmpEvent.getTimestamp().getValue()); // Test LttngLocation after a getNext, parse and parse tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp)); - tmpEvent = testStream.readEvent(tmpContext); + tmpEvent = testStream.readNextEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue()); tmpEvent = testStream.parseEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue()); @@ -371,31 +371,31 @@ public class LTTngTraceTest extends TestCase { assertTrue("location has wrong flag", location.isLastOperationParse()); assertEquals("location has wrong operation time", nextEventTimestamp, location.getOperationTimeValue()); tmpContext = testStream1.seekEvent(location); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null); assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue()); // Test LttngLocation after a getNext, parse and getNext tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp)); - tmpEvent = testStream.readEvent(tmpContext); + tmpEvent = testStream.readNextEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue()); tmpEvent = testStream.parseEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue()); - tmpEvent = testStream.readEvent(tmpContext); + tmpEvent = testStream.readNextEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue()); location = (LttngLocation) tmpContext.getLocation().clone(); assertTrue("location has wrong flag", location.isLastOperationReadNext()); assertEquals("location has wrong operation time", nextEventTimestamp, location.getOperationTimeValue()); tmpContext = testStream1.seekEvent(location); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null); assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp, tmpEvent.getTimestamp().getValue()); // Test LttngLocation after a getNext, getNext and parse tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp)); - tmpEvent = testStream.readEvent(tmpContext); + tmpEvent = testStream.readNextEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue()); - tmpEvent = testStream.readEvent(tmpContext); + tmpEvent = testStream.readNextEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue()); tmpEvent = testStream.parseEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp, tmpEvent.getTimestamp().getValue()); @@ -403,7 +403,7 @@ public class LTTngTraceTest extends TestCase { assertTrue("location has wrong flag", location.isLastOperationParse()); assertEquals("location has wrong operation time", nextnextEventTimestamp, location.getOperationTimeValue()); tmpContext = testStream1.seekEvent(location); - tmpEvent = testStream1.readEvent(tmpContext); + tmpEvent = testStream1.readNextEvent(tmpContext); assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null); assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp, tmpEvent.getTimestamp().getValue()); } diff --git a/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/trace/LTTngTextTrace.java b/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/trace/LTTngTextTrace.java index 085dc358f7..7a970c1a57 100644 --- a/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/trace/LTTngTextTrace.java +++ b/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/trace/LTTngTextTrace.java @@ -91,7 +91,7 @@ public class LTTngTextTrace extends TmfTrace implements ITmfEventPar final Long endTime = currentLttngEvent.getTimestamp().getValue(); positionToFirstEvent(); - readEvent(new TmfContext(null, 0)); + readNextEvent(new TmfContext(null, 0)); final Long starTime = currentLttngEvent.getTimestamp().getValue(); positionToFirstEvent(); diff --git a/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/trace/LTTngTrace.java b/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/trace/LTTngTrace.java index dfaf4c9088..8531c8ca15 100644 --- a/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/trace/LTTngTrace.java +++ b/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/trace/LTTngTrace.java @@ -13,7 +13,6 @@ package org.eclipse.linuxtools.internal.lttng.core.trace; -import java.io.FileNotFoundException; import java.util.HashMap; import java.util.Iterator; import java.util.Vector; @@ -38,6 +37,7 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.experiment.TmfExperiment; import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType; import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest; @@ -116,18 +116,19 @@ public class LTTngTrace extends TmfTrace implements ITmfEventParser< @Override public synchronized void initTrace(final IResource resource, final String path, final Class eventType) - throws FileNotFoundException { + throws TmfTraceException { super.initialize(resource, path, eventType); initialize(resource, path, eventType); } + @SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected synchronized void initialize(final IResource resource, final String path, final Class eventType) - throws FileNotFoundException { + throws TmfTraceException { try { currentJniTrace = JniTraceFactory.getJniTrace(path, traceLibPath, SHOW_LTT_DEBUG_DEFAULT); } catch (final Exception e) { - throw new FileNotFoundException(e.getMessage()); + throw new TmfTraceException(e.getMessage()); } // Export all the event types from the JNI side @@ -153,7 +154,8 @@ public class LTTngTrace extends TmfTrace implements ITmfEventParser< eventContent.setEvent(currentLttngEvent); fParser = (ITmfEventParser) this; - + fCacheSize = CHECKPOINT_PAGE_SIZE; + // // Bypass indexing if asked // if ( bypassIndexing == false ) { // indexTrace(true); @@ -172,7 +174,7 @@ public class LTTngTrace extends TmfTrace implements ITmfEventParser< || (!jniTrace.isLiveTraceSupported() || !LiveTraceManager.isLiveTrace(jniTrace.getTracepath()))) { // Set the time range of the trace final TmfContext context = seekEvent(0); - final LttngEvent event = readEvent(context); + final LttngEvent event = readNextEvent(context); final LttngTimestamp startTime = new LttngTimestamp(event.getTimestamp()); final LttngTimestamp endTime = new LttngTimestamp(currentJniTrace.getEndTime().getTime()); setTimeRange(new TmfTimeRange(startTime, endTime)); @@ -183,7 +185,7 @@ public class LTTngTrace extends TmfTrace implements ITmfEventParser< // Set the time range of the trace final TmfContext context = seekEvent(0); - final LttngEvent event = readEvent(context); + final LttngEvent event = readNextEvent(context); setEndTime(TmfTimestamp.BIG_BANG); final long startTime = event != null ? event.getTimestamp().getValue() : TmfTimestamp.BIG_BANG.getValue(); fStreamingInterval = LTTNG_STREAMING_INTERVAL; @@ -471,7 +473,7 @@ public class LTTngTrace extends TmfTrace implements ITmfEventParser< // If the location is marked with the read next flag // then it is pointing to the next event following the operation time if (curLocation.isLastOperationReadNext()) - readEvent(context); + readNextEvent(context); return context; } @@ -616,7 +618,7 @@ public class LTTngTrace extends TmfTrace implements ITmfEventParser< public int nbEventsRead = 0; @Override - public synchronized LttngEvent readEvent(final ITmfContext context) { + public synchronized LttngEvent readNextEvent(final ITmfContext context) { if (PRINT_DEBUG) System.out.println("getNextEvent(context) context.getLocation() -> " //$NON-NLS-1$ diff --git a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng/stubs/LTTngTraceStub.java b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng/stubs/LTTngTraceStub.java index 4c3d4dadf7..2743c538d3 100644 --- a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng/stubs/LTTngTraceStub.java +++ b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng/stubs/LTTngTraceStub.java @@ -19,6 +19,7 @@ import java.io.RandomAccessFile; import org.eclipse.core.resources.IResource; import org.eclipse.linuxtools.internal.lttng.core.event.LttngEvent; import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser; import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation; @@ -53,7 +54,7 @@ public class LTTngTraceStub extends TmfTrace implements ITmfEventPar * @param parser * @throws FileNotFoundException */ - public LTTngTraceStub(final IResource resource) throws FileNotFoundException { + public LTTngTraceStub(final IResource resource) throws TmfTraceException { this(resource, DEFAULT_TRACE_CACHE_SIZE); } @@ -63,10 +64,14 @@ public class LTTngTraceStub extends TmfTrace implements ITmfEventPar * @param cacheSize * @throws FileNotFoundException */ - public LTTngTraceStub(final IResource resource, final int cacheSize) throws FileNotFoundException { + public LTTngTraceStub(final IResource resource, final int cacheSize) throws TmfTraceException { // super(resource, LttngEvent.class, resource.getName(), cacheSize, true); super(resource, LttngEvent.class, resource.getName(), cacheSize); - fTrace = new RandomAccessFile(resource.getName(), "r"); + try { + fTrace = new RandomAccessFile(resource.getName(), "r"); + } catch (FileNotFoundException e) { + throw new TmfTraceException(e.getMessage()); + } fParser = new LTTngEventParserStub(); } diff --git a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/CTFDummyInputTest.java b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/CTFDummyInputTest.java index 9943be4313..6af7ebded8 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/CTFDummyInputTest.java +++ b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/CTFDummyInputTest.java @@ -12,9 +12,8 @@ package org.eclipse.linuxtools.lttng2.kernel.core.tests.stateprovider; -import java.io.FileNotFoundException; - import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.CTFDummyInput; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.junit.BeforeClass; /** @@ -27,7 +26,7 @@ public class CTFDummyInputTest extends CTFKernelStateInputTest { /* Hiding superclass method */ @BeforeClass - public static void initialize() throws FileNotFoundException { + public static void initialize() throws TmfTraceException { input = new CTFDummyInput(CTFTestFiles.getTestTrace()); } diff --git a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/CTFKernelStateInputTest.java b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/CTFKernelStateInputTest.java index 57f0b71c0c..0c6038976e 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/CTFKernelStateInputTest.java +++ b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/CTFKernelStateInputTest.java @@ -12,16 +12,15 @@ package org.eclipse.linuxtools.lttng2.kernel.core.tests.stateprovider; -import static org.junit.Assert.*; - -import java.io.FileNotFoundException; +import static org.junit.Assert.assertEquals; +import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.CTFKernelStateInput; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; +import org.eclipse.linuxtools.tmf.core.statesystem.StateSystem; +import org.eclipse.linuxtools.tmf.core.statesystem.helpers.IStateChangeInput; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; -import org.eclipse.linuxtools.tmf.core.statesystem.StateSystem; -import org.eclipse.linuxtools.tmf.core.statesystem.helpers.IStateChangeInput; -import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.CTFKernelStateInput; /** * Tests for the LTTng 2.0 kernel state provider @@ -34,7 +33,7 @@ public class CTFKernelStateInputTest { protected static IStateChangeInput input; @BeforeClass - public static void initialize() throws FileNotFoundException { + public static void initialize() throws TmfTraceException { input = new CTFKernelStateInput(CTFTestFiles.getTestTrace()); } diff --git a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/CTFTestFiles.java b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/CTFTestFiles.java index ffae44c9aa..577c6b0440 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/CTFTestFiles.java +++ b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/CTFTestFiles.java @@ -12,10 +12,9 @@ package org.eclipse.linuxtools.lttng2.kernel.core.tests.stateprovider; -import java.io.FileNotFoundException; - import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; /** * Definitions used by all tests using CTF trace files @@ -40,7 +39,7 @@ public abstract class CTFTestFiles { public static CtfTmfTrace trace = null; - public static CtfTmfTrace getTestTrace() throws FileNotFoundException { + public static CtfTmfTrace getTestTrace() throws TmfTraceException { if (trace == null) { trace = new CtfTmfTrace(); trace.initTrace(null, traceFile, CtfTmfEvent.class); diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfEventTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfEventTest.java index b3d5d45834..4ccb2a93f1 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfEventTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfEventTest.java @@ -1,6 +1,8 @@ package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor; -import static org.junit.Assert.*; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import java.io.FileNotFoundException; @@ -8,6 +10,7 @@ import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfIterator; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace; import org.eclipse.linuxtools.tmf.core.event.ITmfEventField; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -39,7 +42,7 @@ public class CtfTmfEventTest { * @throws FileNotFoundException */ @Before - public void setUp() throws FileNotFoundException { + public void setUp() throws TmfTraceException { CtfTmfTrace trace = TestParams.createTrace(); CtfIterator tr = new CtfIterator(trace); tr.advance(); diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/TestParams.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/TestParams.java index 60671ee281..503ea40fe3 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/TestParams.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/TestParams.java @@ -1,16 +1,16 @@ package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor; import java.io.File; -import java.io.FileNotFoundException; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; public abstract class TestParams { /* Path to test traces */ - private static final String testTracePath1 = "Tests/traces/trace20m"; //$NON-NLS-1$ + private static final String testTracePath1 = "testfiles/trace20m"; //$NON-NLS-1$ private static CtfTmfTrace testTrace1 = null; private static final File emptyFile = new File(""); //$NON-NLS-1$ @@ -24,7 +24,7 @@ public abstract class TestParams { return emptyTrace; } - public static CtfTmfTrace createTrace() throws FileNotFoundException { + public static CtfTmfTrace createTrace() throws TmfTraceException { if ( testTrace1 == null ) { testTrace1 = new CtfTmfTrace(); testTrace1.initTrace(null, testTracePath1, CtfTmfEvent.class); diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/headless/Benchmark.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/headless/Benchmark.java index 8202a7be50..34e2c1f86c 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/headless/Benchmark.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/headless/Benchmark.java @@ -11,7 +11,6 @@ *******************************************************************************/ package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor.headless; -import java.io.FileNotFoundException; import java.io.IOException; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -21,6 +20,7 @@ import java.util.Vector; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfIterator; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; public class Benchmark { @@ -50,7 +50,7 @@ public class Benchmark { trace = new CtfTmfTrace(); try { trace.initTrace(null, TRACE_PATH, CtfTmfEvent.class); - } catch (final FileNotFoundException e) { + } catch (final TmfTraceException e) { loops = NUM_LOOPS +1; break; } diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTest.java index 33beb803e3..d16b7e1798 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTest.java @@ -30,6 +30,7 @@ import org.eclipse.linuxtools.tmf.core.event.TmfEvent; import org.eclipse.linuxtools.tmf.core.event.TmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEventType; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin; import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub; @@ -114,6 +115,8 @@ public class TmfEventTest extends TestCase { final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null); final File test = new File(FileLocator.toFileURL(location).toURI()); trace = new TmfTraceStub(test.toURI().getPath(), 500, false); + } catch (final TmfTraceException e) { + e.printStackTrace(); } catch (final URISyntaxException e) { e.printStackTrace(); } catch (final IOException e) { @@ -274,6 +277,8 @@ public class TmfEventTest extends TestCase { final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(fTracePath), null); final File test = new File(FileLocator.toFileURL(location).toURI()); trace = new TmfTraceStub(test.toURI().getPath(), 500, false); + } catch (final TmfTraceException e) { + e.printStackTrace(); } catch (final URISyntaxException e) { e.printStackTrace(); } catch (final IOException e) { diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/experiment/TmfExperimentTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/experiment/TmfExperimentTest.java index ea72941947..c6d259726f 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/experiment/TmfExperimentTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/experiment/TmfExperimentTest.java @@ -26,6 +26,7 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.experiment.TmfExperiment; import org.eclipse.linuxtools.tmf.core.experiment.TmfExperimentContext; import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest; @@ -67,6 +68,8 @@ public class TmfExperimentTest extends TestCase { final File test = new File(FileLocator.toFileURL(location).toURI()); final TmfTraceStub trace = new TmfTraceStub(test.getPath(), 0, true); fTraces[0] = trace; + } catch (final TmfTraceException e) { + e.printStackTrace(); } catch (final URISyntaxException e) { e.printStackTrace(); } catch (final IOException e) { @@ -151,11 +154,11 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 2, event.getTimestamp().getValue()); assertEquals("Event rank", 2, context.getRank()); @@ -168,11 +171,11 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1002, context.getRank()); @@ -185,11 +188,11 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4000, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4001, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 4002, event.getTimestamp().getValue()); assertEquals("Event rank", 4002, context.getRank()); } @@ -205,7 +208,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 9, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 10, context.getRank()); @@ -218,7 +221,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 999, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); @@ -231,7 +234,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1002, context.getRank()); @@ -244,7 +247,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4500, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4501, context.getRank()); } @@ -260,7 +263,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -284,7 +287,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -296,7 +299,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); @@ -308,7 +311,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4000, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4001, context.getRank()); } @@ -323,7 +326,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 2, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 2, event.getTimestamp().getValue()); assertEquals("Event rank", 2, context.getRank()); @@ -335,7 +338,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 9, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 10, context.getRank()); @@ -347,7 +350,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 999, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); @@ -359,7 +362,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1002, context.getRank()); @@ -371,7 +374,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4500, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4501, context.getRank()); } @@ -386,7 +389,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -410,7 +413,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -422,7 +425,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); @@ -434,7 +437,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4000, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4001, context.getRank()); } @@ -449,7 +452,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 9, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 10, context.getRank()); @@ -461,7 +464,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 999, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); @@ -473,7 +476,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1002, context.getRank()); @@ -485,7 +488,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4500, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4501, context.getRank()); } @@ -500,7 +503,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -525,7 +528,7 @@ public class TmfExperimentTest extends TestCase { // Read NB_EVENTS ITmfEvent event = null;; for (int i = 0; i < NB_READS; i++) { - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", i + 1, event.getTimestamp().getValue()); assertEquals("Event rank", i + 1, context.getRank()); } @@ -544,11 +547,11 @@ public class TmfExperimentTest extends TestCase { // On lower bound, returns the first event (ts = 0) final TmfContext context = fExperiment.seekEvent(new TmfTimestamp(0, SCALE, 0)); - ITmfEvent event = fExperiment.readEvent(context); + ITmfEvent event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); for (int i = 2; i < 20; i++) { - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", i, event.getTimestamp().getValue()); } } diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/experiment/TmfMultiTraceExperimentTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/experiment/TmfMultiTraceExperimentTest.java index 9b291307dc..bd27477611 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/experiment/TmfMultiTraceExperimentTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/experiment/TmfMultiTraceExperimentTest.java @@ -26,6 +26,7 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.experiment.TmfExperiment; import org.eclipse.linuxtools.tmf.core.experiment.TmfExperimentContext; import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest; @@ -72,6 +73,8 @@ public class TmfMultiTraceExperimentTest extends TestCase { test = new File(FileLocator.toFileURL(location).toURI()); final TmfTraceStub trace2 = new TmfTraceStub(test.getPath(), 0, true); fTraces[1] = trace2; + } catch (final TmfTraceException e) { + e.printStackTrace(); } catch (final URISyntaxException e) { e.printStackTrace(); } catch (final IOException e) { @@ -155,11 +158,11 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 2, event.getTimestamp().getValue()); assertEquals("Event rank", 2, context.getRank()); @@ -172,11 +175,11 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1002, context.getRank()); @@ -189,11 +192,11 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4000, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4001, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 4002, event.getTimestamp().getValue()); assertEquals("Event rank", 4002, context.getRank()); } @@ -209,7 +212,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 9, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 10, context.getRank()); @@ -222,7 +225,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 999, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); @@ -235,7 +238,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1002, context.getRank()); @@ -248,7 +251,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4500, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4501, context.getRank()); } @@ -264,7 +267,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -288,7 +291,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -300,7 +303,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); @@ -312,7 +315,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4000, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4001, context.getRank()); } @@ -327,7 +330,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 2, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 2, event.getTimestamp().getValue()); assertEquals("Event rank", 2, context.getRank()); @@ -339,7 +342,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 9, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 10, context.getRank()); @@ -351,7 +354,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 999, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); @@ -363,7 +366,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1002, context.getRank()); @@ -375,7 +378,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4500, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4501, context.getRank()); } @@ -390,7 +393,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -414,7 +417,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -426,7 +429,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); @@ -438,7 +441,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4000, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4001, context.getRank()); } @@ -453,7 +456,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 9, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 10, context.getRank()); @@ -465,7 +468,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 999, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); @@ -477,7 +480,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1002, context.getRank()); @@ -489,7 +492,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4500, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4501, context.getRank()); } @@ -504,7 +507,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -529,7 +532,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { // Read NB_EVENTS ITmfEvent event = null;; for (int i = 0; i < NB_READS; i++) { - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", i + 1, event.getTimestamp().getValue()); assertEquals("Event rank", i + 1, context.getRank()); } @@ -548,11 +551,11 @@ public class TmfMultiTraceExperimentTest extends TestCase { // On lower bound, returns the first event (ts = 0) final TmfContext context = fExperiment.seekEvent(new TmfTimestamp(0, SCALE, 0)); - ITmfEvent event = fExperiment.readEvent(context); + ITmfEvent event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); for (int i = 2; i < 20; i++) { - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", i, event.getTimestamp().getValue()); } } diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfCoalescedEventRequestTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfCoalescedEventRequestTest.java index f5d591e9e5..41e617e730 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfCoalescedEventRequestTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfCoalescedEventRequestTest.java @@ -27,6 +27,7 @@ import org.eclipse.linuxtools.tmf.core.component.TmfProviderManager; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.request.TmfCoalescedDataRequest; import org.eclipse.linuxtools.tmf.core.request.TmfCoalescedEventRequest; import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest; @@ -403,8 +404,10 @@ public class TmfCoalescedEventRequestTest extends TestCase { URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null); File test = new File(FileLocator.toFileURL(location).toURI()); fTrace = new TmfTraceStub(test.getPath(), 500); - } catch (URISyntaxException e) { + } catch (TmfTraceException e) { e.printStackTrace(); + } catch (URISyntaxException e) { + e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfCheckpointIndexTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfCheckpointIndexTest.java index 9511b7b555..f61a8a9590 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfCheckpointIndexTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfCheckpointIndexTest.java @@ -14,7 +14,6 @@ package org.eclipse.linuxtools.tmf.core.tests.trace; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; import java.net.URISyntaxException; import java.net.URL; @@ -25,6 +24,7 @@ import junit.framework.TestCase; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin; import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpoint; @@ -86,7 +86,7 @@ public class TmfCheckpointIndexTest extends TestCase { } private class TestTrace extends TmfTraceStub { - public TestTrace(String path, int blockSize) throws FileNotFoundException { + public TestTrace(String path, int blockSize) throws TmfTraceException { super(path, blockSize); fIndexer = new TestIndexer(this); } @@ -106,6 +106,8 @@ public class TmfCheckpointIndexTest extends TestCase { final File test = new File(FileLocator.toFileURL(location).toURI()); fTrace = new TestTrace(test.toURI().getPath(), BLOCK_SIZE); fTrace.indexTrace(); + } catch (final TmfTraceException e) { + e.printStackTrace(); } catch (final URISyntaxException e) { e.printStackTrace(); } catch (final IOException e) { diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfExperimentTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfExperimentTest.java index c26f6c5089..2deb9e54dd 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfExperimentTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfExperimentTest.java @@ -26,6 +26,7 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.experiment.TmfExperiment; import org.eclipse.linuxtools.tmf.core.experiment.TmfExperimentContext; import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest; @@ -66,6 +67,8 @@ public class TmfExperimentTest extends TestCase { final File test = new File(FileLocator.toFileURL(location).toURI()); final TmfTraceStub trace = new TmfTraceStub(test.getPath(), true); fTraces[0] = trace; + } catch (final TmfTraceException e) { + e.printStackTrace(); } catch (final URISyntaxException e) { e.printStackTrace(); } catch (final IOException e) { @@ -152,7 +155,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); for (int i = 1; i < 20; i++) { - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", i, event.getTimestamp().getValue()); } @@ -171,11 +174,11 @@ public class TmfExperimentTest extends TestCase { // On lower bound, returns the first event (ts = 0) final TmfContext context = fExperiment.seekEvent(new TmfTimestamp(0, SCALE, 0)); - ITmfEvent event = fExperiment.readEvent(context); + ITmfEvent event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); for (int i = 2; i < 20; i++) { - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", i, event.getTimestamp().getValue()); } } @@ -193,7 +196,7 @@ public class TmfExperimentTest extends TestCase { ITmfEvent event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); // assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); // assertEquals("Event rank", 1, context.getRank()); @@ -204,7 +207,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); // assertEquals("Event rank", 1000, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); // assertEquals("Event rank", 1001, context.getRank()); @@ -215,7 +218,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); // assertEquals("Event rank", 4000, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); // assertEquals("Event rank", 4001, context.getRank()); } @@ -229,7 +232,7 @@ public class TmfExperimentTest extends TestCase { ITmfEvent event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); // assertEquals("Event rank", 9, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); // assertEquals("Event rank", 10, context.getRank()); @@ -240,7 +243,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); // assertEquals("Event rank", 999, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); // assertEquals("Event rank", 1000, context.getRank()); @@ -251,7 +254,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); // assertEquals("Event rank", 1001, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); // assertEquals("Event rank", 1002, context.getRank()); @@ -262,7 +265,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); // assertEquals("Event rank", 4500, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); // assertEquals("Event rank", 4501, context.getRank()); } @@ -276,7 +279,7 @@ public class TmfExperimentTest extends TestCase { ITmfEvent event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); // assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); // assertEquals("Event rank", 1, context.getRank()); @@ -287,7 +290,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", null, event); // assertEquals("Event rank", NB_EVENTS, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", null, event); // assertEquals("Event rank", NB_EVENTS, context.getRank()); } @@ -304,7 +307,7 @@ public class TmfExperimentTest extends TestCase { ITmfEvent event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -314,7 +317,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); @@ -324,7 +327,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4000, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4001, context.getRank()); } @@ -337,7 +340,7 @@ public class TmfExperimentTest extends TestCase { ITmfEvent event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 2, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 2, event.getTimestamp().getValue()); assertEquals("Event rank", 2, context.getRank()); @@ -347,7 +350,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 9, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 10, context.getRank()); @@ -357,7 +360,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 999, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); @@ -367,7 +370,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1002, context.getRank()); @@ -377,7 +380,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4500, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4501, context.getRank()); } @@ -390,7 +393,7 @@ public class TmfExperimentTest extends TestCase { ITmfEvent event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -400,7 +403,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", null, event); assertEquals("Event rank", NB_EVENTS, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", null, event); assertEquals("Event rank", NB_EVENTS, context.getRank()); } @@ -417,7 +420,7 @@ public class TmfExperimentTest extends TestCase { ITmfEvent event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -427,7 +430,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); @@ -437,7 +440,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4000, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4001, context.getRank()); } @@ -450,7 +453,7 @@ public class TmfExperimentTest extends TestCase { ITmfEvent event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 9, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 10, context.getRank()); @@ -460,7 +463,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 999, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); @@ -470,7 +473,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1002, context.getRank()); @@ -480,7 +483,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4500, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4501, context.getRank()); } @@ -493,7 +496,7 @@ public class TmfExperimentTest extends TestCase { ITmfEvent event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -503,7 +506,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", null, event); assertEquals("Event rank", NB_EVENTS, context.getRank()); - event = fExperiment.readEvent(context); + event = fExperiment.readNextEvent(context); assertEquals("Event timestamp", null, event); assertEquals("Event rank", NB_EVENTS, context.getRank()); } diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceTest.java index f1c4e43998..a6d63b90b4 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceTest.java @@ -14,7 +14,6 @@ package org.eclipse.linuxtools.tmf.core.tests.trace; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; import java.net.URISyntaxException; import java.net.URL; @@ -31,6 +30,7 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest; import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest; import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin; @@ -92,6 +92,8 @@ public class TmfTraceTest extends TestCase { final File test = new File(FileLocator.toFileURL(location).toURI()); fTrace = new TmfTraceStub(test.toURI().getPath(), BLOCK_SIZE); fTrace.indexTrace(); + } catch (final TmfTraceException e) { + e.printStackTrace(); } catch (final URISyntaxException e) { e.printStackTrace(); } catch (final IOException e) { @@ -301,7 +303,7 @@ public class TmfTraceTest extends TestCase { try { trace.initialize(null, null, TmfEvent.class); fail("TmfTrace.initialize() - no exception thrown"); - } catch (FileNotFoundException e) { + } catch (TmfTraceException e) { // Success } catch (Exception e) { fail("TmfTrace.initialize() - wrong exception thrown"); @@ -515,7 +517,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); @@ -528,7 +530,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); @@ -541,7 +543,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); } @@ -557,7 +559,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); @@ -570,7 +572,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); @@ -583,7 +585,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); @@ -596,7 +598,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); } @@ -612,7 +614,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); @@ -625,7 +627,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", null, event); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", null, event); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); } @@ -655,7 +657,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -667,7 +669,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); @@ -679,7 +681,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4000, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4001, context.getRank()); } @@ -694,7 +696,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 2, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", 2, event.getTimestamp().getValue()); assertEquals("Event rank", 2, context.getRank()); @@ -706,7 +708,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 9, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 10, context.getRank()); @@ -718,7 +720,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 999, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); @@ -730,7 +732,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1002, context.getRank()); @@ -742,7 +744,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4500, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4501, context.getRank()); } @@ -757,7 +759,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -769,7 +771,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", null, event); assertEquals("Event rank", NB_EVENTS, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", null, event); assertEquals("Event rank", NB_EVENTS, context.getRank()); } @@ -799,7 +801,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -811,7 +813,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); @@ -823,7 +825,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4000, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4001, context.getRank()); } @@ -838,7 +840,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 9, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 10, context.getRank()); @@ -850,7 +852,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 999, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); @@ -862,7 +864,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1002, context.getRank()); @@ -874,7 +876,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4500, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4501, context.getRank()); } @@ -889,7 +891,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -901,7 +903,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", null, event); assertEquals("Event rank", NB_EVENTS, context.getRank()); - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", null, event); assertEquals("Event rank", NB_EVENTS, context.getRank()); } @@ -935,7 +937,7 @@ public class TmfTraceTest extends TestCase { // Position the trace at event NB_READS for (int i = 1; i < NB_READS; i++) { - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", i, event.getTimestamp().getValue()); } @@ -952,10 +954,10 @@ public class TmfTraceTest extends TestCase { } // ------------------------------------------------------------------------ - // readEvent - updates the context + // readNextEvent - updates the context // ------------------------------------------------------------------------ - public void testGetEvent() throws Exception { + public void testReadNextEvent() throws Exception { final int NB_READS = 20; @@ -965,7 +967,7 @@ public class TmfTraceTest extends TestCase { // Read NB_EVENTS ITmfEvent event; for (int i = 0; i < NB_READS; i++) { - event = fTrace.readEvent(context); + event = fTrace.readNextEvent(context); assertEquals("Event timestamp", i + 1, event.getTimestamp().getValue()); assertEquals("Event rank", i + 1, context.getRank()); } diff --git a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/component/TmfDataProviderStub.java b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/component/TmfDataProviderStub.java index 6df409a7ec..5592b28433 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/component/TmfDataProviderStub.java +++ b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/component/TmfDataProviderStub.java @@ -21,6 +21,7 @@ import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; import org.eclipse.linuxtools.tmf.core.component.TmfDataProvider; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest; import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest; import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin; @@ -46,6 +47,8 @@ public class TmfDataProviderStub extends TmfDataProvider { try { final File test = new File(FileLocator.toFileURL(location).toURI()); fTrace = new TmfTraceStub(test.getPath(), 0, true); + } catch (final TmfTraceException e) { + e.printStackTrace(); } catch (final URISyntaxException e) { e.printStackTrace(); } diff --git a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/component/TmfEventProviderStub.java b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/component/TmfEventProviderStub.java index 34d87e1baa..d90b6ba7f9 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/component/TmfEventProviderStub.java +++ b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/component/TmfEventProviderStub.java @@ -21,6 +21,7 @@ import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; import org.eclipse.linuxtools.tmf.core.component.TmfEventProvider; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest; import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest; import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin; @@ -46,6 +47,8 @@ public class TmfEventProviderStub extends TmfEventProvider { try { final File test = new File(FileLocator.toFileURL(location).toURI()); fTrace = new TmfTraceStub(test.getPath(), 0, true); + } catch (final TmfTraceException e) { + e.printStackTrace(); } catch (final URISyntaxException e) { e.printStackTrace(); } diff --git a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub.java b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub.java index 69d3a87424..cc0595a48b 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub.java +++ b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub.java @@ -22,6 +22,7 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser; import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation; @@ -68,7 +69,7 @@ public class TmfTraceStub extends TmfTrace implements ITmfEventParser< * @param path * @throws FileNotFoundException */ - public TmfTraceStub(final String path) throws FileNotFoundException { + public TmfTraceStub(final String path) throws TmfTraceException { this(path, DEFAULT_TRACE_CACHE_SIZE, false); } @@ -77,7 +78,7 @@ public class TmfTraceStub extends TmfTrace implements ITmfEventParser< * @param cacheSize * @throws FileNotFoundException */ - public TmfTraceStub(final String path, final int cacheSize) throws FileNotFoundException { + public TmfTraceStub(final String path, final int cacheSize) throws TmfTraceException { this(path, cacheSize, false); } @@ -86,9 +87,13 @@ public class TmfTraceStub extends TmfTrace implements ITmfEventParser< * @param cacheSize * @throws FileNotFoundException */ - public TmfTraceStub(final String path, final int cacheSize, final long interval) throws FileNotFoundException { + public TmfTraceStub(final String path, final int cacheSize, final long interval) throws TmfTraceException { super(null, TmfEvent.class, path, cacheSize, interval); - fTrace = new RandomAccessFile(path, "r"); + try { + fTrace = new RandomAccessFile(path, "r"); + } catch (FileNotFoundException e) { + throw new TmfTraceException(e.getMessage()); + } fParser = new TmfEventParserStub(this); } @@ -97,7 +102,7 @@ public class TmfTraceStub extends TmfTrace implements ITmfEventParser< * @param cacheSize * @throws FileNotFoundException */ - public TmfTraceStub(final String path, final int cacheSize, final ITmfTraceIndexer indexer) throws FileNotFoundException { + public TmfTraceStub(final String path, final int cacheSize, final ITmfTraceIndexer indexer) throws TmfTraceException { this(path, cacheSize, false, null, indexer); } @@ -106,7 +111,7 @@ public class TmfTraceStub extends TmfTrace implements ITmfEventParser< * @param waitForCompletion * @throws FileNotFoundException */ - public TmfTraceStub(final String path, final boolean waitForCompletion) throws FileNotFoundException { + public TmfTraceStub(final String path, final boolean waitForCompletion) throws TmfTraceException { this(path, DEFAULT_TRACE_CACHE_SIZE, waitForCompletion); } @@ -116,9 +121,13 @@ public class TmfTraceStub extends TmfTrace implements ITmfEventParser< * @param waitForCompletion * @throws FileNotFoundException */ - public TmfTraceStub(final String path, final int cacheSize, final boolean waitForCompletion) throws FileNotFoundException { + public TmfTraceStub(final String path, final int cacheSize, final boolean waitForCompletion) throws TmfTraceException { super(null, TmfEvent.class, path, cacheSize); - fTrace = new RandomAccessFile(path, "r"); + try { + fTrace = new RandomAccessFile(path, "r"); + } catch (FileNotFoundException e) { + throw new TmfTraceException(e.getMessage()); + } fParser = new TmfEventParserStub(this); } @@ -128,9 +137,13 @@ public class TmfTraceStub extends TmfTrace implements ITmfEventParser< * @param waitForCompletion * @throws FileNotFoundException */ - public TmfTraceStub(final IResource resource, final String path, final int cacheSize, final boolean waitForCompletion) throws FileNotFoundException { + public TmfTraceStub(final IResource resource, final String path, final int cacheSize, final boolean waitForCompletion) throws TmfTraceException { super(resource, TmfEvent.class, path, cacheSize); - fTrace = new RandomAccessFile(path, "r"); + try { + fTrace = new RandomAccessFile(path, "r"); + } catch (FileNotFoundException e) { + throw new TmfTraceException(e.getMessage()); + } fParser = new TmfEventParserStub(this); } @@ -143,18 +156,26 @@ public class TmfTraceStub extends TmfTrace implements ITmfEventParser< */ @SuppressWarnings("unchecked") public TmfTraceStub(final String path, final int cacheSize, final boolean waitForCompletion, - final ITmfEventParser parser, final ITmfTraceIndexer indexer) throws FileNotFoundException { + final ITmfEventParser parser, final ITmfTraceIndexer indexer) throws TmfTraceException { super(null, TmfEvent.class, path, cacheSize, 0, indexer); - fTrace = new RandomAccessFile(path, "r"); + try { + fTrace = new RandomAccessFile(path, "r"); + } catch (FileNotFoundException e) { + throw new TmfTraceException(e.getMessage()); + } fParser = (ITmfEventParser) ((parser != null) ? parser : new TmfEventParserStub(this)); } /** * Copy constructor */ - public TmfTraceStub(final TmfTraceStub trace) throws FileNotFoundException { + public TmfTraceStub(final TmfTraceStub trace) throws TmfTraceException { super(trace); - fTrace = new RandomAccessFile(getPath(), "r"); + try { + fTrace = new RandomAccessFile(getPath(), "r"); + } catch (FileNotFoundException e) { + throw new TmfTraceException(e.getMessage()); + } fParser = new TmfEventParserStub(this); } @@ -163,14 +184,18 @@ public class TmfTraceStub extends TmfTrace implements ITmfEventParser< } @Override - public void initTrace(final IResource resource, final String path, final Class type) throws FileNotFoundException { - fTrace = new RandomAccessFile(path, "r"); + public void initTrace(final IResource resource, final String path, final Class type) throws TmfTraceException { + try { + fTrace = new RandomAccessFile(path, "r"); + } catch (FileNotFoundException e) { + throw new TmfTraceException(e.getMessage()); + } fParser = new TmfEventParserStub(this); super.initTrace(resource, path, type); } @Override - public void initialize(final IResource resource, final String path, final Class type) throws FileNotFoundException { + public void initialize(final IResource resource, final String path, final Class type) throws TmfTraceException { super.initialize(resource, path, type); } diff --git a/org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF index 3bf8d3f114..1c48649f00 100644 --- a/org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF +++ b/org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF @@ -17,6 +17,7 @@ Export-Package: org.eclipse.linuxtools.internal.tmf.core;x-friends:="org.eclipse org.eclipse.linuxtools.tmf.core.component, org.eclipse.linuxtools.tmf.core.ctfadaptor, org.eclipse.linuxtools.tmf.core.event, + org.eclipse.linuxtools.tmf.core.exceptions, org.eclipse.linuxtools.tmf.core.experiment, org.eclipse.linuxtools.tmf.core.filter, org.eclipse.linuxtools.tmf.core.filter.model, diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java index faff4ad4a3..78b8f4aac2 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java @@ -1,7 +1,5 @@ package org.eclipse.linuxtools.tmf.core.ctfadaptor; -import java.io.FileNotFoundException; - import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; @@ -10,6 +8,7 @@ import org.eclipse.linuxtools.tmf.core.component.TmfEventProvider; import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp; import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest; import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest; import org.eclipse.linuxtools.tmf.core.signal.TmfSignal; @@ -58,7 +57,7 @@ public class CtfTmfTrace extends TmfEventProvider implements ITmfTr @Override public void initTrace(final IResource resource, final String path, final Class eventType) - throws FileNotFoundException { + throws TmfTraceException { this.fResource = resource; try { this.fTrace = new CTFTrace(path); @@ -68,7 +67,7 @@ public class CtfTmfTrace extends TmfEventProvider implements ITmfTr * was not found or was not recognized as a CTF trace. Throw into * the new type of exception expected by the rest of TMF. */ - throw new FileNotFoundException(e.getMessage()); + throw new TmfTraceException(e.getMessage()); } this.iterator = new CtfIterator(this, 0, 0); setStartTime(iterator.getCurrentEvent().getTimestamp()); @@ -292,7 +291,7 @@ public class CtfTmfTrace extends TmfEventProvider implements ITmfTr } @Override - public CtfTmfEvent readEvent(final ITmfContext context) { + public CtfTmfEvent readNextEvent(final ITmfContext context) { iterator.advance(); return iterator.getCurrentEvent(); } diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/exceptions/TmfTraceException.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/exceptions/TmfTraceException.java new file mode 100644 index 0000000000..8d588bbc75 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/exceptions/TmfTraceException.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Francois Chouinard - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.tmf.core.exceptions; + +/** + * TmfTraceException + *

+ * TMF trace related exception + */ +public class TmfTraceException extends Exception { + + /** + * The exception version ID + */ + private static final long serialVersionUID = -6829650938285722133L; + + /** + * @param errMsg the error message + */ + public TmfTraceException(String errMsg) { + super(errMsg); + } + +} diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/experiment/TmfExperiment.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/experiment/TmfExperiment.java index 5c179244c8..7565efb231 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/experiment/TmfExperiment.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/experiment/TmfExperiment.java @@ -247,7 +247,7 @@ public class TmfExperiment extends TmfEventProvider impl */ public ITmfTimestamp getTimestamp(final int index) { final TmfExperimentContext context = seekEvent(index); - final ITmfEvent event = readEvent(context); + final ITmfEvent event = readNextEvent(context); return (event != null) ? event.getTimestamp() : null; } @@ -302,7 +302,7 @@ public class TmfExperiment extends TmfEventProvider impl @SuppressWarnings("unchecked") public T getNext(final ITmfContext context) { if (context instanceof TmfExperimentContext) - return (T) readEvent(context); + return (T) readNextEvent(context); return null; } @@ -346,7 +346,7 @@ public class TmfExperiment extends TmfEventProvider impl * ourselves higher up. */ expLocation.getLocation().locations[i] = context.getContexts()[i].getLocation().clone(); - context.getEvents()[i] = fTraces[i].readEvent(context.getContexts()[i]); + context.getEvents()[i] = fTraces[i].readNextEvent(context.getContexts()[i]); } // Tracer.trace("Ctx: SeekLocation - done"); @@ -398,7 +398,7 @@ public class TmfExperiment extends TmfEventProvider impl // And locate the event ITmfEvent event = parseEvent(context); while ((event != null) && (event.getTimestamp().compareTo(timestamp, false) < 0)) { - readEvent(context); + readNextEvent(context); event = parseEvent(context); } @@ -438,7 +438,7 @@ public class TmfExperiment extends TmfEventProvider impl ITmfEvent event = parseEvent(context); long pos = context.getRank(); while ((event != null) && (pos++ < rank)) { - readEvent(context); + readNextEvent(context); event = parseEvent(context); } @@ -494,7 +494,7 @@ public class TmfExperiment extends TmfEventProvider impl * @return the next event */ @Override - public synchronized ITmfEvent readEvent(final ITmfContext context) { + public synchronized ITmfEvent readNextEvent(final ITmfContext context) { // Validate the context if (!(context instanceof TmfExperimentContext)) @@ -512,7 +512,7 @@ public class TmfExperiment extends TmfEventProvider impl final int lastTrace = expContext.getLastTrace(); if (lastTrace != TmfExperimentContext.NO_TRACE) { final ITmfContext traceContext = expContext.getContexts()[lastTrace]; - expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].readEvent(traceContext); + expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].readNextEvent(traceContext); expContext.setLastTrace(TmfExperimentContext.NO_TRACE); } @@ -602,7 +602,7 @@ public class TmfExperiment extends TmfEventProvider impl final int lastTrace = expContext.getLastTrace(); if (lastTrace != TmfExperimentContext.NO_TRACE) { final ITmfContext traceContext = expContext.getContexts()[lastTrace]; - expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].readEvent(traceContext); + expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].readNextEvent(traceContext); expContext.setLastTrace(TmfExperimentContext.NO_TRACE); fExperimentContext = (TmfExperimentContext) context; } diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTrace.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTrace.java index 190306d7f9..cdbd4a2bd1 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTrace.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTrace.java @@ -13,14 +13,13 @@ package org.eclipse.linuxtools.tmf.core.trace; -import java.io.FileNotFoundException; - import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider; import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp; import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest; /** @@ -50,21 +49,21 @@ import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest; * Example 1: Process a whole trace *

  * ITmfContext context = trace.seekEvent(0);
- * ITmfEvent event = trace.getEvent(context);
+ * ITmfEvent event = trace.readEvent(context);
  * while (event != null) {
  *     processEvent(event);
- *     event = trace.getEvent(context);
+ *     event = trace.readEvent(context);
  * }
  * 
* Example 2: Process 50 events starting from the 1000th event *
  * int nbEventsRead = 0;
  * ITmfContext context = trace.seekEvent(1000);
- * ITmfEvent event = trace.getEvent(context);
+ * ITmfEvent event = trace.readEvent(context);
  * while (event != null && nbEventsRead < 50) {
  *     nbEventsRead++;
  *     processEvent(event);
- *     event = trace.getEvent(context);
+ *     event = trace.readEvent(context);
  * }
  * 
* Example 3: Process the events between 2 timestamps (inclusive) @@ -72,10 +71,10 @@ import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest; * ITmfTimestamp startTime = ...; * ITmfTimestamp endTime = ...; * ITmfContext context = trace.seekEvent(startTime); - * ITmfEvent event = trace.getEvent(context); + * ITmfEvent event = trace.readEvent(context); * while (event != null && event.getTimestamp().compareTo(endTime) <= 0) { * processEvent(event); - * event = trace.getEvent(context); + * event = trace.readEvent(context); * } * * A trace is also an event provider so it can process event requests @@ -123,9 +122,9 @@ public interface ITmfTrace extends ITmfDataProvider { * @param resource the trace resource * @param path the trace path * @param type the trace event type - * @throws FileNotFoundException + * @throws TmfTraceException */ - public void initTrace(IResource resource, String path, Class type) throws FileNotFoundException; + public void initTrace(IResource resource, String path, Class type) throws TmfTraceException; /** * Validate that the trace is of the correct type. @@ -279,6 +278,6 @@ public interface ITmfTrace extends ITmfDataProvider { * @param context the read context (will be updated) * @return the event pointed to by the context */ - public ITmfEvent readEvent(ITmfContext context); + public ITmfEvent readNextEvent(ITmfContext context); } diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java index 86e38d5d3e..9695bf812d 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java @@ -24,6 +24,7 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp; import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest; import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest; @@ -57,7 +58,7 @@ public abstract class TmfTrace extends TmfEventProvider /** * The default trace cache size */ - public static final int DEFAULT_TRACE_CACHE_SIZE = 50000; + public static final int DEFAULT_TRACE_CACHE_SIZE = 10000; // ------------------------------------------------------------------------ // Attributes @@ -121,7 +122,7 @@ public abstract class TmfTrace extends TmfEventProvider * @param cacheSize the trace cache size * @throws FileNotFoundException */ - protected TmfTrace(final IResource resource, final Class type, final String path, final int cacheSize) throws FileNotFoundException { + protected TmfTrace(final IResource resource, final Class type, final String path, final int cacheSize) throws TmfTraceException { this(resource, type, path, cacheSize, 0, null); } @@ -136,7 +137,7 @@ public abstract class TmfTrace extends TmfEventProvider * @param interval the trace streaming interval * @throws FileNotFoundException */ - protected TmfTrace(final IResource resource, final Class type, final String path, final int cacheSize, final long interval) throws FileNotFoundException { + protected TmfTrace(final IResource resource, final Class type, final String path, final int cacheSize, final long interval) throws TmfTraceException { this(resource, type, path, cacheSize, interval, null); } @@ -152,7 +153,7 @@ public abstract class TmfTrace extends TmfEventProvider * @throws FileNotFoundException */ protected TmfTrace(final IResource resource, final Class type, final String path, final int cacheSize, - final long interval, final ITmfTraceIndexer indexer) throws FileNotFoundException { + final long interval, final ITmfTraceIndexer indexer) throws TmfTraceException { this(resource, type, path, cacheSize, interval, null, null); } @@ -169,7 +170,7 @@ public abstract class TmfTrace extends TmfEventProvider */ @SuppressWarnings({ "unchecked", "rawtypes" }) protected TmfTrace(final IResource resource, final Class type, final String path, final int cacheSize, - final long interval, final ITmfTraceIndexer indexer, final ITmfEventParser parser) throws FileNotFoundException { + final long interval, final ITmfTraceIndexer indexer, final ITmfEventParser parser) throws TmfTraceException { super(); fCacheSize = (cacheSize > 0) ? cacheSize : DEFAULT_TRACE_CACHE_SIZE; fStreamingInterval = interval; @@ -184,7 +185,7 @@ public abstract class TmfTrace extends TmfEventProvider * @param trace the original trace */ @SuppressWarnings({ "unchecked", "rawtypes" }) - public TmfTrace(final TmfTrace trace) throws FileNotFoundException { + public TmfTrace(final TmfTrace trace) throws TmfTraceException { super(); if (trace == null) throw new IllegalArgumentException(); @@ -203,7 +204,7 @@ public abstract class TmfTrace extends TmfEventProvider * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#initTrace(org.eclipse.core.resources.IResource, java.lang.String, java.lang.Class) */ @Override - public void initTrace(final IResource resource, final String path, final Class type) throws FileNotFoundException { + public void initTrace(final IResource resource, final String path, final Class type) throws TmfTraceException { initialize(resource, path, type); fIndexer.buildIndex(false); } @@ -217,9 +218,9 @@ public abstract class TmfTrace extends TmfEventProvider * * @throws FileNotFoundException */ - protected void initialize(final IResource resource, final String path, final Class type) throws FileNotFoundException { + protected void initialize(final IResource resource, final String path, final Class type) throws TmfTraceException { if (path == null) - throw new FileNotFoundException(); + throw new TmfTraceException("Invalid trace path"); //$NON-NLS-1$ fPath = path; fResource = resource; String traceName = (resource != null) ? resource.getName() : null; @@ -228,6 +229,8 @@ public abstract class TmfTrace extends TmfEventProvider final int sep = path.lastIndexOf(Path.SEPARATOR); traceName = (sep >= 0) ? path.substring(sep + 1) : path; } + if (fParser == null && !(this instanceof ITmfEventParser)) + throw new TmfTraceException("Invalid trace parser"); //$NON-NLS-1$ super.init(traceName, type); } @@ -384,9 +387,9 @@ public abstract class TmfTrace extends TmfEventProvider // And locate the requested event context long pos = context.getRank(); if (pos < rank) { - ITmfEvent event = readEvent(context); + ITmfEvent event = readNextEvent(context); while (event != null && ++pos < rank) { - event = readEvent(context); + event = readNextEvent(context); } } return context; @@ -407,11 +410,11 @@ public abstract class TmfTrace extends TmfEventProvider // And locate the requested event context final ITmfContext nextEventContext = context.clone(); // Must use clone() to get the right subtype... - ITmfEvent event = readEvent(nextEventContext); + ITmfEvent event = readNextEvent(nextEventContext); while (event != null && event.getTimestamp().compareTo(timestamp, false) < 0) { context.setLocation(nextEventContext.getLocation().clone()); context.increaseRank(); - event = readEvent(nextEventContext); + event = readNextEvent(nextEventContext); } return context; } @@ -421,10 +424,10 @@ public abstract class TmfTrace extends TmfEventProvider // ------------------------------------------------------------------------ /* (non-Javadoc) - * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#readEvent(org.eclipse.linuxtools.tmf.core.trace.ITmfContext) + * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#readNextEvent(org.eclipse.linuxtools.tmf.core.trace.ITmfContext) */ @Override - public synchronized ITmfEvent readEvent(final ITmfContext context) { + public synchronized ITmfEvent readNextEvent(final ITmfContext context) { // parseEvent() does not update the context final ITmfEvent event = fParser.parseEvent(context); if (event != null) { @@ -496,7 +499,7 @@ public abstract class TmfTrace extends TmfEventProvider @SuppressWarnings("unchecked") public T getNext(final ITmfContext context) { if (context instanceof TmfContext) - return (T) readEvent(context); + return (T) readNextEvent(context); return null; } diff --git a/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/impl/Uml2SDTestFacility.java b/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/impl/Uml2SDTestFacility.java index 8088ec2adc..61c57c09df 100644 --- a/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/impl/Uml2SDTestFacility.java +++ b/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/impl/Uml2SDTestFacility.java @@ -22,6 +22,7 @@ import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.experiment.TmfExperiment; import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal; import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser; @@ -127,6 +128,9 @@ public class Uml2SDTestFacility { final URL location = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path("tracesets/sdEvents"), null); //$NON-NLS-1$ final File test = new File(FileLocator.toFileURL(location).toURI()); return new TmfTraceStub(test.getPath(), 500, true, parser, null); + } catch (final TmfTraceException e) { + e.printStackTrace(); + throw new RuntimeException(e); } catch (final URISyntaxException e) { e.printStackTrace(); throw new RuntimeException(e); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtTrace.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtTrace.java index f1a2cc5357..512088bf1a 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtTrace.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtTrace.java @@ -25,6 +25,7 @@ import org.eclipse.core.resources.IResource; import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputLine; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.io.BufferedRandomAccessFile; import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser; @@ -46,14 +47,14 @@ public class CustomTxtTrace extends TmfTrace implements ITmfEven fEventType = new CustomTxtEventType(fDefinition); } - public CustomTxtTrace(final IResource resource, final CustomTxtTraceDefinition definition, final String path, final int pageSize) throws FileNotFoundException { + public CustomTxtTrace(final IResource resource, final CustomTxtTraceDefinition definition, final String path, final int pageSize) throws TmfTraceException { super(resource, CustomTxtEvent.class, path, (pageSize > 0) ? pageSize : DEFAULT_CACHE_SIZE); fDefinition = definition; fEventType = new CustomTxtEventType(fDefinition); } @Override - public void initTrace(final IResource resource, final String path, final Class eventType) throws FileNotFoundException { + public void initTrace(final IResource resource, final String path, final Class eventType) throws TmfTraceException { super.initTrace(resource, path, eventType); } @@ -166,7 +167,7 @@ public class CustomTxtTrace extends TmfTrace implements ITmfEven } @Override - public synchronized TmfEvent readEvent(final ITmfContext context) { + public synchronized TmfEvent readNextEvent(final ITmfContext context) { final ITmfContext savedContext = context.clone(); final TmfEvent event = parseEvent(context); if (event != null) { diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTrace.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTrace.java index bc36be6d80..b6d1b3c9b7 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTrace.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTrace.java @@ -27,6 +27,7 @@ import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefin import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition.InputElement; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.io.BufferedRandomAccessFile; import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser; @@ -59,7 +60,7 @@ public class CustomXmlTrace extends TmfTrace implements ITmfEven fRecordInputElement = getRecordInputElement(fDefinition.rootInputElement); } - public CustomXmlTrace(final IResource resource, final CustomXmlTraceDefinition definition, final String path, final int pageSize) throws FileNotFoundException { + public CustomXmlTrace(final IResource resource, final CustomXmlTraceDefinition definition, final String path, final int pageSize) throws TmfTraceException { super(null, CustomXmlEvent.class, path, (pageSize > 0) ? pageSize : DEFAULT_CACHE_SIZE); fDefinition = definition; fEventType = new CustomXmlEventType(fDefinition); @@ -67,7 +68,7 @@ public class CustomXmlTrace extends TmfTrace implements ITmfEven } @Override - public void initTrace(final IResource resource, final String path, final Class eventType) throws FileNotFoundException { + public void initTrace(final IResource resource, final String path, final Class eventType) throws TmfTraceException { super.initTrace(resource, path, eventType); } @@ -168,7 +169,7 @@ public class CustomXmlTrace extends TmfTrace implements ITmfEven } @Override - public synchronized TmfEvent readEvent(final ITmfContext context) { + public synchronized TmfEvent readNextEvent(final ITmfContext context) { final ITmfContext savedContext = context.clone(); final TmfEvent event = parseEvent(context); if (event != null) { diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/wizards/CustomTxtParserOutputWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/wizards/CustomTxtParserOutputWizardPage.java index 22d5087a9a..fac3fdda17 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/wizards/CustomTxtParserOutputWizardPage.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/wizards/CustomTxtParserOutputWizardPage.java @@ -1,7 +1,6 @@ package org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards; import java.io.File; -import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; @@ -15,6 +14,7 @@ import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomEventsTable; import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition.OutputColumn; import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTrace; import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; @@ -203,7 +203,7 @@ public class CustomTxtParserOutputWizardPage extends WizardPage { previewTable = new CustomEventsTable(definition, tableContainer, CACHE_SIZE); previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); previewTable.setTrace(trace, true); - } catch (final FileNotFoundException e) { + } catch (final TmfTraceException e) { e.printStackTrace(); } catch (final IOException e) { e.printStackTrace(); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/wizards/CustomXmlParserOutputWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/wizards/CustomXmlParserOutputWizardPage.java index af84490931..fd198b7375 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/wizards/CustomXmlParserOutputWizardPage.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/wizards/CustomXmlParserOutputWizardPage.java @@ -1,7 +1,6 @@ package org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards; import java.io.File; -import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; @@ -16,6 +15,7 @@ import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefiniti import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition.OutputColumn; import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTrace; import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; @@ -204,7 +204,7 @@ public class CustomXmlParserOutputWizardPage extends WizardPage { previewTable = new CustomEventsTable(definition, tableContainer, CACHE_SIZE); previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); previewTable.setTrace(trace, true); - } catch (final FileNotFoundException e) { + } catch (final TmfTraceException e) { e.printStackTrace(); } catch (final IOException e) { e.printStackTrace(); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenExperimentHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenExperimentHandler.java index e17e49514e..db83133887 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenExperimentHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenExperimentHandler.java @@ -13,7 +13,6 @@ package org.eclipse.linuxtools.internal.tmf.ui.project.handlers; import java.io.ByteArrayInputStream; -import java.io.FileNotFoundException; import java.io.InputStream; import java.util.List; @@ -27,6 +26,7 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.TreeSelection; import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.experiment.TmfExperiment; import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal; import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager; @@ -138,7 +138,7 @@ public class OpenExperimentHandler extends AbstractHandler { } try { trace.initTrace(element.getResource(), element.getLocation().getPath(), traceEvent.getClass()); - } catch (final FileNotFoundException e) { + } catch (final TmfTraceException e) { displayErrorMsg(""); //$NON-NLS-1$ } cacheSize = Math.min(cacheSize, trace.getCacheSize()); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenTraceHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenTraceHandler.java index e4ce66a07b..e0a8e91c3e 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenTraceHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenTraceHandler.java @@ -13,7 +13,6 @@ package org.eclipse.linuxtools.internal.tmf.ui.project.handlers; import java.io.ByteArrayInputStream; -import java.io.FileNotFoundException; import java.io.InputStream; import org.eclipse.core.commands.AbstractHandler; @@ -27,6 +26,7 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.TreeSelection; import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.experiment.TmfExperiment; import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal; import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager; @@ -136,7 +136,7 @@ public class OpenTraceHandler extends AbstractHandler { try { trace.initTrace(fTrace.getResource(), fTrace.getLocation().getPath(), traceEvent.getClass()); - } catch (final FileNotFoundException e) { + } catch (final TmfTraceException e) { displayErrorMsg(Messages.OpenTraceHandler_NoTrace); return null; } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/EventsViewEditor.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/EventsViewEditor.java index 61a7f37b8a..7cd3f7971e 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/EventsViewEditor.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/EventsViewEditor.java @@ -12,7 +12,6 @@ package org.eclipse.linuxtools.tmf.ui.editors; -import java.io.FileNotFoundException; import java.util.List; import org.eclipse.core.resources.IFile; @@ -22,6 +21,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.InvalidRegistryObjectException; import org.eclipse.linuxtools.internal.tmf.ui.project.handlers.Messages; import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.experiment.TmfExperiment; import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal; import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager; @@ -133,7 +133,7 @@ public class EventsViewEditor extends TmfEditor { } try { trace.initTrace(traceElement.getResource(), traceElement.getLocation().getPath(), traceEvent.getClass()); - } catch (final FileNotFoundException e) { + } catch (final TmfTraceException e) { } cacheSize = Math.min(cacheSize, trace.getCacheSize()); traces[i] = trace; @@ -162,7 +162,7 @@ public class EventsViewEditor extends TmfEditor { throw new PartInitException(Messages.OpenTraceHandler_NoTraceType); try { trace.initTrace(traceElement.getResource(), traceElement.getLocation().getPath(), traceEvent.getClass()); - } catch (final FileNotFoundException e) { + } catch (final TmfTraceException e) { } final ITmfTrace[] traces = new ITmfTrace[] { trace }; final TmfExperiment experiment = new TmfExperiment(traceEvent.getClass(), traceElement.getName(), traces, trace.getCacheSize()); @@ -187,7 +187,7 @@ public class EventsViewEditor extends TmfEditor { throw new PartInitException(Messages.OpenTraceHandler_NoTraceType); try { trace.initTrace(traceElement.getResource(), traceElement.getLocation().getPath(), traceEvent.getClass()); - } catch (final FileNotFoundException e) { + } catch (final TmfTraceException e) { } final ITmfTrace[] traces = new ITmfTrace[] { trace }; final TmfExperiment experiment = new TmfExperiment(traceEvent.getClass(), traceElement.getName(), traces, trace.getCacheSize()); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java index 1b613fe7f8..8af891cad4 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java @@ -12,7 +12,6 @@ package org.eclipse.linuxtools.tmf.ui.editors; -import java.io.FileNotFoundException; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.List; @@ -36,6 +35,7 @@ import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTrace; import org.eclipse.linuxtools.internal.tmf.ui.project.handlers.Messages; import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.experiment.TmfExperiment; import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler; import org.eclipse.linuxtools.tmf.core.signal.TmfTraceSelectedSignal; @@ -128,7 +128,7 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus } try { trace.initTrace(traceElement.getResource(), traceElement.getLocation().getPath(), traceEvent.getClass()); - } catch (final FileNotFoundException e) { + } catch (final TmfTraceException e) { } cacheSize = Math.min(cacheSize, trace.getCacheSize()); traces[i] = trace; @@ -156,7 +156,7 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus throw new PartInitException(Messages.OpenTraceHandler_NoTraceType); try { trace.initTrace(traceElement.getResource(), traceElement.getLocation().getPath(), traceEvent.getClass()); - } catch (final FileNotFoundException e) { + } catch (final TmfTraceException e) { } fTrace = trace; break; @@ -176,7 +176,7 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus throw new PartInitException(Messages.OpenTraceHandler_NoTraceType); try { trace.initTrace(traceElement.getResource(), traceElement.getLocation().getPath(), traceEvent.getClass()); - } catch (final FileNotFoundException e) { + } catch (final TmfTraceException e) { } fTrace = trace; break; @@ -464,7 +464,7 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus } } catch (final InvalidRegistryObjectException e) { e.printStackTrace(); - } catch (final FileNotFoundException e) { + } catch (final TmfTraceException e) { e.printStackTrace(); } catch (final CoreException e) { e.printStackTrace(); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartView.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartView.java index 46f0b6797c..d9077d7abc 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartView.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartView.java @@ -179,7 +179,7 @@ public class TimeChartView extends TmfView implements ITmfTimeScaleSelectionList } while (true) { long rank = context.getRank(); - ITmfEvent event = trace.readEvent(context); + ITmfEvent event = trace.readNextEvent(context); if (event == null) { done = true; break; @@ -447,7 +447,7 @@ public class TimeChartView extends TmfView implements ITmfTimeScaleSelectionList if (interrupted) return; long rank = fContext.getRank(); - ITmfEvent event = trace.readEvent(fContext); + ITmfEvent event = trace.readNextEvent(fContext); if (event == null) { break; } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/TmfRawEventViewer.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/TmfRawEventViewer.java index dc762813ea..b0c9ae14fa 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/TmfRawEventViewer.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/TmfRawEventViewer.java @@ -388,7 +388,7 @@ public class TmfRawEventViewer extends Composite implements ControlListener, Sel long rank = 0; while (!context.getLocation().equals(endLocation)) { location = context.getLocation().clone(); - ITmfEvent event = fTrace.readEvent(context); + ITmfEvent event = fTrace.readNextEvent(context); if (event == null) { break; } @@ -428,7 +428,7 @@ public class TmfRawEventViewer extends Composite implements ControlListener, Sel } else { //fBottomContext = fTrace.seekEvent(fLines.get(fLines.size() - 1).rank + 1); fBottomContext = fTrace.seekEvent(fLines.get(fLines.size() - 1).location); - fTrace.readEvent(fBottomContext); + fTrace.readNextEvent(fBottomContext); } if (fBottomContext == null) { break; @@ -436,7 +436,7 @@ public class TmfRawEventViewer extends Composite implements ControlListener, Sel } long rank = fBottomContext.getRank(); ITmfLocation location = fBottomContext.getLocation() != null ? fBottomContext.getLocation().clone() : null; - ITmfEvent event = fTrace.readEvent(fBottomContext); + ITmfEvent event = fTrace.readNextEvent(fBottomContext); if (event == null) { break; } -- 2.34.1