use of com.rabbitmq.client.impl.nio.ByteBufferOutputStream in project rabbitmq-java-client by rabbitmq.
the class FrameTest method writeLargeFrame.
@Test
public void writeLargeFrame() throws IOException {
List<Frame> frames = new ArrayList<Frame>();
int totalFrameSize = 0;
int[] framesSize = new int[] { 100, 75, 20000, 150 };
for (int frameSize : framesSize) {
Frame frame = new Frame(AMQP.FRAME_METHOD, 1, new byte[frameSize]);
frames.add(frame);
totalFrameSize += frame.size();
}
AccumulatorWritableByteChannel channel = new AccumulatorWritableByteChannel();
ByteBuffer buffer = ByteBuffer.allocate(8192);
for (Frame frame : frames) {
frame.writeTo(new DataOutputStream(new ByteBufferOutputStream(channel, buffer)));
}
drain(channel, buffer);
checkWrittenChunks(totalFrameSize, channel);
}
use of com.rabbitmq.client.impl.nio.ByteBufferOutputStream in project rabbitmq-java-client by rabbitmq.
the class FrameTest method writeFrames.
@Test
public void writeFrames() throws IOException {
List<Frame> frames = new ArrayList<Frame>();
Random random = new Random();
int totalFrameSize = 0;
for (int i = 0; i < 100; i++) {
byte[] payload = new byte[random.nextInt(2000) + 1];
Frame frame = new Frame(AMQP.FRAME_METHOD, 1, payload);
frames.add(frame);
totalFrameSize += frame.size();
}
AccumulatorWritableByteChannel channel = new AccumulatorWritableByteChannel();
ByteBuffer buffer = ByteBuffer.allocate(8192);
for (Frame frame : frames) {
frame.writeTo(new DataOutputStream(new ByteBufferOutputStream(channel, buffer)));
}
drain(channel, buffer);
checkWrittenChunks(totalFrameSize, channel);
}
Aggregations