ServerTransportFactory { public static ServerTransport getServerTransport(ServerTransportConfig serverConfig) { ServerTransport serverTransport = ExtensionLoaderFactory.getExtensionLoader(ServerTransport.class) .getExtension(serverConfig.getContainer(), new Class[] { ServerTransportConfig.class }, new Object[] { serverConfig }); if (serverTransport != null) { String key = Integer.toString(serverConfig.getPort()); SERVER_TRANSPORT_MAP.put(key, serverTransport); } return serverTransport; }  static ServerTransport getServerTransport(ServerTransportConfig serverConfig); static final Map<String, ServerTransport> SERVER_TRANSPORT_MAP; }
@Test public void getServerTransport() throws Exception { ServerTransportConfig config = new ServerTransportConfig(); config.setHost("0.0.0.0"); config.setPort(22222); config.setBossThreads(1); config.setIoThreads(8); config.setBizMaxThreads(200); config.setBizPoolQueues(50); config.setDaemon(false); config.setContainer("test"); ServerTransport server = ServerTransportFactory.getServerTransport(config); Assert.assertNotNull(server); boolean error = false; try { config.setContainer("testasdasd"); ServerTransportFactory.getServerTransport(config); } catch (Exception e) { error = true; } Assert.assertTrue(error); }