Search in sources :

Example 1 with Type

use of io.opencensus.trace.MessageEvent.Type in project instrumentation-java by census-instrumentation.

the class AbstractHttpHandlerTest method handleMessageSent.

@Test
public void handleMessageSent() {
    Type type = Type.SENT;
    long uncompressed = 456L;
    HttpRequestContext context = new HttpRequestContext(fakeSpan, tagContext);
    handler.handleMessageSent(context, uncompressed);
    verify(fakeSpan).addMessageEvent(captor.capture());
    MessageEvent messageEvent = captor.getValue();
    assertThat(messageEvent.getType()).isEqualTo(type);
    assertThat(messageEvent.getMessageId()).isEqualTo(1L);
    assertThat(messageEvent.getUncompressedMessageSize()).isEqualTo(uncompressed);
    assertThat(messageEvent.getCompressedMessageSize()).isEqualTo(0);
}
Also used : Type(io.opencensus.trace.MessageEvent.Type) MessageEvent(io.opencensus.trace.MessageEvent) Test(org.junit.Test)

Example 2 with Type

use of io.opencensus.trace.MessageEvent.Type in project instrumentation-java by census-instrumentation.

the class AbstractHttpHandlerTest method handleMessageReceived.

@Test
public void handleMessageReceived() {
    Type type = Type.RECEIVED;
    long uncompressed = 456L;
    HttpRequestContext context = new HttpRequestContext(fakeSpan, tagContext);
    handler.handleMessageReceived(context, uncompressed);
    verify(fakeSpan).addMessageEvent(captor.capture());
    MessageEvent messageEvent = captor.getValue();
    assertThat(messageEvent.getType()).isEqualTo(type);
    assertThat(messageEvent.getMessageId()).isEqualTo(1L);
    assertThat(messageEvent.getUncompressedMessageSize()).isEqualTo(uncompressed);
    assertThat(messageEvent.getCompressedMessageSize()).isEqualTo(0);
}
Also used : Type(io.opencensus.trace.MessageEvent.Type) MessageEvent(io.opencensus.trace.MessageEvent) Test(org.junit.Test)

Aggregations

MessageEvent (io.opencensus.trace.MessageEvent)2 Type (io.opencensus.trace.MessageEvent.Type)2 Test (org.junit.Test)2