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=fd3ea36f7044f7fcc7a1a789794a64baf7d98ba5;hpb=13be1a8f5f3fc3c35a7b7152d4f0c803dcbcb624;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 fd3ea36f70..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 @@ -1,85 +1,96 @@ +/******************************************************************************* + * Copyright (c) 2013 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: + * Matthew Khouzam - Initial API and implementation + *******************************************************************************/ + package org.eclipse.linuxtools.ctf.core.tests.trace; 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.EventDeclaration; -import org.eclipse.linuxtools.ctf.core.event.metadata.exceptions.ParseException; +import org.eclipse.linuxtools.ctf.core.event.IEventDeclaration; import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration; -import org.eclipse.linuxtools.ctf.core.tests.TestParams; +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; import org.eclipse.linuxtools.ctf.core.trace.StreamInput; -import org.junit.After; +import org.eclipse.linuxtools.internal.ctf.core.event.EventDeclaration; +import org.eclipse.linuxtools.internal.ctf.core.event.metadata.exceptions.ParseException; import org.junit.Before; import org.junit.Test; /** * The class StreamTest contains tests for the class * {@link Stream}. - * + * * @author ematkho * @version $Revision: 1.0 $ */ +@SuppressWarnings("javadoc") public class StreamTest { - private Stream fixture; + private static final CtfTestTrace testTrace = CtfTestTrace.KERNEL; - /** - * Launch the test. - * - * @param args - * the command line arguments - */ - public static void main(String[] args) { - new org.junit.runner.JUnitCore().run(StreamTest.class); - } + private Stream fixture; /** * Perform pre-test initialization. - * - * @throws CTFReaderException + * + * @throws CTFReaderException */ @Before public void setUp() throws CTFReaderException { - fixture = new Stream(TestParams.createTrace()); + 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(TestParams.createTrace()), - (FileChannel) null, TestParams.getEmptyFile())); + fixture.addInput(new StreamInput(new Stream(testTrace.getTrace()), createFile())); } - /** - * Perform post-test clean-up. - */ - @After - public void tearDown() { - // Add additional tear down code here + 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]; } /** * Run the Stream(CTFTrace) constructor test. - * - * @throws CTFReaderException + * + * @throws CTFReaderException */ @Test public void testStream() throws CTFReaderException { - CTFTrace trace = TestParams.createTrace(); + CTFTrace trace = testTrace.getTrace(); Stream result = new Stream(trace); assertNotNull(result); } /** - * Run the void addEvent(EventDeclaration) method test with the basic - * event. - * @throws ParseException + * Run the void addEvent(EventDeclaration) method test with the basic event. + * + * @throws ParseException */ @Test public void testAddEvent_base() throws ParseException { @@ -88,25 +99,19 @@ public class StreamTest { } /** - * Run the void addEvent(EventDeclaration) method test with an event - * of which we modified the id. - * @throws ParseException - * - * @throws ParseException + * Run the boolean eventContextIsSet() method test. */ @Test - public void testAddEvent_modifiedEvent() throws ParseException { - EventDeclaration event = new EventDeclaration(); - event.setId(1L); - fixture.addEvent(event); + public void testEventContextIsSet() { + assertTrue(fixture.isEventContextSet()); } /** * Run the boolean eventContextIsSet() method test. */ @Test - public void testEventContextIsSet() { - assertTrue(fixture.eventContextIsSet()); + public void testToString() { + assertNotNull(fixture.toString()); } /** @@ -114,7 +119,7 @@ public class StreamTest { */ @Test public void testEventHeaderIsSet() { - assertTrue(fixture.eventHeaderIsSet()); + assertTrue(fixture.isEventHeaderSet()); } /** @@ -138,7 +143,7 @@ public class StreamTest { */ @Test public void testGetEvents() { - HashMap result = fixture.getEvents(); + Map result = fixture.getEvents(); assertNotNull(result); } @@ -183,7 +188,7 @@ public class StreamTest { */ @Test public void testIdIsSet() { - boolean result = fixture.idIsSet(); + boolean result = fixture.isIdSet(); assertTrue(result); } @@ -192,11 +197,10 @@ public class StreamTest { */ @Test public void testPacketContextIsSet() { - boolean result = fixture.packetContextIsSet(); + boolean result = fixture.isPacketContextSet(); assertTrue(result); } - /** * Run the void setEventContext(StructDeclaration) method test. */