@Test public void testBasicCreateException() { String serverClassName = "com.neueda.etiqet.core.testing.FakeTestServer"; try { Server server = ServerFactory.create(serverClassName); fail("This should have thrown an exception because FakeTestServer shouldn't exist"); } catch (Exception e) { assertTrue(e instanceof EtiqetException); assertEquals("Error creating server of type: " + serverClassName, e.getMessage()); } }
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);  }