I want to dump some requests (of type javax.servlet.http.HttpServletRequest
) into a file and then later replay them from the file, so that I can test future cha
In my particular case, I eventually solved the problem by using a CodedOutputStream
to write the com.google.protobuf.GeneratedMessage
(foo
below):
ByteArrayOutputStream bos = new ByteArrayOutputStream();
CodedOutputStream cos = CodedOutputStream.newInstance(bos);
foo.writeTo(cos);
This can be read in using a CodedInputStream
with something like:
byte[] ba = readBytesFromOutputFile();
CodedInputStream cis = CodedInputStream.newInstance(ba);
The CodedInputStream
can then be passed to a message builder to complete the deserialization.