use of io.protostuff.ProtobufOutput 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.ProtobufOutput 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.ProtobufOutput 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();
}
use of io.protostuff.ProtobufOutput in project incubator-servicecomb-java-chassis by apache.
the class TestHighwayServerConnection method createBuffer.
protected Buffer createBuffer(WrapSchema schema, Object value) throws Exception {
Buffer headerBuffer;
LinkedBuffer linkedBuffer = LinkedBuffer.allocate();
ProtobufOutput output = new ProtobufOutput(linkedBuffer);
schema.writeObject(output, value);
try (BufferOutputStream os = new BufferOutputStream()) {
LinkedBuffer.writeTo(os, linkedBuffer);
headerBuffer = os.getBuffer();
}
return headerBuffer;
}
use of io.protostuff.ProtobufOutput in project incubator-servicecomb-java-chassis by apache.
the class HighwayOutputStream method write.
public void write(WrapSchema headerSchema, Object header, WrapSchema bodySchema, Object body) throws Exception {
// 写protobuf数据
LinkedBuffer linkedBuffer = LinkedBuffer.allocate();
ProtobufOutput output = new ProtobufOutput(linkedBuffer);
// 写header
if (headerSchema != null) {
headerSchema.writeObject(output, header, protobufFeature);
}
int headerSize = output.getSize();
// void时bodySchema为null
if (bodySchema != null) {
bodySchema.writeObject(output, body, protobufFeature);
}
writeLength(output.getSize(), headerSize);
LinkedBuffer.writeTo(this, linkedBuffer);
}
Aggregations