HttpClientFactory implements IMessagingClientFactory { public void stop() { this.logger.fine( "iPojo unregisters a servlet for HTTP messaging." ); resetClients( true ); } HttpClientFactory();  HttpClientFactory( BundleContext bundleContext ); synchronized void setHttpServerIp( final String serverIp ); synchronized void setHttpPort( final int port ); HttpDmClient getDmClient(); void start(); void stop(); @Override IMessagingClient createClient( ReconfigurableClient<?> parent ); @Override String getType(); @Override boolean setConfiguration( final Map<String, String> configuration ); void reconfigure();  }
@Test public void testStop() throws Exception { Assert.assertEquals( 0, this.factory.agentClients.size()); this.factory.stop(); testFactoryReconfigurationClientAgent(); Assert.assertEquals( 1, this.factory.agentClients.size()); this.factory.stop(); Assert.assertEquals( 0, this.factory.agentClients.size()); }
@Test @SuppressWarnings({ "rawtypes" }) public void testStop_errorOnClose() throws Exception { ReconfigurableClient parent = Mockito.mock( ReconfigurableClientDm.class ); Mockito.doThrow( new IOException( "For tests..." )).when( parent ).closeConnection(); HttpAgentClient client = new HttpAgentClient( parent, "localhost", 24587 ); this.factory.agentClients.add( client ); Assert.assertEquals( 1, this.factory.agentClients.size()); this.factory.stop(); Assert.assertEquals( 0, this.factory.agentClients.size()); Mockito.verify( parent, Mockito.times( 1 )).closeConnection(); }