/*******************************************************************************
- * Copyright (c) 2012 Ericsson
+ * Copyright (c) 2012, 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
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeTrue;
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfIterator;
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocation;
+import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocationInfo;
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent;
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
*/
public class CtfIteratorTest {
- private CtfIterator fixture;
+ private static final int TRACE_INDEX = 0;
- /**
- * Launch the test.
- *
- * @param args
- * the command line arguments
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(CtfIteratorTest.class);
- }
+ private CtfIterator fixture;
/**
* Perform pre-test initialization.
- *
- * @throws TmfTraceException
- * If the test trace is not found
*/
@Before
- public void setUp() throws TmfTraceException {
- fixture = new CtfIterator(createTrace());
- CtfLocation ctfLocation = new CtfLocation(Long.valueOf(1));
- ctfLocation.setLocation(Long.valueOf(1));
+ public void setUp() {
+ assumeTrue(CtfTmfTestTraces.tracesExist());
+ fixture = new CtfIterator(getTrace());
+ CtfLocation ctfLocation = new CtfLocation(new CtfLocationInfo(1, 0));
fixture.setLocation(ctfLocation);
fixture.increaseRank();
}
*/
@After
public void tearDown() {
- fixture.dispose();
+ if (fixture != null) {
+ fixture.dispose();
+ }
}
-
- private static CtfTmfTrace createTrace() throws TmfTraceException {
- return TestParams.createTrace();
+ private static CtfTmfTrace getTrace() {
+ return CtfTmfTestTraces.getTestTrace(TRACE_INDEX);
}
/**
* Run the CtfIterator(CtfTmfTrace) constructor on a non init'ed trace.
- *
- * @throws TmfTraceException
- * If the test trace is not found
*/
@Test
- public void testCtfIterator_noinit() throws TmfTraceException {
- CtfTmfTrace trace = createTrace();
+ public void testCtfIterator_noinit() {
+ CtfTmfTrace trace = getTrace();
CtfIterator result = new CtfIterator(trace);
assertNotNull(result);
}
/**
* Run the CtfIterator(CtfTmfTrace) constructor on an init'ed trace.
- *
- * @throws TmfTraceException
- * If the test trace is not found
*/
@Test
- public void testCtfIterator_init() throws TmfTraceException {
- CtfTmfTrace trace = createTrace();
- trace.init("test"); //$NON-NLS-1$
+ public void testCtfIterator_init() {
+ CtfTmfTrace trace = getTrace();
+ trace.init("test");
CtfIterator result = new CtfIterator(trace);
assertNotNull(result);
/**
* Run the CtfIterator(CtfTmfTrace,long,long) constructor test, which
* specifies an initial position for the iterator.
- *
- * @throws TmfTraceException
- * If the test trace is not found
*/
@Test
- public void testCtfIterator_position() throws TmfTraceException {
- CtfTmfTrace trace = createTrace();
+ public void testCtfIterator_position() {
+ CtfTmfTrace trace = getTrace();
long timestampValue = 1L;
long rank = 1L;
- CtfIterator result = new CtfIterator(trace, timestampValue, rank);
+ CtfIterator result = new CtfIterator(trace, new CtfLocationInfo(timestampValue, 0), rank);
assertNotNull(result);
}
/**
* Run the int compareTo(CtfIterator) method test.
- *
- * @throws TmfTraceException
- * If the test trace is not found
*/
@Test
- public void testCompareTo() throws TmfTraceException {
- CtfIterator o = new CtfIterator(createTrace());
+ public void testCompareTo() {
+ CtfIterator o = new CtfIterator(getTrace());
int result = fixture.compareTo(o);
assertEquals(1L, result);
/**
* Run the boolean equals(Object) method test. Compare with another iterator
* on the same trace.
- *
- * @throws TmfTraceException
- * If the test trace is not found
*/
@Test
- public void testEquals_other() throws TmfTraceException {
- CtfIterator obj = new CtfIterator(createTrace());
- CtfLocation ctfLocation1 = new CtfLocation(Long.valueOf(1));
- ctfLocation1.setLocation(Long.valueOf(1));
+ public void testEquals_other() {
+ CtfIterator obj = new CtfIterator(getTrace());
+ CtfLocation ctfLocation1 = new CtfLocation(new CtfLocationInfo(1, 0));
obj.setLocation(ctfLocation1);
obj.increaseRank();
*/
@Test
public void testSetLocation() {
- CtfLocation location = new CtfLocation(Long.valueOf(1));
- location.setLocation(Long.valueOf(1));
+ CtfLocation location = new CtfLocation(new CtfLocationInfo(1, 0));
fixture.setLocation(location);
}
}