Skip to content

Commit 07ea374

Browse files
committed
Polishing
1 parent 09b45d2 commit 07ea374

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

spring-jms/src/test/java/org/springframework/jms/listener/DefaultMessageListenerContainerTests.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import static org.mockito.BDDMockito.*;
3535

3636
/**
37-
*
3837
* @author Stephane Nicoll
3938
*/
4039
public class DefaultMessageListenerContainerTests {
@@ -103,6 +102,7 @@ public void runnableIsInvokedEvenIfContainerIsNotRunning() throws InterruptedExc
103102
runnable2.waitForCompletion();
104103
}
105104

105+
106106
private DefaultMessageListenerContainer createRunningContainer() {
107107
DefaultMessageListenerContainer container = createContainer(createSuccessfulConnectionFactory());
108108
container.afterPropertiesSet();
@@ -111,10 +111,8 @@ private DefaultMessageListenerContainer createRunningContainer() {
111111
}
112112

113113
private DefaultMessageListenerContainer createContainer(ConnectionFactory connectionFactory) {
114-
115114
Destination destination = new Destination() {};
116115

117-
118116
DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
119117
container.setConnectionFactory(connectionFactory);
120118
container.setCacheLevel(DefaultMessageListenerContainer.CACHE_NONE);
@@ -133,8 +131,8 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
133131
});
134132
return connectionFactory;
135133
}
136-
catch (JMSException e) {
137-
throw new IllegalStateException(); // never happen
134+
catch (JMSException ex) {
135+
throw new IllegalStateException(ex); // never happen
138136
}
139137
}
140138

@@ -143,7 +141,6 @@ private ConnectionFactory createRecoverableContainerFactory(final int failingAtt
143141
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
144142
given(connectionFactory.createConnection()).will(new Answer<Object>() {
145143
int currentAttempts = 0;
146-
147144
@Override
148145
public Object answer(InvocationOnMock invocation) throws Throwable {
149146
currentAttempts++;
@@ -157,8 +154,8 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
157154
});
158155
return connectionFactory;
159156
}
160-
catch (JMSException e) {
161-
throw new IllegalStateException(); // never happen
157+
catch (JMSException ex) {
158+
throw new IllegalStateException(ex); // never happen
162159
}
163160
}
164161

@@ -168,12 +165,14 @@ private ConnectionFactory createSuccessfulConnectionFactory() {
168165
given(connectionFactory.createConnection()).willReturn(mock(Connection.class));
169166
return connectionFactory;
170167
}
171-
catch (JMSException e) {
172-
throw new IllegalStateException(); // never happen
168+
catch (JMSException ex) {
169+
throw new IllegalStateException(ex); // never happen
173170
}
174171
}
175172

173+
176174
private static class TestRunnable implements Runnable {
175+
177176
private final CountDownLatch countDownLatch = new CountDownLatch(1);
178177

179178
@Override
@@ -185,7 +184,6 @@ public void waitForCompletion() throws InterruptedException {
185184
this.countDownLatch.await(2, TimeUnit.SECONDS);
186185
assertEquals("callback was not invoked", 0, this.countDownLatch.getCount());
187186
}
188-
189187
}
190188

191189
}

0 commit comments

Comments
 (0)