Search in sources :

Example 11 with RequestHeader

use of org.apache.servicecomb.transport.highway.message.RequestHeader in project java-chassis by ServiceComb.

the class TestHighwayCodec method test_decode_request_successful_and_not_copy_header.

@Test
public void test_decode_request_successful_and_not_copy_header(@Mocked Endpoint endpoint) throws Exception {
    // test decode request not thrown exception and not copy header
    // header should copied before invocation start.
    commonMock();
    Invocation invocation = new Invocation(endpoint, operationMeta, null);
    invocation.addContext("X-B3-traceId", "test1");
    Assert.assertEquals("test1", invocation.getContext("X-B3-traceId"));
    RequestHeader headers = new RequestHeader();
    Map<String, String> context = new HashMap<>();
    headers.setContext(context);
    HighwayCodec.decodeRequest(invocation, headers, operationProtobuf, bodyBuffer);
    Assert.assertEquals("test1", invocation.getContext("X-B3-traceId"));
    context.put("X-B3-traceId", "test2");
    HighwayCodec.decodeRequest(invocation, headers, operationProtobuf, bodyBuffer);
    Assert.assertEquals("test1", invocation.getContext("X-B3-traceId"));
}
Also used : Invocation(org.apache.servicecomb.core.Invocation) HashMap(java.util.HashMap) RequestHeader(org.apache.servicecomb.transport.highway.message.RequestHeader) Test(org.junit.Test)

Aggregations

RequestHeader (org.apache.servicecomb.transport.highway.message.RequestHeader)11 Test (org.junit.Test)6 Buffer (io.vertx.core.buffer.Buffer)3 Holder (javax.xml.ws.Holder)3 MockUp (mockit.MockUp)3 LoginRequest (org.apache.servicecomb.transport.highway.message.LoginRequest)3 LinkedBuffer (io.protostuff.LinkedBuffer)2 NetSocket (io.vertx.core.net.NetSocket)2 Expectations (mockit.Expectations)2 ByteBuf (io.netty.buffer.ByteBuf)1 Input (io.protostuff.Input)1 SocketAddressImpl (io.vertx.core.net.impl.SocketAddressImpl)1 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 HashMap (java.util.HashMap)1 Endpoint (org.apache.servicecomb.core.Endpoint)1 Invocation (org.apache.servicecomb.core.Invocation)1 OperationMeta (org.apache.servicecomb.core.definition.OperationMeta)1 SchemaMeta (org.apache.servicecomb.core.definition.SchemaMeta)1 InvocationFinishEvent (org.apache.servicecomb.core.event.InvocationFinishEvent)1