### Question:
ServientConfig { static ProtocolServer initializeServer(Config config, String serverName) throws ServientConfigException { try { Class<ProtocolServer> serverKlass = (Class<ProtocolServer>) Class.forName(serverName); Constructor<ProtocolServer> constructor; ProtocolServer server; if (hasConstructor(serverKlass, Config.class)) { constructor = serverKlass.getConstructor(Config.class); server = constructor.newInstance(config); } else { constructor = serverKlass.getConstructor(); server = constructor.newInstance(); } return server; } catch (ClassCastException | ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { throw new ServientConfigException(e); } } ServientConfig(List<ProtocolServer> servers,
                   Map<String, ProtocolClientFactory> clientFactories,
                   Map<String, Object> credentialStore);  ServientConfig(Config config); List<ProtocolServer> getServers(); Map<String, ProtocolClientFactory> getClientFactories(); Map<String, Object> getCredentialStore(); @Override String toString();  }### Answer:
@Test public void initializeServer() throws ServientConfigException { ProtocolServer server = ServientConfig.initializeServer(config, MyProtocolServer.class.getName()); assertThat(server, instanceOf(MyProtocolServer.class)); }
@Test(expected = ServientConfigException.class) public void initializeServerWithoutImplementation() throws ServientConfigException { ServientConfig.initializeServer(config, MyBadMissingImplementationProtocolServer.class.getName()); }
@Test(expected = ServientConfigException.class) public void initializeServerMissingConstructor() throws ServientConfigException { ServientConfig.initializeServer(config, MyBadMissingConstructorProtocolServer.class.getName()); }