Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/Argument/isValid/isvalid001.java
41160 views
1
/*
2
* Copyright (c) 2000, 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
package nsk.jdi.Argument.isValid;
25
26
import java.io.PrintStream;
27
import java.io.Serializable;
28
29
import java.util.Map;
30
import java.util.Set;
31
import java.util.List;
32
import java.util.Iterator;
33
import java.util.NoSuchElementException;
34
35
import com.sun.jdi.VirtualMachineManager;
36
import com.sun.jdi.Bootstrap;
37
import com.sun.jdi.connect.Connector;
38
import com.sun.jdi.connect.Connector.Argument;
39
import com.sun.jdi.connect.Connector.BooleanArgument;
40
41
/**
42
* The test for the implementation of an object of the type <BR>
43
* Connector.Argument. <BR>
44
* <BR>
45
* The test checks up that results of the method <BR>
46
* <code>com.sun.jdi.connect.Connector.Argument.isValid()</code> <BR>
47
* complies with its specification, that is, <BR>
48
* "Returns: true if the value is valid to be used in setValue(String)" <BR>
49
* in case when Argument implements BooleanArgument . <BR>
50
* <BR>
51
* In case of a wrong boolean value returned, <BR>
52
* the test produces the return value 97 and <BR>
53
* a corresponding error message. <BR>
54
* Otherwise, the test is passed and produces <BR>
55
* the return value 95 and no message. <BR>
56
*/
57
58
59
public class isvalid001 {
60
61
public static void main(String argv[]) {
62
System.exit(run(argv, System.out) + 95); // JCK-compatible exit status
63
}
64
65
public static int run(String argv[], PrintStream out) {
66
67
int exitCode = 0;
68
int exitCode0 = 0;
69
int exitCode2 = 2;
70
//
71
String sErr1 = "WARNING\n" +
72
"Method tested: " +
73
"jdi.Connector.Argument.isValid\n" ;
74
//
75
String sErr2 = "ERROR\n" +
76
"Method tested: " +
77
"jdi.Connector.Argument.isValid\n" ;
78
79
VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
80
81
List connectorsList = vmm.allConnectors();
82
Iterator connectorsListIterator = connectorsList.iterator();
83
//
84
Connector.Argument argument = null;
85
Connector.BooleanArgument booleanArg = null;
86
87
for ( ; ; ) {
88
try {
89
Connector connector =
90
(Connector) connectorsListIterator.next();
91
92
Map defaultArguments = connector.defaultArguments();
93
Set keyset = defaultArguments.keySet();
94
int keysetSize = defaultArguments.size();
95
Iterator keysetIterator = keyset.iterator();
96
97
for ( ; ; ) {
98
try {
99
String argName = (String) keysetIterator.next();
100
101
try {
102
argument = (Connector.Argument)
103
defaultArguments.get(argName);
104
try {
105
booleanArg = (Connector.BooleanArgument)
106
defaultArguments.get(argName);
107
break ;
108
} catch ( ClassCastException e) {
109
}
110
} catch ( ClassCastException e) {
111
}
112
} catch ( NoSuchElementException e) {
113
break ;
114
}
115
}
116
if (booleanArg != null) {
117
break ;
118
}
119
} catch ( NoSuchElementException e) {
120
out.println(sErr1 +
121
"no Connector with BooleanArgument found\n");
122
return exitCode0;
123
}
124
}
125
126
if (!argument.isValid("true")) {
127
exitCode = exitCode2;
128
out.println(sErr2 +
129
"check: isValid('true')\n" +
130
"error: returned value != true\n");
131
}
132
133
if (!argument.isValid("false")) {
134
exitCode = exitCode2;
135
out.println(sErr2 +
136
"check: isValid('false')\n" +
137
"error: returned value != true\n");
138
}
139
140
if (argument.isValid("fals")) {
141
exitCode = exitCode2;
142
out.println(sErr2 +
143
"check: isValid('fals')\n" +
144
"error: returned value == true\n");
145
}
146
147
if (argument.isValid("")) {
148
exitCode = exitCode2;
149
out.println(sErr2 +
150
"check: isValid(<empty_string>)\n" +
151
"error: returned value == true\n");
152
}
153
154
155
if (exitCode != exitCode0)
156
out.println("TEST FAILED");
157
158
return exitCode;
159
}
160
}
161
162