--- old/test/jdk/com/sun/jndi/dns/lib/DNSTestUtils.java 2018-03-22 09:58:53.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/lib/DNSTestUtils.java 2018-03-22 09:58:52.000000000 +0800 @@ -24,6 +24,7 @@ import javax.naming.Context; import javax.naming.NamingException; import javax.naming.directory.Attributes; +import java.io.Closeable; import java.io.PrintStream; import java.net.DatagramSocket; import java.nio.file.Files; @@ -149,6 +150,19 @@ } } + /* + * Clean up given closable resource + */ + public static void cleanupClosableRes(Closeable res) { + if (res != null) { + try { + res.close(); + } catch (Exception e) { + // ignore + } + } + } + private static void extractProperty(String propString, Hashtable env) { int index; @@ -243,4 +257,21 @@ throw new RuntimeException("Check schema failed."); } } + + public static String getRootUrl(Hashtable env) { + return (String) env.get(TEST_DNS_ROOT_URL); + } + + /* + * Assemble a fully-qualified domain name from the base component and the + * domain name. + */ + public static String buildFqdn(String base, Hashtable env, + boolean primary) { + String domain = (String) (primary ? + env.get("DNS_DOMAIN") : + env.get("FOREIGN_DOMAIN")); + + return base + "." + domain; + } }