1818package com .rabbitmq .client .test .server ;
1919
2020import java .io .IOException ;
21- import java .util .HashMap ;
2221
2322import com .rabbitmq .client .AMQP ;
2423import com .rabbitmq .client .Channel ;
25- import com .rabbitmq .client .Connection ;
26- import com .rabbitmq .client .ConnectionFactory ;
2724import com .rabbitmq .client .test .BrokerTestCase ;
2825import com .rabbitmq .tools .Host ;
2926
3229 * (following the scenarios given in bug 20578).
3330 */
3431public class ExclusiveQueueDurability extends BrokerTestCase {
35- private Channel secondaryChannel ;
36- private Connection secondaryConnection ;
3732
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 {
4235 try {
4336 channel .queueDeclare (queueName , false , false , false , null );
4437 } catch (IOException ioe ) {
@@ -47,47 +40,19 @@ void verifyQueueMissing(Channel channel, String queueName)
4740 }
4841 }
4942
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- ConnectionFactory cf2 = connectionFactory .clone ();
62- cf2 .setHost ("localhost" );
63- cf2 .setPort (5673 );
64- secondaryConnection = cf2 .newConnection ();
65- secondaryChannel = secondaryConnection .createChannel ();
66- }
67-
68- @ Override
69- protected void releaseResources () throws IOException {
70- secondaryChannel .abort ();
71- secondaryChannel = null ;
72- secondaryConnection .abort ();
73- secondaryConnection = null ;
74- super .releaseResources ();
75- }
76-
7743 // 1) connection and queue are on same node, node restarts -> queue
7844 // should no longer exist
7945 public void testConnectionQueueSameNode () throws Exception {
80- secondaryChannel .queueDeclare ("scenario1" , true , true , false , noArgs );
81- restartAbruptly ();
82- verifyQueueMissing (secondaryChannel , "scenario1" );
46+ channel .queueDeclare ("scenario1" , true , true , false , null );
47+ restartPrimaryAbruptly ();
48+ verifyQueueMissing (channel , "scenario1" );
8349 }
8450
85- protected void restartAbruptly () throws IOException {
86- secondaryConnection .abort ();
87- secondaryConnection = null ;
88- secondaryChannel = null ;
89- Host .executeCommand ("cd ../rabbitmq-test; make restart-secondary-node" );
90- openChannel ();
51+ private void restartPrimaryAbruptly () throws IOException {
52+ connection = null ;
53+ channel = null ;
54+ Host .executeCommand ("cd ../rabbitmq-test; make restart-app" );
55+ setUp ();
9156 }
9257
9358 /*
0 commit comments