3232
3333import java .io .IOException ;
3434
35- import junit .framework .TestCase ;
36-
3735import com .rabbitmq .client .Channel ;
3836import com .rabbitmq .client .Connection ;
3937import com .rabbitmq .client .QueueingConsumer ;
4038import com .rabbitmq .client .test .BrokerTestCase ;
41-
4239import com .rabbitmq .tools .Host ;
4340
44-
4541public class MemoryAlarms extends BrokerTestCase {
4642
4743 private static final String Q = "Restart" ;
@@ -50,9 +46,7 @@ public class MemoryAlarms extends BrokerTestCase {
5046 private Channel channel2 ;
5147
5248 @ Override
53- protected void setUp ()
54- throws IOException
55- {
49+ protected void setUp () throws IOException {
5650 connectionFactory .setRequestedHeartbeat (1 );
5751 super .setUp ();
5852 if (connection2 == null ) {
@@ -62,9 +56,7 @@ protected void setUp()
6256 }
6357
6458 @ Override
65- protected void tearDown ()
66- throws IOException
67- {
59+ protected void tearDown () throws IOException {
6860 if (channel2 != null ) {
6961 channel2 .abort ();
7062 channel2 = null ;
@@ -78,49 +70,39 @@ protected void tearDown()
7870 }
7971
8072 @ Override
81- protected void createResources ()
82- throws IOException
83- {
73+ protected void createResources () throws IOException {
8474 channel .queueDeclare (Q , false , false , false , null );
8575 }
8676
8777 @ Override
88- protected void releaseResources ()
89- throws IOException
90- {
78+ protected void releaseResources () throws IOException {
9179 channel .queueDelete (Q );
9280 }
9381
94- protected void setMemoryAlarm ()
95- throws IOException , InterruptedException
96- {
82+ protected void setMemoryAlarm () throws IOException , InterruptedException {
9783 Host .executeCommand ("cd ../rabbitmq-test; make set-memory-alarm" );
9884 }
9985
100- protected void clearMemoryAlarm ()
101- throws IOException , InterruptedException
102- {
86+ protected void clearMemoryAlarm () throws IOException , InterruptedException {
10387 Host .executeCommand ("cd ../rabbitmq-test; make clear-memory-alarm" );
10488 }
10589
106- public void testFlowControl ()
107- throws IOException , InterruptedException
108- {
90+ public void testFlowControl () throws IOException , InterruptedException {
10991 basicPublishVolatile (Q );
11092 setMemoryAlarm ();
111- //non-publish actions only after an alarm should be fine
93+ // non-publish actions only after an alarm should be fine
11294 assertNotNull (basicGet (Q ));
11395 QueueingConsumer c = new QueueingConsumer (channel );
11496 String consumerTag = channel .basicConsume (Q , true , c );
115- //publishes after an alarm should not go through
97+ // publishes after an alarm should not go through
11698 basicPublishVolatile (Q );
117- assertNull (c .nextDelivery (10 )); //the publish is async, so this is racy
118- //heartbeat monitoring should be disabled
119- Thread .sleep (3100 ); //3x heartbeat interval + epsilon
120- //once the alarm has cleared the publishes should go through
99+ assertNull (c .nextDelivery (10 )); // the publish is async, so this is racy
100+ // heartbeat monitoring should be disabled
101+ Thread .sleep (3100 ); // 3x heartbeat interval + epsilon
102+ // once the alarm has cleared the publishes should go through
121103 clearMemoryAlarm ();
122104 assertNotNull (c .nextDelivery ());
123- //everything should be back to normal
105+ // everything should be back to normal
124106 channel .basicCancel (consumerTag );
125107 basicPublishVolatile (Q );
126108 assertNotNull (basicGet (Q ));
0 commit comments