Skip to content

Commit 718ce02

Browse files
kenliao94mattrpav
authored andcommitted
Fix verify stop
1 parent 54f2e88 commit 718ce02

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCIOExceptionHandlerMockeryTest.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818

1919
import static org.junit.Assert.assertTrue;
2020
import static org.junit.Assert.fail;
21+
import static org.mockito.ArgumentMatchers.any;
22+
import static org.mockito.Mockito.doNothing;
2123
import static org.mockito.Mockito.mock;
24+
import static org.mockito.Mockito.timeout;
25+
import static org.mockito.Mockito.verify;
2226
import static org.mockito.Mockito.when;
2327

2428
import java.io.IOException;
@@ -27,14 +31,14 @@
2731
import org.apache.activemq.broker.Locker;
2832
import org.apache.activemq.broker.SuppressReplyException;
2933
import org.apache.activemq.util.LeaseLockerIOExceptionHandler;
30-
import org.apache.activemq.util.Wait;
34+
import org.apache.activemq.util.ServiceStopper;
3135
import org.junit.Test;
3236
import org.slf4j.Logger;
3337
import org.slf4j.LoggerFactory;
3438

3539
public class JDBCIOExceptionHandlerMockeryTest {
3640
private static final Logger LOG = LoggerFactory.getLogger(JDBCIOExceptionHandlerMockeryTest.class);
37-
private HashMap<Thread, Throwable> exceptions = new HashMap<Thread, Throwable>();
41+
private final HashMap<Thread, Throwable> exceptions = new HashMap<Thread, Throwable>();
3842

3943
@Test
4044
public void testShutdownWithoutTransportRestart() throws Exception {
@@ -52,8 +56,10 @@ public void testShutdownWithoutTransportRestart() throws Exception {
5256
when(brokerService.isStarted()).thenReturn(true);
5357
when(brokerService.isRestartAllowed()).thenReturn(false);
5458
when(brokerService.getPersistenceAdapter()).thenReturn(jdbcPersistenceAdapter);
59+
doNothing().when(brokerService).setSystemExitOnShutdown(false);
60+
doNothing().when(brokerService).stopAllConnectors(any(ServiceStopper.class));
5561
when(jdbcPersistenceAdapter.getLocker()).thenReturn(locker);
56-
when(locker.keepAlive()).thenReturn(true); // Connection is down
62+
when(locker.keepAlive()).thenReturn(true);
5763

5864
LeaseLockerIOExceptionHandler underTest = new LeaseLockerIOExceptionHandler();
5965
underTest.setBrokerService(brokerService);
@@ -64,7 +70,7 @@ public void testShutdownWithoutTransportRestart() throws Exception {
6470
} catch (SuppressReplyException expected) {
6571
}
6672

67-
73+
verify(brokerService, timeout(5000).times(1)).stop();
6874
assertTrue("no exceptions: " + exceptions, exceptions.isEmpty());
6975
}
7076
}

0 commit comments

Comments
 (0)