use of org.gridkit.jvmtool.event.ErrorEvent in project jvm-tools by aragozin.
the class ThreadEventReaderTest method read_dump_v2.
@Test
public void read_dump_v2() throws FileNotFoundException, IOException {
EventReader<Event> reader = ThreadEventCodec.createEventReader(new FileInputStream("src/test/resources/dump_v2.std"));
int n = 0;
for (Event e : reader) {
if (e instanceof ErrorEvent) {
fail("Error", ((ErrorEvent) e).exception());
}
// System.out.println(((MultiCounterEvent)e).counters());
++n;
}
System.out.println("Read " + n + " traces from file");
}
use of org.gridkit.jvmtool.event.ErrorEvent in project jvm-tools by aragozin.
the class EventDecoratorTest method verify_error_event.
@Test
public void verify_error_event() {
SimpleErrorEvent ee = new SimpleErrorEvent(new Exception("Boom"));
EventDecorator deco = new EventDecorator();
ErrorEvent c = deco.wrap(ee);
assertThat(c).is(eventEquals(ee));
}
use of org.gridkit.jvmtool.event.ErrorEvent in project jvm-tools by aragozin.
the class EventEqualToCondition method matches.
@Override
public boolean matches(Event value) {
if (expected instanceof ErrorEvent) {
if (value instanceof ErrorEvent) {
assertThat(((ErrorEvent) value).exception().toString()).isEqualTo(((ErrorEvent) expected).exception().toString());
} else {
fail("Event " + value + " should be ErrorEvent");
}
} else {
if (value instanceof ErrorEvent) {
fail("Event " + value + " should not be ErrorEvent");
}
}
if (expected instanceof TimestampedEvent) {
if (value instanceof TimestampedEvent) {
assertThat(((TimestampedEvent) value).timestamp()).isEqualTo(((TimestampedEvent) expected).timestamp());
} else {
fail("Event " + value + " should be TimestampedEvent");
}
} else {
if (value instanceof TimestampedEvent) {
fail("Event " + value + " should not be TimestampedEvent");
}
}
if (expected instanceof TaggedEvent) {
if (value instanceof TaggedEvent) {
assertThat(((TaggedEvent) value).tags().toString()).isEqualTo(((TaggedEvent) expected).tags().toString());
} else {
fail("Event " + value + " should be TaggedEvent");
}
} else {
if (value instanceof TaggedEvent) {
fail("Event " + value + " should not be TaggedEvent");
}
}
if (expected instanceof MultiCounterEvent) {
if (value instanceof MultiCounterEvent) {
assertThat(countersToString(((MultiCounterEvent) value).counters())).isEqualTo(countersToString(((MultiCounterEvent) expected).counters()));
} else {
fail("Event " + value + " should be MultiCounterEvent");
}
} else {
if (value instanceof MultiCounterEvent) {
fail("Event " + value + " should not be MultiCounterEvent");
}
}
if (expected instanceof ThreadSnapshotEvent) {
if (value instanceof ThreadSnapshotEvent) {
assertThat(((ThreadSnapshotEvent) value).threadId()).isEqualTo(((ThreadSnapshotEvent) expected).threadId());
assertThat(((ThreadSnapshotEvent) value).threadName()).isEqualTo(((ThreadSnapshotEvent) expected).threadName());
assertThat(((ThreadSnapshotEvent) value).threadState()).isEqualTo(((ThreadSnapshotEvent) expected).threadState());
StackFrameList etrace = ((ThreadSnapshotEvent) expected).stackTrace();
StackFrameList atrace = ((ThreadSnapshotEvent) value).stackTrace();
if (etrace == null) {
assertThat(atrace).isNull();
} else if (atrace == null) {
fail("Stack trace should not be null");
}
if (etrace != null) {
assertThat(atrace.toArray()).containsExactly(etrace.toArray());
}
} else {
fail("Event " + value + " should be ThreadSnapshotEvent");
}
} else {
if (value instanceof ThreadSnapshotEvent) {
fail("Event " + value + " should not be ThreadSnapshotEvent");
}
}
return true;
}
use of org.gridkit.jvmtool.event.ErrorEvent in project jvm-tools by aragozin.
the class EventSeqEqualToCondition method matches.
private boolean matches(Event expected, Event value) {
if (expected instanceof ErrorEvent) {
if (value instanceof ErrorEvent) {
assertThat(((ErrorEvent) value).exception().toString()).isEqualTo(((ErrorEvent) expected).exception().toString());
} else {
fail("Event " + value + " should be ErrorEvent");
}
} else {
if (value instanceof ErrorEvent) {
fail("Event " + value + " should not be ErrorEvent", ((ErrorEvent) value).exception());
}
}
if (expected instanceof TimestampedEvent) {
if (value instanceof TimestampedEvent) {
assertThat(((TimestampedEvent) value).timestamp()).isEqualTo(((TimestampedEvent) expected).timestamp());
} else {
fail("Event " + value + " should be TimestampedEvent");
}
} else {
if (value instanceof TimestampedEvent) {
fail("Event " + value + " should not be TimestampedEvent");
}
}
if (expected instanceof TaggedEvent) {
if (value instanceof TaggedEvent) {
assertThat(((TaggedEvent) value).tags().toString()).isEqualTo(((TaggedEvent) expected).tags().toString());
} else {
fail("Event " + value + " should be TaggedEvent");
}
} else {
if (value instanceof TaggedEvent) {
fail("Event " + value + " should not be TaggedEvent");
}
}
if (expected instanceof MultiCounterEvent) {
if (value instanceof MultiCounterEvent) {
assertThat(countersToString(((MultiCounterEvent) value).counters())).isEqualTo(countersToString(((MultiCounterEvent) expected).counters()));
} else {
fail("Event " + value + " should be MultiCounterEvent");
}
} else {
if (value instanceof MultiCounterEvent) {
fail("Event " + value + " should not be MultiCounterEvent");
}
}
if (expected instanceof ThreadSnapshotEvent) {
if (value instanceof ThreadSnapshotEvent) {
assertThat(((ThreadSnapshotEvent) value).threadId()).isEqualTo(((ThreadSnapshotEvent) expected).threadId());
assertThat(((ThreadSnapshotEvent) value).threadName()).isEqualTo(((ThreadSnapshotEvent) expected).threadName());
assertThat(((ThreadSnapshotEvent) value).threadState()).isEqualTo(((ThreadSnapshotEvent) expected).threadState());
StackFrameList etrace = ((ThreadSnapshotEvent) expected).stackTrace();
StackFrameList atrace = ((ThreadSnapshotEvent) value).stackTrace();
if (etrace == null) {
assertThat(atrace).isNull();
} else if (atrace == null) {
fail("Stack trace should not be null");
}
if (etrace != null) {
assertThat(atrace.toArray()).containsExactly(etrace.toArray());
}
} else {
fail("Event " + value + " should be ThreadSnapshotEvent");
}
} else {
if (value instanceof ThreadSnapshotEvent) {
fail("Event " + value + " should not be ThreadSnapshotEvent");
}
}
return true;
}
use of org.gridkit.jvmtool.event.ErrorEvent in project jvm-tools by aragozin.
the class ThreadEventReaderTest method read_dump_v1.
@Test
public void read_dump_v1() throws FileNotFoundException, IOException {
EventReader<Event> reader = ThreadEventCodec.createEventReader(new FileInputStream("src/test/resources/dump_v1.std"));
int n = 0;
for (Event e : reader) {
if (e instanceof ErrorEvent) {
fail("Error", ((ErrorEvent) e).exception());
}
++n;
}
System.out.println("Read " + n + " traces from file");
}
Aggregations