From 7886b91f56aeb1ae755af287e0561919c92e527f Mon Sep 17 00:00:00 2001 From: Alexandre Montplaisir Date: Wed, 7 Aug 2013 16:04:04 -0400 Subject: [PATCH] tmf: Remove redundant tests in TmfTraceTest Since the consolidation of constructors, some of these tests now do the exact same thing as others, so they can be removed. Change-Id: I0bd4db596b45e4f4662d19226448e294e99fdefa Signed-off-by: Alexandre Montplaisir Reviewed-on: https://git.eclipse.org/r/15225 Tested-by: Hudson CI Reviewed-by: Bernd Hufmann IP-Clean: Bernd Hufmann --- .../tmf/core/tests/trace/TmfTraceTest.java | 94 ++----------------- 1 file changed, 6 insertions(+), 88 deletions(-) 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 979b413435..c105b473c6 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 @@ -65,7 +65,6 @@ public class TmfTraceTest { private static final long DEFAULT_INITIAL_OFFSET_VALUE = (1L * 100 * 1000 * 1000); // .1sec private static final String DIRECTORY = "testfiles"; private static final String TEST_STREAM = "A-Test-10K"; - private static final int BLOCK_SIZE = 500; private static final int NB_EVENTS = 10000; private static TmfTraceStub fTrace = null; @@ -113,7 +112,7 @@ public class TmfTraceTest { // ------------------------------------------------------------------------ @Test - public void testStandardConstructor() throws TmfTraceException { + public void testFullConstructor() throws TmfTraceException { try { final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null); File testfile = new File(FileLocator.toFileURL(location).toURI()); @@ -140,100 +139,19 @@ public class TmfTraceTest { } } - @Test - public void testStandardConstructorCacheSize() throws TmfTraceException { - try { - final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null); - File testfile = new File(FileLocator.toFileURL(location).toURI()); - TmfTraceStub trace = new TmfTraceStub(testfile.toURI().getPath(), 0, false, null, null); - trace.indexTrace(true); - - assertEquals("getType", ITmfEvent.class, trace.getType()); - assertNull("getResource", trace.getResource()); - assertEquals("getPath", testfile.toURI().getPath(), trace.getPath()); - assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize()); - assertEquals("getStreamingInterval", 0, trace.getStreamingInterval()); - assertEquals("getName", TEST_STREAM, trace.getName()); - - assertEquals("getNbEvents", NB_EVENTS, trace.getNbEvents()); - assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue()); - assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue()); - assertEquals("getStartTime", 1, trace.getStartTime().getValue()); - assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue()); - - } catch (final URISyntaxException e) { - fail("URISyntaxException"); - } catch (final IOException e) { - fail("IOException"); - } - - try { - final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null); - File testfile = new File(FileLocator.toFileURL(location).toURI()); - TmfTraceStub trace = new TmfTraceStub(testfile.toURI().getPath(), ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, false, null, null); - trace.indexTrace(true); - - assertEquals("getType", ITmfEvent.class, trace.getType()); - assertNull("getResource", trace.getResource()); - assertEquals("getPath", testfile.toURI().getPath(), trace.getPath()); - assertEquals("getCacheSize", BLOCK_SIZE, trace.getCacheSize()); - assertEquals("getStreamingInterval", 0, trace.getStreamingInterval()); - assertEquals("getName", TEST_STREAM, trace.getName()); - - assertEquals("getNbEvents", NB_EVENTS, trace.getNbEvents()); - assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue()); - assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue()); - assertEquals("getStartTime", 1, trace.getStartTime().getValue()); - assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue()); - - } catch (final URISyntaxException e) { - fail("URISyntaxException"); - } catch (final IOException e) { - fail("IOException"); - } - } - - @Test - public void testFullConstructor() throws TmfTraceException { - try { - final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null); - File testfile = new File(FileLocator.toFileURL(location).toURI()); - TmfTraceStub trace = new TmfTraceStub(testfile.toURI().getPath(), BLOCK_SIZE, false, null, null); - trace.indexTrace(true); - - assertEquals("getType", ITmfEvent.class, trace.getType()); - assertNull("getResource", trace.getResource()); - assertEquals("getPath", testfile.toURI().getPath(), trace.getPath()); - assertEquals("getCacheSize", BLOCK_SIZE, trace.getCacheSize()); - assertEquals("getStreamingInterval", 0, trace.getStreamingInterval()); - assertEquals("getName", TEST_STREAM, trace.getName()); - - assertEquals("getNbEvents", NB_EVENTS, trace.getNbEvents()); - assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue()); - assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue()); - assertEquals("getStartTime", 1, trace.getStartTime().getValue()); - assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue()); - - } catch (final URISyntaxException e) { - fail("URISyntaxException"); - } catch (final IOException e) { - fail("IOException"); - } - } - @Test public void testLiveTraceConstructor() throws TmfTraceException { final long interval = 100; try { final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null); File testfile = new File(FileLocator.toFileURL(location).toURI()); - TmfTraceStub trace = new TmfTraceStub(testfile.toURI().getPath(), BLOCK_SIZE, interval); + TmfTraceStub trace = new TmfTraceStub(testfile.toURI().getPath(), ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, interval); trace.indexTrace(true); assertEquals("getType", ITmfEvent.class, trace.getType()); assertNull("getResource", trace.getResource()); assertEquals("getPath", testfile.toURI().getPath(), trace.getPath()); - assertEquals("getCacheSize", BLOCK_SIZE, trace.getCacheSize()); + assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize()); assertEquals("getStreamingInterval", interval, trace.getStreamingInterval()); assertEquals("getName", TEST_STREAM, trace.getName()); @@ -255,14 +173,14 @@ public class TmfTraceTest { try { final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null); File testfile = new File(FileLocator.toFileURL(location).toURI()); - TmfTraceStub original = new TmfTraceStub(testfile.toURI().getPath(), BLOCK_SIZE, false, new TmfCheckpointIndexer(null), null); + TmfTraceStub original = new TmfTraceStub(testfile.toURI().getPath(), ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, false, new TmfCheckpointIndexer(null), null); TmfTraceStub trace = new TmfTraceStub(original); trace.indexTrace(true); assertEquals("getType", ITmfEvent.class, trace.getType()); assertNull("getResource", trace.getResource()); assertEquals("getPath", testfile.toURI().getPath(), trace.getPath()); - assertEquals("getCacheSize", BLOCK_SIZE, trace.getCacheSize()); + assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize()); assertEquals("getStreamingInterval", 0, trace.getStreamingInterval()); assertEquals("getName", TEST_STREAM, trace.getName()); @@ -1377,7 +1295,7 @@ public class TmfTraceTest { @Test public void testCancel() throws InterruptedException { - final int limit = BLOCK_SIZE; + final int limit = 500; final Vector requestedEvents = new Vector(); final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH); -- 2.34.1