8210339: Add 10 JNDI tests to com/sun/jndi/dns/FedTests/
authorxyin
Mon, 22 Oct 2018 14:08:07 +0800
changeset 52207 bca2b63dd839
parent 52206 2e495bbdc2b7
child 52208 5bf98ad48412
8210339: Add 10 JNDI tests to com/sun/jndi/dns/FedTests/ Reviewed-by: vtewari, rriggs
test/jdk/com/sun/jndi/dns/FedTests/CannotProceed.dns
test/jdk/com/sun/jndi/dns/FedTests/CannotProceed.java
test/jdk/com/sun/jndi/dns/FedTests/FedObjectFactory.java
test/jdk/com/sun/jndi/dns/FedTests/FedSubordinateNs.java
test/jdk/com/sun/jndi/dns/FedTests/GetAttrsNns.dns
test/jdk/com/sun/jndi/dns/FedTests/GetAttrsNns.java
test/jdk/com/sun/jndi/dns/FedTests/GetAttrsSubInterior.dns
test/jdk/com/sun/jndi/dns/FedTests/GetAttrsSubInterior.java
test/jdk/com/sun/jndi/dns/FedTests/GetAttrsSubLeaf.dns
test/jdk/com/sun/jndi/dns/FedTests/GetAttrsSubLeaf.java
test/jdk/com/sun/jndi/dns/FedTests/ListFedBase.java
test/jdk/com/sun/jndi/dns/FedTests/ListNns.dns
test/jdk/com/sun/jndi/dns/FedTests/ListNns.java
test/jdk/com/sun/jndi/dns/FedTests/ListSubInterior.dns
test/jdk/com/sun/jndi/dns/FedTests/ListSubInterior.java
test/jdk/com/sun/jndi/dns/FedTests/ListSubLeaf.dns
test/jdk/com/sun/jndi/dns/FedTests/ListSubLeaf.java
test/jdk/com/sun/jndi/dns/FedTests/LookupNns.dns
test/jdk/com/sun/jndi/dns/FedTests/LookupNns.java
test/jdk/com/sun/jndi/dns/FedTests/LookupSubInterior.dns
test/jdk/com/sun/jndi/dns/FedTests/LookupSubInterior.java
test/jdk/com/sun/jndi/dns/FedTests/LookupSubLeaf.dns
test/jdk/com/sun/jndi/dns/FedTests/LookupSubLeaf.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jndi/dns/FedTests/CannotProceed.dns	Mon Oct 22 14:08:07 2018 +0800
@@ -0,0 +1,50 @@
+#
+# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+################################################################################
+# Capture file for CannotProceed.java
+#
+# NOTE: This hexadecimal dump of DNS protocol messages was generated by
+#       running the CannotProceed application program against a real DNS
+#       server along with DNSTracer
+#
+################################################################################
+
+# DNS Request
+
+0000: A0 F4 01 00 00 01 00 00   00 00 00 00 05 68 6F 73  .............hos
+0010: 74 31 07 64 6F 6D 61 69   6E 31 03 63 6F 6D 00 00  t1.domain1.com..
+0020: 10 00 01                                           ...
+
+
+# DNS Response
+
+0000: A0 F4 85 80 00 01 00 01   00 01 00 01 05 68 6F 73  .............hos
+0010: 74 31 07 64 6F 6D 61 69   6E 31 03 63 6F 6D 00 00  t1.domain1.com..
+0020: 10 00 01 C0 0C 00 10 00   01 00 00 8C A0 00 15 14  ................
+0030: 41 20 76 65 72 79 20 70   6F 70 75 6C 61 72 20 68  A very popular h
+0040: 6F 73 74 2E C0 12 00 02   00 01 00 00 8C A0 00 05  ost.............
+0050: 02 6E 73 C0 12 C0 50 00   01 00 01 00 00 8C A0 00  .ns...P.........
+0060: 04 7F 00 00 01                                     .....
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jndi/dns/FedTests/CannotProceed.java	Mon Oct 22 14:08:07 2018 +0800
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.naming.CannotProceedException;
+import javax.naming.directory.InitialDirContext;
+
+/*
+ * @test
+ * @bug 8210339
+ * @summary Try to do a look up beyond DNS with no appropriate subordinate ns
+ *          should result in a CannotProceedException.
+ * @library ../lib/
+ * @modules java.base/sun.security.util
+ * @run main CannotProceed
+ */
+
+public class CannotProceed extends DNSTestBase {
+
+    public static void main(String[] args) throws Exception {
+        new CannotProceed().run(args);
+    }
+
+    /*
+     * Try to do a look up beyond DNS with no appropriate subordinate ns
+     * should result in a CannotProceedException.
+     */
+    @Override
+    public void runTest() throws Exception {
+        setContext(new InitialDirContext(env()));
+        Object nns = context().lookup("host1" + "/a/b/c");
+        DNSTestUtils.debug("obj is: " + nns);
+        throw new RuntimeException("Failed: expecting CannotProceedException");
+    }
+
+    @Override
+    public boolean handleException(Exception e) {
+        if (e instanceof CannotProceedException) {
+            System.out.println("Got expected exception: " + e);
+            return true;
+        }
+
+        return super.handleException(e);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jndi/dns/FedTests/FedObjectFactory.java	Mon Oct 22 14:08:07 2018 +0800
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.spi.ObjectFactory;
+import java.util.Hashtable;
+
+/*
+ * This class is used to support dynamic nns, for testing federation of
+ * the DNS service provider.
+ */
+public class FedObjectFactory implements ObjectFactory {
+    @Override
+    public Object getObjectInstance(Object obj, Name name, Context nameCtx,
+            Hashtable<?, ?> environment) {
+        if (name != null && name.get(name.size() - 1).equals("")) {
+            System.out.println("got nns name");
+            return FedSubordinateNs.getRoot();
+        }
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jndi/dns/FedTests/FedSubordinateNs.java	Mon Oct 22 14:08:07 2018 +0800
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import com.sun.jndi.toolkit.dir.HierMemDirCtx;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+
+/*
+ * This class is responsible for creating a temporary namespace to be
+ * used in federation tests.
+ */
+public class FedSubordinateNs {
+    static DirContext root = null;
+
+    static {
+        try {
+            Attributes rootAttrs = new BasicAttributes("name", "root");
+            rootAttrs.put("description", "in-memory root");
+
+            Attributes aAttrs = new BasicAttributes("name", "a");
+            aAttrs.put("description", "in-memory 1st level");
+
+            Attributes bAttrs = new BasicAttributes("name", "b");
+            bAttrs.put("description", "in-memory 2nd level");
+
+            Attributes cAttrs = new BasicAttributes("name", "c");
+            cAttrs.put("description", "in-memory 3rd level");
+
+            root = new HierMemDirCtx();
+            root.modifyAttributes("", DirContext.ADD_ATTRIBUTE, rootAttrs);
+
+            root.createSubcontext("a", aAttrs);
+            root.createSubcontext("a/b", bAttrs);
+            root.createSubcontext("a/b/c", cAttrs);
+            root.createSubcontext("x");
+        } catch (NamingException e) {
+            System.out.println("Problem in static initialization of root:" + e);
+        }
+    }
+
+    static DirContext getRoot() {
+        return root;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jndi/dns/FedTests/GetAttrsNns.dns	Mon Oct 22 14:08:07 2018 +0800
@@ -0,0 +1,50 @@
+#
+# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+################################################################################
+# Capture file for GetAttrsNns.java
+#
+# NOTE: This hexadecimal dump of DNS protocol messages was generated by
+#       running the GetAttrsNns application program against a real DNS
+#       server along with DNSTracer
+#
+################################################################################
+
+# DNS Request
+
+0000: 54 E6 01 00 00 01 00 00   00 00 00 00 05 68 6F 73  T............hos
+0010: 74 31 07 64 6F 6D 61 69   6E 31 03 63 6F 6D 00 00  t1.domain1.com..
+0020: 10 00 01                                           ...
+
+
+# DNS Response
+
+0000: 54 E6 85 80 00 01 00 01   00 01 00 01 05 68 6F 73  T............hos
+0010: 74 31 07 64 6F 6D 61 69   6E 31 03 63 6F 6D 00 00  t1.domain1.com..
+0020: 10 00 01 C0 0C 00 10 00   01 00 00 8C A0 00 15 14  ................
+0030: 41 20 76 65 72 79 20 70   6F 70 75 6C 61 72 20 68  A very popular h
+0040: 6F 73 74 2E C0 12 00 02   00 01 00 00 8C A0 00 05  ost.............
+0050: 02 6E 73 C0 12 C0 50 00   01 00 01 00 00 8C A0 00  .ns...P.........
+0060: 04 7F 00 00 01                                     .....
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jndi/dns/FedTests/GetAttrsNns.java	Mon Oct 22 14:08:07 2018 +0800
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.InitialDirContext;
+
+/*
+ * @test
+ * @bug 8210339
+ * @summary Tests that we can get the attributes of the nns of a DNS entry.
+ *          Use getAttributes form that has no attrIds parameter.
+ * @library ../lib/ ../AttributeTests/
+ * @modules java.naming/com.sun.jndi.toolkit.dir
+ *          java.base/sun.security.util
+ * @build FedSubordinateNs FedObjectFactory
+ * @run main/othervm GetAttrsNns
+ */
+
+public class GetAttrsNns extends GetAttrsBase {
+
+    public GetAttrsNns() {
+        setMandatoryAttrs("name", "description");
+    }
+
+    public static void main(String[] args) throws Exception {
+        new GetAttrsNns().run(args);
+    }
+
+    /*
+     * Tests that we can get the attributes of the nns of a DNS entry.
+     */
+    @Override
+    public void runTest() throws Exception {
+        env().put(Context.OBJECT_FACTORIES, "FedObjectFactory");
+        setContext(new InitialDirContext(env()));
+
+        Attributes retAttrs = getAttributes();
+        verifyAttributes(retAttrs);
+    }
+
+    /*
+     * Use getAttributes form that has no attrIds parameter.
+     */
+    @Override
+    public Attributes getAttributes() throws NamingException {
+        return context().getAttributes(getKey() + "/");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jndi/dns/FedTests/GetAttrsSubInterior.dns	Mon Oct 22 14:08:07 2018 +0800
@@ -0,0 +1,50 @@
+#
+# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+################################################################################
+# Capture file for GetAttrsSubInterior.java
+#
+# NOTE: This hexadecimal dump of DNS protocol messages was generated by
+#       running the GetAttrsSubInterior application program against a real DNS
+#       server along with DNSTracer
+#
+################################################################################
+
+# DNS Request
+
+0000: 5F 82 01 00 00 01 00 00   00 00 00 00 05 68 6F 73  _............hos
+0010: 74 31 07 64 6F 6D 61 69   6E 31 03 63 6F 6D 00 00  t1.domain1.com..
+0020: 10 00 01                                           ...
+
+
+# DNS Response
+
+0000: 5F 82 85 80 00 01 00 01   00 01 00 01 05 68 6F 73  _............hos
+0010: 74 31 07 64 6F 6D 61 69   6E 31 03 63 6F 6D 00 00  t1.domain1.com..
+0020: 10 00 01 C0 0C 00 10 00   01 00 00 8C A0 00 15 14  ................
+0030: 41 20 76 65 72 79 20 70   6F 70 75 6C 61 72 20 68  A very popular h
+0040: 6F 73 74 2E C0 12 00 02   00 01 00 00 8C A0 00 05  ost.............
+0050: 02 6E 73 C0 12 C0 50 00   01 00 01 00 00 8C A0 00  .ns...P.........
+0060: 04 7F 00 00 01                                     .....
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jndi/dns/FedTests/GetAttrsSubInterior.java	Mon Oct 22 14:08:07 2018 +0800
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.InitialDirContext;
+
+/*
+ * @test
+ * @bug 8210339
+ * @summary Tests that we can get the attributes of the interior node
+ *          in the subordinate naming system of a DNS entry.
+ *          Use getAttributes form that has no attrIds parameter.
+ * @library ../lib/ ../AttributeTests/
+ * @modules java.naming/com.sun.jndi.toolkit.dir
+ *          java.base/sun.security.util
+ * @build FedSubordinateNs FedObjectFactory
+ * @run main/othervm GetAttrsSubInterior
+ */
+
+public class GetAttrsSubInterior extends GetAttrsBase {
+
+    // pre defined attribute value for '/a/b'
+    public static final String ATTRIBUTE_VALUE = "b";
+
+    public GetAttrsSubInterior() {
+        setMandatoryAttrs("name", "description");
+    }
+
+    public static void main(String[] args) throws Exception {
+        new GetAttrsSubInterior().run(args);
+    }
+
+    /*
+     * Tests that we can get the attributes of the interior node
+     * in the subordinate naming system of a DNS entry.
+     */
+    @Override
+    public void runTest() throws Exception {
+        env().put(Context.OBJECT_FACTORIES, "FedObjectFactory");
+        setContext(new InitialDirContext(env()));
+
+        Attributes retAttrs = getAttributes();
+        Attribute attr = retAttrs.get("name");
+        verifyAttributes(retAttrs);
+        verifyAttribute(attr);
+    }
+
+    /*
+     * Use getAttributes form that has no attrIds parameter.
+     */
+    @Override
+    public Attributes getAttributes() throws NamingException {
+        return context().getAttributes(getKey() + "/a/b");
+    }
+
+    private void verifyAttribute(Attribute attr) throws NamingException {
+        if (attr == null || !ATTRIBUTE_VALUE.equals(attr.get())) {
+            throw new RuntimeException(
+                    "Expecting attribute value: " + ATTRIBUTE_VALUE
+                            + ", but actual: " + (attr != null ?
+                            attr.get() :
+                            attr));
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jndi/dns/FedTests/GetAttrsSubLeaf.dns	Mon Oct 22 14:08:07 2018 +0800
@@ -0,0 +1,50 @@
+#
+# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+################################################################################
+# Capture file for GetAttrsSubLeaf.java
+#
+# NOTE: This hexadecimal dump of DNS protocol messages was generated by
+#       running the GetAttrsSubLeaf application program against a real DNS
+#       server along with DNSTracer
+#
+################################################################################
+
+# DNS Request
+
+0000: F6 56 01 00 00 01 00 00   00 00 00 00 05 68 6F 73  .V...........hos
+0010: 74 31 07 64 6F 6D 61 69   6E 31 03 63 6F 6D 00 00  t1.domain1.com..
+0020: 10 00 01                                           ...
+
+
+# DNS Response
+
+0000: F6 56 85 80 00 01 00 01   00 01 00 01 05 68 6F 73  .V...........hos
+0010: 74 31 07 64 6F 6D 61 69   6E 31 03 63 6F 6D 00 00  t1.domain1.com..
+0020: 10 00 01 C0 0C 00 10 00   01 00 00 8C A0 00 15 14  ................
+0030: 41 20 76 65 72 79 20 70   6F 70 75 6C 61 72 20 68  A very popular h
+0040: 6F 73 74 2E C0 12 00 02   00 01 00 00 8C A0 00 05  ost.............
+0050: 02 6E 73 C0 12 C0 50 00   01 00 01 00 00 8C A0 00  .ns...P.........
+0060: 04 7F 00 00 01                                     .....
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jndi/dns/FedTests/GetAttrsSubLeaf.java	Mon Oct 22 14:08:07 2018 +0800
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.InitialDirContext;
+
+/*
+ * @test
+ * @bug 8210339
+ * @summary Tests that we can get the attributes of the leaf node
+ *          in the subordinate naming system of a DNS entry.
+ *          Use getAttributes form that has no attrIds parameter.
+ * @library ../lib/ ../AttributeTests/
+ * @modules java.naming/com.sun.jndi.toolkit.dir
+ *          java.base/sun.security.util
+ * @build FedSubordinateNs FedObjectFactory
+ * @run main/othervm GetAttrsSubLeaf
+ */
+
+public class GetAttrsSubLeaf extends GetAttrsBase {
+
+    // pre defined attribute value for '/a/b/c'
+    public static final String ATTRIBUTE_VALUE = "c";
+
+    public GetAttrsSubLeaf() {
+        setMandatoryAttrs("name", "description");
+    }
+
+    public static void main(String[] args) throws Exception {
+        new GetAttrsSubLeaf().run(args);
+    }
+
+    /*
+     * Tests that we can get the attributes of the leaf node
+     * in the subordinate naming system of a DNS entry.
+     */
+    @Override
+    public void runTest() throws Exception {
+        env().put(Context.OBJECT_FACTORIES, "FedObjectFactory");
+        setContext(new InitialDirContext(env()));
+
+        Attributes retAttrs = getAttributes();
+        Attribute attr = retAttrs.get("name");
+        verifyAttributes(retAttrs);
+        verifyAttribute(attr);
+    }
+
+    /*
+     * Use getAttributes form that has no attrIds parameter.
+     */
+    @Override
+    public Attributes getAttributes() throws NamingException {
+        return context().getAttributes(getKey() + "/a/b/c");
+    }
+
+    private void verifyAttribute(Attribute attr) throws NamingException {
+        if (attr == null || !ATTRIBUTE_VALUE.equals(attr.get())) {
+            throw new RuntimeException(
+                    "Expecting attribute value: " + ATTRIBUTE_VALUE
+                            + ", but actual: " + (attr != null ?
+                            attr.get() :
+                            attr));
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jndi/dns/FedTests/ListFedBase.java	Mon Oct 22 14:08:07 2018 +0800
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.naming.Binding;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+
+/**
+ * Abstract test base for Fed list related test, this class extends DNSTestBase.
+ *
+ * @see DNSTestBase
+ * @see TestBase
+ */
+abstract class ListFedBase extends DNSTestBase {
+    private String key;
+
+    public ListFedBase() {
+        // set default test data
+        setKey("host1");
+    }
+
+    /**
+     * Verify given NamingEnumeration match expected count.
+     *
+     * @param enumObj       given NamingEnumeration instance
+     * @param expectedCount given expected count
+     * @throws NamingException
+     */
+    public void verifyNamingEnumeration(NamingEnumeration enumObj,
+            int expectedCount) throws NamingException {
+        DNSTestUtils.debug("Enum is: " + enumObj);
+
+        int count = 0;
+        Binding res;
+
+        while (enumObj.hasMore()) {
+            res = (Binding) enumObj.next();
+            DNSTestUtils.debug(res);
+            ++count;
+        }
+
+        if (count != expectedCount) {
+            throw new RuntimeException(
+                    "Expecting " + expectedCount + " entries but got " + count);
+        }
+    }
+
+    public String getKey() {
+        return key;
+    }
+
+    public void setKey(String key) {
+        this.key = key;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jndi/dns/FedTests/ListNns.dns	Mon Oct 22 14:08:07 2018 +0800
@@ -0,0 +1,50 @@
+#
+# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+################################################################################
+# Capture file for ListNns.java
+#
+# NOTE: This hexadecimal dump of DNS protocol messages was generated by
+#       running the ListNns application program against a real DNS
+#       server along with DNSTracer
+#
+################################################################################
+
+# DNS Request
+
+0000: 61 43 01 00 00 01 00 00   00 00 00 00 05 68 6F 73  aC...........hos
+0010: 74 31 07 64 6F 6D 61 69   6E 31 03 63 6F 6D 00 00  t1.domain1.com..
+0020: 10 00 01                                           ...
+
+
+# DNS Response
+
+0000: 61 43 85 80 00 01 00 01   00 01 00 01 05 68 6F 73  aC...........hos
+0010: 74 31 07 64 6F 6D 61 69   6E 31 03 63 6F 6D 00 00  t1.domain1.com..
+0020: 10 00 01 C0 0C 00 10 00   01 00 00 8C A0 00 15 14  ................
+0030: 41 20 76 65 72 79 20 70   6F 70 75 6C 61 72 20 68  A very popular h
+0040: 6F 73 74 2E C0 12 00 02   00 01 00 00 8C A0 00 05  ost.............
+0050: 02 6E 73 C0 12 C0 50 00   01 00 01 00 00 8C A0 00  .ns...P.........
+0060: 04 7F 00 00 01                                     .....
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jndi/dns/FedTests/ListNns.java	Mon Oct 22 14:08:07 2018 +0800
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.naming.Context;
+import javax.naming.NamingEnumeration;
+import javax.naming.directory.InitialDirContext;
+
+/*
+ * @test
+ * @bug 8210339
+ * @summary Test that we can List the nns of a DNS entry.
+ * @library ../lib/
+ * @modules java.naming/com.sun.jndi.toolkit.dir
+ *          java.base/sun.security.util
+ * @build FedSubordinateNs FedObjectFactory
+ * @run main/othervm ListNns
+ */
+
+public class ListNns extends ListFedBase {
+
+    private static final int COUNT_LIMIT = 2; // a, x - 2 entries
+
+    public static void main(String[] args) throws Exception {
+        new ListNns().run(args);
+    }
+
+    /*
+     * Test that we can List the nns of a DNS entry.
+     */
+    @Override
+    public void runTest() throws Exception {
+        env().put(Context.OBJECT_FACTORIES, "FedObjectFactory");
+        setContext(new InitialDirContext(env()));
+
+        NamingEnumeration enumObj = context().listBindings(getKey() + "/");
+        verifyNamingEnumeration(enumObj, COUNT_LIMIT);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jndi/dns/FedTests/ListSubInterior.dns	Mon Oct 22 14:08:07 2018 +0800
@@ -0,0 +1,50 @@
+#
+# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+################################################################################
+# Capture file for ListSubInterior.java
+#
+# NOTE: This hexadecimal dump of DNS protocol messages was generated by
+#       running the ListSubInterior application program against a real DNS
+#       server along with DNSTracer
+#
+################################################################################
+
+# DNS Request
+
+0000: C3 12 01 00 00 01 00 00   00 00 00 00 05 68 6F 73  .............hos
+0010: 74 31 07 64 6F 6D 61 69   6E 31 03 63 6F 6D 00 00  t1.domain1.com..
+0020: 10 00 01                                           ...
+
+
+# DNS Response
+
+0000: C3 12 85 80 00 01 00 01   00 01 00 01 05 68 6F 73  .............hos
+0010: 74 31 07 64 6F 6D 61 69   6E 31 03 63 6F 6D 00 00  t1.domain1.com..
+0020: 10 00 01 C0 0C 00 10 00   01 00 00 8C A0 00 15 14  ................
+0030: 41 20 76 65 72 79 20 70   6F 70 75 6C 61 72 20 68  A very popular h
+0040: 6F 73 74 2E C0 12 00 02   00 01 00 00 8C A0 00 05  ost.............
+0050: 02 6E 73 C0 12 C0 50 00   01 00 01 00 00 8C A0 00  .ns...P.........
+0060: 04 7F 00 00 01                                     .....
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jndi/dns/FedTests/ListSubInterior.java	Mon Oct 22 14:08:07 2018 +0800
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.naming.Context;
+import javax.naming.NamingEnumeration;
+import javax.naming.directory.InitialDirContext;
+
+/*
+ * @test
+ * @bug 8210339
+ * @summary list of a interior using a composite name with DNS name
+ *          as first component
+ * @library ../lib/
+ * @modules java.naming/com.sun.jndi.toolkit.dir
+ *          java.base/sun.security.util
+ * @build FedSubordinateNs FedObjectFactory
+ * @run main/othervm ListSubInterior
+ */
+
+public class ListSubInterior extends ListFedBase {
+
+    private static final int COUNT_LIMIT = 1; // c - 1 entry
+
+    public static void main(String[] args) throws Exception {
+        new ListSubInterior().run(args);
+    }
+
+    /*
+     * list of a interior using a composite name with DNS name
+     * as first component
+     */
+    @Override
+    public void runTest() throws Exception {
+        env().put(Context.OBJECT_FACTORIES, "FedObjectFactory");
+        setContext(new InitialDirContext(env()));
+
+        NamingEnumeration enumObj = context().listBindings(getKey() + "/a/b");
+        verifyNamingEnumeration(enumObj, COUNT_LIMIT);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jndi/dns/FedTests/ListSubLeaf.dns	Mon Oct 22 14:08:07 2018 +0800
@@ -0,0 +1,50 @@
+#
+# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+################################################################################
+# Capture file for ListSubLeaf.java
+#
+# NOTE: This hexadecimal dump of DNS protocol messages was generated by
+#       running the ListSubLeaf application program against a real DNS
+#       server along with DNSTracer
+#
+################################################################################
+
+# DNS Request
+
+0000: 75 9D 01 00 00 01 00 00   00 00 00 00 05 68 6F 73  u............hos
+0010: 74 31 07 64 6F 6D 61 69   6E 31 03 63 6F 6D 00 00  t1.domain1.com..
+0020: 10 00 01                                           ...
+
+
+# DNS Response
+
+0000: 75 9D 85 80 00 01 00 01   00 01 00 01 05 68 6F 73  u............hos
+0010: 74 31 07 64 6F 6D 61 69   6E 31 03 63 6F 6D 00 00  t1.domain1.com..
+0020: 10 00 01 C0 0C 00 10 00   01 00 00 8C A0 00 15 14  ................
+0030: 41 20 76 65 72 79 20 70   6F 70 75 6C 61 72 20 68  A very popular h
+0040: 6F 73 74 2E C0 12 00 02   00 01 00 00 8C A0 00 05  ost.............
+0050: 02 6E 73 C0 12 C0 50 00   01 00 01 00 00 8C A0 00  .ns...P.........
+0060: 04 7F 00 00 01                                     .....
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jndi/dns/FedTests/ListSubLeaf.java	Mon Oct 22 14:08:07 2018 +0800
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.naming.Context;
+import javax.naming.NamingEnumeration;
+import javax.naming.directory.InitialDirContext;
+
+/*
+ * @test
+ * @bug 8210339
+ * @summary list of a leaf using a composite name with DNS name as
+ *          first component
+ * @library ../lib/
+ * @modules java.naming/com.sun.jndi.toolkit.dir
+ *          java.base/sun.security.util
+ * @build FedSubordinateNs FedObjectFactory
+ * @run main/othervm ListSubLeaf
+ */
+
+public class ListSubLeaf extends ListFedBase {
+
+    private static final int COUNT_LIMIT = 0; // no entry
+
+    public static void main(String[] args) throws Exception {
+        new ListSubLeaf().run(args);
+    }
+
+    /*
+     * list of a leaf using a composite name with DNS name as
+     * first component
+     */
+    @Override
+    public void runTest() throws Exception {
+        env().put(Context.OBJECT_FACTORIES, "FedObjectFactory");
+        setContext(new InitialDirContext(env()));
+
+        NamingEnumeration enumObj = context().listBindings(getKey() + "/a/b/c");
+        verifyNamingEnumeration(enumObj, COUNT_LIMIT);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jndi/dns/FedTests/LookupNns.dns	Mon Oct 22 14:08:07 2018 +0800
@@ -0,0 +1,50 @@
+#
+# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+################################################################################
+# Capture file for LookupNns.java
+#
+# NOTE: This hexadecimal dump of DNS protocol messages was generated by
+#       running the LookupNns application program against a real DNS
+#       server along with DNSTracer
+#
+################################################################################
+
+# DNS Request
+
+0000: 9D 2B 01 00 00 01 00 00   00 00 00 00 05 68 6F 73  .+...........hos
+0010: 74 31 07 64 6F 6D 61 69   6E 31 03 63 6F 6D 00 00  t1.domain1.com..
+0020: 10 00 01                                           ...
+
+
+# DNS Response
+
+0000: 9D 2B 85 80 00 01 00 01   00 01 00 01 05 68 6F 73  .+...........hos
+0010: 74 31 07 64 6F 6D 61 69   6E 31 03 63 6F 6D 00 00  t1.domain1.com..
+0020: 10 00 01 C0 0C 00 10 00   01 00 00 8C A0 00 15 14  ................
+0030: 41 20 76 65 72 79 20 70   6F 70 75 6C 61 72 20 68  A very popular h
+0040: 6F 73 74 2E C0 12 00 02   00 01 00 00 8C A0 00 05  ost.............
+0050: 02 6E 73 C0 12 C0 50 00   01 00 01 00 00 8C A0 00  .ns...P.........
+0060: 04 7F 00 00 01                                     .....
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jndi/dns/FedTests/LookupNns.java	Mon Oct 22 14:08:07 2018 +0800
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.naming.Context;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.InitialDirContext;
+
+/*
+ * @test
+ * @bug 8210339
+ * @summary Test that we can lookup the nns of a DNS entry.
+ * @library ../lib/ ../FactoryTests/
+ * @modules java.naming/com.sun.jndi.toolkit.dir
+ *          java.base/sun.security.util
+ * @build FedSubordinateNs FedObjectFactory
+ * @run main/othervm LookupNns
+ */
+
+public class LookupNns extends LookupFactoryBase {
+
+    public static void main(String[] args) throws Exception {
+        new LookupNns().run(args);
+    }
+
+    /*
+     * Test that we can lookup the nns of a DNS entry.
+     */
+    @Override
+    public void runTest() throws Exception {
+        // initial context with object factory
+        env().put(Context.OBJECT_FACTORIES, "FedObjectFactory");
+        setContext(new InitialDirContext(env()));
+
+        Object nns = context().lookup(getKey() + "/");
+        verifyLookupObject(nns, DirContext.class);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jndi/dns/FedTests/LookupSubInterior.dns	Mon Oct 22 14:08:07 2018 +0800
@@ -0,0 +1,50 @@
+#
+# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+################################################################################
+# Capture file for LookupSubInterior.java
+#
+# NOTE: This hexadecimal dump of DNS protocol messages was generated by
+#       running the LookupSubInterior application program against a real DNS
+#       server along with DNSTracer
+#
+################################################################################
+
+# DNS Request
+
+0000: 40 96 01 00 00 01 00 00   00 00 00 00 05 68 6F 73  @............hos
+0010: 74 31 07 64 6F 6D 61 69   6E 31 03 63 6F 6D 00 00  t1.domain1.com..
+0020: 10 00 01                                           ...
+
+
+# DNS Response
+
+0000: 40 96 85 80 00 01 00 01   00 01 00 01 05 68 6F 73  @............hos
+0010: 74 31 07 64 6F 6D 61 69   6E 31 03 63 6F 6D 00 00  t1.domain1.com..
+0020: 10 00 01 C0 0C 00 10 00   01 00 00 8C A0 00 15 14  ................
+0030: 41 20 76 65 72 79 20 70   6F 70 75 6C 61 72 20 68  A very popular h
+0040: 6F 73 74 2E C0 12 00 02   00 01 00 00 8C A0 00 05  ost.............
+0050: 02 6E 73 C0 12 C0 50 00   01 00 01 00 00 8C A0 00  .ns...P.........
+0060: 04 7F 00 00 01                                     .....
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jndi/dns/FedTests/LookupSubInterior.java	Mon Oct 22 14:08:07 2018 +0800
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.InitialDirContext;
+
+/*
+ * @test
+ * @bug 8210339
+ * @summary Look up of a Interior using a composite name with DNS name as
+ *          first component
+ * @library ../lib/ ../FactoryTests/
+ * @modules java.naming/com.sun.jndi.toolkit.dir
+ *          java.base/sun.security.util
+ * @build FedSubordinateNs FedObjectFactory
+ * @run main/othervm LookupSubInterior
+ */
+
+public class LookupSubInterior extends LookupFactoryBase {
+
+    // pre defined attribute value for '/a/b'
+    public static final String ATTRIBUTE_VALUE = "b";
+
+    public static void main(String[] args) throws Exception {
+        new LookupSubInterior().run(args);
+    }
+
+    /*
+     * Look up of a Interior using a composite name with DNS name as
+     * first component
+     */
+    @Override
+    public void runTest() throws Exception {
+        // initial context with object factory
+        env().put(Context.OBJECT_FACTORIES, "FedObjectFactory");
+        setContext(new InitialDirContext(env()));
+
+        Object obj = context().lookup(getKey() + "/a/b");
+
+        verifyLookupObject(obj, DirContext.class);
+
+        Attributes attrs = ((DirContext) obj).getAttributes("");
+        Attribute attr = attrs.get("name");
+
+        DNSTestUtils.debug(getKey() + "/a/b is: " + attrs);
+        verifyAttribute(attr);
+    }
+
+    private void verifyAttribute(Attribute attr) throws NamingException {
+        if (attr == null || !ATTRIBUTE_VALUE.equals(attr.get())) {
+            throw new RuntimeException(
+                    "Expecting attribute value: " + ATTRIBUTE_VALUE
+                            + ", but actual: " + (attr != null ?
+                            attr.get() :
+                            attr));
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jndi/dns/FedTests/LookupSubLeaf.dns	Mon Oct 22 14:08:07 2018 +0800
@@ -0,0 +1,50 @@
+#
+# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+################################################################################
+# Capture file for LookupSubInterior.java
+#
+# NOTE: This hexadecimal dump of DNS protocol messages was generated by
+#       running the LookupSubInterior application program against a real DNS
+#       server along with DNSTracer
+#
+################################################################################
+
+# DNS Request
+
+0000: 04 19 01 00 00 01 00 00   00 00 00 00 05 68 6F 73  .............hos
+0010: 74 31 07 64 6F 6D 61 69   6E 31 03 63 6F 6D 00 00  t1.domain1.com..
+0020: 10 00 01                                           ...
+
+
+# DNS Response
+
+0000: 04 19 85 80 00 01 00 01   00 01 00 01 05 68 6F 73  .............hos
+0010: 74 31 07 64 6F 6D 61 69   6E 31 03 63 6F 6D 00 00  t1.domain1.com..
+0020: 10 00 01 C0 0C 00 10 00   01 00 00 8C A0 00 15 14  ................
+0030: 41 20 76 65 72 79 20 70   6F 70 75 6C 61 72 20 68  A very popular h
+0040: 6F 73 74 2E C0 12 00 02   00 01 00 00 8C A0 00 05  ost.............
+0050: 02 6E 73 C0 12 C0 50 00   01 00 01 00 00 8C A0 00  .ns...P.........
+0060: 04 7F 00 00 01                                     .....
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jndi/dns/FedTests/LookupSubLeaf.java	Mon Oct 22 14:08:07 2018 +0800
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.InitialDirContext;
+
+/*
+ * @test
+ * @bug 8210339
+ * @summary Look up of a leaf using a composite name with DNS name as
+ *          first component
+ * @library ../lib/ ../FactoryTests/
+ * @modules java.naming/com.sun.jndi.toolkit.dir
+ *          java.base/sun.security.util
+ * @build FedSubordinateNs FedObjectFactory
+ * @run main/othervm LookupSubLeaf
+ */
+
+public class LookupSubLeaf extends LookupFactoryBase {
+
+    // pre defined attribute value for '/a/b/c'
+    public static final String ATTRIBUTE_VALUE = "c";
+
+    public static void main(String[] args) throws Exception {
+        new LookupSubLeaf().run(args);
+    }
+
+    /*
+     * Look up of a leaf using a composite name with DNS name as
+     * first component
+     */
+    @Override
+    public void runTest() throws Exception {
+        // initial context with object factory
+        env().put(Context.OBJECT_FACTORIES, "FedObjectFactory");
+        setContext(new InitialDirContext(env()));
+
+        Object obj = context().lookup(getKey() + "/a/b/c");
+
+        verifyLookupObject(obj, DirContext.class);
+
+        Attributes attrs = ((DirContext) obj).getAttributes("");
+        Attribute attr = attrs.get("name");
+
+        DNSTestUtils.debug(getKey() + "/a/b/c is: " + attrs);
+        verifyAttribute(attr);
+    }
+
+    private void verifyAttribute(Attribute attr) throws NamingException {
+        if (attr == null || !ATTRIBUTE_VALUE.equals(attr.get())) {
+            throw new RuntimeException(
+                    "Expecting attribute value: " + ATTRIBUTE_VALUE
+                            + ", but actual: " + (attr != null ?
+                            attr.get() :
+                            attr));
+        }
+    }
+}