32
32
33
33
import java .io .IOException ;
34
34
35
- import junit .framework .TestCase ;
36
-
37
35
import com .rabbitmq .client .Channel ;
38
36
import com .rabbitmq .client .Connection ;
39
37
import com .rabbitmq .client .QueueingConsumer ;
40
38
import com .rabbitmq .client .test .BrokerTestCase ;
41
-
42
39
import com .rabbitmq .tools .Host ;
43
40
44
-
45
41
public class MemoryAlarms extends BrokerTestCase {
46
42
47
43
private static final String Q = "Restart" ;
@@ -50,9 +46,7 @@ public class MemoryAlarms extends BrokerTestCase {
50
46
private Channel channel2 ;
51
47
52
48
@ Override
53
- protected void setUp ()
54
- throws IOException
55
- {
49
+ protected void setUp () throws IOException {
56
50
connectionFactory .setRequestedHeartbeat (1 );
57
51
super .setUp ();
58
52
if (connection2 == null ) {
@@ -62,9 +56,7 @@ protected void setUp()
62
56
}
63
57
64
58
@ Override
65
- protected void tearDown ()
66
- throws IOException
67
- {
59
+ protected void tearDown () throws IOException {
68
60
if (channel2 != null ) {
69
61
channel2 .abort ();
70
62
channel2 = null ;
@@ -78,49 +70,39 @@ protected void tearDown()
78
70
}
79
71
80
72
@ Override
81
- protected void createResources ()
82
- throws IOException
83
- {
73
+ protected void createResources () throws IOException {
84
74
channel .queueDeclare (Q , false , false , false , null );
85
75
}
86
76
87
77
@ Override
88
- protected void releaseResources ()
89
- throws IOException
90
- {
78
+ protected void releaseResources () throws IOException {
91
79
channel .queueDelete (Q );
92
80
}
93
81
94
- protected void setMemoryAlarm ()
95
- throws IOException , InterruptedException
96
- {
82
+ protected void setMemoryAlarm () throws IOException , InterruptedException {
97
83
Host .executeCommand ("cd ../rabbitmq-test; make set-memory-alarm" );
98
84
}
99
85
100
- protected void clearMemoryAlarm ()
101
- throws IOException , InterruptedException
102
- {
86
+ protected void clearMemoryAlarm () throws IOException , InterruptedException {
103
87
Host .executeCommand ("cd ../rabbitmq-test; make clear-memory-alarm" );
104
88
}
105
89
106
- public void testFlowControl ()
107
- throws IOException , InterruptedException
108
- {
90
+ public void testFlowControl () throws IOException , InterruptedException {
109
91
basicPublishVolatile (Q );
110
92
setMemoryAlarm ();
111
- //non-publish actions only after an alarm should be fine
93
+ // non-publish actions only after an alarm should be fine
112
94
assertNotNull (basicGet (Q ));
113
95
QueueingConsumer c = new QueueingConsumer (channel );
114
96
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
116
98
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
121
103
clearMemoryAlarm ();
122
104
assertNotNull (c .nextDelivery ());
123
- //everything should be back to normal
105
+ // everything should be back to normal
124
106
channel .basicCancel (consumerTag );
125
107
basicPublishVolatile (Q );
126
108
assertNotNull (basicGet (Q ));
0 commit comments