@Test public void testCreateWithExtraConfig() throws EtiqetException { String serverClassName = "com.neueda.etiqet.core.testing.server.TestServer"; String configFile = "etiqet-core/src/test/resources/properties/testDefaultServer.properties"; String extraConfig = "src/test/resources/properties/test.properties"; Server server = ServerFactory.create(serverClassName, configFile, extraConfig); assertTrue(server instanceof TestServer); assertEquals(configFile, server.serverConfig); assertEquals(12, server.getConfig().getKeySet().size()); assertEquals("config.properties", server.getConfig().getString("fix.config.file.path")); assertEquals("server.cfg", server.getConfig().getString("fix.server.config.file.path")); assertEquals("database.properties", server.getConfig().getString("shell.database.properties.path")); assertEquals("remoteshell.properties", server.getConfig().getString("shell.remoteshell.properties.path")); assertEquals("protocolConfig.properties", server.getConfig().getString("config.protocol.file.path")); assertTrue(server.getConfig().getBoolean("test.boolean.true")); assertTrue(server.getConfig().getBoolean("test.boolean.convert.true")); assertFalse(server.getConfig().getBoolean("test.boolean.false")); assertFalse(server.getConfig().getBoolean("test.boolean.convert.false")); assertEquals(Integer.valueOf(20), server.getConfig().getInteger("test.int")); assertEquals(Long.valueOf(20), server.getConfig().getLong("test.int")); assertEquals(Double.valueOf(25.3), server.getConfig().getDouble("test.double")); assertEquals("etiqet-core/src/test/resources/properties/testConfig.properties", server.getConfig().getString("config.client.file.path")); }
public static Server create(String serverType) throws EtiqetException { Server instance; try { instance = (Server) Class.forName(serverType).newInstance(); } catch (Exception e) { LOG.error(ERROR_CREATING_SERVER + serverType, e); throw new EtiqetException(ERROR_CREATING_SERVER + serverType, e); } return instance; }
ServerFactory { public static Server create(String serverType) throws EtiqetException { Server instance; try { instance = (Server) Class.forName(serverType).newInstance(); } catch (Exception e) { LOG.error(ERROR_CREATING_SERVER + serverType, e); throw new EtiqetException(ERROR_CREATING_SERVER + serverType, e); } return instance; } }
ServerFactory { public static Server create(String serverType) throws EtiqetException { Server instance; try { instance = (Server) Class.forName(serverType).newInstance(); } catch (Exception e) { LOG.error(ERROR_CREATING_SERVER + serverType, e); throw new EtiqetException(ERROR_CREATING_SERVER + serverType, e); } return instance; } private  ServerFactory(); }
ServerFactory { public static Server create(String serverType) throws EtiqetException { Server instance; try { instance = (Server) Class.forName(serverType).newInstance(); } catch (Exception e) { LOG.error(ERROR_CREATING_SERVER + serverType, e); throw new EtiqetException(ERROR_CREATING_SERVER + serverType, e); } return instance; } private  ServerFactory(); static Server create(String serverType); static Server create(String serverType, String config); static Server create(String serverType, String config, String extraConfig); }
ServerFactory { public static Server create(String serverType) throws EtiqetException { Server instance; try { instance = (Server) Class.forName(serverType).newInstance(); } catch (Exception e) { LOG.error(ERROR_CREATING_SERVER + serverType, e); throw new EtiqetException(ERROR_CREATING_SERVER + serverType, e); } return instance; } private  ServerFactory(); static Server create(String serverType); static Server create(String serverType, String config); static Server create(String serverType, String config, String extraConfig);  }