int result = fixture.compareTo(o);
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NullPointerException
- // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.createStreamInputReaders(CTFTraceReader.java:152)
- // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.<init>(CTFTraceReader.java:92)
- // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfIterator.<init>(CtfIterator.java:40)
- assertEquals(0, result);
+ assertEquals(1L, result);
}
/**
int result = fixture.compareTo(o);
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NullPointerException
- // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.createStreamInputReaders(CTFTraceReader.java:152)
- // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.<init>(CTFTraceReader.java:92)
- // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfIterator.<init>(CtfIterator.java:40)
- assertEquals(0, result);
+ assertEquals(1, result);
}
/**
CtfIterator o = new CtfIterator(createTrace());
int result = fixture.compareTo(o);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NullPointerException
- // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.createStreamInputReaders(CTFTraceReader.java:152)
- // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.<init>(CTFTraceReader.java:92)
- // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfIterator.<init>(CtfIterator.java:40)
- assertEquals(0, result);
+ assertEquals(1, result);
}
/**
fixture.increaseRank();
fixture.dispose();
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NullPointerException
- // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.createStreamInputReaders(CTFTraceReader.java:152)
- // at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.<init>(CTFTraceReader.java:92)
- // at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfIterator.<init>(CtfIterator.java:40)
}
/**
// at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.createStreamInputReaders(CTFTraceReader.java:152)
// at org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader.<init>(CTFTraceReader.java:92)
// at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfIterator.<init>(CtfIterator.java:40)
- assertEquals(0L, result);
+ assertEquals(1L, result);
}
/**
import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;
import org.eclipse.linuxtools.tmf.core.statesystem.IStateSystemQuerier;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
// An unexpected exception was thrown in user code while executing this test:
// org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException: Path must be a valid directory
// at org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace.initTrace(CtfTmfTrace.java:98)
- assertNotNull(result);
+ assertNull(result);
}
@Test
public void testGetNext_1()
throws Exception {
CtfTmfTrace fixture = initTrace();
- ITmfContext context = new TmfContext();
+ ITmfContext context = fixture.seekEvent(0);
CtfTmfEvent result = fixture.getNext(context);
public void testReadNextEvent_1()
throws Exception {
CtfTmfTrace fixture = initTrace();
- ITmfContext context = new TmfContext();
+ ITmfContext context = fixture.seekEvent(0);
CtfTmfEvent result = fixture.readNextEvent(context);
private final CtfTmfTrace ctfTmfTrace;
- final public static CtfLocation nullLocation = new CtfLocation(
+ final public static CtfLocation NULL_LOCATION = new CtfLocation(
CtfLocation.INVALID_LOCATION);
private CtfLocation curLocation;
private long curRank;
*
*/
private void setUnknownLocation() {
- this.curLocation = nullLocation;
+ this.curLocation = NULL_LOCATION;
this.curRank = UNKNOWN_RANK;
}
if (ret) {
curLocation.setLocation(getCurrentEvent().getTimestampValue());
+ } else {
+ curLocation = NULL_LOCATION;
}
return ret;
}
if (ret) {
curLocation.setLocation(getCurrentEvent().getTimestampValue());
+ } else {
+ curLocation = NULL_LOCATION;
}
return ret;
}
*/
@Override
public long getRank() {
- return super.getIndex();
+ return curRank;
}
/**
*/
@Override
public void setRank(final long rank) {
- if(!this.curLocation.equals(nullLocation)) {
- seekRank(rank);
- }
+ curRank = rank;
}
/*
*/
@Override
public boolean advance() {
- return super.advance();
+ boolean ret = super.advance();
+ if (ret) {
+ curLocation.setLocation(getCurrentEvent().getTimestampValue());
+ } else {
+ curLocation = NULL_LOCATION;
+ }
+ return ret;
}
/**
// The trace resource
private IResource fResource;
- /*
- * Since in TMF, "traces" can read events, this trace here will have its own
- * iterator. The user can instantiate extra iterator if they want to seek at
- * many places at the same time.
- */
- protected CtfIterator iterator;
-
/* Reference to the state system assigned to this trace */
protected IStateSystemQuerier ss = null;
* @throws TmfTraceException
* @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#initTrace(IResource, String, Class<CtfTmfEvent>)
*/
- @SuppressWarnings("unused")
@Override
public void initTrace(final IResource resource, final String path, final Class<CtfTmfEvent> eventType)
throws TmfTraceException {
*/
throw new TmfTraceException(e.getMessage());
}
- this.iterator = new CtfIterator(this, 0, 0);
+ CtfIterator iterator = new CtfIterator(this, 0, 0);
setStartTime(TmfTimestamp.BIG_BANG);
- if( !this.iterator.getLocation().equals(CtfIterator.nullLocation)) {
+ if( !iterator.getLocation().equals(CtfIterator.NULL_LOCATION)) {
setStartTime(iterator.getCurrentEvent().getTimestamp());
}
TmfSignalManager.register(this);
* @return boolean
* @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#validate(IProject, String)
*/
- @SuppressWarnings("unused")
@Override
public boolean validate(final IProject project, final String path) {
try {
}
/**
- * Method getCurrentLocation.
- * @return ITmfLocation<?>
+ * Method getCurrentLocation. This is not applicable in CTF
+ * @return null, since the trace has no knowledge of the current location
* @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getCurrentLocation()
*/
@Override
public ITmfLocation<?> getCurrentLocation() {
- return iterator.getLocation();
+ return null;
}
// ------------------------------------------------------------------------
if (currentLocation == null) {
currentLocation = new CtfLocation(0L);
}
- if( !iterator.getLocation().equals(CtfIterator.nullLocation)) {
- iterator.setLocation(currentLocation);
- }
- return iterator;
+ CtfIterator context = new CtfIterator(this);
+ context.setLocation(currentLocation);
+ context.setRank(ITmfContext.UNKNOWN_RANK);
+ return context;
}
/**
@Override
public double getLocationRatio(final ITmfLocation<?> location) {
final CtfLocation curLocation = (CtfLocation) location;
+ CtfIterator iterator = new CtfIterator(this);
iterator.seek(curLocation.getLocation());
return ((double) iterator.getCurrentEvent().getTimestampValue() - iterator
.getStartTime())
*/
@Override
public ITmfContext seekEvent(final ITmfTimestamp timestamp) {
- iterator.seek(timestamp.getValue());
- return iterator;
+ CtfIterator context = new CtfIterator(this);
+ context.seek(timestamp.getValue());
+ context.setRank(ITmfContext.UNKNOWN_RANK);
+ return context;
}
/**
*/
@Override
public ITmfContext seekEvent(final long rank) {
- iterator.setRank(rank);
- return iterator;
+ CtfIterator context = new CtfIterator(this);
+ context.seekRank(rank);
+ context.setRank(rank);
+ return context;
}
/**
*/
@Override
public ITmfContext seekEvent(final double ratio) {
- iterator.seek((long) (this.fNbEvents * ratio));
- return iterator;
+ CtfIterator context = new CtfIterator(this);
+ context.seek((long) (this.fNbEvents * ratio));
+ context.setRank(ITmfContext.UNKNOWN_RANK);
+ return context;
}
/**
* @return CtfTmfEvent
* @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#readNextEvent(ITmfContext)
*/
- @SuppressWarnings("unused")
@Override
public CtfTmfEvent readNextEvent(final ITmfContext context) {
- CtfTmfEvent event = iterator.getCurrentEvent();
- iterator.advance();
+ CtfTmfEvent event = null;
+ if (context instanceof CtfIterator) {
+ CtfIterator ctfIterator = (CtfIterator) context;
+ event = ctfIterator.getCurrentEvent();
+ ctfIterator.advance();
+ }
return event;
}
* sub-classes.
* @throws TmfTraceException
*/
- @SuppressWarnings({ "unused", "static-method" })
protected void buildStateSystem() throws TmfTraceException {
/*
* Nothing is done in the basic implementation, please specify