import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;
import java.io.File;
import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
import org.eclipse.linuxtools.ctf.core.trace.Stream;
import org.eclipse.linuxtools.internal.ctf.core.event.metadata.exceptions.ParseException;
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
* <code>{@link CTFTrace}</code>.
*
* @author ematkho
- * @version $Revision: 1.0 $
*/
-@SuppressWarnings("javadoc")
+@SuppressWarnings("nls")
public class CTFTraceTest {
private static final int TRACE_INDEX = 0;
private CTFTrace fixture;
- /**
- * Launch the test.
- *
- * @param args
- * the command line arguments
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(CTFTraceTest.class);
- }
-
/**
* Perform pre-test initialization.
*/
fixture.setByteOrder(ByteOrder.BIG_ENDIAN);
}
- /**
- * Perform post-test clean-up.
- */
- @After
- public void tearDown() {
- // Add additional tear down code here
- }
-
/**
* Run the CTFTrace(File) constructor test with a known existing trace.
*/
* Run the CTFTrace(File) constructor test with an invalid path.
*
* @throws CTFReaderException
+ * is expected
*/
@Test(expected = org.eclipse.linuxtools.ctf.core.trace.CTFReaderException.class)
public void testOpen_invalid() throws CTFReaderException {
- File path = new File(""); //$NON-NLS-1$
+ File path = new File("");
CTFTrace result = new CTFTrace(path);
assertNotNull(result);
}
/**
* Run the void addStream(Stream) method test.
- *
- * @throws ParseException
- * @throws CTFReaderException
*/
@Test
- public void testAddStream() throws ParseException, CTFReaderException {
+ public void testAddStream() {
// test number of streams
int nbStreams = fixture.nbStreams();
assertEquals(1, nbStreams);
+
// Add a stream
- Stream stream = new Stream(CtfTestTraces.getTestTrace(TRACE_INDEX));
- stream.setId(1234);
- fixture.addStream(stream);
+ try {
+ Stream stream = new Stream(CtfTestTraces.getTestTrace(TRACE_INDEX));
+ stream.setId(1234);
+ fixture.addStream(stream);
+ } catch (CTFReaderException e) {
+ fail();
+ } catch (ParseException e) {
+ fail();
+ }
+
// test number of streams
nbStreams = fixture.nbStreams();
assertEquals(2, nbStreams);
*/
@Test
public void testLookupDefinition() {
- String lookupPath = "trace.packet.header"; //$NON-NLS-1$
+ String lookupPath = "trace.packet.header";
Definition result = fixture.lookupDefinition(lookupPath);
assertNotNull(result);
}
}
/**
- * Run the CTFClock getClock() method test.
- */
- @Test
- public void testGetClock_1() {
- CTFClock result = fixture.getClock();
- assertNotNull(result);
- }
-
- /**
- * Run the CTFClock getClock() method test.
- *
- */
- @Test
- public void testGetClock_2() {
- CTFClock result = fixture.getClock("Blabla"); //$NON-NLS-1$
- assertNull(result);
- }
-
- /**
- * Run the CTFClock getClock(String) method test.
- */
- @Test
- public void testGetClock_3() {
- String name = "invisibleClock"; //$NON-NLS-1$
- CTFClock result = fixture.getClock(name);
- assertNull(result);
- }
-
-
- /**
- * Run the CTFClock getClock(String) method test.
+ * Run the CTFClock getClock/setClock method test.
*/
@Test
- public void testSetClock_1() {
- String name = "clockyClock"; //$NON-NLS-1$
+ public void testGetSetClock_1() {
+ String name = "clockyClock";
fixture.addClock(name, new CTFClock());
CTFClock result = fixture.getClock(name);
}
/**
- * Run the CTFClock getClock(String) method test.
+ * Run the CTFClock getClock/setClock method test.
*/
@Test
- public void testSetClock_2() {
- String name = ""; //$NON-NLS-1$
+ public void testGetSetClock_2() {
+ String name = "";
CTFClock ctfClock = new CTFClock();
- ctfClock.addAttribute("name", "Bob"); //$NON-NLS-1$ //$NON-NLS-2$
- ctfClock.addAttribute("pi", new Double(java.lang.Math.PI)); //$NON-NLS-1$
+ ctfClock.addAttribute("name", "Bob");
+ ctfClock.addAttribute("pi", new Double(java.lang.Math.PI));
fixture.addClock(name, ctfClock);
CTFClock result = fixture.getClock(name);
assertNotNull(result);
- assertTrue( (Double)ctfClock.getProperty("pi")> 3.0); //$NON-NLS-1$
- assertTrue( ctfClock.getName().equals("Bob")); //$NON-NLS-1$
+ assertTrue((Double) ctfClock.getProperty("pi") > 3.0);
+ assertTrue(ctfClock.getName().equals("Bob"));
}
/**
*/
@Test
public void testLookupEnvironment_1() {
- String key = ""; //$NON-NLS-1$
+ String key = "";
String result = fixture.lookupEnvironment(key);
assertNull(result);
}
*/
@Test
public void testLookupEnvironment_2() {
- String key = "otherTest"; //$NON-NLS-1$
+ String key = "otherTest";
String result = fixture.lookupEnvironment(key);
assertNull(result);
}
*/
@Test
public void testLookupEnvironment_3() {
- String key = "test"; //$NON-NLS-1$
+ String key = "test";
fixture.addEnvironmentVar(key, key);
String result = fixture.lookupEnvironment(key);
assertTrue(result.equals(key));
*/
@Test
public void testLookupEnvironment_4() {
- String key = "test"; //$NON-NLS-1$
- fixture.addEnvironmentVar(key, "bozo"); //$NON-NLS-1$
- fixture.addEnvironmentVar(key, "the clown"); //$NON-NLS-1$
+ String key = "test";
+ fixture.addEnvironmentVar(key, "bozo");
+ fixture.addEnvironmentVar(key, "the clown");
String result = fixture.lookupEnvironment(key);
assertNotNull(result);
}