* int intType = 1; long longType = 2; ustring stringType = 3;
* vector<ustring> vectorOfStrings = 4; }
*
* }
* */
UnitTestStruct1 inputStruct = new UnitTestStruct1();
UnitTestStruct1 outputStruct = new UnitTestStruct1();
inputStruct.setIntType(10);
inputStruct.setLongType(20);
inputStruct.setStringType("one");
inputStruct.setFieldDirty(UnitTestStruct1.Field_VECTOROFSTRINGS);
inputStruct.getVectorOfStrings().add(new TextBytes("one"));
inputStruct.getVectorOfStrings().add(new TextBytes("two"));
inputStruct.getVectorOfStrings().add(new TextBytes("three"));
OutgoingMessageContext<UnitTestStruct1, UnitTestStruct1> request = new OutgoingMessageContext<UnitTestStruct1, UnitTestStruct1>(
"testService", "testMethod", inputStruct, outputStruct, null);
request.setRequestId(10);
encoder.encodeRequest(request);
// stream the data in one byte at a time
while (output.available() != 0) {
ByteBuffer buffer = output.read();
input.getWriteBuf().put(buffer.get());
input.flush();
if (buffer.remaining() != 0) {
output.putBack(buffer);
}
// validate that the decoder doesn't return the frame until the
// appropriate time
if (output.available() != 0)
assertTrue(decoder.getNextRequestFrame() == null);
}
RPCFrame.IncomingFrame incomingFrame = decoder.getNextRequestFrame();
// at this point the frame should be available ...
assertTrue(incomingFrame != null);
// check frame header values ...
assertTrue(incomingFrame._service.equals("testService"));
assertTrue(incomingFrame._method.equals("testMethod"));
assertTrue(incomingFrame._requestId == 10);
assertTrue(incomingFrame._type == RPCFrame.MSG_TYPE.REQUEST.ordinal());
// deserialize the input struct
outputStruct.deserialize(new DataInputStream(incomingFrame._payload),
new BinaryProtocol());
// validate values of deserialized struct against original (input) struct
assertTrue(outputStruct.getIntType() == inputStruct.getIntType());
assertTrue(outputStruct.getLongType() == inputStruct.getLongType());
assertTrue(outputStruct.getStringType().equals(inputStruct.getStringType()));
assertTrue(outputStruct.getVectorOfStrings().size() == inputStruct
.getVectorOfStrings().size());
assertTrue(outputStruct.getVectorOfStrings().get(0).equals(
inputStruct.getVectorOfStrings().get(0)));
assertTrue(outputStruct.getVectorOfStrings().get(1).equals(
inputStruct.getVectorOfStrings().get(1)));
assertTrue(outputStruct.getVectorOfStrings().get(2).equals(
inputStruct.getVectorOfStrings().get(2)));
}