--- old/test/jdk/com/sun/jndi/dns/AttributeTests/GetAny.java 2018-03-22 09:58:52.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/AttributeTests/GetAny.java 2018-03-22 09:58:51.000000000 +0800 @@ -76,6 +76,7 @@ } finally { DNSTestUtils.cleanup(ctx); + DNSTestUtils.cleanupClosableRes(socket); } } } --- 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; + } } --- /dev/null 2018-03-22 09:58:54.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/AttributeTests/GetAttrs.dns 2018-03-22 09:58:54.000000000 +0800 @@ -0,0 +1,58 @@ +# +# 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 GetAttrs.java +# +# NOTE: This hexadecimal dump of DNS protocol messages was generated by +# running the GetAttrs application program against a real DNS +# server along with DNSTracer +# +################################################################################ + +# DNS Request + +0000: 2F EA 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: FF 00 FF ... + + +# DNS Response + +0000: 2F EA 85 80 00 01 00 06 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: FF 00 FF 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 0C 00 1D 00 01 00 00 8C A0 00 10 ost............. +0050: 00 12 16 13 88 97 1A 35 69 68 41 38 00 9B 16 58 .......5ihA8...X +0060: C0 0C 00 0D 00 01 00 00 8C A0 00 13 0C 54 68 65 .............The +0070: 20 4F 72 69 67 69 6E 61 6C 05 53 75 6E 6E 79 C0 Original.Sunny. +0080: 0C 00 0F 00 01 00 00 8C A0 00 12 00 14 05 72 65 ..............re +0090: 6C 61 79 05 74 65 78 61 73 02 75 73 00 C0 0C 00 lay.texas.us.... +00A0: 0F 00 01 00 00 8C A0 00 0F 00 0A 05 72 65 6C 61 ............rela +00B0: 79 04 6F 68 69 6F C0 99 C0 0C 00 01 00 01 00 01 y.ohio.......... +00C0: 51 80 00 04 01 02 04 01 C0 12 00 02 00 01 00 00 Q............... +00D0: 8C A0 00 05 02 6E 73 C0 12 C0 D4 00 01 00 01 00 .....ns......... +00E0: 00 8C A0 00 04 7F 00 00 01 ......... + + --- /dev/null 2018-03-22 09:58:55.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/AttributeTests/GetAttrs.java 2018-03-22 09:58:55.000000000 +0800 @@ -0,0 +1,55 @@ +/* + * 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. + */ + +/* + * @test + * @bug 8198882 + * @summary Tests that we can get the attributes of a DNS entry. + * Use getAttributes form that has no attrIds parameter. + * @modules java.base/sun.security.util + * @library ../lib/ + * @run main GetAttrs + */ + +import javax.naming.directory.Attributes; + +public class GetAttrs extends GetAttrsBase { + + public static void main(String[] args) throws Exception { + new GetAttrs().run(args); + } + + @Override public void runTest() throws Exception { + initContext(); + Attributes retAttrs = getAttributes(); + verifyAttributes(retAttrs); + } + + /* + * Tests that we can get the attributes of a DNS entry. + * Use getAttributes form that has no attrIds parameter. + */ + @Override public Attributes getAttributes() throws Exception { + return context().getAttributes(getKey()); + } +} --- /dev/null 2018-03-22 09:58:56.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/AttributeTests/GetAttrsBase.java 2018-03-22 09:58:56.000000000 +0800 @@ -0,0 +1,72 @@ +/* + * 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.directory.Attributes; +import javax.naming.directory.InitialDirContext; + +public abstract class GetAttrsBase extends DNSTestBase { + private String key; + private String[] mandatoryAttrs; + + { + // set default test data + setKey("host1"); + setMandatoryAttrs( + new String[] { "A", "MX", "HINFO", "TXT", "29" // "LOC" + }); + } + + private static final String[] OPTIONAL_ATTRIBUTES = {}; + + public void initContext() throws Exception { + setContext(new InitialDirContext(env())); + } + + public abstract Attributes getAttributes() throws Exception; + + public void verifyAttributes(Attributes retAttrs) throws Exception { + if (retAttrs != null) { + DNSTestUtils.verifySchema(retAttrs, mandatoryAttrs, + OPTIONAL_ATTRIBUTES); + } else { + throw new RuntimeException( + "Failed, Attributes which required to verify was null unexpectedly"); + } + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String[] getMandatoryAttrs() { + return mandatoryAttrs; + } + + public void setMandatoryAttrs(String[] mandatoryAttrs) { + this.mandatoryAttrs = mandatoryAttrs; + } +} --- /dev/null 2018-03-22 09:58:57.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/AttributeTests/GetAttrsEmptyAttrIds.dns 2018-03-22 09:58:56.000000000 +0800 @@ -0,0 +1,58 @@ +# +# 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 GetAttrsEmptyAttrIds.java +# +# NOTE: This hexadecimal dump of DNS protocol messages was generated by +# running the GetAttrsEmptyAttrIds application program against a real DNS +# server along with DNSTracer +# +################################################################################ + +# DNS Request + +0000: BC 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: FF 00 01 ... + + +# DNS Response + +0000: BC 12 85 80 00 01 00 06 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: FF 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 0C 00 1D 00 01 00 00 8C A0 00 10 ost............. +0050: 00 12 16 13 88 97 1A 35 69 68 41 38 00 9B 16 58 .......5ihA8...X +0060: C0 0C 00 0D 00 01 00 00 8C A0 00 13 0C 54 68 65 .............The +0070: 20 4F 72 69 67 69 6E 61 6C 05 53 75 6E 6E 79 C0 Original.Sunny. +0080: 0C 00 0F 00 01 00 00 8C A0 00 11 00 0A 05 72 65 ..............re +0090: 6C 61 79 04 6F 68 69 6F 02 75 73 00 C0 0C 00 0F lay.ohio.us..... +00A0: 00 01 00 00 8C A0 00 10 00 14 05 72 65 6C 61 79 ...........relay +00B0: 05 74 65 78 61 73 C0 98 C0 0C 00 01 00 01 00 01 .texas.......... +00C0: 51 80 00 04 01 02 04 01 C0 12 00 02 00 01 00 00 Q............... +00D0: 8C A0 00 05 02 6E 73 C0 12 C0 D4 00 01 00 01 00 .....ns......... +00E0: 00 8C A0 00 04 7F 00 00 01 ......... + + --- /dev/null 2018-03-22 09:58:58.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/AttributeTests/GetAttrsEmptyAttrIds.java 2018-03-22 09:58:57.000000000 +0800 @@ -0,0 +1,59 @@ +/* + * 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. + */ + +/* + * @test + * @bug 8198882 + * @summary Tests that we can get the attributes of a DNS entry. + * Specify that no attributes are to be returned. + * @modules java.base/sun.security.util + * @library ../lib/ + * @run main GetAttrsEmptyAttrIds + */ + +import javax.naming.directory.Attributes; + +public class GetAttrsEmptyAttrIds extends GetAttrsBase { + { + // set new test data instead of default value + setMandatoryAttrs(new String[] {}); + } + + public static void main(String[] args) throws Exception { + new GetAttrsEmptyAttrIds().run(args); + } + + @Override public void runTest() throws Exception { + initContext(); + Attributes retAttrs = getAttributes(); + verifyAttributes(retAttrs); + } + + /* + * Tests that we can get the attributes of a DNS entry. + * Specify that no attributes are to be returned. + */ + @Override public Attributes getAttributes() throws Exception { + return context().getAttributes(getKey(), new String[] {}); + } +} --- /dev/null 2018-03-22 09:58:59.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/AttributeTests/GetAttrsNonExistentAttrIds.dns 2018-03-22 09:58:59.000000000 +0800 @@ -0,0 +1,58 @@ +# +# 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 GetAttrsNonExistentAttrIds.java +# +# NOTE: This hexadecimal dump of DNS protocol messages was generated by +# running the GetAttrsNonExistentAttrIds application program against +# a real DNS server along with DNSTracer +# +################################################################################ + +# DNS Request + +0000: FC 9A 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: FF 00 01 ... + + +# DNS Response + +0000: FC 9A 85 80 00 01 00 06 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: FF 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 0C 00 1D 00 01 00 00 8C A0 00 10 ost............. +0050: 00 12 16 13 88 97 1A 35 69 68 41 38 00 9B 16 58 .......5ihA8...X +0060: C0 0C 00 0D 00 01 00 00 8C A0 00 13 0C 54 68 65 .............The +0070: 20 4F 72 69 67 69 6E 61 6C 05 53 75 6E 6E 79 C0 Original.Sunny. +0080: 0C 00 0F 00 01 00 00 8C A0 00 12 00 14 05 72 65 ..............re +0090: 6C 61 79 05 74 65 78 61 73 02 75 73 00 C0 0C 00 lay.texas.us.... +00A0: 0F 00 01 00 00 8C A0 00 0F 00 0A 05 72 65 6C 61 ............rela +00B0: 79 04 6F 68 69 6F C0 99 C0 0C 00 01 00 01 00 01 y.ohio.......... +00C0: 51 80 00 04 01 02 04 01 C0 12 00 02 00 01 00 00 Q............... +00D0: 8C A0 00 05 02 6E 73 C0 12 C0 D4 00 01 00 01 00 .....ns......... +00E0: 00 8C A0 00 04 7F 00 00 01 ......... + + --- /dev/null 2018-03-22 09:59:00.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/AttributeTests/GetAttrsNonExistentAttrIds.java 2018-03-22 09:59:00.000000000 +0800 @@ -0,0 +1,62 @@ +/* + * 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. + */ + +/* + * @test + * @bug 8198882 + * @summary Tests that we can get the attributes of a DNS entry. + * Supply at least one nonexistent attribute name in attrIds + * (should be ignored). + * @modules java.base/sun.security.util + * @library ../lib/ + * @run main GetAttrsNonExistentAttrIds + */ + +import javax.naming.directory.Attributes; + +public class GetAttrsNonExistentAttrIds extends GetAttrsBase { + + public static void main(String[] args) throws Exception { + new GetAttrsNonExistentAttrIds().run(args); + } + + @Override public void runTest() throws Exception { + initContext(); + Attributes retAttrs = getAttributes(); + verifyAttributes(retAttrs); + } + + /* + * Tests that we can get the attributes of a DNS entry. + * Supply at least one nonexistent attribute name in attrIds + * (should be ignored). + */ + @Override public Attributes getAttributes() throws Exception { + String[] attrIds = new String[getMandatoryAttrs().length + 1]; + attrIds[0] = "SOA"; + System.arraycopy(getMandatoryAttrs(), 0, attrIds, 1, + getMandatoryAttrs().length); + + return context().getAttributes(getKey(), attrIds); + } +} --- /dev/null 2018-03-22 09:59:01.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/AttributeTests/GetAttrsNotFound.dns 2018-03-22 09:59:01.000000000 +0800 @@ -0,0 +1,49 @@ +# +# 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 GetAttrsNotFound.java +# +# NOTE: This hexadecimal dump of DNS protocol messages was generated by +# running the GetAttrsNotFound application program against a real DNS +# server along with DNSTracer +# +################################################################################ + +# DNS Request + +0000: 56 B1 01 00 00 01 00 00 00 00 00 00 08 6E 6F 74 V............not +0010: 66 6F 75 6E 64 07 64 6F 6D 61 69 6E 31 03 63 6F found.domain1.co +0020: 6D 00 00 FF 00 FF m..... + + +# DNS Response + +0000: 56 B1 85 83 00 01 00 00 00 01 00 00 08 6E 6F 74 V............not +0010: 66 6F 75 6E 64 07 64 6F 6D 61 69 6E 31 03 63 6F found.domain1.co +0020: 6D 00 00 FF 00 FF C0 15 00 06 00 01 00 00 8C A0 m............... +0030: 00 26 02 6E 73 C0 15 0A 70 6F 73 74 6D 61 73 74 .&.ns...postmast +0040: 65 72 C0 15 00 00 00 01 00 00 1C 20 00 00 0E 10 er......... .... +0050: 00 06 97 80 00 01 51 80 ......Q. + + --- /dev/null 2018-03-22 09:59:02.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/AttributeTests/GetAttrsNotFound.java 2018-03-22 09:59:02.000000000 +0800 @@ -0,0 +1,74 @@ +/* + * 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. + */ + +/* + * @test + * @bug 8198882 + * @summary Tests that get attributes of a missing child entry results + * in NameNotFoundException. + * @modules java.base/sun.security.util + * @library ../lib/ + * @run main GetAttrsNotFound + */ + +import javax.naming.NameNotFoundException; +import javax.naming.directory.Attributes; + +public class GetAttrsNotFound extends GetAttrsBase { + { + // set new test data instead of default value + setKey("notfound"); + } + + public static void main(String[] args) throws Exception { + new GetAttrsNotFound().run(args); + } + + @Override public void runTest() throws Exception { + initContext(); + Attributes retAttrs = getAttributes(); + verifyAttributes(retAttrs); + } + + /* + * Tests that get attributes of a missing child entry results + * in NameNotFoundException. + */ + @Override public Attributes getAttributes() throws Exception { + return context().getAttributes(getKey()); + } + + @Override public void verifyAttributes(Attributes attrs) { + throw new RuntimeException( + "Failed: getAttributes succeeded unexpectedly"); + } + + @Override public boolean handleException(Exception e) { + if (e instanceof NameNotFoundException) { + System.out.println("Got exception as expected : " + e); + return true; + } + + return super.handleException(e); + } +} --- /dev/null 2018-03-22 09:59:04.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/AttributeTests/GetAttrsNullAttrIds.dns 2018-03-22 09:59:03.000000000 +0800 @@ -0,0 +1,58 @@ +# +# 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 GetAttrsNullAttrIds.java +# +# NOTE: This hexadecimal dump of DNS protocol messages was generated by +# running the GetAttrsNullAttrIds application program against a real DNS +# server along with DNSTracer +# +################################################################################ + +# DNS Request + +0000: 60 3C 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: FF 00 FF ... + + +# DNS Response + +0000: 60 3C 85 80 00 01 00 06 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: FF 00 FF 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 0C 00 1D 00 01 00 00 8C A0 00 10 ost............. +0050: 00 12 16 13 88 97 1A 35 69 68 41 38 00 9B 16 58 .......5ihA8...X +0060: C0 0C 00 0D 00 01 00 00 8C A0 00 13 0C 54 68 65 .............The +0070: 20 4F 72 69 67 69 6E 61 6C 05 53 75 6E 6E 79 C0 Original.Sunny. +0080: 0C 00 0F 00 01 00 00 8C A0 00 11 00 0A 05 72 65 ..............re +0090: 6C 61 79 04 6F 68 69 6F 02 75 73 00 C0 0C 00 0F lay.ohio.us..... +00A0: 00 01 00 00 8C A0 00 10 00 14 05 72 65 6C 61 79 ...........relay +00B0: 05 74 65 78 61 73 C0 98 C0 0C 00 01 00 01 00 01 .texas.......... +00C0: 51 80 00 04 01 02 04 01 C0 12 00 02 00 01 00 00 Q............... +00D0: 8C A0 00 05 02 6E 73 C0 12 C0 D4 00 01 00 01 00 .....ns......... +00E0: 00 8C A0 00 04 7F 00 00 01 ......... + + --- /dev/null 2018-03-22 09:59:04.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/AttributeTests/GetAttrsNullAttrIds.java 2018-03-22 09:59:04.000000000 +0800 @@ -0,0 +1,57 @@ +/* + * 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. + */ + +/* + * @test + * @bug 8198882 + * @summary Tests that we can get the attributes of a DNS entry. + * Use getAttributes form that accepts an attrIds parameter + * and supply null for it. + * @modules java.base/sun.security.util + * @library ../lib/ + * @run main GetAttrsNullAttrIds + */ + +import javax.naming.directory.Attributes; + +public class GetAttrsNullAttrIds extends GetAttrsBase { + + public static void main(String[] args) throws Exception { + new GetAttrsNullAttrIds().run(args); + } + + @Override public void runTest() throws Exception { + initContext(); + Attributes retAttrs = getAttributes(); + verifyAttributes(retAttrs); + } + + /* + * Tests that we can get the attributes of a DNS entry. + * Use getAttributes form that accepts an attrIds parameter + * and supply null for it. + */ + @Override public Attributes getAttributes() throws Exception { + return context().getAttributes(getKey(), null); + } +} --- /dev/null 2018-03-22 09:59:06.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/AttributeTests/GetAttrsSomeAttrIds.dns 2018-03-22 09:59:05.000000000 +0800 @@ -0,0 +1,58 @@ +# +# 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 GetAttrsSomeAttrIds.java +# +# NOTE: This hexadecimal dump of DNS protocol messages was generated by +# running the GetAttrsSomeAttrIds application program against a real DNS +# server along with DNSTracer +# +################################################################################ + +# DNS Request + +0000: 20 34 01 00 00 01 00 00 00 00 00 00 05 68 6F 73 4...........hos +0010: 74 31 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 t1.domain1.com.. +0020: FF 00 01 ... + + +# DNS Response + +0000: 20 34 85 80 00 01 00 06 00 01 00 01 05 68 6F 73 4...........hos +0010: 74 31 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 t1.domain1.com.. +0020: FF 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 0C 00 1D 00 01 00 00 8C A0 00 10 ost............. +0050: 00 12 16 13 88 97 1A 35 69 68 41 38 00 9B 16 58 .......5ihA8...X +0060: C0 0C 00 0D 00 01 00 00 8C A0 00 13 0C 54 68 65 .............The +0070: 20 4F 72 69 67 69 6E 61 6C 05 53 75 6E 6E 79 C0 Original.Sunny. +0080: 0C 00 0F 00 01 00 00 8C A0 00 12 00 14 05 72 65 ..............re +0090: 6C 61 79 05 74 65 78 61 73 02 75 73 00 C0 0C 00 lay.texas.us.... +00A0: 0F 00 01 00 00 8C A0 00 0F 00 0A 05 72 65 6C 61 ............rela +00B0: 79 04 6F 68 69 6F C0 99 C0 0C 00 01 00 01 00 01 y.ohio.......... +00C0: 51 80 00 04 01 02 04 01 C0 12 00 02 00 01 00 00 Q............... +00D0: 8C A0 00 05 02 6E 73 C0 12 C0 D4 00 01 00 01 00 .....ns......... +00E0: 00 8C A0 00 04 7F 00 00 01 ......... + + --- /dev/null 2018-03-22 09:59:09.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/AttributeTests/GetAttrsSomeAttrIds.java 2018-03-22 09:59:08.000000000 +0800 @@ -0,0 +1,59 @@ +/* + * 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. + */ + +/* + * @test + * @bug 8198882 + * @summary Tests that we can get the attributes of a DNS entry. + * Specify a subset of the attributes to be returned. + * @modules java.base/sun.security.util + * @library ../lib/ + * @run main GetAttrsSomeAttrIds + */ + +import javax.naming.directory.Attributes; + +public class GetAttrsSomeAttrIds extends GetAttrsBase { + { + // set new test data instead of default value + setMandatoryAttrs(new String[] { "A", "MX", "TXT" }); + } + + public static void main(String[] args) throws Exception { + new GetAttrsSomeAttrIds().run(args); + } + + @Override public void runTest() throws Exception { + initContext(); + Attributes retAttrs = getAttributes(); + verifyAttributes(retAttrs); + } + + /* + * Tests that we can get the attributes of a DNS entry. + * Specify a subset of the attributes to be returned. + */ + @Override public Attributes getAttributes() throws Exception { + return context().getAttributes(getKey(), getMandatoryAttrs()); + } +} --- /dev/null 2018-03-22 09:59:11.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/AttributeTests/GetNonstandard.dns 2018-03-22 09:59:10.000000000 +0800 @@ -0,0 +1,49 @@ +# +# 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 GetNonstandard.java +# +# NOTE: This hexadecimal dump of DNS protocol messages was generated by +# running the GetNonstandard application program against a real DNS +# server along with DNSTracer +# +################################################################################ + +# DNS Request + +0000: 43 D5 01 00 00 01 00 00 00 00 00 00 05 68 6F 73 C............hos +0010: 74 31 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 t1.domain1.com.. +0020: 1D 00 01 ... + + +# DNS Response + +0000: 43 D5 85 80 00 01 00 01 00 01 00 01 05 68 6F 73 C............hos +0010: 74 31 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 t1.domain1.com.. +0020: 1D 00 01 C0 0C 00 1D 00 01 00 00 8C A0 00 10 00 ................ +0030: 12 16 13 88 97 1A 35 69 68 41 38 00 9B 16 58 C0 ......5ihA8...X. +0040: 12 00 02 00 01 00 00 8C A0 00 05 02 6E 73 C0 12 ............ns.. +0050: C0 4B 00 01 00 01 00 00 8C A0 00 04 7F 00 00 01 .K.............. + + --- /dev/null 2018-03-22 09:59:12.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/AttributeTests/GetNonstandard.java 2018-03-22 09:59:11.000000000 +0800 @@ -0,0 +1,96 @@ +/* + * 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. + */ + +/* + * @test + * @bug 8198882 + * @summary Tests that we can get an attribute that has a nonstandard name from + * a DNS entry. + * @modules java.base/sun.security.util + * @library ../lib/ + * @run main GetNonstandard + */ + +import javax.naming.NamingException; +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import java.util.Arrays; + +public class GetNonstandard extends GetAttrsBase { + { + // set new test data instead of default value + setMandatoryAttrs(new String[] { "29" // LOC + }); + } + + // "40 2 0.373 N 105 17 23.528 W 1638m" + private static final byte[] EXPECTED_VALUE = { (byte) 0, // version + (byte) 18, // size + (byte) 22, // horiz pre + (byte) 19, // vert pre + (byte) -120, // latitude 1 + (byte) -105, // latitude 2 + (byte) 26, // longitude 1 + (byte) 53, // longitude 2 + (byte) 105, // altitude 1 + (byte) 104, // altitude 2 + (byte) 65, (byte) 56, (byte) 0, (byte) -101, (byte) 22, + (byte) 88, }; + + public static void main(String[] args) throws Exception { + new GetNonstandard().run(args); + } + + @Override public void runTest() throws Exception { + initContext(); + Attributes retAttrs = getAttributes(); + verifyAttributes(retAttrs); + verifyLoc(retAttrs); + } + + /* + * Tests that we can get an attribute that has a nonstandard name from + * a DNS entry. + */ + @Override public Attributes getAttributes() throws Exception { + return context().getAttributes(getKey(), getMandatoryAttrs()); + } + + private void verifyLoc(Attributes retAttrs) throws NamingException { + Attribute loc = retAttrs.get(getMandatoryAttrs()[0]); + byte[] val = (byte[]) loc.get(0); + + DNSTestUtils.debug("Expected: " + Arrays.toString(EXPECTED_VALUE)); + DNSTestUtils.debug("Actual: " + Arrays.toString(val)); + + if (val.length != EXPECTED_VALUE.length) { + throw new RuntimeException( + "Failed: unexpected value length " + val.length + + ", expected " + EXPECTED_VALUE.length); + } + + if (!Arrays.equals(val, EXPECTED_VALUE)) { + throw new RuntimeException("Failed: values not match"); + } + } +} --- /dev/null 2018-03-22 09:59:14.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/AttributeTests/GetNumericIRRs.dns 2018-03-22 09:59:13.000000000 +0800 @@ -0,0 +1,148 @@ +# +# 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 GetNumericIRRs.java +# +# NOTE: This hexadecimal dump of DNS protocol messages was generated by +# running the GetNumericIRRs application program against a real DNS +# server along with DNSTracer +# +################################################################################ + +# DNS Request + +0000: D6 36 01 00 00 01 00 00 00 00 00 00 05 68 6F 73 .6...........hos +0010: 74 31 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 t1.domain1.com.. +0020: FF 00 01 ... + + +# DNS Response + +0000: D6 36 85 80 00 01 00 06 00 01 00 01 05 68 6F 73 .6...........hos +0010: 74 31 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 t1.domain1.com.. +0020: FF 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 0C 00 1D 00 01 00 00 8C A0 00 10 ost............. +0050: 00 12 16 13 88 97 1A 35 69 68 41 38 00 9B 16 58 .......5ihA8...X +0060: C0 0C 00 0D 00 01 00 00 8C A0 00 13 0C 54 68 65 .............The +0070: 20 4F 72 69 67 69 6E 61 6C 05 53 75 6E 6E 79 C0 Original.Sunny. +0080: 0C 00 0F 00 01 00 00 8C A0 00 11 00 0A 05 72 65 ..............re +0090: 6C 61 79 04 6F 68 69 6F 02 75 73 00 C0 0C 00 0F lay.ohio.us..... +00A0: 00 01 00 00 8C A0 00 10 00 14 05 72 65 6C 61 79 ...........relay +00B0: 05 74 65 78 61 73 C0 98 C0 0C 00 01 00 01 00 01 .texas.......... +00C0: 51 80 00 04 01 02 04 01 C0 12 00 02 00 01 00 00 Q............... +00D0: 8C A0 00 05 02 6E 73 C0 12 C0 D4 00 01 00 01 00 .....ns......... +00E0: 00 8C A0 00 04 7F 00 00 01 ......... + + +# DNS Request + +0000: 3F B9 01 00 00 01 00 00 00 00 00 00 07 64 6F 6D ?............dom +0010: 61 69 6E 31 03 63 6F 6D 00 00 FF 00 01 ain1.com..... + + +# DNS Response + +0000: 3F B9 85 80 00 01 00 03 00 00 00 01 07 64 6F 6D ?............dom +0010: 61 69 6E 31 03 63 6F 6D 00 00 FF 00 01 C0 0C 00 ain1.com........ +0020: 06 00 01 00 00 8C A0 00 26 02 6E 73 C0 0C 0A 70 ........&.ns...p +0030: 6F 73 74 6D 61 73 74 65 72 C0 0C 00 00 00 01 00 ostmaster....... +0040: 00 1C 20 00 00 0E 10 00 06 97 80 00 01 51 80 C0 .. ..........Q.. +0050: 0C 00 02 00 01 00 00 8C A0 00 02 C0 29 C0 0C 00 ............)... +0060: 10 00 01 00 00 8C A0 00 0C 0B 54 65 73 74 20 64 ..........Test d +0070: 6F 6D 61 69 6E C0 29 00 01 00 01 00 00 8C A0 00 omain.)......... +0080: 04 7F 00 00 01 ..... + + +# DNS Request + +0000: F2 5D 01 00 00 01 00 00 00 00 00 00 04 69 70 76 .]...........ipv +0010: 36 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 1C 6.domain1.com... +0020: 00 01 .. + + +# DNS Response + +0000: F2 5D 85 80 00 01 00 01 00 01 00 01 04 69 70 76 .]...........ipv +0010: 36 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 1C 6.domain1.com... +0020: 00 01 C0 0C 00 1C 00 01 00 00 8C A0 00 10 00 0A ................ +0030: 00 0B 00 0C 00 0D 00 0E 00 01 00 02 00 03 C0 11 ................ +0040: 00 02 00 01 00 00 8C A0 00 05 02 6E 73 C0 11 C0 ...........ns... +0050: 4A 00 01 00 01 00 00 8C A0 00 04 7F 00 00 01 J.............. + + +# DNS Request + +0000: 4E 2D 01 00 00 01 00 00 00 00 00 00 03 73 75 6E N-...........sun +0010: 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 05 00 .domain1.com.... +0020: 01 . + + +# DNS Response + +0000: 4E 2D 85 80 00 01 00 01 00 01 00 01 03 73 75 6E N-...........sun +0010: 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 05 00 .domain1.com.... +0020: 01 C0 0C 00 05 00 01 00 00 8C A0 00 08 05 68 6F ..............ho +0030: 73 74 31 C0 10 C0 10 00 02 00 01 00 00 8C A0 00 st1............. +0040: 05 02 6E 73 C0 10 C0 41 00 01 00 01 00 00 8C A0 ..ns...A........ +0050: 00 04 7F 00 00 01 ...... + + +# DNS Request + +0000: 9D 9B 01 00 00 01 00 00 00 00 00 00 04 5F 66 74 ............._ft +0010: 70 04 5F 54 63 70 07 64 6F 6D 61 69 6E 31 03 63 p._Tcp.domain1.c +0020: 6F 6D 00 00 21 00 01 om..!.. + + +# DNS Response + +0000: 9D 9B 85 80 00 01 00 01 00 01 00 02 04 5F 66 74 ............._ft +0010: 70 04 5F 54 63 70 07 64 6F 6D 61 69 6E 31 03 63 p._Tcp.domain1.c +0020: 6F 6D 00 00 21 00 01 C0 0C 00 21 00 01 00 00 8C om..!.....!..... +0030: A0 00 19 00 01 00 00 00 15 05 68 6F 73 74 34 07 ..........host4. +0040: 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 C0 3F 00 02 domain1.com..?.. +0050: 00 01 00 00 8C A0 00 05 02 6E 73 C0 3F C0 39 00 .........ns.?.9. +0060: 01 00 01 00 01 51 80 00 04 01 02 04 04 C0 58 00 .....Q........X. +0070: 01 00 01 00 00 8C A0 00 04 7F 00 00 01 ............. + + +# DNS Request + +0000: 77 5B 01 00 00 01 00 00 00 00 00 00 01 31 01 34 w[...........1.4 +0010: 01 32 01 31 07 69 6E 2D 61 64 64 72 04 61 72 70 .2.1.in-addr.arp +0020: 61 00 00 0C 00 01 a..... + + +# DNS Response + +0000: 77 5B 85 80 00 01 00 01 00 01 00 01 01 31 01 34 w[...........1.4 +0010: 01 32 01 31 07 69 6E 2D 61 64 64 72 04 61 72 70 .2.1.in-addr.arp +0020: 61 00 00 0C 00 01 C0 0C 00 0C 00 01 00 00 8C A0 a............... +0030: 00 13 05 68 6F 73 74 31 07 64 6F 6D 61 69 6E 31 ...host1.domain1 +0040: 03 63 6F 6D 00 C0 0E 00 02 00 01 00 00 8C A0 00 .com............ +0050: 05 02 6E 73 C0 38 C0 51 00 01 00 01 00 00 8C A0 ..ns.8.Q........ +0060: 00 04 7F 00 00 01 ...... + + --- /dev/null 2018-03-22 09:59:15.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/AttributeTests/GetNumericIRRs.java 2018-03-22 09:59:14.000000000 +0800 @@ -0,0 +1,59 @@ +/* + * 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. + */ + +/* + * @test + * @bug 8198882 + * @summary Tests that we can get the attributes of a DNS entry by naming + * specific RRs by their type codes and "IN" for internet class. + * Omit NAPTR for now because bind doesn't support it. + * @modules java.base/sun.security.util + * @library ../lib/ + * @run main GetNumericIRRs + */ + +import javax.naming.directory.Attributes; + +public class GetNumericIRRs extends GetRRsBase { + + public static void main(String[] args) throws Exception { + new GetNumericIRRs().run(args); + } + + @Override public void runTest() throws Exception { + initContext(); + testAgainstNonRootUrl(); + switchToRootUrl(); + testAgainstRootUrl(); + } + + /* + * Tests that we can get the attributes of a DNS entry by naming + * specific RRs by their type codes and "IN" for internet class. + * Omit NAPTR for now because bind doesn't support it. + */ + @Override public Attributes getAttributes() throws Exception { + return context().getAttributes(getKeys()[getIndex()], + getNumAttrs()[getIndex()]); + } +} --- /dev/null 2018-03-22 09:59:18.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/AttributeTests/GetNumericRRs.dns 2018-03-22 09:59:17.000000000 +0800 @@ -0,0 +1,148 @@ +# +# 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 GetNumericRRs.java +# +# NOTE: This hexadecimal dump of DNS protocol messages was generated by +# running the GetNumericRRs application program against a real DNS +# server along with DNSTracer +# +################################################################################ + +# DNS Request + +0000: 7C 4B 01 00 00 01 00 00 00 00 00 00 05 68 6F 73 .K...........hos +0010: 74 31 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 t1.domain1.com.. +0020: FF 00 01 ... + + +# DNS Response + +0000: 7C 4B 85 80 00 01 00 06 00 01 00 01 05 68 6F 73 .K...........hos +0010: 74 31 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 t1.domain1.com.. +0020: FF 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 0C 00 1D 00 01 00 00 8C A0 00 10 ost............. +0050: 00 12 16 13 88 97 1A 35 69 68 41 38 00 9B 16 58 .......5ihA8...X +0060: C0 0C 00 0D 00 01 00 00 8C A0 00 13 0C 54 68 65 .............The +0070: 20 4F 72 69 67 69 6E 61 6C 05 53 75 6E 6E 79 C0 Original.Sunny. +0080: 0C 00 0F 00 01 00 00 8C A0 00 12 00 14 05 72 65 ..............re +0090: 6C 61 79 05 74 65 78 61 73 02 75 73 00 C0 0C 00 lay.texas.us.... +00A0: 0F 00 01 00 00 8C A0 00 0F 00 0A 05 72 65 6C 61 ............rela +00B0: 79 04 6F 68 69 6F C0 99 C0 0C 00 01 00 01 00 01 y.ohio.......... +00C0: 51 80 00 04 01 02 04 01 C0 12 00 02 00 01 00 00 Q............... +00D0: 8C A0 00 05 02 6E 73 C0 12 C0 D4 00 01 00 01 00 .....ns......... +00E0: 00 8C A0 00 04 7F 00 00 01 ......... + + +# DNS Request + +0000: 60 6F 01 00 00 01 00 00 00 00 00 00 07 64 6F 6D `o...........dom +0010: 61 69 6E 31 03 63 6F 6D 00 00 FF 00 01 ain1.com..... + + +# DNS Response + +0000: 60 6F 85 80 00 01 00 03 00 00 00 01 07 64 6F 6D `o...........dom +0010: 61 69 6E 31 03 63 6F 6D 00 00 FF 00 01 C0 0C 00 ain1.com........ +0020: 06 00 01 00 00 8C A0 00 26 02 6E 73 C0 0C 0A 70 ........&.ns...p +0030: 6F 73 74 6D 61 73 74 65 72 C0 0C 00 00 00 01 00 ostmaster....... +0040: 00 1C 20 00 00 0E 10 00 06 97 80 00 01 51 80 C0 .. ..........Q.. +0050: 0C 00 02 00 01 00 00 8C A0 00 02 C0 29 C0 0C 00 ............)... +0060: 10 00 01 00 00 8C A0 00 0C 0B 54 65 73 74 20 64 ..........Test d +0070: 6F 6D 61 69 6E C0 29 00 01 00 01 00 00 8C A0 00 omain.)......... +0080: 04 7F 00 00 01 ..... + + +# DNS Request + +0000: 97 B5 01 00 00 01 00 00 00 00 00 00 04 69 70 76 .............ipv +0010: 36 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 1C 6.domain1.com... +0020: 00 01 .. + + +# DNS Response + +0000: 97 B5 85 80 00 01 00 01 00 01 00 01 04 69 70 76 .............ipv +0010: 36 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 1C 6.domain1.com... +0020: 00 01 C0 0C 00 1C 00 01 00 00 8C A0 00 10 00 0A ................ +0030: 00 0B 00 0C 00 0D 00 0E 00 01 00 02 00 03 C0 11 ................ +0040: 00 02 00 01 00 00 8C A0 00 05 02 6E 73 C0 11 C0 ...........ns... +0050: 4A 00 01 00 01 00 00 8C A0 00 04 7F 00 00 01 J.............. + + +# DNS Request + +0000: 61 7E 01 00 00 01 00 00 00 00 00 00 03 73 75 6E a............sun +0010: 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 05 00 .domain1.com.... +0020: 01 . + + +# DNS Response + +0000: 61 7E 85 80 00 01 00 01 00 01 00 01 03 73 75 6E a............sun +0010: 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 05 00 .domain1.com.... +0020: 01 C0 0C 00 05 00 01 00 00 8C A0 00 08 05 68 6F ..............ho +0030: 73 74 31 C0 10 C0 10 00 02 00 01 00 00 8C A0 00 st1............. +0040: 05 02 6E 73 C0 10 C0 41 00 01 00 01 00 00 8C A0 ..ns...A........ +0050: 00 04 7F 00 00 01 ...... + + +# DNS Request + +0000: 7D 9A 01 00 00 01 00 00 00 00 00 00 04 5F 66 74 ............._ft +0010: 70 04 5F 54 63 70 07 64 6F 6D 61 69 6E 31 03 63 p._Tcp.domain1.c +0020: 6F 6D 00 00 21 00 01 om..!.. + + +# DNS Response + +0000: 7D 9A 85 80 00 01 00 01 00 01 00 02 04 5F 66 74 ............._ft +0010: 70 04 5F 54 63 70 07 64 6F 6D 61 69 6E 31 03 63 p._Tcp.domain1.c +0020: 6F 6D 00 00 21 00 01 C0 0C 00 21 00 01 00 00 8C om..!.....!..... +0030: A0 00 19 00 01 00 00 00 15 05 68 6F 73 74 34 07 ..........host4. +0040: 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 C0 3F 00 02 domain1.com..?.. +0050: 00 01 00 00 8C A0 00 05 02 6E 73 C0 3F C0 39 00 .........ns.?.9. +0060: 01 00 01 00 01 51 80 00 04 01 02 04 04 C0 58 00 .....Q........X. +0070: 01 00 01 00 00 8C A0 00 04 7F 00 00 01 ............. + + +# DNS Request + +0000: B2 B9 01 00 00 01 00 00 00 00 00 00 01 31 01 34 .............1.4 +0010: 01 32 01 31 07 69 6E 2D 61 64 64 72 04 61 72 70 .2.1.in-addr.arp +0020: 61 00 00 0C 00 01 a..... + + +# DNS Response + +0000: B2 B9 85 80 00 01 00 01 00 01 00 01 01 31 01 34 .............1.4 +0010: 01 32 01 31 07 69 6E 2D 61 64 64 72 04 61 72 70 .2.1.in-addr.arp +0020: 61 00 00 0C 00 01 C0 0C 00 0C 00 01 00 00 8C A0 a............... +0030: 00 13 05 68 6F 73 74 31 07 64 6F 6D 61 69 6E 31 ...host1.domain1 +0040: 03 63 6F 6D 00 C0 0E 00 02 00 01 00 00 8C A0 00 .com............ +0050: 05 02 6E 73 C0 38 C0 51 00 01 00 01 00 00 8C A0 ..ns.8.Q........ +0060: 00 04 7F 00 00 01 ...... + + --- /dev/null 2018-03-22 09:59:21.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/AttributeTests/GetNumericRRs.java 2018-03-22 09:59:20.000000000 +0800 @@ -0,0 +1,64 @@ +/* + * 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. + */ + +/* + * @test + * @bug 8198882 + * @summary Tests that we can get the attributes of a DNS entry by naming + * specific RRs by their type codes. Omit NAPTR for now because + * bind doesn't support it. + * @modules java.base/sun.security.util + * @library ../lib/ + * @run main GetNumericRRs + */ + +import javax.naming.directory.Attributes; + +public class GetNumericRRs extends GetRRsBase { + { + // set new test data instead of default value + setNumAttrs(new String[][] { { "1", "15", "13", "16" }, { "2", "6" }, + { "28" }, { "5" }, { "33" }, { "12" }, }); + } + + public static void main(String[] args) throws Exception { + new GetNumericRRs().run(args); + } + + @Override public void runTest() throws Exception { + initContext(); + testAgainstNonRootUrl(); + switchToRootUrl(); + testAgainstRootUrl(); + } + + /* + * Tests that we can get the attributes of a DNS entry by naming + * specific RRs by their type codes. Omit NAPTR for now because + * bind doesn't support it. + */ + @Override public Attributes getAttributes() throws Exception { + return context().getAttributes(getKeys()[getIndex()], + getNumAttrs()[getIndex()]); + } +} --- /dev/null 2018-03-22 09:59:23.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/AttributeTests/GetRRs.dns 2018-03-22 09:59:22.000000000 +0800 @@ -0,0 +1,148 @@ +# +# 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 GetRRs.java +# +# NOTE: This hexadecimal dump of DNS protocol messages was generated by +# running the GetRRs application program against a real DNS +# server along with DNSTracer +# +################################################################################ + +# DNS Request + +0000: 91 E0 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: FF 00 01 ... + + +# DNS Response + +0000: 91 E0 85 80 00 01 00 06 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: FF 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 0C 00 1D 00 01 00 00 8C A0 00 10 ost............. +0050: 00 12 16 13 88 97 1A 35 69 68 41 38 00 9B 16 58 .......5ihA8...X +0060: C0 0C 00 0D 00 01 00 00 8C A0 00 13 0C 54 68 65 .............The +0070: 20 4F 72 69 67 69 6E 61 6C 05 53 75 6E 6E 79 C0 Original.Sunny. +0080: 0C 00 0F 00 01 00 00 8C A0 00 11 00 0A 05 72 65 ..............re +0090: 6C 61 79 04 6F 68 69 6F 02 75 73 00 C0 0C 00 0F lay.ohio.us..... +00A0: 00 01 00 00 8C A0 00 10 00 14 05 72 65 6C 61 79 ...........relay +00B0: 05 74 65 78 61 73 C0 98 C0 0C 00 01 00 01 00 01 .texas.......... +00C0: 51 80 00 04 01 02 04 01 C0 12 00 02 00 01 00 00 Q............... +00D0: 8C A0 00 05 02 6E 73 C0 12 C0 D4 00 01 00 01 00 .....ns......... +00E0: 00 8C A0 00 04 7F 00 00 01 ......... + + +# DNS Request + +0000: 07 37 01 00 00 01 00 00 00 00 00 00 07 64 6F 6D .7...........dom +0010: 61 69 6E 31 03 63 6F 6D 00 00 FF 00 01 ain1.com..... + + +# DNS Response + +0000: 07 37 85 80 00 01 00 03 00 00 00 01 07 64 6F 6D .7...........dom +0010: 61 69 6E 31 03 63 6F 6D 00 00 FF 00 01 C0 0C 00 ain1.com........ +0020: 06 00 01 00 00 8C A0 00 26 02 6E 73 C0 0C 0A 70 ........&.ns...p +0030: 6F 73 74 6D 61 73 74 65 72 C0 0C 00 00 00 01 00 ostmaster....... +0040: 00 1C 20 00 00 0E 10 00 06 97 80 00 01 51 80 C0 .. ..........Q.. +0050: 0C 00 02 00 01 00 00 8C A0 00 02 C0 29 C0 0C 00 ............)... +0060: 10 00 01 00 00 8C A0 00 0C 0B 54 65 73 74 20 64 ..........Test d +0070: 6F 6D 61 69 6E C0 29 00 01 00 01 00 00 8C A0 00 omain.)......... +0080: 04 7F 00 00 01 ..... + + +# DNS Request + +0000: FF 0E 01 00 00 01 00 00 00 00 00 00 04 69 70 76 .............ipv +0010: 36 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 1C 6.domain1.com... +0020: 00 01 .. + + +# DNS Response + +0000: FF 0E 85 80 00 01 00 01 00 01 00 01 04 69 70 76 .............ipv +0010: 36 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 1C 6.domain1.com... +0020: 00 01 C0 0C 00 1C 00 01 00 00 8C A0 00 10 00 0A ................ +0030: 00 0B 00 0C 00 0D 00 0E 00 01 00 02 00 03 C0 11 ................ +0040: 00 02 00 01 00 00 8C A0 00 05 02 6E 73 C0 11 C0 ...........ns... +0050: 4A 00 01 00 01 00 00 8C A0 00 04 7F 00 00 01 J.............. + + +# DNS Request + +0000: 41 94 01 00 00 01 00 00 00 00 00 00 03 73 75 6E A............sun +0010: 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 05 00 .domain1.com.... +0020: 01 . + + +# DNS Response + +0000: 41 94 85 80 00 01 00 01 00 01 00 01 03 73 75 6E A............sun +0010: 07 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 00 05 00 .domain1.com.... +0020: 01 C0 0C 00 05 00 01 00 00 8C A0 00 08 05 68 6F ..............ho +0030: 73 74 31 C0 10 C0 10 00 02 00 01 00 00 8C A0 00 st1............. +0040: 05 02 6E 73 C0 10 C0 41 00 01 00 01 00 00 8C A0 ..ns...A........ +0050: 00 04 7F 00 00 01 ...... + + +# DNS Request + +0000: 8B D6 01 00 00 01 00 00 00 00 00 00 04 5F 66 74 ............._ft +0010: 70 04 5F 54 63 70 07 64 6F 6D 61 69 6E 31 03 63 p._Tcp.domain1.c +0020: 6F 6D 00 00 21 00 01 om..!.. + + +# DNS Response + +0000: 8B D6 85 80 00 01 00 01 00 01 00 02 04 5F 66 74 ............._ft +0010: 70 04 5F 54 63 70 07 64 6F 6D 61 69 6E 31 03 63 p._Tcp.domain1.c +0020: 6F 6D 00 00 21 00 01 C0 0C 00 21 00 01 00 00 8C om..!.....!..... +0030: A0 00 19 00 01 00 00 00 15 05 68 6F 73 74 34 07 ..........host4. +0040: 64 6F 6D 61 69 6E 31 03 63 6F 6D 00 C0 3F 00 02 domain1.com..?.. +0050: 00 01 00 00 8C A0 00 05 02 6E 73 C0 3F C0 39 00 .........ns.?.9. +0060: 01 00 01 00 01 51 80 00 04 01 02 04 04 C0 58 00 .....Q........X. +0070: 01 00 01 00 00 8C A0 00 04 7F 00 00 01 ............. + + +# DNS Request + +0000: D9 CF 01 00 00 01 00 00 00 00 00 00 01 31 01 34 .............1.4 +0010: 01 32 01 31 07 69 6E 2D 61 64 64 72 04 61 72 70 .2.1.in-addr.arp +0020: 61 00 00 0C 00 01 a..... + + +# DNS Response + +0000: D9 CF 85 80 00 01 00 01 00 01 00 01 01 31 01 34 .............1.4 +0010: 01 32 01 31 07 69 6E 2D 61 64 64 72 04 61 72 70 .2.1.in-addr.arp +0020: 61 00 00 0C 00 01 C0 0C 00 0C 00 01 00 00 8C A0 a............... +0030: 00 13 05 68 6F 73 74 31 07 64 6F 6D 61 69 6E 31 ...host1.domain1 +0040: 03 63 6F 6D 00 C0 0E 00 02 00 01 00 00 8C A0 00 .com............ +0050: 05 02 6E 73 C0 38 C0 51 00 01 00 01 00 00 8C A0 ..ns.8.Q........ +0060: 00 04 7F 00 00 01 ...... + + --- /dev/null 2018-03-22 09:59:26.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/AttributeTests/GetRRs.java 2018-03-22 09:59:25.000000000 +0800 @@ -0,0 +1,58 @@ +/* + * 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. + */ + +/* + * @test + * @bug 8198882 + * @summary Tests that we can get the attributes of a DNS entry by naming + * specific RRs by name. Omit NAPTR for now because bind doesn't + * support it. + * @modules java.base/sun.security.util + * @library ../lib/ + * @run main GetRRs + */ + +import javax.naming.directory.Attributes; + +public class GetRRs extends GetRRsBase { + public static void main(String[] args) throws Exception { + new GetRRs().run(args); + } + + @Override public void runTest() throws Exception { + initContext(); + testAgainstNonRootUrl(); + switchToRootUrl(); + testAgainstRootUrl(); + } + + /* + * Tests that we can get the attributes of a DNS entry by naming + * specific RRs by name. Omit NAPTR for now because bind doesn't + * support it. + */ + @Override public Attributes getAttributes() throws Exception { + return context() + .getAttributes(getKeys()[getIndex()], getAttrs()[getIndex()]); + } +} --- /dev/null 2018-03-22 09:59:28.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/AttributeTests/GetRRsBase.java 2018-03-22 09:59:27.000000000 +0800 @@ -0,0 +1,102 @@ +/* + * 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.Context; +import javax.naming.NamingException; +import javax.naming.directory.Attributes; +import javax.naming.directory.InitialDirContext; + +public abstract class GetRRsBase extends GetAttrsBase { + private String[] keys; + private String[][] numAttrs; + private String[][] attrs; + + { + // set default test data + setKeys(new String[] { "host1", "", "ipv6", "sun", "_ftp._Tcp", + "1.4.2.1.in-addr.arpa", }); + setNumAttrs(new String[][] { { "IN 1", "IN 15", "IN 13", "IN 16" }, + { "IN 2", "IN 6" }, { "IN 28" }, { "IN 5" }, { "IN 33" }, + { "IN 12" }, }); + setAttrs( + new String[][] { { "A", "MX", "HINFO", "TXT" }, { "NS", "SOA" }, + { "AAAA" }, { "CNAME" }, { "SRV" }, { "PTR" }, }); + } + + private static final int ROOT_LIMIT = 5; // point at which to use root ctx + + private int index; + + public void testAgainstNonRootUrl() throws Exception { + for (index = 0; index < ROOT_LIMIT; index++) { + Attributes retAttrs = getAttributes(); + verifyAttributes(retAttrs); + } + } + + public void switchToRootUrl() throws NamingException { + DNSTestUtils.cleanup(context()); + env().put(Context.PROVIDER_URL, DNSTestUtils.getRootUrl(env())); + setContext(new InitialDirContext(env())); + } + + public void testAgainstRootUrl() throws Exception { + for (index = ROOT_LIMIT; index < keys.length; index++) { + Attributes retAttrs = getAttributes(); + verifyAttributes(retAttrs); + } + } + + @Override public void verifyAttributes(Attributes retAttrs) + throws Exception { + DNSTestUtils.verifySchema(retAttrs, attrs[index], new String[] {}); + } + + public int getIndex() { + return index; + } + + public String[] getKeys() { + return keys; + } + + public void setKeys(String[] keys) { + this.keys = keys; + } + + public String[][] getNumAttrs() { + return numAttrs; + } + + public void setNumAttrs(String[][] numAttrs) { + this.numAttrs = numAttrs; + } + + public String[][] getAttrs() { + return attrs; + } + + public void setAttrs(String[][] attrs) { + this.attrs = attrs; + } +} --- /dev/null 2018-03-22 09:59:29.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/lib/DNSTestBase.java 2018-03-22 09:59:29.000000000 +0800 @@ -0,0 +1,67 @@ +/* + * 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.directory.DirContext; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.util.Hashtable; + +public abstract class DNSTestBase extends TestBase { + private DatagramSocket socket; + private Hashtable env; + private DirContext ctx; + + @Override public void initRes() throws Exception { + // Create socket on localhost only to avoid possible noise packet + socket = new DatagramSocket(0, InetAddress.getLoopbackAddress()); + } + + @Override public void initTest(String[] args) { + env = DNSTestUtils.initEnv(socket, this.getClass().getName(), args); + } + + @Override public void cleanupTest() { + DNSTestUtils.cleanup(ctx); + DNSTestUtils.cleanupClosableRes(socket); + } + + public Hashtable env() { + if (env == null) { + throw new RuntimeException("Test had not been initialized"); + } + + return env; + } + + public DirContext context() { + if (ctx == null) { + throw new RuntimeException("Context had not been initialized"); + } + + return ctx; + } + + public void setContext(DirContext context) { + ctx = context; + } +} --- /dev/null 2018-03-22 09:59:30.000000000 +0800 +++ new/test/jdk/com/sun/jndi/dns/lib/TestBase.java 2018-03-22 09:59:30.000000000 +0800 @@ -0,0 +1,61 @@ +/* + * 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. + */ + +public abstract class TestBase { + + public void run(String[] args) throws Exception { + initRes(); + initTest(args); + setupTest(); + launch(); + } + + public void initRes() throws Exception { + } + + public void initTest(String[] args) { + } + + public void setupTest() { + } + + public void launch() throws Exception { + try { + runTest(); + } catch (Exception e) { + if (!handleException(e)) { + throw e; + } + } finally { + cleanupTest(); + } + } + + public abstract void runTest() throws Exception; + + public boolean handleException(Exception e) { + return false; + } + + public abstract void cleanupTest(); +}