Java Code Examples for com.linecorp.armeria.common.grpc.GrpcSerializationFormats#PROTO

The following examples show how to use com.linecorp.armeria.common.grpc.GrpcSerializationFormats#PROTO . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArmeriaServerCallTest.java    From armeria with Apache License 2.0 6 votes vote down vote up
@Test
public void messageRead_wrappedByteBuf() {
    tearDown();

    call = new ArmeriaServerCall<>(
            HttpHeaders.of(),
            TestServiceGrpc.getUnaryCallMethod(),
            CompressorRegistry.getDefaultInstance(),
            DecompressorRegistry.getDefaultInstance(),
            res,
            MAX_MESSAGE_BYTES,
            MAX_MESSAGE_BYTES,
            ctx,
            GrpcSerializationFormats.PROTO,
            new DefaultJsonMarshaller(MessageMarshaller.builder().build()),
            true,
            false,
            ResponseHeaders.builder(HttpStatus.OK)
                           .contentType(GrpcSerializationFormats.PROTO.mediaType())
                           .build());

    final ByteBuf buf = GrpcTestUtil.requestByteBuf();
    call.messageRead(new DeframedMessage(buf, 0));

    verify(buffersAttr).put(any(), same(buf));
}
 
Example 2
Source File: GrpcMessageMarshallerTest.java    From armeria with Apache License 2.0 6 votes vote down vote up
@Test
public void deserializeRequest_wrappedByteBuf() throws Exception {
    marshaller = new GrpcMessageMarshaller<>(
            ByteBufAllocator.DEFAULT,
            GrpcSerializationFormats.PROTO,
            TestServiceGrpc.getUnaryCallMethod(),
            DEFAULT_JSON_MARSHALLER,
            true);
    final ByteBuf buf = ByteBufAllocator.DEFAULT.buffer(GrpcTestUtil.REQUEST_MESSAGE.getSerializedSize());
    assertThat(buf.refCnt()).isEqualTo(1);
    buf.writeBytes(GrpcTestUtil.REQUEST_MESSAGE.toByteArray());
    final SimpleRequest request = marshaller.deserializeRequest(new DeframedMessage(buf, 0));
    assertThat(request).isEqualTo(GrpcTestUtil.REQUEST_MESSAGE);
    assertThat(buf.refCnt()).isEqualTo(1);
    buf.release();
}
 
Example 3
Source File: GrpcMessageMarshallerTest.java    From armeria with Apache License 2.0 6 votes vote down vote up
@Test
public void deserializeResponse_wrappedByteBuf() throws Exception {
    marshaller = new GrpcMessageMarshaller<>(
            ByteBufAllocator.DEFAULT,
            GrpcSerializationFormats.PROTO,
            TestServiceGrpc.getUnaryCallMethod(),
            DEFAULT_JSON_MARSHALLER,
            true);
    final ByteBuf buf = ByteBufAllocator.DEFAULT.buffer(GrpcTestUtil.RESPONSE_MESSAGE.getSerializedSize());
    assertThat(buf.refCnt()).isEqualTo(1);
    buf.writeBytes(GrpcTestUtil.RESPONSE_MESSAGE.toByteArray());
    final SimpleResponse response = marshaller.deserializeResponse(new DeframedMessage(buf, 0));
    assertThat(response).isEqualTo(GrpcTestUtil.RESPONSE_MESSAGE);
    assertThat(buf.refCnt()).isEqualTo(1);
    buf.release();
}
 
Example 4
Source File: ArmeriaServerCallTest.java    From armeria with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    completionFuture = new CompletableFuture<>();
    when(res.whenComplete()).thenReturn(completionFuture);

    ctx = ServiceRequestContext.builder(HttpRequest.of(HttpMethod.POST, "/"))
                               .eventLoop(eventLoop.get())
                               .build();

    call = new ArmeriaServerCall<>(
            HttpHeaders.of(),
            TestServiceGrpc.getUnaryCallMethod(),
            CompressorRegistry.getDefaultInstance(),
            DecompressorRegistry.getDefaultInstance(),
            res,
            MAX_MESSAGE_BYTES,
            MAX_MESSAGE_BYTES,
            ctx,
            GrpcSerializationFormats.PROTO,
            new DefaultJsonMarshaller(MessageMarshaller.builder().build()),
            false,
            false,
            ResponseHeaders.builder(HttpStatus.OK)
                           .contentType(GrpcSerializationFormats.PROTO.mediaType())
                           .build());
    call.setListener(listener);
    call.messageReader().onSubscribe(subscription);

    ctx.setAttr(GrpcUnsafeBufferUtil.BUFFERS, buffersAttr);
}
 
Example 5
Source File: GrpcMessageMarshallerTest.java    From armeria with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {

    marshaller = new GrpcMessageMarshaller<>(
            ByteBufAllocator.DEFAULT,
            GrpcSerializationFormats.PROTO,
            TestServiceGrpc.getUnaryCallMethod(),
            DEFAULT_JSON_MARSHALLER,
            false);
}