can now run passBybytes, but it's broken

This commit is contained in:
David Renshaw 2014-09-04 11:03:59 -04:00
parent d33af5fa71
commit 9d23cd8cb0
3 changed files with 19 additions and 5 deletions

View file

@ -56,10 +56,24 @@ public abstract class TestCase<RequestFactory extends StructFactory<RequestBuild
org.capnproto.Serialize.writeMessage(writer, requestMessage);
}
new org.capnproto.ArrayInputStream(requestBytes);
{
org.capnproto.MessageReader messageReader =
org.capnproto.ByteChannelMessageReader.create(new org.capnproto.ArrayInputStream(requestBytes));
this.handleRequest(messageReader.getRoot(requestFactory), response);
}
// TODO
throw new Error("unimplemented");
{
org.capnproto.ArrayOutputStream writer = new org.capnproto.ArrayOutputStream(responseBytes);
org.capnproto.Serialize.writeMessage(writer, responseMessage);
}
{
org.capnproto.MessageReader messageReader =
org.capnproto.ByteChannelMessageReader.create(new org.capnproto.ArrayInputStream(responseBytes));
if (!this.checkResponse(messageReader.getRoot(responseFactory), expected)) {
throw new Error("incorrect response");
}
}
}
}

View file

@ -9,7 +9,7 @@ public final class ArrayInputStream implements BufferedInputStream {
public final ByteBuffer buf;
public ArrayInputStream(ByteBuffer buf) {
this.buf = buf;
this.buf = buf.asReadOnlyBuffer();
}
public final int read(ByteBuffer dst) throws IOException {

View file

@ -9,7 +9,7 @@ public final class ArrayOutputStream implements BufferedOutputStream {
public final ByteBuffer buf;
public ArrayOutputStream(ByteBuffer buf) {
this.buf = buf;
this.buf = buf.duplicate();
}
public final int write(ByteBuffer src) throws IOException {