@Test public void testProxyConfig() { Config config = newConfig() .set("proxy", newConfig() .set("enabled", "true") .set("host", "example.com") .set("port", "9119") .set("user", "me") .set("password", "'(#%") .set("use_ssl", true)); TDClientBuilder builder = TDClientFactory.clientBuilderFromConfig( DEFAULT_DEFAULT_SYSTEM_CONFIG, ImmutableMap.of(), config, SECRETS); TDClientConfig clientConfig = builder.buildConfig(); assertThat(clientConfig.proxy.get().getUser(), is(Optional.of("me"))); assertThat(clientConfig.proxy.get().getPassword(), is(Optional.of("'(#%"))); assertThat(clientConfig.proxy.get().getUri(), is(URI.create("https: }
private static ProxyConfig proxyConfig(Config config, SecretProvider secrets) { ProxyConfig.ProxyConfigBuilder builder = new ProxyConfig.ProxyConfigBuilder(); Optional<String> host = secrets.getSecretOptional("host").or(config.getOptional("host", String.class)); if (host.isPresent()) { builder.setHost(host.get()); } Optional<Integer> port = secrets.getSecretOptional("port").transform(Integer::parseInt).or(config.getOptional("port", Integer.class)); if (port.isPresent()) { builder.setPort(port.get()); } Optional<String> user = secrets.getSecretOptional("user").or(config.getOptional("user", String.class)); if (user.isPresent()) { builder.setUser(user.get()); } Optional<String> password = secrets.getSecretOptional("password").or(config.getOptional("password", String.class)); if (password.isPresent()) { builder.setPassword(password.get()); } Optional<Boolean> useSsl = config.getOptional("use_ssl", Boolean.class); if (useSsl.isPresent()) { builder.useSSL(useSsl.get()); } return builder.createProxyConfig(); }
TDClientFactory { private static ProxyConfig proxyConfig(Config config, SecretProvider secrets) { ProxyConfig.ProxyConfigBuilder builder = new ProxyConfig.ProxyConfigBuilder(); Optional<String> host = secrets.getSecretOptional("host").or(config.getOptional("host", String.class)); if (host.isPresent()) { builder.setHost(host.get()); } Optional<Integer> port = secrets.getSecretOptional("port").transform(Integer::parseInt).or(config.getOptional("port", Integer.class)); if (port.isPresent()) { builder.setPort(port.get()); } Optional<String> user = secrets.getSecretOptional("user").or(config.getOptional("user", String.class)); if (user.isPresent()) { builder.setUser(user.get()); } Optional<String> password = secrets.getSecretOptional("password").or(config.getOptional("password", String.class)); if (password.isPresent()) { builder.setPassword(password.get()); } Optional<Boolean> useSsl = config.getOptional("use_ssl", Boolean.class); if (useSsl.isPresent()) { builder.useSSL(useSsl.get()); } return builder.createProxyConfig(); } }
TDClientFactory { private static ProxyConfig proxyConfig(Config config, SecretProvider secrets) { ProxyConfig.ProxyConfigBuilder builder = new ProxyConfig.ProxyConfigBuilder(); Optional<String> host = secrets.getSecretOptional("host").or(config.getOptional("host", String.class)); if (host.isPresent()) { builder.setHost(host.get()); } Optional<Integer> port = secrets.getSecretOptional("port").transform(Integer::parseInt).or(config.getOptional("port", Integer.class)); if (port.isPresent()) { builder.setPort(port.get()); } Optional<String> user = secrets.getSecretOptional("user").or(config.getOptional("user", String.class)); if (user.isPresent()) { builder.setUser(user.get()); } Optional<String> password = secrets.getSecretOptional("password").or(config.getOptional("password", String.class)); if (password.isPresent()) { builder.setPassword(password.get()); } Optional<Boolean> useSsl = config.getOptional("use_ssl", Boolean.class); if (useSsl.isPresent()) { builder.useSSL(useSsl.get()); } return builder.createProxyConfig(); }  }
TDClientFactory { private static ProxyConfig proxyConfig(Config config, SecretProvider secrets) { ProxyConfig.ProxyConfigBuilder builder = new ProxyConfig.ProxyConfigBuilder(); Optional<String> host = secrets.getSecretOptional("host").or(config.getOptional("host", String.class)); if (host.isPresent()) { builder.setHost(host.get()); } Optional<Integer> port = secrets.getSecretOptional("port").transform(Integer::parseInt).or(config.getOptional("port", Integer.class)); if (port.isPresent()) { builder.setPort(port.get()); } Optional<String> user = secrets.getSecretOptional("user").or(config.getOptional("user", String.class)); if (user.isPresent()) { builder.setUser(user.get()); } Optional<String> password = secrets.getSecretOptional("password").or(config.getOptional("password", String.class)); if (password.isPresent()) { builder.setPassword(password.get()); } Optional<Boolean> useSsl = config.getOptional("use_ssl", Boolean.class); if (useSsl.isPresent()) { builder.useSSL(useSsl.get()); } return builder.createProxyConfig(); }   }
TDClientFactory { private static ProxyConfig proxyConfig(Config config, SecretProvider secrets) { ProxyConfig.ProxyConfigBuilder builder = new ProxyConfig.ProxyConfigBuilder(); Optional<String> host = secrets.getSecretOptional("host").or(config.getOptional("host", String.class)); if (host.isPresent()) { builder.setHost(host.get()); } Optional<Integer> port = secrets.getSecretOptional("port").transform(Integer::parseInt).or(config.getOptional("port", Integer.class)); if (port.isPresent()) { builder.setPort(port.get()); } Optional<String> user = secrets.getSecretOptional("user").or(config.getOptional("user", String.class)); if (user.isPresent()) { builder.setUser(user.get()); } Optional<String> password = secrets.getSecretOptional("password").or(config.getOptional("password", String.class)); if (password.isPresent()) { builder.setPassword(password.get()); } Optional<Boolean> useSsl = config.getOptional("use_ssl", Boolean.class); if (useSsl.isPresent()) { builder.useSSL(useSsl.get()); } return builder.createProxyConfig(); }    }