/*******************************************************************************
- * 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.ctf.core.trace.CTFReaderException;
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfIterator;
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocation;
-import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocationData;
+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.CtfTmfTestTrace;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
*/
public class CtfIteratorTest {
- private CtfIterator fixture;
+ private static final CtfTmfTestTrace testTrace = CtfTmfTestTrace.KERNEL;
- /**
- * Launch the test.
- *
- * @param args
- * the command line arguments
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(CtfIteratorTest.class);
- }
+ private CtfTmfTrace trace;
+ private CtfIterator iterator;
/**
* Perform pre-test initialization.
- *
- * @throws TmfTraceException
- * If the test trace is not found
+ * @throws CTFReaderException error
*/
@Before
- public void setUp() throws TmfTraceException {
- fixture = new CtfIterator(createTrace());
- CtfLocation ctfLocation = new CtfLocation(new CtfLocationData(1, 0));
- ctfLocation.setLocation(new CtfLocationData(1, 0));
- fixture.setLocation(ctfLocation);
- fixture.increaseRank();
+ public void setUp() throws CTFReaderException {
+ assumeTrue(testTrace.exists());
+ trace = testTrace.getTrace();
+ iterator = new CtfIterator(trace);
+ CtfLocation ctfLocation = new CtfLocation(new CtfLocationInfo(1, 0));
+ iterator.setLocation(ctfLocation);
+ iterator.increaseRank();
}
/**
*/
@After
public void tearDown() {
- fixture.dispose();
- }
-
-
- private static CtfTmfTrace createTrace() throws TmfTraceException {
- return TestParams.createTrace();
+ if (iterator != null) {
+ iterator.dispose();
+ }
}
/**
* Run the CtfIterator(CtfTmfTrace) constructor on a non init'ed trace.
- *
- * @throws TmfTraceException
- * If the test trace is not found
+ * @throws CTFReaderException error
*/
@Test
- public void testCtfIterator_noinit() throws TmfTraceException {
- CtfTmfTrace trace = createTrace();
+ public void testCtfIterator_noinit() throws CTFReaderException {
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
+ * @throws CTFReaderException error
*/
@Test
- public void testCtfIterator_init() throws TmfTraceException {
- CtfTmfTrace trace = createTrace();
- trace.init("test"); //$NON-NLS-1$
+ public void testCtfIterator_init() throws CTFReaderException {
+ 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
+ * @throws CTFReaderException error
*/
@Test
- public void testCtfIterator_position() throws TmfTraceException {
- CtfTmfTrace trace = createTrace();
+ public void testCtfIterator_position() throws CTFReaderException {
long timestampValue = 1L;
long rank = 1L;
- CtfIterator result = new CtfIterator(trace, new CtfLocationData(timestampValue, 0), rank);
+ CtfIterator result = new CtfIterator(trace, new CtfLocationInfo(timestampValue, 0), rank);
assertNotNull(result);
}
*/
@Test
public void testAdvance() {
- boolean result = fixture.advance();
+ boolean result = iterator.advance();
assertTrue(result);
}
*/
@Test
public void testClone() {
- CtfIterator result = fixture.clone();
+ CtfIterator result = iterator.clone();
assertNotNull(result);
}
/**
* Run the int compareTo(CtfIterator) method test.
- *
- * @throws TmfTraceException
- * If the test trace is not found
+ * @throws CTFReaderException error
*/
@Test
- public void testCompareTo() throws TmfTraceException {
- CtfIterator o = new CtfIterator(createTrace());
- int result = fixture.compareTo(o);
+ public void testCompareTo() throws CTFReaderException {
+ CtfIterator o = new CtfIterator(trace);
+ int result = iterator.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
+ * @throws CTFReaderException error
*/
@Test
- public void testEquals_other() throws TmfTraceException {
- CtfIterator obj = new CtfIterator(createTrace());
- CtfLocation ctfLocation1 = new CtfLocation(new CtfLocationData(1, 0));
- ctfLocation1.setLocation(new CtfLocationData(1, 0));
+ public void testEquals_other() throws CTFReaderException {
+ CtfIterator obj = new CtfIterator(trace);
+ CtfLocation ctfLocation1 = new CtfLocation(new CtfLocationInfo(1, 0));
obj.setLocation(ctfLocation1);
obj.increaseRank();
- boolean result = fixture.equals(obj);
+ boolean result = iterator.equals(obj);
assertTrue(result);
}
@Test
public void testEquals_empty() {
Object obj = new Object();
- boolean result = fixture.equals(obj);
+ boolean result = iterator.equals(obj);
assertFalse(result);
}
*/
@Test
public void testGetCtfTmfTrace() {
- CtfTmfTrace result = fixture.getCtfTmfTrace();
+ CtfTmfTrace result = iterator.getCtfTmfTrace();
assertNotNull(result);
}
*/
@Test
public void testGetCurrentEvent() {
- CtfTmfEvent result = fixture.getCurrentEvent();
+ CtfTmfEvent result = iterator.getCurrentEvent();
assertNotNull(result);
}
*/
@Test
public void testGetLocation() {
- CtfLocation result = fixture.getLocation();
+ CtfLocation result = iterator.getLocation();
assertNotNull(result);
}
*/
@Test
public void testGetRank() {
- long result = fixture.getRank();
+ long result = iterator.getRank();
assertEquals(1L, result);
}
*/
@Test
public void testHasValidRank() {
- boolean result = fixture.hasValidRank();
+ boolean result = iterator.hasValidRank();
assertTrue(result);
}
*/
@Test
public void testHashCode() {
- int result = fixture.hashCode();
- int result2 = fixture.hashCode();
+ int result = iterator.hashCode();
+ int result2 = iterator.hashCode();
assertEquals(result, result2);
}
*/
@Test
public void testIncreaseRank() {
- fixture.increaseRank();
+ iterator.increaseRank();
}
/**
@Test
public void testSeek() {
long timestamp = 1L;
- boolean result = fixture.seek(timestamp);
+ boolean result = iterator.seek(timestamp);
assertTrue(result);
}
*/
@Test
public void testSetLocation() {
- CtfLocation location = new CtfLocation(new CtfLocationData(1, 0));
- location.setLocation(new CtfLocationData(1, 0));
- fixture.setLocation(location);
+ CtfLocation location = new CtfLocation(new CtfLocationInfo(1, 0));
+ iterator.setLocation(location);
}
}