use of io.protostuff.LinkedBuffer in project java-chassis by ServiceComb.
the class HighwayClient method createLogin.
@Override
public TcpOutputStream createLogin() {
try {
LinkedBuffer linkedBuffer = LinkedBuffer.allocate();
ProtobufOutput output = new ProtobufOutput(linkedBuffer);
RequestHeader header = new RequestHeader();
header.setMsgType(MsgType.LOGIN);
header.writeObject(output);
LoginRequest login = new LoginRequest();
login.setProtocol(HighwayTransport.NAME);
login.writeObject(output);
HighwayOutputStream os = new HighwayOutputStream();
os.write(header, LoginRequest.getLoginRequestSchema(), login);
return os;
} catch (Throwable e) {
throw new Error("impossible.", e);
}
}
use of io.protostuff.LinkedBuffer in project java-chassis by ServiceComb.
the class TestArgsNotWrapSchema method testWriteObjectToSchema.
@Test
public void testWriteObjectToSchema() {
boolean status = true;
LinkedBuffer linkedBuffer = LinkedBuffer.allocate();
ProtobufOutput output = new ProtobufOutput(linkedBuffer);
String[] stringArray = new String[1];
stringArray[0] = "abc";
try {
argsNotWrapSchema.writeObject(output, stringArray);
} catch (Exception e) {
status = false;
}
Assert.assertTrue(status);
}
use of io.protostuff.LinkedBuffer in project java-chassis by ServiceComb.
the class TestArgsNotWrapSchema method testWriteObject.
@Test
public void testWriteObject() {
boolean status = true;
LinkedBuffer linkedBuffer = LinkedBuffer.allocate();
ProtobufOutput output = new ProtobufOutput(linkedBuffer);
String[] stringArray = new String[1];
try {
argsNotWrapSchema.writeObject(output, stringArray);
} catch (Exception e) {
status = false;
}
Assert.assertTrue(status);
}
use of io.protostuff.LinkedBuffer in project java-chassis by ServiceComb.
the class TestArgsWrapSchema method testWriteObject.
@Test
public void testWriteObject() {
boolean status = true;
LinkedBuffer linkedBuffer = LinkedBuffer.allocate();
ProtobufOutput output = new ProtobufOutput(linkedBuffer);
String[] stringArray = new String[1];
stringArray[0] = "abc";
MultiWrapper multiWrapper = Mockito.mock(MultiWrapper.class);
Mockito.when(schema.newMessage()).thenReturn(multiWrapper);
try {
argsWrapSchema.writeObject(output, stringArray);
} catch (IOException e) {
status = true;
}
Assert.assertTrue(status);
}
use of io.protostuff.LinkedBuffer in project java-chassis by ServiceComb.
the class TestProtobufSchemaUtils method toByteArray.
private byte[] toByteArray(WrapSchema schema, Object value) throws Exception {
LinkedBuffer linkedBuffer = LinkedBuffer.allocate();
ProtobufOutput output = new ProtobufOutput(linkedBuffer);
schema.writeObject(output, value);
return output.toByteArray();
}
Aggregations