TransportHandlerDelegate extends Delegate { @Override public void applyDelegate(Config config) { if (transportHandlerType == null) { return; } if (config.getDefaultClientConnection() == null) { config.setDefaultClientConnection(new OutboundConnection()); } if (config.getDefaultServerConnection() == null) { config.setDefaultServerConnection(new InboundConnection()); } config.getDefaultClientConnection().setTransportHandlerType(transportHandlerType); config.getDefaultServerConnection().setTransportHandlerType(transportHandlerType); } TransportHandlerDelegate(); TransportHandlerType getTransportHandlerType(); void setTransportHandlerType(TransportHandlerType transportHandlerType); @Override void applyDelegate(Config config);  }
@Test public void testApplyDelegate() { Config config = Config.createConfig(); config.getDefaultClientConnection().setTransportHandlerType(TransportHandlerType.TCP); config.getDefaultServerConnection().setTransportHandlerType(TransportHandlerType.TCP); args = new String[2]; args[0] = "-transport_handler_type"; args[1] = "UDP"; jcommander.parse(args); delegate.applyDelegate(config); assertThat(config.getDefaultClientConnection().getTransportHandlerType(), equalTo(TransportHandlerType.UDP)); assertThat(config.getDefaultServerConnection().getTransportHandlerType(), equalTo(TransportHandlerType.UDP)); }
@Test public void testNothingSetNothingChanges() { Config config = Config.createConfig(); Config config2 = Config.createConfig(); delegate.applyDelegate(config); assertTrue(EqualsBuilder.reflectionEquals(config, config2, "keyStore", "ourCertificate")); }