38
38
import static org .mockito .Mockito .verify ;
39
39
40
40
/**
41
+ * Tests for {@link DefaultMessageListenerContainer}.
42
+ *
41
43
* @author Stephane Nicoll
42
44
* @author Juergen Hoeller
43
45
*/
44
- public class DefaultMessageListenerContainerTests {
46
+ class DefaultMessageListenerContainerTests {
45
47
46
48
@ Test
47
- public void applyBackOff () {
49
+ void applyBackOff () {
48
50
BackOff backOff = mock ();
49
51
BackOffExecution execution = mock ();
50
52
given (execution .nextBackOff ()).willReturn (BackOffExecution .STOP );
@@ -65,7 +67,7 @@ public void applyBackOff() {
65
67
}
66
68
67
69
@ Test
68
- public void applyBackOffRetry () {
70
+ void applyBackOffRetry () {
69
71
BackOff backOff = mock ();
70
72
BackOffExecution execution = mock ();
71
73
given (execution .nextBackOff ()).willReturn (50L , BackOffExecution .STOP );
@@ -84,7 +86,7 @@ public void applyBackOffRetry() {
84
86
}
85
87
86
88
@ Test
87
- public void recoverResetBackOff () {
89
+ void recoverResetBackOff () {
88
90
BackOff backOff = mock ();
89
91
BackOffExecution execution = mock ();
90
92
given (execution .nextBackOff ()).willReturn (50L , 50L , 50L ); // 3 attempts max
@@ -103,7 +105,7 @@ public void recoverResetBackOff() {
103
105
}
104
106
105
107
@ Test
106
- public void stopAndRestart () {
108
+ void stopAndRestart () {
107
109
DefaultMessageListenerContainer container = createRunningContainer ();
108
110
container .stop ();
109
111
@@ -112,7 +114,7 @@ public void stopAndRestart() {
112
114
}
113
115
114
116
@ Test
115
- public void stopWithCallbackAndRestart () throws InterruptedException {
117
+ void stopWithCallbackAndRestart () throws InterruptedException {
116
118
DefaultMessageListenerContainer container = createRunningContainer ();
117
119
118
120
TestRunnable stopCallback = new TestRunnable ();
@@ -124,7 +126,7 @@ public void stopWithCallbackAndRestart() throws InterruptedException {
124
126
}
125
127
126
128
@ Test
127
- public void stopCallbackIsInvokedEvenIfContainerIsNotRunning () throws InterruptedException {
129
+ void stopCallbackIsInvokedEvenIfContainerIsNotRunning () throws InterruptedException {
128
130
DefaultMessageListenerContainer container = createRunningContainer ();
129
131
container .stop ();
130
132
@@ -137,7 +139,7 @@ public void stopCallbackIsInvokedEvenIfContainerIsNotRunning() throws Interrupte
137
139
}
138
140
139
141
140
- private DefaultMessageListenerContainer createRunningContainer () {
142
+ private static DefaultMessageListenerContainer createRunningContainer () {
141
143
DefaultMessageListenerContainer container = createContainer (createSuccessfulConnectionFactory ());
142
144
container .setCacheLevel (DefaultMessageListenerContainer .CACHE_CONNECTION );
143
145
container .setBackOff (new FixedBackOff (100 , 1 ));
@@ -146,7 +148,7 @@ private DefaultMessageListenerContainer createRunningContainer() {
146
148
return container ;
147
149
}
148
150
149
- private ConnectionFactory createSuccessfulConnectionFactory () {
151
+ private static ConnectionFactory createSuccessfulConnectionFactory () {
150
152
try {
151
153
ConnectionFactory connectionFactory = mock ();
152
154
given (connectionFactory .createConnection ()).willReturn (mock ());
@@ -157,7 +159,7 @@ private ConnectionFactory createSuccessfulConnectionFactory() {
157
159
}
158
160
}
159
161
160
- private DefaultMessageListenerContainer createContainer (ConnectionFactory connectionFactory ) {
162
+ private static DefaultMessageListenerContainer createContainer (ConnectionFactory connectionFactory ) {
161
163
Destination destination = new Destination () {};
162
164
163
165
DefaultMessageListenerContainer container = new DefaultMessageListenerContainer ();
@@ -167,7 +169,7 @@ private DefaultMessageListenerContainer createContainer(ConnectionFactory connec
167
169
return container ;
168
170
}
169
171
170
- private ConnectionFactory createFailingContainerFactory () {
172
+ private static ConnectionFactory createFailingContainerFactory () {
171
173
try {
172
174
ConnectionFactory connectionFactory = mock ();
173
175
given (connectionFactory .createConnection ()).will (invocation -> {
@@ -180,7 +182,7 @@ private ConnectionFactory createFailingContainerFactory() {
180
182
}
181
183
}
182
184
183
- private ConnectionFactory createRecoverableContainerFactory (final int failingAttempts ) {
185
+ private static ConnectionFactory createRecoverableContainerFactory (final int failingAttempts ) {
184
186
try {
185
187
ConnectionFactory connectionFactory = mock ();
186
188
given (connectionFactory .createConnection ()).will (new Answer <Object >() {
@@ -213,7 +215,7 @@ public void run() {
213
215
this .countDownLatch .countDown ();
214
216
}
215
217
216
- public void waitForCompletion () throws InterruptedException {
218
+ void waitForCompletion () throws InterruptedException {
217
219
this .countDownLatch .await (1 , TimeUnit .SECONDS );
218
220
assertThat (this .countDownLatch .getCount ()).as ("callback was not invoked" ).isEqualTo (0 );
219
221
}
0 commit comments