@Override public void removeMessagingClientFactory( IMessagingClientFactory factory ) { String factoryType = factory != null ? factory.getType() : null; IMessagingClient oldClient = null; synchronized( this ) { if( this.messagingClient != null && this.messagingClient.getMessagingType().equals( factoryType )) { // This is the messaging factory we were using... // We must release our messaging client right now. oldClient = resetInternalClient(); } } terminateClient( oldClient, "The previous client could not be terminated correctly.", this.logger ); this.logger.fine( "A messaging factory was removed: " + factoryType ); }
@Override public void removeMessagingClientFactory( IMessagingClientFactory factory ) { String factoryType = factory != null ? factory.getType() : null; IMessagingClient oldClient = null; synchronized( this ) { if( this.messagingClient != null && this.messagingClient.getMessagingType().equals( factoryType )) { // This is the messaging factory we were using... // We must release our messaging client right now. oldClient = resetInternalClient(); } } terminateClient( oldClient, "The previous client could not be terminated correctly.", this.logger ); this.logger.fine( "A messaging factory was removed: " + factoryType ); }
terminateClient( oldClient, "The previous client could not be terminated correctly.", this.logger );
terminateClient( oldClient, "The previous client could not be terminated correctly.", this.logger );
@Test public void testTerminateClient_2() throws Exception { Logger logger = Logger.getLogger( getClass().getName()); JmxWrapperForMessagingClient client = Mockito.mock( JmxWrapperForMessagingClient.class ); ReconfigurableClient.terminateClient( client, "", logger ); Mockito.verify( client ).closeConnection(); Mockito.verify( client ).unregisterService();; Mockito.verifyNoMoreInteractions( client ); }
@Test public void testTerminateClient_3() throws Exception { Logger logger = Logger.getLogger( getClass().getName()); JmxWrapperForMessagingClient client = Mockito.mock( JmxWrapperForMessagingClient.class ); Mockito.doThrow( new IOException( "for test" )).when( client ).closeConnection(); ReconfigurableClient.terminateClient( client, "", logger ); Mockito.verify( client ).closeConnection(); Mockito.verify( client ).unregisterService();; Mockito.verifyNoMoreInteractions( client ); }
@Test public void testTerminateClient_1() throws Exception { Logger logger = Logger.getLogger( getClass().getName()); IMessagingClient client = Mockito.mock( IMessagingClient.class ); ReconfigurableClient.terminateClient( client, "", logger ); Mockito.verify( client, Mockito.only()).closeConnection(); }