Skip to content

Commit ea13988

Browse files
author
Alexandru Scvortov
committed
don't dead-letter on delete and purge; update tests
1 parent 7e3c47b commit ea13988

File tree

1 file changed

+14
-40
lines changed

1 file changed

+14
-40
lines changed

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

Lines changed: 14 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -106,35 +106,6 @@ public void run() {
106106
}, args, PropertiesFactory.NULL, "expired");
107107
}
108108

109-
public void testDeadLetterQueueDeleted() throws Exception {
110-
deadLetterTest(new Callable<Void>() {
111-
public Void call() throws Exception{
112-
channel.queueDelete(TEST_QUEUE_NAME);
113-
return null;
114-
}
115-
}, null, PropertiesFactory.NULL, "queue_deleted");
116-
}
117-
118-
public void testDeadLetterQueuePurged() throws Exception {
119-
deadLetterTest(new Callable<Void>() {
120-
public Void call() throws Exception{
121-
channel.queuePurge(TEST_QUEUE_NAME);
122-
return null;
123-
}
124-
}, null, PropertiesFactory.NULL, "queue_purged");
125-
}
126-
127-
public void testDeadLetterQueueLeaseExpire() throws Exception {
128-
Map<String, Object> args = new HashMap<String, Object>();
129-
args.put("x-expires", 1000);
130-
131-
deadLetterTest(new Runnable() {
132-
public void run() {
133-
sleep(2000);
134-
}
135-
}, args, PropertiesFactory.NULL, "queue_deleted");
136-
}
137-
138109
public void testDeadLetterOnReject() throws Exception {
139110
deadLetterTest(new Callable<Void>() {
140111
public Void call() throws Exception {
@@ -187,10 +158,13 @@ public void testDeadLetterMultipleDeadLetterQueues()
187158
}
188159

189160
public void testDeadLetterTwice() throws Exception {
190-
channel.queueDelete(DLQ);
191-
declareQueue(DLQ, DLX, null, null);
161+
Map<String, Object> args = new HashMap<String, Object>();
162+
args.put("x-message-ttl", 1);
192163

193-
declareQueue(DLX);
164+
declareQueue(TEST_QUEUE_NAME, DLX, null, args);
165+
166+
channel.queueDelete(DLQ);
167+
declareQueue(DLQ, DLX, null, args);
194168

195169
channel.queueDeclare(DLQ2, false, true, false, null);
196170

@@ -200,9 +174,7 @@ public void testDeadLetterTwice() throws Exception {
200174

201175
publishN(MSG_COUNT, PropertiesFactory.NULL);
202176

203-
channel.queuePurge(TEST_QUEUE_NAME);
204177
sleep(100);
205-
channel.queueDelete(DLQ);
206178

207179
// There should now be two copies of each message on DLQ2: one
208180
// with one set of death headers, and another with two sets.
@@ -214,10 +186,10 @@ public void process(GetResponse getResponse) {
214186
ArrayList<Object> death = (ArrayList<Object>)headers.get("x-death");
215187
assertNotNull(death);
216188
if (death.size() == 1) {
217-
assertDeathReason(death, 0, TEST_QUEUE_NAME, "queue_purged");
189+
assertDeathReason(death, 0, TEST_QUEUE_NAME, "expired");
218190
} else if (death.size() == 2) {
219-
assertDeathReason(death, 0, DLQ, "queue_deleted");
220-
assertDeathReason(death, 1, TEST_QUEUE_NAME, "queue_purged");
191+
assertDeathReason(death, 0, DLQ, "expired");
192+
assertDeathReason(death, 1, TEST_QUEUE_NAME, "expired");
221193
} else {
222194
fail("message was dead-lettered more times than expected");
223195
}
@@ -241,7 +213,9 @@ public void process(GetResponse getResponse) {
241213
}
242214

243215
public void testDeadLetterNewRK() throws Exception {
244-
declareQueue(TEST_QUEUE_NAME, DLX, "test-other", null);
216+
Map<String, Object> args = new HashMap<String, Object>();
217+
args.put("x-message-ttl", 1);
218+
declareQueue(TEST_QUEUE_NAME, DLX, "test-other", args);
245219

246220
channel.queueDeclare(DLQ2, false, true, false, null);
247221

@@ -260,7 +234,7 @@ public AMQP.BasicProperties create(int msgNum) {
260234
}
261235
});
262236

263-
channel.queuePurge(TEST_QUEUE_NAME);
237+
sleep(100);
264238

265239
consumeN(DLQ, 0, new WithResponse() {
266240
public void process(GetResponse getResponse) {
@@ -278,7 +252,7 @@ public void process(GetResponse getResponse) {
278252
assertNotNull(death);
279253
assertEquals(1, death.size());
280254
assertDeathReason(death, 0, TEST_QUEUE_NAME,
281-
"queue_purged", "amq.direct",
255+
"expired", "amq.direct",
282256
Arrays.asList(new String[]{"test", "foo"}));
283257
}
284258
});

0 commit comments

Comments
 (0)