Search in sources :

Example 81 with ITmfEvent

use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.

the class TmfEventTest method testTmfEventCopy.

@Test
public void testTmfEventCopy() {
    final ITmfEvent event = new TmfEvent(fEvent1);
    assertNotNull("getTrace", event.getTrace());
    assertEquals("getRank", 0, event.getRank());
    assertEquals("getTimestamp", fTimestamp1, event.getTimestamp());
    assertEquals("getType", fType, event.getType());
    assertEquals("getContent", fContent1, event.getContent());
}
Also used : TmfEvent(org.eclipse.tracecompass.tmf.core.event.TmfEvent) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) Test(org.junit.Test)

Example 82 with ITmfEvent

use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.

the class TmfEventTest method testNoRankConstructor.

@Test
public void testNoRankConstructor() {
    final ITmfEvent event = new TmfEvent(fTrace, ITmfContext.UNKNOWN_RANK, fTimestamp1, fType, fContent1);
    assertNotNull("getTrace", event.getTrace());
    assertEquals("getRank", ITmfContext.UNKNOWN_RANK, event.getRank());
    assertEquals("getTimestamp", fTimestamp1, event.getTimestamp());
    assertEquals("getType", fType, event.getType());
    assertEquals("getContent", fContent1, event.getContent());
}
Also used : TmfEvent(org.eclipse.tracecompass.tmf.core.event.TmfEvent) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) Test(org.junit.Test)

Example 83 with ITmfEvent

use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.

the class TmfEventTest method testDefaultConstructor.

// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
@Test
public void testDefaultConstructor() {
    final ITmfEvent event = new TmfEvent(fTrace, ITmfContext.UNKNOWN_RANK, null, null, null);
    assertNotNull("getTrace", event.getTrace());
    assertEquals("getRank", ITmfContext.UNKNOWN_RANK, event.getRank());
    assertEquals("getTimestamp", TmfTimestamp.ZERO, event.getTimestamp());
    assertNull("getType", event.getType());
    assertNull("getContent", event.getContent());
}
Also used : TmfEvent(org.eclipse.tracecompass.tmf.core.event.TmfEvent) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) Test(org.junit.Test)

Example 84 with ITmfEvent

use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.

the class TmfEventTest method testNonEqualTraces.

@Test
public void testNonEqualTraces() {
    final ITmfTrace trace1 = fTrace;
    final ITmfTrace trace2 = STUB_TRACE.getTrace();
    final ITmfEvent event1 = new TmfEvent(trace1, 0, fTimestamp1, fType, fContent1);
    ITmfEvent event2 = new TmfEvent(trace1, 0, fTimestamp1, fType, fContent1);
    assertTrue("equals", event1.equals(event2));
    assertTrue("equals", event2.equals(event1));
    event2 = new TmfEvent(trace2, 0, fTimestamp1, fType, fContent1);
    assertFalse("equals", event1.equals(event2));
    assertFalse("equals", event2.equals(event1));
    trace2.dispose();
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfEvent(org.eclipse.tracecompass.tmf.core.event.TmfEvent) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) Test(org.junit.Test)

Example 85 with ITmfEvent

use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.

the class TmfUml2SDTestTrace method parseEvent.

@Override
public ITmfEvent parseEvent(ITmfContext context) {
    if (!(fEventStream instanceof TmfTraceStub)) {
        return null;
    }
    // Highly inefficient...
    RandomAccessFile stream = ((TmfTraceStub) fEventStream).getStream();
    // String name = eventStream.getName();
    // name = name.substring(name.lastIndexOf('/') + 1);
    long location = 0;
    if (context != null) {
        location = (Long) context.getLocation().getLocationInfo();
    }
    try {
        stream.seek(location);
        long ts = stream.readLong();
        stream.readUTF();
        /* Previously source, now unused */
        String type = stream.readUTF();
        stream.readUTF();
        /* Previously reference, now unused */
        String sender = stream.readUTF();
        String receiver = stream.readUTF();
        String signal = stream.readUTF();
        String[] labels = { "sender", "receiver", "signal" };
        TmfEventType tmfEventType = new TmfEventType(type, TmfEventField.makeRoot(labels));
        String content = "[";
        content += sender;
        content += "," + receiver;
        content += "," + signal;
        content += "]";
        // Pre-parse the content
        TmfEventField[] fields = new TmfEventField[3];
        fields[0] = new TmfEventField("sender", sender, null);
        fields[1] = new TmfEventField("receiver", receiver, null);
        fields[2] = new TmfEventField("signal", signal, null);
        ITmfEventField tmfContent = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, content, fields);
        ITmfEvent tmfEvent = new TmfEvent(fEventStream, ITmfContext.UNKNOWN_RANK, TmfTimestamp.create(ts, -9), tmfEventType, tmfContent);
        return tmfEvent;
    } catch (final EOFException e) {
    } catch (final IOException e) {
    }
    return null;
}
Also used : ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) IOException(java.io.IOException) TmfTraceStub(org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub) ITmfEventField(org.eclipse.tracecompass.tmf.core.event.ITmfEventField) RandomAccessFile(java.io.RandomAccessFile) ITmfEventField(org.eclipse.tracecompass.tmf.core.event.ITmfEventField) TmfEventField(org.eclipse.tracecompass.tmf.core.event.TmfEventField) TmfEvent(org.eclipse.tracecompass.tmf.core.event.TmfEvent) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) TmfEventType(org.eclipse.tracecompass.tmf.core.event.TmfEventType) EOFException(java.io.EOFException)

Aggregations

ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)182 Test (org.junit.Test)127 ITmfContext (org.eclipse.tracecompass.tmf.core.trace.ITmfContext)112 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)40 TmfEventRequest (org.eclipse.tracecompass.tmf.core.request.TmfEventRequest)30 AnalysisManagerTest (org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest)27 ITmfLocation (org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation)25 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)24 NonNull (org.eclipse.jdt.annotation.NonNull)20 TmfEvent (org.eclipse.tracecompass.tmf.core.event.TmfEvent)17 ITmfEventRequest (org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest)16 Vector (java.util.Vector)15 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)15 Predicate (java.util.function.Predicate)14 TmfTraceUtils (org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils)14 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)13 CtfTestTrace (org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace)13 CtfTmfTestTraceUtils (org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils)13 Assert.assertEquals (org.junit.Assert.assertEquals)13 Assert.assertNotNull (org.junit.Assert.assertNotNull)13