Skip to content

Commit 334a1dd

Browse files
author
Emile Joubert
committed
Merged bug25545 into stable
2 parents 66e4194 + 00a95a4 commit 334a1dd

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import java.util.Map;
2323

2424
import com.rabbitmq.client.AMQP;
25+
import com.rabbitmq.client.Consumer;
26+
import com.rabbitmq.client.DefaultConsumer;
2527
import com.rabbitmq.client.test.BrokerTestCase;
2628

2729
public class QueueLease extends BrokerTestCase {
@@ -178,6 +180,33 @@ public void testPassiveQueueDeclareExtendsLease()
178180
}
179181
}
180182

183+
public void testExpiresWithConsumers()
184+
throws InterruptedException, IOException {
185+
Map<String, Object> args = new HashMap<String, Object>();
186+
args.put("x-expires", QUEUE_EXPIRES);
187+
channel.queueDeclare(TEST_EXPIRE_QUEUE, false, false, false, args);
188+
189+
Consumer consumer = new DefaultConsumer(channel);
190+
String consumerTag = channel.basicConsume(TEST_EXPIRE_QUEUE, consumer);
191+
192+
Thread.sleep(SHOULD_EXPIRE_WITHIN);
193+
try {
194+
channel.queueDeclarePassive(TEST_EXPIRE_QUEUE);
195+
} catch (IOException e) {
196+
checkShutdownSignal(AMQP.NOT_FOUND, e);
197+
fail("Queue expired before before passive re-declaration.");
198+
}
199+
200+
channel.basicCancel(consumerTag);
201+
Thread.sleep(SHOULD_EXPIRE_WITHIN);
202+
try {
203+
channel.queueDeclarePassive(TEST_EXPIRE_QUEUE);
204+
fail("Queue should have been expired by now.");
205+
} catch (IOException e) {
206+
checkShutdownSignal(AMQP.NOT_FOUND, e);
207+
}
208+
}
209+
181210
void verifyQueueExpires(String name, boolean expire) throws IOException,
182211
InterruptedException {
183212
Map<String, Object> args = new HashMap<String, Object>();

0 commit comments

Comments
 (0)