Skip to content

Commit 281afb0

Browse files
author
Emile Joubert
committed
Further tests for queue size limits
1 parent 8dfa74e commit 281afb0

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.rabbitmq.client.MessageProperties;
2323
import com.rabbitmq.client.test.BrokerTestCase;
2424
import java.io.IOException;
25+
import java.util.ArrayList;
2526
import java.util.HashMap;
2627
import java.util.Map;
2728

@@ -88,6 +89,37 @@ public void testDlxTailDurable() throws IOException, InterruptedException {
8889
dlxTail(true);
8990
}
9091

92+
public void testMaxlenZero() throws IOException, InterruptedException {
93+
Map<String, Object> args = new HashMap<String, Object>();
94+
args.put("x-max-length", 0);
95+
channel.queueDeclare(q, false, true, true, args);
96+
syncPublish(null, "msg");
97+
assertNull(channel.basicGet(q, true));
98+
}
99+
100+
public void testRequeue() throws IOException, InterruptedException {
101+
declareQueue(false, false);
102+
ArrayList<Long> tags = new ArrayList<Long>(MAXLENGTH);;
103+
fill(false, false, false);
104+
getUnacked(MAXLENGTH, tags);
105+
fill(false, false, false);
106+
channel.basicNack(tags.get(0), false, true);
107+
channel.basicNack(tags.get(MAXLENGTH - 1), true, true);
108+
assertHead(MAXLENGTH, "msg1", q);
109+
}
110+
111+
public void testRequeueWithDlx() throws IOException, InterruptedException {
112+
setupDlx(false);
113+
ArrayList<Long> tags = new ArrayList<Long>(MAXLENGTH);;
114+
fill(false, false, true);
115+
getUnacked(MAXLENGTH, tags);
116+
fill(false, false, true);
117+
channel.basicNack(tags.get(0), false, true);
118+
channel.basicNack(tags.get(MAXLENGTH - 1), true, true);
119+
assertHead(MAXLENGTH, "msg1", q);
120+
assertHead(MAXLENGTH, "msg1", "DLQ");
121+
}
122+
91123
public void dlxHead(boolean persistent) throws IOException, InterruptedException {
92124
AMQP.BasicProperties props = setupDlx(persistent);
93125
fill(persistent, false, true);
@@ -139,4 +171,10 @@ private void assertHead(int expectedLength, String expectedPayload, String queue
139171
assertEquals(expectedPayload, new String(head.getBody()));
140172
assertEquals(expectedLength, head.getMessageCount() + 1);
141173
}
174+
175+
private void getUnacked(int howMany, ArrayList<Long> acks) throws IOException {
176+
for (;howMany > 0; howMany --){
177+
acks.add(channel.basicGet(q, false).getEnvelope().getDeliveryTag());
178+
}
179+
}
142180
}

0 commit comments

Comments
 (0)