Path: blob/master/test/jdk/com/sun/jndi/dns/AttributeTests/GetRRsBase.java
41155 views
/*1* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import javax.naming.Context;24import javax.naming.NamingException;25import javax.naming.directory.Attributes;26import javax.naming.directory.InitialDirContext;2728public abstract class GetRRsBase extends DNSTestBase {29public static final int ROOT_LIMIT = 5; // point at which to use root ctx30private String[] keys;31private String[][] numAttrs;32private String[][] attrs;3334public GetRRsBase() {35// set default test data36setKeys(new String[] { "host1", "", "ipv6", "sun", "_ftp._Tcp",37"1.4.2.1.in-addr.arpa", });38setNumAttrs(new String[][] { { "IN 1", "IN 15", "IN 13", "IN 16" },39{ "IN 2", "IN 6" }, { "IN 28" }, { "IN 5" }, { "IN 33" },40{ "IN 12" }, });41setAttrs(42new String[][] { { "A", "MX", "HINFO", "TXT" }, { "NS", "SOA" },43{ "AAAA" }, { "CNAME" }, { "SRV" }, { "PTR" }, });44}4546public void initContext() throws Exception {47setContext(new InitialDirContext(env()));48}4950public void switchToRootUrl() throws NamingException {51DNSTestUtils.cleanup(context());52env().put(Context.PROVIDER_URL, DNSTestUtils.getRootUrl(env()));53setContext(new InitialDirContext(env()));54}5556public void verifyAttributes(Attributes attrs, String[] mandatory) {57DNSTestUtils.verifySchema(attrs, mandatory, new String[] {});58}5960public Attributes getAttributes(String name, String[] attrIds)61throws Exception {62return context().getAttributes(name, attrIds);63}6465public void setKeys(String[] keys) {66this.keys = keys;67}6869public String[] getKeys() {70return keys;71}7273public void setNumAttrs(String[][] numAttrs) {74this.numAttrs = numAttrs;75}7677public String[][] getNumAttrs() {78return numAttrs;79}8081public void setAttrs(String[][] attrs) {82this.attrs = attrs;83}8485public String[][] getAttrs() {86return attrs;87}88}899091