use of io.protostuff.Input in project java-chassis by ServiceComb.
the class TestArgsWrapSchema method testReadObject.
@Test
public void testReadObject() {
boolean status = true;
Input input = null;
String[] stringArray = new String[1];
stringArray[0] = "abc";
MultiWrapper multiWrapper = Mockito.mock(MultiWrapper.class);
Mockito.when(schema.newMessage()).thenReturn(multiWrapper);
try {
Object object = argsWrapSchema.readObject(input);
Assert.assertNull(object);
} catch (IOException e) {
status = true;
}
Assert.assertTrue(status);
}
use of io.protostuff.Input in project incubator-servicecomb-java-chassis by apache.
the class TestHighwayCodec method testReadRequestHeader.
@Test
public void testReadRequestHeader() {
boolean status = true;
try {
new MockUp<NotWrapSchema>() {
@Mock
public Object readObject(Input input) throws IOException {
return new RequestHeader();
}
};
bodyBuffer = Buffer.buffer("\"abc\"");
RequestHeader requestHeader = HighwayCodec.readRequestHeader(bodyBuffer, null);
Assert.assertNotNull(requestHeader);
Assert.assertEquals(0, requestHeader.getFlags());
} catch (Exception e) {
status = false;
}
Assert.assertTrue(status);
}
use of io.protostuff.Input in project incubator-servicecomb-java-chassis by apache.
the class TestProtobufSchemaUtils method object.
@Test
public void object() throws Exception {
WrapSchema schema = ProtobufSchemaUtils.getOrCreateSchema(Object.class);
LinkedBuffer linkedBuf = LinkedBuffer.allocate();
ProtobufOutput output = new ProtobufOutput(linkedBuf);
schema.writeObject(output, 1);
Input input = new ByteArrayInput(output.toByteArray(), false);
Object result = schema.readObject(input);
Assert.assertEquals(1, result);
Assert.assertThat(result, Matchers.instanceOf(Integer.class));
}
use of io.protostuff.Input in project incubator-servicecomb-java-chassis by apache.
the class TestArgsWrapSchema method testReadObject.
@Test
public void testReadObject() {
boolean status = true;
Input input = null;
String[] stringArray = new String[1];
stringArray[0] = "abc";
MultiWrapper multiWrapper = Mockito.mock(MultiWrapper.class);
Mockito.when(schema.newMessage()).thenReturn(multiWrapper);
try {
Object object = argsWrapSchema.readObject(input);
Assert.assertNull(object);
} catch (IOException e) {
status = true;
}
Assert.assertTrue(status);
}
use of io.protostuff.Input in project java-chassis by ServiceComb.
the class Protostuff method deserialize.
@Override
public Object deserialize(byte[] bytes) throws IOException {
Input input = new ByteArrayInput(bytes, false);
Root result = new Root();
rootSchema.mergeFrom(input, result);
return result;
}
Aggregations