Skip to content

Commit 17a35d4

Browse files
author
Simon MacMullen
committed
Slight abstraction
1 parent 488c2ee commit 17a35d4

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,11 @@ public void testThatCancelledConsumerDoesNotReappearOnRecover() throws IOExcepti
265265
String q = UUID.randomUUID().toString();
266266
channel.queueDeclare(q, false, false, false, null);
267267
String tag = channel.basicConsume(q, new DefaultConsumer(channel));
268-
AMQP.Queue.DeclareOk ok1 = channel.queueDeclarePassive(q);
269-
assertEquals(1, ok1.getConsumerCount());
268+
assertConsumerCount(1, q);
270269
channel.basicCancel(tag);
271270
closeAndWaitForRecovery();
272271
expectChannelRecovery(channel);
273-
AMQP.Queue.DeclareOk ok2 = channel.queueDeclarePassive(q);
274-
assertEquals(0, ok2.getConsumerCount());
272+
assertConsumerCount(0, q);
275273
}
276274

277275
public void testConsumerRecoveryWithManyConsumers() throws IOException, InterruptedException {
@@ -280,12 +278,10 @@ public void testConsumerRecoveryWithManyConsumers() throws IOException, Interrup
280278
for (int i = 0; i < n; i++) {
281279
channel.basicConsume(q, new DefaultConsumer(channel));
282280
}
283-
AMQP.Queue.DeclareOk ok1 = channel.queueDeclarePassive(q);
284-
assertEquals(n, ok1.getConsumerCount());
281+
assertConsumerCount(n, q);
285282
closeAndWaitForRecovery();
286283
expectChannelRecovery(channel);
287-
AMQP.Queue.DeclareOk ok2 = channel.queueDeclarePassive(q);
288-
assertEquals(n, ok2.getConsumerCount());
284+
assertConsumerCount(n, q);
289285

290286
}
291287

@@ -360,6 +356,10 @@ public void handleDelivery(String consumerTag,
360356
publishingConnection.abort();
361357
}
362358

359+
private void assertConsumerCount(int exp, String q) throws IOException {
360+
assertEquals(exp, channel.queueDeclarePassive(q).getConsumerCount());
361+
}
362+
363363
private AMQP.Queue.DeclareOk declareClientNamedQueue(Channel ch, String q) throws IOException {
364364
return ch.queueDeclare(q, true, false, false, null);
365365
}

0 commit comments

Comments
 (0)