Skip to content

Commit 44af895

Browse files
author
Alexandru Scvortov
committed
fixed test
1 parent 3098031 commit 44af895

File tree

1 file changed

+6
-39
lines changed

1 file changed

+6
-39
lines changed

test/src/com/rabbitmq/client/test/functional/FrameMax.java

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,14 @@
4747
public class FrameMax extends BrokerTestCase {
4848
/* This value for FrameMax is larger than the minimum and less
4949
* than what Rabbit suggests. */
50-
final static int FRAME_MAX = 131008;
50+
final static int FRAME_MAX = 70000;
5151
final static int REAL_FRAME_MAX = FRAME_MAX - 8;
5252
final static String ROUTING_KEY = "something";
5353

5454
private String queueName;
5555

5656
public FrameMax() {
5757
connectionFactory = new MyConnectionFactory();
58-
}
59-
60-
@Override
61-
protected void setUp()
62-
throws IOException
63-
{
64-
super.setUp();
6558
connectionFactory.setRequestedFrameMax(FRAME_MAX);
6659
}
6760

@@ -79,29 +72,18 @@ public void testFrameSizes()
7972
{
8073
/* This should result in at least 3 frames. */
8174
int howMuch = 2*FRAME_MAX;
82-
produce(howMuch);
75+
basicPublishVolatile(new byte[howMuch], ROUTING_KEY);
8376
/* Receive everything that was sent out. */
8477
while (howMuch > 0) {
8578
try {
8679
GetResponse response = channel.basicGet(queueName, false);
8780
howMuch -= response.getBody().length;
88-
} catch (RuntimeException e) {
89-
fail(e.toString());
81+
} catch (Exception e) {
82+
fail(e.getCause().toString());
9083
}
9184
}
9285
}
9386

94-
/* Send out howMuch worth of gibberish */
95-
protected void produce(int howMuch)
96-
throws IOException
97-
{
98-
while (howMuch > 0) {
99-
int size = (howMuch <= (REAL_FRAME_MAX)) ? howMuch : (REAL_FRAME_MAX);
100-
basicPublishVolatile(new byte[size], ROUTING_KEY);
101-
howMuch -= size;
102-
}
103-
}
104-
10587
/* ConnectionFactory that uses MyFrameHandler rather than
10688
* SocketFrameHandler. */
10789
private static class MyConnectionFactory extends ConnectionFactory {
@@ -124,25 +106,10 @@ public Frame readFrame() throws IOException {
124106
Frame f = super.readFrame();
125107
int size = f.getPayload().length;
126108
if (size > REAL_FRAME_MAX)
127-
throw new FrameTooLargeException(size, REAL_FRAME_MAX);
109+
fail("Received frame of size " + size
110+
+ ", which exceeds " + REAL_FRAME_MAX + ".");
128111
//System.out.printf("Received a frame of size %d.\n", f.getPayload().length);
129112
return f;
130113
}
131114
}
132-
133-
private static class FrameTooLargeException extends RuntimeException {
134-
private int _frameSize;
135-
private int _maxSize;
136-
137-
public FrameTooLargeException(int frameSize, int maxSize) {
138-
_frameSize = frameSize;
139-
_maxSize = maxSize;
140-
}
141-
142-
@Override
143-
public String toString() {
144-
return "Received frame of size " + _frameSize
145-
+ ", which exceeds " + _maxSize + ".";
146-
}
147-
}
148115
}

0 commit comments

Comments
 (0)