author | xyin |
Mon, 22 Oct 2018 13:53:39 +0800 | |
changeset 52205 | a562c65c3c74 |
permissions | -rw-r--r-- |
52205
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
1 |
/* |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
2 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
4 |
* |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
8 |
* |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
13 |
* accompanied this code). |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
14 |
* |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
18 |
* |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
21 |
* questions. |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
22 |
*/ |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
23 |
|
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
24 |
import javax.naming.NamingException; |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
25 |
import javax.naming.directory.Attributes; |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
26 |
|
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
27 |
/** |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
28 |
* Abstract test base for Config related tests, this class extends DNSTestBase. |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
29 |
* |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
30 |
* @see DNSTestBase |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
31 |
* @see TestBase |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
32 |
*/ |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
33 |
abstract class AuthRecursiveBase extends DNSTestBase { |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
34 |
|
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
35 |
private static final String KEY = "host1"; |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
36 |
private static final String[] MANDATORY_ATTRIBUTES = { "A", "MX", "HINFO", |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
37 |
"TXT", "29" }; |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
38 |
private static final String[] OPTIONAL_ATTRIBUTES = {}; |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
39 |
|
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
40 |
private String fqdnUrl; |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
41 |
private String foreignFqdnUrl; |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
42 |
|
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
43 |
/** |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
44 |
* Setup test before real test run, it overrides the method of TestBase. |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
45 |
*/ |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
46 |
@Override |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
47 |
public void setupTest() { |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
48 |
super.setupTest(); |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
49 |
String fqdn = DNSTestUtils.buildFqdn(KEY, env(), true); |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
50 |
|
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
51 |
String foreignLeaf = (String) env().get("FOREIGN_LEAF"); |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
52 |
String foreignFqdn = DNSTestUtils.buildFqdn(foreignLeaf, env(), false); |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
53 |
|
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
54 |
fqdnUrl = DNSTestUtils.getRootUrl(env()) + "/" + fqdn; |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
55 |
foreignFqdnUrl = DNSTestUtils.getRootUrl(env()) + "/" + foreignFqdn; |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
56 |
} |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
57 |
|
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
58 |
/** |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
59 |
* Overload method of retrieveAndVerifyData, it will retrieve all of the |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
60 |
* attributes associated with given named object and do verification. |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
61 |
* |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
62 |
* @param name given named object |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
63 |
* @throws NamingException if a naming exception is encountered |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
64 |
*/ |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
65 |
public void retrieveAndVerifyData(String name) throws NamingException { |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
66 |
Attributes retAttrs = context().getAttributes(name); |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
67 |
DNSTestUtils.verifySchema(retAttrs, MANDATORY_ATTRIBUTES, |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
68 |
OPTIONAL_ATTRIBUTES); |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
69 |
} |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
70 |
|
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
71 |
/** |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
72 |
* Retrieves selected attributes associated with a named object and do |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
73 |
* verification. |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
74 |
* |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
75 |
* @param name given named object |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
76 |
* @param attrIds given ids of the attributes to retrieve |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
77 |
* @throws NamingException if a naming exception is encountered |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
78 |
*/ |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
79 |
public void retrieveAndVerifyData(String name, String[] attrIds) |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
80 |
throws NamingException { |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
81 |
Attributes retAttrs = context().getAttributes(name, attrIds); |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
82 |
DNSTestUtils.verifySchema(retAttrs, MANDATORY_ATTRIBUTES, |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
83 |
OPTIONAL_ATTRIBUTES); |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
84 |
} |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
85 |
|
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
86 |
/** |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
87 |
* Return parsed flag from given test name. |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
88 |
* |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
89 |
* @return parsed flag from given test name |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
90 |
*/ |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
91 |
public String parseFlagFromTestName() { |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
92 |
String name = (String) env().get("testname"); |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
93 |
if (name == null || name.isEmpty()) { |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
94 |
throw new RuntimeException("test name expecting not null/empty"); |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
95 |
} |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
96 |
|
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
97 |
if (name.endsWith("Default")) { |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
98 |
return "default"; |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
99 |
} else if (name.endsWith("True")) { |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
100 |
return "true"; |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
101 |
} else if (name.endsWith("False")) { |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
102 |
return "false"; |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
103 |
} else { |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
104 |
throw new RuntimeException("Invalid test name " + name); |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
105 |
} |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
106 |
} |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
107 |
|
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
108 |
public String getFqdnUrl() { |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
109 |
return fqdnUrl; |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
110 |
} |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
111 |
|
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
112 |
public String getForeignFqdnUrl() { |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
113 |
return foreignFqdnUrl; |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
114 |
} |
a562c65c3c74
8200151: Add 8 JNDI tests to com/sun/jndi/dns/ConfigTests/
xyin
parents:
diff
changeset
|
115 |
} |