X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=org.eclipse.linuxtools.tmf.core.tests%2Fsrc%2Forg%2Feclipse%2Flinuxtools%2Ftmf%2Fcore%2Ftests%2Ftrace%2FTmfExperimentTest.java;h=d3ca984e19179661c85b0ff2c7633254dbedc55c;hb=d62bb1853c3388385d5ce10b0302b3dde139c3ab;hp=9968c89651505629765361d1234fc7a4e94b571b;hpb=17324c9af83d2de8c742d27e517e28edd255f2f6;p=deliverable%2Ftracecompass.git 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 9968c89651..d3ca984e19 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 @@ -38,14 +38,14 @@ import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation; import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment; -import org.eclipse.linuxtools.tmf.core.trace.TmfLocation; +import org.eclipse.linuxtools.tmf.core.trace.TmfLongLocation; import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfExperimentStub; import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub; /** * Test suite for the TmfExperiment class (single trace). */ -@SuppressWarnings({ "nls" }) +@SuppressWarnings({"nls","javadoc"}) public class TmfExperimentTest extends TestCase { // ------------------------------------------------------------------------ @@ -58,8 +58,8 @@ public class TmfExperimentTest extends TestCase { private static int NB_EVENTS = 10000; private static int BLOCK_SIZE = 1000; - private ITmfTrace[] fTestTraces; - private TmfExperimentStub fExperiment; + private ITmfTrace[] fTestTraces; + private TmfExperimentStub fExperiment; private static byte SCALE = (byte) -3; @@ -67,8 +67,7 @@ public class TmfExperimentTest extends TestCase { // Housekeeping // ------------------------------------------------------------------------ - @SuppressWarnings("unchecked") - private synchronized ITmfTrace[] setupTrace(final String path) { + private synchronized ITmfTrace[] setupTrace(final String path) { if (fTestTraces == null) { fTestTraces = new ITmfTrace[1]; try { @@ -89,12 +88,15 @@ public class TmfExperimentTest extends TestCase { private synchronized void setupExperiment() { if (fExperiment == null) { - fExperiment = new TmfExperimentStub(EXPERIMENT, fTestTraces, BLOCK_SIZE); + fExperiment = new TmfExperimentStub(EXPERIMENT, fTestTraces, BLOCK_SIZE); fExperiment.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, true); } } - public TmfExperimentTest(final String name) throws Exception { + /** + * @param name the test name + */ + public TmfExperimentTest(final String name) { super(name); } @@ -116,12 +118,12 @@ public class TmfExperimentTest extends TestCase { public void testSimpleTmfExperimentConstructor() { - TmfExperiment experiment = new TmfExperiment(TmfEvent.class, EXPERIMENT, fTestTraces); + TmfExperiment experiment = new TmfExperiment(TmfEvent.class, EXPERIMENT, fTestTraces); assertEquals("GetId", EXPERIMENT, experiment.getName()); assertEquals("GetCacheSize", TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, experiment.getCacheSize()); experiment.dispose(); - experiment = new TmfExperiment(TmfEvent.class, EXPERIMENT, null); + experiment = new TmfExperiment(TmfEvent.class, EXPERIMENT, null); experiment.dispose(); } @@ -144,11 +146,11 @@ public class TmfExperimentTest extends TestCase { @SuppressWarnings("static-access") public void testSetCurrentExperiment() { - TmfExperiment experiment = new TmfExperiment(TmfEvent.class, EXPERIMENT, fTestTraces); + TmfExperiment experiment = new TmfExperiment(TmfEvent.class, EXPERIMENT, fTestTraces); experiment.setCurrentExperiment(experiment); assertEquals("getCurrentExperiment", experiment, experiment.getCurrentExperiment()); - TmfExperiment experiment2 = new TmfExperiment(TmfEvent.class, EXPERIMENT, null); + TmfExperiment experiment2 = new TmfExperiment(TmfEvent.class, EXPERIMENT, null); experiment.setCurrentExperiment(experiment2); assertEquals("getCurrentExperiment", experiment2, experiment.getCurrentExperiment()); @@ -160,7 +162,7 @@ public class TmfExperimentTest extends TestCase { // getTimestamp // ------------------------------------------------------------------------ - public void testGetTimestamp() throws Exception { + public void testGetTimestamp() { assertEquals("getTimestamp", new TmfTimestamp( 1, (byte) -3), fExperiment.getTimestamp( 0)); assertEquals("getTimestamp", new TmfTimestamp( 2, (byte) -3), fExperiment.getTimestamp( 1)); assertEquals("getTimestamp", new TmfTimestamp( 11, (byte) -3), fExperiment.getTimestamp( 10)); @@ -176,7 +178,7 @@ public class TmfExperimentTest extends TestCase { // Bookmarks file handling // ------------------------------------------------------------------------ - public void testBookmarks() throws Exception { + public void testBookmarks() { assertNull("GetBookmarksFile", fExperiment.getBookmarksFile()); IFile bookmarks = (IFile) fTestTraces[0].getResource(); fExperiment.setBookmarksFile(bookmarks); @@ -187,13 +189,13 @@ public class TmfExperimentTest extends TestCase { // seekEvent by location // ------------------------------------------------------------------------ - public void testSeekBadLocation() throws Exception { - ITmfContext context = fExperiment.seekEvent(new TmfLocation(0L)); + public void testSeekBadLocation() { + ITmfContext context = fExperiment.seekEvent(new TmfLongLocation(0L)); assertNull("seekEvent", context); } - public void testSeekNoTrace() throws Exception { - TmfExperiment experiment = new TmfExperiment(TmfEvent.class, EXPERIMENT, null); + public void testSeekNoTrace() { + TmfExperiment experiment = new TmfExperiment(TmfEvent.class, EXPERIMENT, null); ITmfContext context = experiment.seekEvent((TmfExperimentLocation) null); assertNull("seekEvent", context); experiment.dispose(); @@ -203,7 +205,7 @@ public class TmfExperimentTest extends TestCase { // seekEvent on ratio // ------------------------------------------------------------------------ - public void testSeekEventOnRatio() throws Exception { + public void testSeekEventOnRatio() { // First event ITmfContext context = fExperiment.seekEvent(0.0); @@ -242,8 +244,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Context rank", 0, context.getRank()); } - @SuppressWarnings("rawtypes") - public void testGetLocationRatio() throws Exception { + public void testGetLocationRatio() { // First event ITmfContext context = fExperiment.seekEvent((ITmfLocation) null); @@ -268,7 +269,7 @@ public class TmfExperimentTest extends TestCase { } // @SuppressWarnings("rawtypes") -// public void testGetCurrentLocation() throws Exception { +// public void testGetCurrentLocation() { // ITmfContext context = fExperiment.seekEvent((ITmfLocation) null); // ITmfLocation location = fExperiment.getCurrentLocation(); // assertEquals("getCurrentLocation", location, context.getLocation()); @@ -278,7 +279,7 @@ public class TmfExperimentTest extends TestCase { // seekEvent on rank // ------------------------------------------------------------------------ - public void testSeekRankOnCacheBoundary() throws Exception { + public void testSeekRankOnCacheBoundary() { long cacheSize = fExperiment.getCacheSize(); @@ -307,7 +308,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Context rank", 4 * cacheSize + 1, context.getRank()); } - public void testSeekRankNotOnCacheBoundary() throws Exception { + public void testSeekRankNotOnCacheBoundary() { long cacheSize = fExperiment.getCacheSize(); @@ -344,7 +345,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Context rank", 4501, context.getRank()); } - public void testSeekRankOutOfScope() throws Exception { + public void testSeekRankOutOfScope() { // Position trace at beginning ITmfContext context = fExperiment.seekEvent(-1); @@ -367,7 +368,7 @@ public class TmfExperimentTest extends TestCase { // seekEvent on timestamp // ------------------------------------------------------------------------ - public void testSeekTimestampOnCacheBoundary() throws Exception { + public void testSeekTimestampOnCacheBoundary() { long cacheSize = fExperiment.getCacheSize(); @@ -396,7 +397,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Context rank", 4 * cacheSize + 1, context.getRank()); } - public void testSeekTimestampNotOnCacheBoundary() throws Exception { + public void testSeekTimestampNotOnCacheBoundary() { // Position trace at event rank 1 (TS = 2) ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(2, SCALE, 0)); @@ -439,7 +440,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Context rank", 4501, context.getRank()); } - public void testSeekTimestampOutOfScope() throws Exception { + public void testSeekTimestampOutOfScope() { // Position trace at beginning ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(-1, SCALE, 0)); @@ -460,7 +461,7 @@ public class TmfExperimentTest extends TestCase { // seekEvent by location (context rank is undefined) // ------------------------------------------------------------------------ - public void testSeekLocationOnCacheBoundary() throws Exception { + public void testSeekLocationOnCacheBoundary() { long cacheSize = fExperiment.getCacheSize(); @@ -495,7 +496,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 4 * cacheSize + 2, event.getTimestamp().getValue()); } - public void testSeekLocationNotOnCacheBoundary() throws Exception { + public void testSeekLocationNotOnCacheBoundary() { long cacheSize = fExperiment.getCacheSize(); @@ -531,10 +532,10 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 4502, event.getTimestamp().getValue()); } - public void testSeekLocationOutOfScope() throws Exception { + public void testSeekLocationOutOfScope() { // Position trace at beginning - ITmfContext context = fExperiment.seekEvent((ITmfLocation) null); + ITmfContext context = fExperiment.seekEvent((ITmfLocation) null); ITmfEvent event = fExperiment.getNext(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); @@ -544,7 +545,7 @@ public class TmfExperimentTest extends TestCase { // getNext - updates the context // ------------------------------------------------------------------------ - private void validateContextRanks(ITmfContext context) { + private static void validateContextRanks(ITmfContext context) { assertTrue("Experiment context type", context instanceof TmfExperimentContext); TmfExperimentContext ctx = (TmfExperimentContext) context; @@ -563,7 +564,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Experiment context rank", expRank, ctx.getRank()); } - public void testGetNextAfteSeekingOnTS_1() throws Exception { + public void testGetNextAfteSeekingOnTS_1() { final long INITIAL_TS = 1; final int NB_READS = 20; @@ -589,7 +590,7 @@ public class TmfExperimentTest extends TestCase { validateContextRanks(context); } - public void testGetNextAfteSeekingOnTS_2() throws Exception { + public void testGetNextAfteSeekingOnTS_2() { final long INITIAL_TS = 2; final int NB_READS = 20; @@ -615,7 +616,7 @@ public class TmfExperimentTest extends TestCase { validateContextRanks(context); } - public void testGetNextAfteSeekingOnTS_3() throws Exception { + public void testGetNextAfteSeekingOnTS_3() { final long INITIAL_TS = 500; final int NB_READS = 20; @@ -641,7 +642,7 @@ public class TmfExperimentTest extends TestCase { validateContextRanks(context); } - public void testGetNextAfterSeekingOnRank_1() throws Exception { + public void testGetNextAfterSeekingOnRank_1() { final long INITIAL_RANK = 0L; final int NB_READS = 20; @@ -667,7 +668,7 @@ public class TmfExperimentTest extends TestCase { validateContextRanks(context); } - public void testGetNextAfterSeekingOnRank_2() throws Exception { + public void testGetNextAfterSeekingOnRank_2() { final long INITIAL_RANK = 1L; final int NB_READS = 20; @@ -693,7 +694,7 @@ public class TmfExperimentTest extends TestCase { validateContextRanks(context); } - public void testGetNextAfterSeekingOnRank_3() throws Exception { + public void testGetNextAfterSeekingOnRank_3() { final long INITIAL_RANK = 500L; final int NB_READS = 20; @@ -719,9 +720,9 @@ public class TmfExperimentTest extends TestCase { validateContextRanks(context); } - public void testGetNextAfterSeekingOnLocation_1() throws Exception { + public void testGetNextAfterSeekingOnLocation_1() { - final ITmfLocation INITIAL_LOC = null; + final ITmfLocation INITIAL_LOC = null; final long INITIAL_TS = 1; final int NB_READS = 20; @@ -746,9 +747,9 @@ public class TmfExperimentTest extends TestCase { validateContextRanks(context); } - public void testGetNextAfterSeekingOnLocation_2() throws Exception { + public void testGetNextAfterSeekingOnLocation_2() { - final ITmfLocation INITIAL_LOC = fExperiment.seekEvent(1L).getLocation(); + final ITmfLocation INITIAL_LOC = fExperiment.seekEvent(1L).getLocation(); final long INITIAL_TS = 2; final int NB_READS = 20; @@ -771,9 +772,9 @@ public class TmfExperimentTest extends TestCase { validateContextRanks(context); } - public void testGetNextAfterSeekingOnLocation_3() throws Exception { + public void testGetNextAfterSeekingOnLocation_3() { - final ITmfLocation INITIAL_LOC = fExperiment.seekEvent(500L).getLocation(); + final ITmfLocation INITIAL_LOC = fExperiment.seekEvent(500L).getLocation(); final long INITIAL_TS = 501; final int NB_READS = 20; @@ -796,39 +797,39 @@ public class TmfExperimentTest extends TestCase { validateContextRanks(context); } - public void testGetNextLocation() throws Exception { + public void testGetNextLocation() { ITmfContext context1 = fExperiment.seekEvent(0); fExperiment.getNext(context1); - ITmfLocation location = context1.getLocation().clone(); + ITmfLocation location = context1.getLocation(); ITmfEvent event1 = fExperiment.getNext(context1); ITmfContext context2 = fExperiment.seekEvent(location); ITmfEvent event2 = fExperiment.getNext(context2); assertEquals("Event timestamp", event1.getTimestamp().getValue(), event2.getTimestamp().getValue()); } - public void testGetNextEndLocation() throws Exception { + public void testGetNextEndLocation() { ITmfContext context1 = fExperiment.seekEvent(fExperiment.getNbEvents() - 1); fExperiment.getNext(context1); - ITmfLocation location = context1.getLocation().clone(); + ITmfLocation location = context1.getLocation(); ITmfContext context2 = fExperiment.seekEvent(location); ITmfEvent event = fExperiment.getNext(context2); assertNull("Event", event); } - + // ------------------------------------------------------------------------ // processRequest // ------------------------------------------------------------------------ - public void testProcessRequestForNbEvents() throws Exception { + public void testProcessRequestForNbEvents() throws InterruptedException { final int blockSize = 100; final int nbEvents = 1000; - final Vector requestedEvents = new Vector(); + final Vector requestedEvents = new Vector(); final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH); - final TmfEventRequest request = new TmfEventRequest(TmfEvent.class, range, nbEvents, blockSize) { + final TmfEventRequest request = new TmfEventRequest(TmfEvent.class, range, nbEvents, blockSize) { @Override - public void handleData(final TmfEvent event) { + public void handleData(final ITmfEvent event) { super.handleData(event); requestedEvents.add(event); } @@ -847,16 +848,16 @@ public class TmfExperimentTest extends TestCase { } } - public void testProcessRequestForNbEvents2() throws Exception { + public void testProcessRequestForNbEvents2() throws InterruptedException { final int blockSize = 2 * NB_EVENTS; final int nbEvents = 1000; - final Vector requestedEvents = new Vector(); + final Vector requestedEvents = new Vector(); final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH); - final TmfEventRequest request = new TmfEventRequest(TmfEvent.class, range, nbEvents, blockSize) { + final TmfEventRequest request = new TmfEventRequest(TmfEvent.class, range, nbEvents, blockSize) { @Override - public void handleData(final TmfEvent event) { + public void handleData(final ITmfEvent event) { super.handleData(event); requestedEvents.add(event); } @@ -875,17 +876,17 @@ public class TmfExperimentTest extends TestCase { } } - public void testProcessRequestForAllEvents() throws Exception { + public void testProcessRequestForAllEvents() throws InterruptedException { final int nbEvents = TmfDataRequest.ALL_DATA; final int blockSize = 1; - final Vector requestedEvents = new Vector(); + final Vector requestedEvents = new Vector(); final long nbExpectedEvents = NB_EVENTS; final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH); - final TmfEventRequest request = new TmfEventRequest(TmfEvent.class, range, nbEvents, blockSize) { + final TmfEventRequest request = new TmfEventRequest(TmfEvent.class, range, nbEvents, blockSize) { @Override - public void handleData(final TmfEvent event) { + public void handleData(final ITmfEvent event) { super.handleData(event); requestedEvents.add(event); } @@ -908,17 +909,17 @@ public class TmfExperimentTest extends TestCase { // cancel // ------------------------------------------------------------------------ - public void testCancel() throws Exception { + public void testCancel() throws InterruptedException { final int nbEvents = NB_EVENTS; final int blockSize = BLOCK_SIZE; - final Vector requestedEvents = new Vector(); + final Vector requestedEvents = new Vector(); final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH); - final TmfEventRequest request = new TmfEventRequest(TmfEvent.class, range, nbEvents, blockSize) { + final TmfEventRequest request = new TmfEventRequest(TmfEvent.class, range, nbEvents, blockSize) { int nbRead = 0; @Override - public void handleData(final TmfEvent event) { + public void handleData(final ITmfEvent event) { super.handleData(event); requestedEvents.add(event); if (++nbRead == blockSize) {