1818
1919import static org .junit .Assert .assertTrue ;
2020import static org .junit .Assert .fail ;
21+ import static org .mockito .ArgumentMatchers .any ;
22+ import static org .mockito .Mockito .doNothing ;
2123import static org .mockito .Mockito .mock ;
24+ import static org .mockito .Mockito .timeout ;
25+ import static org .mockito .Mockito .verify ;
2226import static org .mockito .Mockito .when ;
2327
2428import java .io .IOException ;
2731import org .apache .activemq .broker .Locker ;
2832import org .apache .activemq .broker .SuppressReplyException ;
2933import org .apache .activemq .util .LeaseLockerIOExceptionHandler ;
30- import org .apache .activemq .util .Wait ;
34+ import org .apache .activemq .util .ServiceStopper ;
3135import org .junit .Test ;
3236import org .slf4j .Logger ;
3337import org .slf4j .LoggerFactory ;
3438
3539public 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