private JerseyClientBuilder clientBuilder() { InMemoryDnsResolver customDnsResolver = new InMemoryDnsResolver(); for (TestRegister register : TestRegister.values()) { customDnsResolver.add(register.getHostname(), InetAddress.getLoopbackAddress()); } customDnsResolver.add("localhost", InetAddress.getLoopbackAddress()); return new JerseyClientBuilder(appRule.getEnvironment()) .using(appRule.getConfiguration().getJerseyClientConfiguration()) .using(customDnsResolver); }
@Override protected void configure(ServerBuilder sb) throws Exception { dnsResolver = new InMemoryDnsResolver(); dnsResolver.add("a.com", NetUtil.LOCALHOST4); dnsResolver.add("b.com", NetUtil.LOCALHOST4); dnsResolver.add("c.com", NetUtil.LOCALHOST4); dnsResolver.add("mismatch.com", NetUtil.LOCALHOST4); dnsResolver.add("127.0.0.1", NetUtil.LOCALHOST4); final VirtualHostBuilder a = new VirtualHostBuilder("a.com"); final VirtualHostBuilder b = new VirtualHostBuilder("b.com"); final VirtualHostBuilder c = new VirtualHostBuilder("c.com"); a.service("/", new SniTestService("a.com")); b.service("/", new SniTestService("b.com")); c.service("/", new SniTestService("c.com")); a.sslContext(HTTPS, sscA.certificateFile(), sscA.privateKeyFile()); b.sslContext(HTTPS, sscB.certificateFile(), sscB.privateKeyFile()); c.sslContext(HTTPS, sscC.certificateFile(), sscC.privateKeyFile()); sb.virtualHost(a.build()); sb.virtualHost(b.build()); sb.defaultVirtualHost(c.build()); sb.port(0, HTTPS); }
@Override protected ClientConnectionOperator createConnectionOperator(SchemeRegistry schemeRegistry) { resolver = new InMemoryDnsResolver(); DefaultClientConnectionOperator op = new DefaultClientConnectionOperator(schemeRegistry, resolver); return op; }