|
16 | 16 |
|
17 | 17 | package com.rabbitmq.client.test.server; |
18 | 18 |
|
19 | | -import static org.junit.Assert.assertFalse; |
20 | | -import static org.junit.Assert.fail; |
| 19 | +import com.rabbitmq.client.AMQP; |
| 20 | +import com.rabbitmq.client.Channel; |
| 21 | +import com.rabbitmq.client.test.functional.ClusteredTestBase; |
| 22 | +import org.junit.Test; |
21 | 23 |
|
22 | 24 | import java.io.IOException; |
| 25 | +import java.util.concurrent.Callable; |
23 | 26 | import java.util.concurrent.TimeoutException; |
24 | 27 |
|
25 | | -import com.rabbitmq.client.Channel; |
26 | | -import org.junit.Test; |
27 | | - |
28 | | -import com.rabbitmq.client.AMQP; |
29 | | -import com.rabbitmq.client.test.functional.ClusteredTestBase; |
| 28 | +import static org.junit.Assert.assertFalse; |
| 29 | +import static org.junit.Assert.fail; |
30 | 30 |
|
31 | 31 | /** |
32 | 32 | * This tests whether 'absent' queues - durable queues whose home node |
@@ -56,39 +56,19 @@ public class AbsentQueue extends ClusteredTestBase { |
56 | 56 | alternateChannel.queueDelete(Q); |
57 | 57 | } |
58 | 58 |
|
59 | | - @Test public void notFound() throws IOException, InterruptedException { |
| 59 | + @Test public void notFound() throws Exception { |
60 | 60 | waitPropagationInHa(); |
61 | | - assertNotFound(new Task() { |
62 | | - public void run() throws IOException { |
63 | | - channel.queueDeclare(Q, true, false, false, null); |
64 | | - } |
65 | | - }); |
66 | | - assertNotFound(new Task() { |
67 | | - public void run() throws IOException { |
68 | | - channel.queueDeclarePassive(Q); |
69 | | - } |
70 | | - }); |
71 | | - assertNotFound(new Task() { |
72 | | - public void run() throws IOException { |
73 | | - channel.queuePurge(Q); |
74 | | - } |
75 | | - }); |
76 | | - assertNotFound(new Task() { |
77 | | - public void run() throws IOException { |
78 | | - channel.basicGet(Q, true); |
79 | | - } |
80 | | - }); |
81 | | - assertNotFound(new Task() { |
82 | | - public void run() throws IOException { |
83 | | - channel.queueBind(Q, "amq.fanout", "", null); |
84 | | - } |
85 | | - }); |
| 61 | + assertNotFound(() -> channel.queueDeclare(Q, true, false, false, null)); |
| 62 | + assertNotFound(() -> channel.queueDeclarePassive(Q)); |
| 63 | + assertNotFound(() -> channel.queuePurge(Q)); |
| 64 | + assertNotFound(() -> channel.basicGet(Q, true)); |
| 65 | + assertNotFound(() -> channel.queueBind(Q, "amq.fanout", "", null)); |
86 | 66 | } |
87 | 67 |
|
88 | | - protected void assertNotFound(Task t) throws IOException { |
| 68 | + protected void assertNotFound(Callable<?> t) throws Exception { |
89 | 69 | if (clusteredChannel == null) return; |
90 | 70 | try { |
91 | | - t.run(); |
| 71 | + t.call(); |
92 | 72 | if (!HATests.HA_TESTS_RUNNING) fail("expected not_found"); |
93 | 73 | } catch (IOException ioe) { |
94 | 74 | assertFalse(HATests.HA_TESTS_RUNNING); |
@@ -116,8 +96,4 @@ private void waitPropagationInHa() throws IOException, InterruptedException { |
116 | 96 | } |
117 | 97 | } |
118 | 98 |
|
119 | | - private interface Task { |
120 | | - void run() throws IOException; |
121 | | - } |
122 | | - |
123 | 99 | } |
0 commit comments