|
18 | 18 | package com.rabbitmq.client.test.server; |
19 | 19 |
|
20 | 20 | import java.io.IOException; |
21 | | -import java.util.HashMap; |
22 | 21 |
|
23 | 22 | import com.rabbitmq.client.AMQP; |
24 | 23 | import com.rabbitmq.client.Channel; |
25 | | -import com.rabbitmq.client.Connection; |
26 | | -import com.rabbitmq.client.ConnectionFactory; |
27 | 24 | import com.rabbitmq.client.test.BrokerTestCase; |
28 | 25 | import com.rabbitmq.tools.Host; |
29 | 26 |
|
|
32 | 29 | * (following the scenarios given in bug 20578). |
33 | 30 | */ |
34 | 31 | public class ExclusiveQueueDurability extends BrokerTestCase { |
35 | | - private Channel secondaryChannel; |
36 | | - private Connection secondaryConnection; |
37 | 32 |
|
38 | | - HashMap<String, Object> noArgs = new HashMap<String, Object>(); |
39 | | - |
40 | | - void verifyQueueMissing(Channel channel, String queueName) |
41 | | - throws IOException { |
| 33 | + void verifyQueueMissing(Channel channel, String queueName) |
| 34 | + throws IOException { |
42 | 35 | try { |
43 | | - channel.queueDeclare(queueName, false, false, false, null); |
| 36 | + channel.queueDeclare(queueName, true, true, false, null); |
44 | 37 | } catch (IOException ioe) { |
45 | 38 | checkShutdownSignal(AMQP.RESOURCE_LOCKED, ioe); |
46 | 39 | fail("Declaring the queue resulted in a channel exception, probably meaning that it already exists"); |
47 | 40 | } |
48 | 41 | } |
49 | 42 |
|
50 | | - @Override |
51 | | - protected void createResources() throws IOException { |
52 | | - super.createResources(); |
53 | | - openChannel(); |
54 | | - |
55 | | - } |
56 | | - |
57 | | - // TODO extract some commonality between this and DurableBindingLifecycle |
58 | | - public void openChannel() |
59 | | - throws IOException |
60 | | - { |
61 | | - Host.executeCommand("cd ../rabbitmq-test; make restart-secondary-node"); |
62 | | - ConnectionFactory cf2 = connectionFactory.clone(); |
63 | | - cf2.setHost("localhost"); |
64 | | - cf2.setPort(5673); |
65 | | - secondaryConnection = cf2.newConnection(); |
66 | | - secondaryChannel = secondaryConnection.createChannel(); |
67 | | - } |
68 | | - |
69 | | - @Override |
70 | | - protected void releaseResources() throws IOException { |
71 | | - secondaryChannel.abort(); |
72 | | - secondaryChannel = null; |
73 | | - secondaryConnection.abort(); |
74 | | - secondaryConnection = null; |
75 | | - super.releaseResources(); |
76 | | - } |
77 | | - |
78 | 43 | // 1) connection and queue are on same node, node restarts -> queue |
79 | 44 | // should no longer exist |
80 | 45 | public void testConnectionQueueSameNode() throws Exception { |
81 | | - secondaryChannel.queueDeclare("scenario1", true, true, false, noArgs); |
82 | | - restartAbruptly(); |
83 | | - verifyQueueMissing(secondaryChannel, "scenario1"); |
| 46 | + channel.queueDeclare("scenario1", true, true, false, null); |
| 47 | + restartPrimaryAbruptly(); |
| 48 | + verifyQueueMissing(channel, "scenario1"); |
84 | 49 | } |
85 | 50 |
|
86 | | - protected void restartAbruptly() throws IOException { |
87 | | - secondaryConnection.abort(); |
88 | | - secondaryConnection = null; |
89 | | - secondaryChannel = null; |
90 | | - Host.executeCommand("cd ../rabbitmq-test; make restart-secondary-node"); |
91 | | - openChannel(); |
| 51 | + private void restartPrimaryAbruptly() throws IOException { |
| 52 | + connection = null; |
| 53 | + channel = null; |
| 54 | + Host.executeCommand("cd ../rabbitmq-test; make restart-app"); |
| 55 | + setUp(); |
92 | 56 | } |
93 | 57 |
|
94 | 58 | /* |
|
0 commit comments