3535import java .util .HashMap ;
3636
3737import com .rabbitmq .client .Channel ;
38+ import com .rabbitmq .client .Connection ;
39+ import com .rabbitmq .client .ConnectionFactory ;
40+ import com .rabbitmq .client .test .BrokerTestCase ;
41+ import com .rabbitmq .tools .Host ;
3842
3943/**
4044 * This tests whether exclusive, durable queues are deleted when appropriate
4145 * (following the scenarios given in bug 20578).
4246 */
43- public class ExclusiveQueueDurability extends RestartBase {
47+ public class ExclusiveQueueDurability extends BrokerTestCase {
48+ private Channel secondaryChannel ;
49+ private Connection secondaryConnection ;
4450
4551 HashMap <String , Object > noArgs = new HashMap <String , Object >();
4652
@@ -54,12 +60,47 @@ void verifyQueueMissing(Channel channel, String queueName)
5460 }
5561 }
5662
63+ @ Override
64+ protected void createResources () throws IOException {
65+ super .createResources ();
66+ openChannel ();
67+
68+ }
69+
70+ // TODO extract some commonality between this and DurableBindingLifecycle
71+ public void openChannel ()
72+ throws IOException
73+ {
74+ ConnectionFactory cf2 = connectionFactory .clone ();
75+ cf2 .setHost ("localhost" );
76+ cf2 .setPort (5673 );
77+ secondaryConnection = cf2 .newConnection ();
78+ secondaryChannel = secondaryConnection .createChannel ();
79+ }
80+
81+ @ Override
82+ protected void releaseResources () throws IOException {
83+ secondaryChannel .abort ();
84+ secondaryChannel = null ;
85+ secondaryConnection .abort ();
86+ secondaryConnection = null ;
87+ super .releaseResources ();
88+ }
89+
5790 // 1) connection and queue are on same node, node restarts -> queue
5891 // should no longer exist
5992 public void testConnectionQueueSameNode () throws Exception {
60- channel .queueDeclare ("scenario1" , true , true , false , noArgs );
93+ secondaryChannel .queueDeclare ("scenario1" , true , true , false , noArgs );
6194 restartAbruptly ();
62- verifyQueueMissing (channel , "scenario1" );
95+ verifyQueueMissing (secondaryChannel , "scenario1" );
96+ }
97+
98+ protected void restartAbruptly () throws IOException {
99+ secondaryConnection .abort ();
100+ secondaryConnection = null ;
101+ secondaryChannel = null ;
102+ Host .executeCommand ("cd ../rabbitmq-test; make restart-secondary-node" );
103+ openChannel ();
63104 }
64105
65106 /*
0 commit comments