@Test public void testStart_dmFound() throws Exception { Bundle b = Mockito.mock( Bundle.class ); Mockito.when( b.getSymbolicName()).thenReturn( "net.roboconf.dm" ); this.factory.httpService = Mockito.mock( HttpService.class ); this.factory.bundleContext = Mockito.mock( BundleContext.class ); Mockito.when( this.factory.bundleContext.getBundles()).thenReturn( new Bundle[] { b }); this.factory.start(); Mockito.verify( this.factory.httpService, Mockito.times( 1 )).registerServlet( Mockito.eq( HttpConstants.DM_SOCKET_PATH ), Mockito.any( Servlet.class ), Mockito.any( Dictionary.class ), Mockito.isNull( HttpContext.class )); }
public void start() throws Exception { boolean found = false; for( Bundle b : this.bundleContext.getBundles()) { if( "net.roboconf.dm".equals( b.getSymbolicName())) { found = true; break; } } if( found ) { this.logger.fine( "iPojo registers a servlet for HTTP messaging." ); Hashtable<String,String> initParams = new Hashtable<String,String> (); initParams.put( "servlet-name", "Roboconf DM (HTTP messaging)" ); DmWebSocketServlet messagingServlet = new DmWebSocketServlet( this ); this.httpService.registerServlet( HttpConstants.DM_SOCKET_PATH, messagingServlet, initParams, null ); } else { this.logger.warning( "Roboconf's DM bundle was not found. No servlet will be registered." ); } }
HttpClientFactory implements IMessagingClientFactory { public void start() throws Exception { boolean found = false; for( Bundle b : this.bundleContext.getBundles()) { if( "net.roboconf.dm".equals( b.getSymbolicName())) { found = true; break; } } if( found ) { this.logger.fine( "iPojo registers a servlet for HTTP messaging." ); Hashtable<String,String> initParams = new Hashtable<String,String> (); initParams.put( "servlet-name", "Roboconf DM (HTTP messaging)" ); DmWebSocketServlet messagingServlet = new DmWebSocketServlet( this ); this.httpService.registerServlet( HttpConstants.DM_SOCKET_PATH, messagingServlet, initParams, null ); } else { this.logger.warning( "Roboconf's DM bundle was not found. No servlet will be registered." ); } } }
HttpClientFactory implements IMessagingClientFactory { public void start() throws Exception { boolean found = false; for( Bundle b : this.bundleContext.getBundles()) { if( "net.roboconf.dm".equals( b.getSymbolicName())) { found = true; break; } } if( found ) { this.logger.fine( "iPojo registers a servlet for HTTP messaging." ); Hashtable<String,String> initParams = new Hashtable<String,String> (); initParams.put( "servlet-name", "Roboconf DM (HTTP messaging)" ); DmWebSocketServlet messagingServlet = new DmWebSocketServlet( this ); this.httpService.registerServlet( HttpConstants.DM_SOCKET_PATH, messagingServlet, initParams, null ); } else { this.logger.warning( "Roboconf's DM bundle was not found. No servlet will be registered." ); } } HttpClientFactory();  HttpClientFactory( BundleContext bundleContext ); }
HttpClientFactory implements IMessagingClientFactory { public void start() throws Exception { boolean found = false; for( Bundle b : this.bundleContext.getBundles()) { if( "net.roboconf.dm".equals( b.getSymbolicName())) { found = true; break; } } if( found ) { this.logger.fine( "iPojo registers a servlet for HTTP messaging." ); Hashtable<String,String> initParams = new Hashtable<String,String> (); initParams.put( "servlet-name", "Roboconf DM (HTTP messaging)" ); DmWebSocketServlet messagingServlet = new DmWebSocketServlet( this ); this.httpService.registerServlet( HttpConstants.DM_SOCKET_PATH, messagingServlet, initParams, null ); } else { this.logger.warning( "Roboconf's DM bundle was not found. No servlet will be registered." ); } } 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(); }
HttpClientFactory implements IMessagingClientFactory { public void start() throws Exception { boolean found = false; for( Bundle b : this.bundleContext.getBundles()) { if( "net.roboconf.dm".equals( b.getSymbolicName())) { found = true; break; } } if( found ) { this.logger.fine( "iPojo registers a servlet for HTTP messaging." ); Hashtable<String,String> initParams = new Hashtable<String,String> (); initParams.put( "servlet-name", "Roboconf DM (HTTP messaging)" ); DmWebSocketServlet messagingServlet = new DmWebSocketServlet( this ); this.httpService.registerServlet( HttpConstants.DM_SOCKET_PATH, messagingServlet, initParams, null ); } else { this.logger.warning( "Roboconf's DM bundle was not found. No servlet will be registered." ); } } 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();  }