{
public void run()
{
try
{
RegionalizedMethodCall rmc = cm200.regionalizedMethodCallFromObjectStream(new ObjectInputStream(new ByteArrayInputStream(stream)));
ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream outStream = new ObjectOutputStream(out);
RegionalizedReturnValue rrv = new RegionalizedReturnValue("A result", rmc);
cm200.objectToObjectStream(rrv, outStream);
outStream.close();
out.close();
// test that the output stream has got "/hello" as it's region Fqn.
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(out.toByteArray()));
assert in.readByte() == CacheMarshaller200.MAGICNUMBER_FQN : "The stream should start with an Fqn";
// discard the nest refId short
in.readShort();
Fqn f = cm200.unmarshallFqn(in, new UnmarshalledReferences());
assert region.equals(f) : "Should use the same region for the response as was used for the request!";
}
catch (Throwable t)
{
throwables.add(t);
}
}
});
}
else if (i % 3 == 1)
{
// task 2 above
e.execute(new Runnable()
{
public void run()
{
try
{
cm200.objectFromObjectStream(new ObjectInputStream(new ByteArrayInputStream(stream)));
// and now just send back a 'void' return type (In JGroups this is treated as a null)
cm200.objectToObjectStream(null, new ObjectOutputStream(new ByteArrayOutputStream()));
}
catch (Throwable t)
{
throwables.add(t);
}
}
});
}
else if (i % 3 == 2)
{
// task 3 above
e.execute(new Runnable()
{
public void run()
{
try
{
// and now don't bother with any umarshalling
// directly marshall a boolean.
ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream outStream = new ObjectOutputStream(out);
cm200.objectToObjectStream(true, outStream);
outStream.close();
out.close();
// test that the output stream has got "/hello" as it's region Fqn.
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(out.toByteArray()));
byte magic = in.readByte();
assert magic != CacheMarshaller200.MAGICNUMBER_FQN : "The stream should NOT start with an Fqn!";
assert magic == CacheMarshaller200.MAGICNUMBER_NULL : "Should start with a NULL. Instead, was " + magic;
assert in.readByte() == CacheMarshaller200.MAGICNUMBER_BOOLEAN : "Should have a boolean magic number before the boolean value";