< prev index next >
test/jdk/com/sun/jndi/dns/lib/DNSTestUtils.java
Print this page
*** 22,31 ****
--- 22,32 ----
*/
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;
import java.nio.file.Path;
import java.nio.file.Paths;
*** 147,156 ****
--- 148,170 ----
// ignore
}
}
}
+ /*
+ * 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<Object, Object> env) {
int index;
if ((index = propString.indexOf('=')) > 0) {
*** 241,246 ****
--- 255,277 ----
debug(attrs);
if (!checkSchema(attrs, mandatory, optional)) {
throw new RuntimeException("Check schema failed.");
}
}
+
+ public static String getRootUrl(Hashtable<Object, Object> 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<Object, Object> env,
+ boolean primary) {
+ String domain = (String) (primary ?
+ env.get("DNS_DOMAIN") :
+ env.get("FOREIGN_DOMAIN"));
+
+ return base + "." + domain;
+ }
}
< prev index next >