Search in sources :

Example 6 with RequestHeader

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

the class HighwayCodec method encodeRequest.

public static TcpOutputStream encodeRequest(Invocation invocation, OperationProtobuf operationProtobuf) throws Exception {
    // 写header
    RequestHeader header = new RequestHeader();
    header.setMsgType(MsgType.REQUEST);
    header.setFlags(0);
    header.setDestMicroservice(invocation.getMicroserviceName());
    header.setSchemaId(invocation.getSchemaId());
    header.setOperationName(invocation.getOperationName());
    header.setContext(invocation.getContext());
    HighwayOutputStream os = new HighwayOutputStream();
    os.write(header, operationProtobuf.getRequestSchema(), invocation.getArgs());
    return os;
}
Also used : RequestHeader(io.servicecomb.transport.highway.message.RequestHeader)

Example 7 with RequestHeader

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

the class TestHighwayServerConnection method init.

@Before
public void init() {
    new Expectations() {

        {
            netSocket.remoteAddress();
            result = new SocketAddressImpl(new InetSocketAddress("127.0.0.1", 80));
        }
    };
    connection = new HighwayServerConnection();
    connection.init(netSocket);
    header = new RequestHeader();
}
Also used : Expectations(mockit.Expectations) InetSocketAddress(java.net.InetSocketAddress) RequestHeader(io.servicecomb.transport.highway.message.RequestHeader) SocketAddressImpl(io.vertx.core.net.impl.SocketAddressImpl) Before(org.junit.Before)

Example 8 with RequestHeader

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

the class TestHighwayServerConnection method testRequestNormal.

@Test
public void testRequestNormal() throws Exception {
    header.setMsgType(MsgType.REQUEST);
    Buffer headerBuffer = createBuffer(requestHeaderSchema, header);
    Buffer bodyBuffer = Buffer.buffer();
    Holder<Boolean> holder = new Holder<>();
    new MockUp<HighwayServerInvoke>() {

        @Mock
        public boolean init(NetSocket netSocket, long msgId, RequestHeader header, Buffer bodyBuffer) {
            return true;
        }

        @Mock
        public void execute() {
            holder.value = true;
        }
    };
    connection.handle(0, headerBuffer, bodyBuffer);
    Assert.assertEquals(null, connection.getProtocol());
    Assert.assertEquals(null, connection.getZipName());
    Assert.assertEquals(true, holder.value);
}
Also used : LinkedBuffer(io.protostuff.LinkedBuffer) Buffer(io.vertx.core.buffer.Buffer) NetSocket(io.vertx.core.net.NetSocket) Holder(javax.xml.ws.Holder) RequestHeader(io.servicecomb.transport.highway.message.RequestHeader) MockUp(mockit.MockUp) Test(org.junit.Test)

Aggregations

RequestHeader (io.servicecomb.transport.highway.message.RequestHeader)8 Test (org.junit.Test)5 LinkedBuffer (io.protostuff.LinkedBuffer)3 Buffer (io.vertx.core.buffer.Buffer)3 MockUp (mockit.MockUp)3 LoginRequest (io.servicecomb.transport.highway.message.LoginRequest)2 NetSocket (io.vertx.core.net.NetSocket)2 Holder (javax.xml.ws.Holder)2 ByteBuf (io.netty.buffer.ByteBuf)1 Input (io.protostuff.Input)1 ProtobufOutput (io.protostuff.ProtobufOutput)1 Endpoint (io.servicecomb.core.Endpoint)1 OperationMeta (io.servicecomb.core.definition.OperationMeta)1 SchemaMeta (io.servicecomb.core.definition.SchemaMeta)1 ReactiveExecutor (io.servicecomb.core.executor.ReactiveExecutor)1 TcpOutputStream (io.servicecomb.foundation.vertx.tcp.TcpOutputStream)1 SocketAddressImpl (io.vertx.core.net.impl.SocketAddressImpl)1 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 Expectations (mockit.Expectations)1