author | phh |
Sat, 30 Nov 2019 14:33:05 -0800 | |
changeset 59330 | 5b96c12f909d |
parent 51192 | 499b873761d8 |
permissions | -rw-r--r-- |
51192
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
1 |
/* |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
2 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
4 |
* |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
8 |
* |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
13 |
* accompanied this code). |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
14 |
* |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
18 |
* |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
21 |
* questions. |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
22 |
*/ |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
23 |
|
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
24 |
import javax.naming.Context; |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
25 |
import javax.naming.NamingException; |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
26 |
import javax.naming.directory.Attributes; |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
27 |
import javax.naming.directory.InitialDirContext; |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
28 |
|
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
29 |
public abstract class GetRRsBase extends DNSTestBase { |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
30 |
public static final int ROOT_LIMIT = 5; // point at which to use root ctx |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
31 |
private String[] keys; |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
32 |
private String[][] numAttrs; |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
33 |
private String[][] attrs; |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
34 |
|
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
35 |
public GetRRsBase() { |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
36 |
// set default test data |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
37 |
setKeys(new String[] { "host1", "", "ipv6", "sun", "_ftp._Tcp", |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
38 |
"1.4.2.1.in-addr.arpa", }); |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
39 |
setNumAttrs(new String[][] { { "IN 1", "IN 15", "IN 13", "IN 16" }, |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
40 |
{ "IN 2", "IN 6" }, { "IN 28" }, { "IN 5" }, { "IN 33" }, |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
41 |
{ "IN 12" }, }); |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
42 |
setAttrs( |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
43 |
new String[][] { { "A", "MX", "HINFO", "TXT" }, { "NS", "SOA" }, |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
44 |
{ "AAAA" }, { "CNAME" }, { "SRV" }, { "PTR" }, }); |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
45 |
} |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
46 |
|
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
47 |
public void initContext() throws Exception { |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
48 |
setContext(new InitialDirContext(env())); |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
49 |
} |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
50 |
|
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
51 |
public void switchToRootUrl() throws NamingException { |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
52 |
DNSTestUtils.cleanup(context()); |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
53 |
env().put(Context.PROVIDER_URL, DNSTestUtils.getRootUrl(env())); |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
54 |
setContext(new InitialDirContext(env())); |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
55 |
} |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
56 |
|
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
57 |
public void verifyAttributes(Attributes attrs, String[] mandatory) { |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
58 |
DNSTestUtils.verifySchema(attrs, mandatory, new String[] {}); |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
59 |
} |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
60 |
|
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
61 |
public Attributes getAttributes(String name, String[] attrIds) |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
62 |
throws Exception { |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
63 |
return context().getAttributes(name, attrIds); |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
64 |
} |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
65 |
|
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
66 |
public void setKeys(String[] keys) { |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
67 |
this.keys = keys; |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
68 |
} |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
69 |
|
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
70 |
public String[] getKeys() { |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
71 |
return keys; |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
72 |
} |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
73 |
|
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
74 |
public void setNumAttrs(String[][] numAttrs) { |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
75 |
this.numAttrs = numAttrs; |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
76 |
} |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
77 |
|
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
78 |
public String[][] getNumAttrs() { |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
79 |
return numAttrs; |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
80 |
} |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
81 |
|
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
82 |
public void setAttrs(String[][] attrs) { |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
83 |
this.attrs = attrs; |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
84 |
} |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
85 |
|
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
86 |
public String[][] getAttrs() { |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
87 |
return attrs; |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
88 |
} |
499b873761d8
8198882: Add 10 JNDI tests to com/sun/jndi/dns/AttributeTests/
xyin
parents:
diff
changeset
|
89 |
} |