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;
}
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();
}
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);
}
Aggregations