use of org.jgroups.util.ByteArrayDataOutputStream in project JGroups by belaban.
the class ByteArrayDataInputOutputStreamTest method testByte.
public void testByte() throws IOException {
ByteArrayDataOutputStream out = new ByteArrayDataOutputStream(Byte.MAX_VALUE * 2);
for (short i = Byte.MIN_VALUE; i <= Byte.MAX_VALUE; i++) out.writeByte(i);
ByteArrayDataInputStream in = new ByteArrayDataInputStream(out.buffer());
for (short i = Byte.MIN_VALUE; i <= Byte.MAX_VALUE; i++) {
byte read = in.readByte();
assert i == read;
}
}
use of org.jgroups.util.ByteArrayDataOutputStream in project JGroups by belaban.
the class ByteArrayDataInputOutputStreamTest method testCompressedLongSequence.
public void testCompressedLongSequence() throws IOException {
ByteArrayDataOutputStream out = new ByteArrayDataOutputStream(1024);
long[] numbers = { 0, 1, 100, 322649, Long.MAX_VALUE - 1000 };
for (long i : numbers) Bits.writeLongSequence(i, i + 100, out);
ByteArrayDataInputStream in = new ByteArrayDataInputStream(out.buffer());
for (long i : numbers) {
long[] seq = { 0, 0 };
Bits.readLongSequence(in, seq, 0);
assert Arrays.equals(seq, new long[] { i, i + 100 });
}
}
use of org.jgroups.util.ByteArrayDataOutputStream in project JGroups by belaban.
the class RouterStub method writeRequest.
protected synchronized void writeRequest(GossipData req) throws Exception {
int size = req.serializedSize();
ByteArrayDataOutputStream out = new ByteArrayDataOutputStream(size + 5);
req.writeTo(out);
client.send(remote, out.buffer(), 0, out.position());
}
Aggregations