use of io.protostuff.Input in project java-chassis by ServiceComb.
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);
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 TestArgsNotWrapSchema method testReadObject.
@Test
public void testReadObject() {
boolean status = true;
Input input = null;
try {
Object object = argsNotWrapSchema.readObject(input);
Assert.assertNotNull(object);
// object is created but no values inside to assert
} catch (Exception e) {
status = false;
}
Assert.assertTrue(status);
}
use of io.protostuff.Input in project incubator-servicecomb-java-chassis by apache.
the class WrapSchema method readObject.
@SuppressWarnings("unchecked")
default <T> T readObject(Buffer buffer, ProtobufFeature protobufFeature) throws Exception {
if (buffer == null || buffer.length() == 0) {
// 空串时,protobuf至少为编码为1字节
return (T) readFromEmpty();
}
ByteBuffer nioBuffer = buffer.getByteBuf().nioBuffer();
Input input = new ByteBufferInput(nioBuffer, false);
ProtobufFeatureUtils.setProtobufFeature(protobufFeature);
try {
return (T) readObject(input);
} finally {
ProtobufFeatureUtils.removeProtobufFeature();
}
}
use of io.protostuff.Input in project java-chassis by ServiceComb.
the class WrapSchema method readObject.
@SuppressWarnings("unchecked")
default default <T> T readObject(Buffer buffer) throws Exception {
if (buffer == null || buffer.length() == 0) {
// 空串时,protobuf至少为编码为1字节
return (T) readFromEmpty();
}
ByteBuffer nioBuffer = buffer.getByteBuf().nioBuffer();
Input input = new ByteBufferInput(nioBuffer, false);
return (T) readObject(input);
}
use of io.protostuff.Input in project java-chassis by ServiceComb.
the class TestArgsNotWrapSchema method testReadObject.
@Test
public void testReadObject() {
boolean status = true;
Input input = null;
try {
Object object = argsNotWrapSchema.readObject(input);
Assert.assertNotNull(object);
// object is created but no values inside to assert
} catch (Exception e) {
status = false;
}
Assert.assertTrue(status);
}
Aggregations