Skip to content

Commit 4e282fe

Browse files
committed
Remove ByteBufferInputStream tests
Class does not longer exist. References #319
1 parent 099cb3d commit 4e282fe

File tree

1 file changed

+7
-69
lines changed

1 file changed

+7
-69
lines changed

src/test/java/com/rabbitmq/client/test/FrameTest.java

Lines changed: 7 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -2,91 +2,29 @@
22

33
import com.rabbitmq.client.AMQP;
44
import com.rabbitmq.client.impl.Frame;
5-
import com.rabbitmq.client.impl.nio.ByteBufferInputStream;
65
import com.rabbitmq.client.impl.nio.ByteBufferOutputStream;
76
import org.junit.Test;
87

98
import java.io.ByteArrayOutputStream;
10-
import java.io.DataInputStream;
119
import java.io.DataOutputStream;
1210
import java.io.IOException;
1311
import java.nio.ByteBuffer;
1412
import java.nio.channels.ReadableByteChannel;
1513
import java.nio.channels.WritableByteChannel;
16-
import java.util.*;
14+
import java.util.ArrayList;
15+
import java.util.Iterator;
16+
import java.util.LinkedList;
17+
import java.util.List;
18+
import java.util.Random;
1719

18-
import static org.hamcrest.Matchers.*;
19-
import static org.junit.Assert.*;
20+
import static org.hamcrest.Matchers.equalTo;
21+
import static org.junit.Assert.assertThat;
2022

2123
/**
2224
*
2325
*/
2426
public class FrameTest {
2527

26-
@Test public void readFrames() throws IOException {
27-
Random random = new Random();
28-
int nbOfFrames = 100;
29-
AccumulatorReadableByteChannel channel = new AccumulatorReadableByteChannel();
30-
31-
for(int i = 0; i < nbOfFrames; i++) {
32-
byte[] payload = new byte[random.nextInt(2000) + 1];
33-
Frame frame = new Frame(AMQP.FRAME_METHOD, 1, payload);
34-
channel.add(frame);
35-
}
36-
37-
ByteBuffer buffer = ByteBuffer.allocate(8192);
38-
39-
DataInputStream inputStream = new DataInputStream(
40-
new ByteBufferInputStream(channel, buffer)
41-
);
42-
43-
int nbReadFrames = 0;
44-
channel.read(buffer);
45-
buffer.flip();
46-
while(buffer.hasRemaining()) {
47-
Frame.readFrom(inputStream);
48-
nbReadFrames++;
49-
if(!buffer.hasRemaining()) {
50-
buffer.clear();
51-
channel.read(buffer);
52-
buffer.flip();
53-
}
54-
55-
}
56-
assertThat(nbReadFrames, equalTo(nbOfFrames));
57-
}
58-
59-
@Test public void readLargeFrame() throws IOException {
60-
AccumulatorReadableByteChannel channel = new AccumulatorReadableByteChannel();
61-
62-
int [] framesSize = new int [] {100, 75, 20000, 150};
63-
for (int frameSize : framesSize) {
64-
Frame frame = new Frame(AMQP.FRAME_METHOD, 1, new byte[frameSize]);
65-
channel.add(frame);
66-
}
67-
68-
ByteBuffer buffer = ByteBuffer.allocate(8192);
69-
70-
DataInputStream inputStream = new DataInputStream(
71-
new ByteBufferInputStream(channel, buffer)
72-
);
73-
74-
int nbReadFrames = 0;
75-
channel.read(buffer);
76-
buffer.flip();
77-
while(buffer.hasRemaining()) {
78-
Frame.readFrom(inputStream);
79-
nbReadFrames++;
80-
if(!buffer.hasRemaining()) {
81-
buffer.clear();
82-
channel.read(buffer);
83-
buffer.flip();
84-
}
85-
86-
}
87-
assertThat(nbReadFrames, equalTo(framesSize.length));
88-
}
89-
9028
@Test
9129
public void writeFrames() throws IOException {
9230
List<Frame> frames = new ArrayList<Frame>();

0 commit comments

Comments
 (0)