34
34
import static org .mockito .BDDMockito .*;
35
35
36
36
/**
37
- *
38
37
* @author Stephane Nicoll
39
38
*/
40
39
public class DefaultMessageListenerContainerTests {
@@ -103,6 +102,7 @@ public void runnableIsInvokedEvenIfContainerIsNotRunning() throws InterruptedExc
103
102
runnable2 .waitForCompletion ();
104
103
}
105
104
105
+
106
106
private DefaultMessageListenerContainer createRunningContainer () {
107
107
DefaultMessageListenerContainer container = createContainer (createSuccessfulConnectionFactory ());
108
108
container .afterPropertiesSet ();
@@ -111,10 +111,8 @@ private DefaultMessageListenerContainer createRunningContainer() {
111
111
}
112
112
113
113
private DefaultMessageListenerContainer createContainer (ConnectionFactory connectionFactory ) {
114
-
115
114
Destination destination = new Destination () {};
116
115
117
-
118
116
DefaultMessageListenerContainer container = new DefaultMessageListenerContainer ();
119
117
container .setConnectionFactory (connectionFactory );
120
118
container .setCacheLevel (DefaultMessageListenerContainer .CACHE_NONE );
@@ -133,8 +131,8 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
133
131
});
134
132
return connectionFactory ;
135
133
}
136
- catch (JMSException e ) {
137
- throw new IllegalStateException (); // never happen
134
+ catch (JMSException ex ) {
135
+ throw new IllegalStateException (ex ); // never happen
138
136
}
139
137
}
140
138
@@ -143,7 +141,6 @@ private ConnectionFactory createRecoverableContainerFactory(final int failingAtt
143
141
ConnectionFactory connectionFactory = mock (ConnectionFactory .class );
144
142
given (connectionFactory .createConnection ()).will (new Answer <Object >() {
145
143
int currentAttempts = 0 ;
146
-
147
144
@ Override
148
145
public Object answer (InvocationOnMock invocation ) throws Throwable {
149
146
currentAttempts ++;
@@ -157,8 +154,8 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
157
154
});
158
155
return connectionFactory ;
159
156
}
160
- catch (JMSException e ) {
161
- throw new IllegalStateException (); // never happen
157
+ catch (JMSException ex ) {
158
+ throw new IllegalStateException (ex ); // never happen
162
159
}
163
160
}
164
161
@@ -168,12 +165,14 @@ private ConnectionFactory createSuccessfulConnectionFactory() {
168
165
given (connectionFactory .createConnection ()).willReturn (mock (Connection .class ));
169
166
return connectionFactory ;
170
167
}
171
- catch (JMSException e ) {
172
- throw new IllegalStateException (); // never happen
168
+ catch (JMSException ex ) {
169
+ throw new IllegalStateException (ex ); // never happen
173
170
}
174
171
}
175
172
173
+
176
174
private static class TestRunnable implements Runnable {
175
+
177
176
private final CountDownLatch countDownLatch = new CountDownLatch (1 );
178
177
179
178
@ Override
@@ -185,7 +184,6 @@ public void waitForCompletion() throws InterruptedException {
185
184
this .countDownLatch .await (2 , TimeUnit .SECONDS );
186
185
assertEquals ("callback was not invoked" , 0 , this .countDownLatch .getCount ());
187
186
}
188
-
189
187
}
190
188
191
189
}
0 commit comments