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