Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/BooleanArgument/booleanValue/booleanvalue002.java
41161 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.BooleanArgument.booleanValue;
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
import com.sun.jdi.connect.LaunchingConnector;
41
42
43
/**
44
* The test for the implementation of an object of the type <BR>
45
* Connector.BooleanArgument. <BR>
46
* <BR>
47
* The test checks up that results of the method <BR>
48
* <code>com.sun.jdi.connect.Connector.BooleanArgument.BooleanValue()</code> <BR>
49
* complies with its specification in the following cases: <BR>
50
<BR>
51
<BR>
52
* <BR>
53
* In case of the method booleanValue() returns a wrong value, <BR>
54
* the test produces the return value 97 and <BR>
55
* a corresponding error message. <BR>
56
* Otherwise, the test is passed and produces <BR>
57
* the return value 95 and no message. <BR>
58
*/
59
60
61
public class booleanvalue002 {
62
63
public static void main(String argv[]) {
64
System.exit(run(argv, System.out) + 95); // JCK-compatible exit status
65
}
66
67
public static int run(String argv[], PrintStream out) {
68
69
int exitCode = 0;
70
int exitCode0 = 0;
71
int exitCode2 = 2;
72
//
73
String sErr1 = "WARNING:\n" +
74
"Method tested: " +
75
"jdi.Connector.BooleanArgument.booleanValue\n" ;
76
//
77
String sErr2 = "INFO:\n" +
78
"Method tested: " +
79
"jdi.Connector.BooleanArgument.booleanValue\n" ;
80
81
82
VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
83
84
List connectorsList = vmm.allConnectors();
85
Iterator connectorsListIterator = connectorsList.iterator();
86
//
87
Connector.BooleanArgument argument = null;
88
89
for ( ; ; ) {
90
try {
91
Connector connector =
92
(Connector) connectorsListIterator.next();
93
94
Map defaultArguments = connector.defaultArguments();
95
Set keyset = defaultArguments.keySet();
96
int keysetSize = defaultArguments.size();
97
Iterator keysetIterator = keyset.iterator();
98
99
for ( ; ; ) {
100
try {
101
String argName = (String) keysetIterator.next();
102
103
try {
104
//
105
argument = (Connector.BooleanArgument)
106
defaultArguments.get(argName);
107
break ;
108
} catch ( ClassCastException e) {
109
}
110
} catch ( NoSuchElementException e) {
111
break ;
112
}
113
}
114
if (argument != null) {
115
break ;
116
}
117
} catch ( NoSuchElementException e) {
118
out.println(sErr1 +
119
"no Connecter with needed BooleanArgument found\n");
120
return exitCode0;
121
}
122
}
123
124
boolean b;
125
126
argument.setValue(true);
127
argument.setValue("");
128
b = argument.booleanValue();
129
if (b) {
130
exitCode = exitCode2;
131
out.println(sErr2 +
132
"check: '' -> true = ? \n" +
133
"result: booleanValue() == " + b + "\n");
134
}
135
136
argument.setValue(true);
137
argument.setValue("tru");
138
b = argument.booleanValue();
139
if (b) {
140
exitCode = exitCode2;
141
out.println(sErr2 +
142
"check: 'tru' -> true = ? \n" +
143
"result: booleanValue() == " + b + "\n");
144
}
145
146
argument.setValue(false);
147
argument.setValue("");
148
b = argument.booleanValue();
149
if (b) {
150
exitCode = exitCode2;
151
out.println(sErr2 +
152
"check: '' -> false = ? \n" +
153
"result: booleanValue() == " + b + "\n");
154
}
155
156
argument.setValue(false);
157
argument.setValue("fals");
158
b = argument.booleanValue();
159
if (b) {
160
exitCode = exitCode2;
161
out.println(sErr2 +
162
"check: '' -> false = ? \n" +
163
"result: booleanValue() == " + b + "\n");
164
}
165
166
argument.setValue("true");
167
argument.setValue("");
168
b = argument.booleanValue();
169
if (b) {
170
exitCode = exitCode2;
171
out.println(sErr2 +
172
"check: '' -> 'true' = ? \n" +
173
"result: booleanValue() == " + b + "\n");
174
}
175
176
argument.setValue("true");
177
argument.setValue("tru");
178
b = argument.booleanValue();
179
if (b) {
180
exitCode = exitCode2;
181
out.println(sErr2 +
182
"check: 'tru' -> 'true' = ? \n" +
183
"result: booleanValue() == " + b + "\n");
184
}
185
186
argument.setValue("false");
187
argument.setValue("");
188
b = argument.booleanValue();
189
if (b) {
190
exitCode = exitCode2;
191
out.println(sErr2 +
192
"check: '' -> 'false' = ? \n" +
193
"result: booleanValue() == " + b + "\n");
194
}
195
196
argument.setValue("false");
197
argument.setValue("fals");
198
b = argument.booleanValue();
199
if (b) {
200
exitCode = exitCode2;
201
out.println(sErr2 +
202
"check: 'fals' -> 'false' = ? \n" +
203
"result: booleanValue() == " + b + "\n");
204
}
205
206
if (exitCode != exitCode0)
207
out.println("TEST FAILED");
208
209
return exitCode;
210
}
211
}
212
213