X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=org.eclipse.linuxtools.ctf.core.tests%2Fsrc%2Forg%2Feclipse%2Flinuxtools%2Fctf%2Fcore%2Ftests%2Ftrace%2FStreamTest.java;h=68fe8a81f93dc5432e2d3d81199f78dac8c9f942;hb=8e15b929fecc6725aee97c83727afc34d033f28c;hp=568262d23b455ab4019a7a3edd4732b67858fab2;hpb=a34d8eee7eb28c1df39d0ab8346bb7d781025f70;p=deliverable%2Ftracecompass.git diff --git a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamTest.java b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamTest.java index 568262d23b..68fe8a81f9 100644 --- a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamTest.java +++ b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamTest.java @@ -15,13 +15,14 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeTrue; -import java.nio.channels.FileChannel; -import java.util.HashMap; +import java.io.File; +import java.io.FilenameFilter; +import java.util.Map; import java.util.Set; import org.eclipse.linuxtools.ctf.core.event.IEventDeclaration; import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration; -import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTraces; +import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTrace; import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; import org.eclipse.linuxtools.ctf.core.trace.CTFTrace; import org.eclipse.linuxtools.ctf.core.trace.Stream; @@ -41,7 +42,7 @@ import org.junit.Test; @SuppressWarnings("javadoc") public class StreamTest { - private static final int TRACE_INDEX = 0; + private static final CtfTestTrace testTrace = CtfTestTrace.KERNEL; private Stream fixture; @@ -52,14 +53,26 @@ public class StreamTest { */ @Before public void setUp() throws CTFReaderException { - assumeTrue(CtfTestTraces.tracesExist()); - fixture = new Stream(CtfTestTraces.getTestTrace(TRACE_INDEX)); + assumeTrue(testTrace.exists()); + fixture = new Stream(testTrace.getTrace()); fixture.setEventContext(new StructDeclaration(1L)); fixture.setPacketContext(new StructDeclaration(1L)); fixture.setEventHeader(new StructDeclaration(1L)); fixture.setId(1L); - fixture.addInput(new StreamInput(new Stream(CtfTestTraces.getTestTrace(TRACE_INDEX)), - (FileChannel) null, CtfTestTraces.getEmptyFile())); + fixture.addInput(new StreamInput(new Stream(testTrace.getTrace()), createFile())); + } + + private static File createFile() { + File path = new File(testTrace.getPath()); + return path.listFiles(new FilenameFilter() { + @Override + public boolean accept(File dir, String name) { + if (name.contains("hann")) { + return true; + } + return false; + } + })[0]; } /** @@ -69,14 +82,14 @@ public class StreamTest { */ @Test public void testStream() throws CTFReaderException { - CTFTrace trace = CtfTestTraces.getTestTrace(TRACE_INDEX); + CTFTrace trace = testTrace.getTrace(); Stream result = new Stream(trace); assertNotNull(result); } /** - * Run the void addEvent(EventDeclaration) method test with the basic - * event. + * Run the void addEvent(EventDeclaration) method test with the basic event. + * * @throws ParseException */ @Test @@ -92,6 +105,7 @@ public class StreamTest { public void testEventContextIsSet() { assertTrue(fixture.isEventContextSet()); } + /** * Run the boolean eventContextIsSet() method test. */ @@ -129,7 +143,7 @@ public class StreamTest { */ @Test public void testGetEvents() { - HashMap result = fixture.getEvents(); + Map result = fixture.getEvents(); assertNotNull(result); } @@ -187,7 +201,6 @@ public class StreamTest { assertTrue(result); } - /** * Run the void setEventContext(StructDeclaration) method test. */