case "hostsPath": if (member.getValue() instanceof String) { obj.setHostsPath((String)member.getValue());
@Test public void testResolveFromFile() { File f = new File(new File(new File(new File("src"), "test"), "resources"), "hosts_config.txt"); VertxInternal vertx = (VertxInternal) vertx(new VertxOptions().setAddressResolverOptions(new AddressResolverOptions().setHostsPath(f.getAbsolutePath()))); vertx.resolveAddress("server.net", onSuccess(addr -> { assertEquals("192.168.0.15", addr.getHostAddress()); assertEquals("server.net", addr.getHostName()); testComplete(); })); await(); }
@Test public void testInvalidHostsConfig() { try { AddressResolverOptions options = new AddressResolverOptions().setHostsPath("whatever.txt"); vertx(new VertxOptions().setAddressResolverOptions(options)); fail(); } catch (VertxException ignore) { } }
@Test public void testCaseInsensitiveResolveFromHosts() { VertxInternal vertx = (VertxInternal) vertx(new VertxOptions().setAddressResolverOptions(new AddressResolverOptions().setHostsPath("hosts_config.txt"))); vertx.resolveAddress("SERVER.NET", onSuccess(addr -> { assertEquals("192.168.0.15", addr.getHostAddress()); assertEquals("server.net", addr.getHostName()); testComplete(); })); await(); }
@Test public void testResolveFromClasspath() { VertxInternal vertx = (VertxInternal) vertx(new VertxOptions().setAddressResolverOptions(new AddressResolverOptions().setHostsPath("hosts_config.txt"))); vertx.resolveAddress("server.net", onSuccess(addr -> { assertEquals("192.168.0.15", addr.getHostAddress()); assertEquals("server.net", addr.getHostName()); testComplete(); })); await(); }
case "hostsPath": if (member.getValue() instanceof String) { obj.setHostsPath((String)member.getValue());
@Test public void testResolveFromFile() { File f = new File(new File(new File(new File("src"), "test"), "resources"), "hosts_config.txt"); VertxInternal vertx = (VertxInternal) vertx(new VertxOptions().setAddressResolverOptions(new AddressResolverOptions().setHostsPath(f.getAbsolutePath()))); vertx.resolveAddress("server.net", onSuccess(addr -> { assertEquals("192.168.0.15", addr.getHostAddress()); assertEquals("server.net", addr.getHostName()); testComplete(); })); await(); }
@Test public void testResolveFromClasspath() { VertxInternal vertx = (VertxInternal) vertx(new VertxOptions().setAddressResolverOptions(new AddressResolverOptions().setHostsPath("hosts_config.txt"))); vertx.resolveAddress("server.net", onSuccess(addr -> { assertEquals("192.168.0.15", addr.getHostAddress()); assertEquals("server.net", addr.getHostName()); testComplete(); })); await(); }
@Test public void testCaseInsensitiveResolveFromHosts() { VertxInternal vertx = (VertxInternal) vertx(new VertxOptions().setAddressResolverOptions(new AddressResolverOptions().setHostsPath("hosts_config.txt"))); vertx.resolveAddress("SERVER.NET", onSuccess(addr -> { assertEquals("192.168.0.15", addr.getHostAddress()); assertEquals("server.net", addr.getHostName()); testComplete(); })); await(); }
@Test public void testInvalidHostsConfig() { try { AddressResolverOptions options = new AddressResolverOptions().setHostsPath("whatever.txt"); vertx(new VertxOptions().setAddressResolverOptions(options)); fail(); } catch (VertxException ignore) { } }