Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/BooleanArgument/setValue/setvalue001.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.setValue;
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
/**
43
* The test for the implementation of a BooleanArgument object. <BR>
44
*
45
* The test checks up that results of the method <BR>
46
* <code>com.sun.jdi.connect.Connector.BooleanArgument.setValue()</code> <BR>
47
* complies with specification. <BR>
48
* The test works as follows:
49
* <BR>
50
* - Virtual Machine Manager is invoked.
51
* - First BooleanArgument is searched among Connectors.<BR>
52
* If no a BooleanArgument is found out the test exits with <BR>
53
* the return value = 95 and a warning message. <BR>
54
* - Under the assumption that the method <BR>
55
* BooleanArgument.booleanValue() works correctly, <BR>
56
* to the value of the BooleanArgument founded, <BR>
57
* which may not have been set or may have an invalid value, <BR>
58
* the sequence of 5 following checks is applied: <BR>
59
* <BR>
60
* 1) setValue(true); booleanValue() must return true; <BR>
61
* 2) setValue(false); booleanValue() must return false; <BR>
62
* 3) setValue(false); booleanValue() must return false; <BR>
63
* 4) setValue(true); booleanValue() must return true; <BR>
64
* 5) setValue(true); booleanValue() must return true; <BR>
65
* <BR>
66
* In case of any check results in a wrong value, <BR>
67
* the test produces the return value 97 and <BR>
68
* a corresponding error message. <BR>
69
* Otherwise, the test is passed and produces <BR>
70
* the return value 95 and no message. <BR>
71
*/
72
73
74
public class setvalue001 {
75
76
public static void main(String argv[]) {
77
System.exit(run(argv, System.out) + 95); // JCK-compatible exit status
78
}
79
80
public static int run(String argv[], PrintStream out) {
81
82
int exitCode = 0;
83
int exitCode0 = 0;
84
int exitCode2 = 2;
85
//
86
String sErr1 = "WARNING\n" +
87
"Method tested: " +
88
"jdi.Connector.BooleanArgument.setValue\n" ;
89
//
90
String sErr2 = "ERROR\n" +
91
"Method tested: " +
92
"jdi.Connector.BooleanArgument.setValue\n" ;
93
94
VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
95
96
List connectorsList = vmm.allConnectors();
97
Iterator connectorsListIterator = connectorsList.iterator();
98
//
99
Connector.BooleanArgument argument = null;
100
101
for ( ; ; ) {
102
try {
103
Connector connector =
104
(Connector) connectorsListIterator.next();
105
106
Map defaultArguments = connector.defaultArguments();
107
Set keyset = defaultArguments.keySet();
108
int keysetSize = defaultArguments.size();
109
Iterator keysetIterator = keyset.iterator();
110
111
for ( ; ; ) {
112
try {
113
String argName = (String) keysetIterator.next();
114
115
try {
116
//
117
argument = (Connector.BooleanArgument)
118
defaultArguments.get(argName);
119
break ;
120
} catch ( ClassCastException e) {
121
}
122
} catch ( NoSuchElementException e) {
123
break ;
124
}
125
}
126
if (argument != null) {
127
break ;
128
}
129
} catch ( NoSuchElementException e) {
130
out.println(sErr1 +
131
"no Connecter with BooleanArgument found\n");
132
return exitCode0;
133
}
134
}
135
136
// 1) initial -> true
137
argument.setValue(true);
138
if (argument.booleanValue() != true) {
139
exitCode = 2;
140
out.println(sErr2 +
141
"case: unknown -> true\n" +
142
"error: a returned value != true");
143
}
144
145
// 2) true -> false
146
argument.setValue(false);
147
if (argument.booleanValue() != false) {
148
exitCode = 2;
149
out.println(sErr2 +
150
"case: true -> false\n" +
151
"error: a returned value != false\n");
152
}
153
154
// 3) false -> false
155
argument.setValue(false);
156
if (argument.booleanValue() != false) {
157
exitCode = 2;
158
out.println(sErr2 +
159
"case: false -> false\n" +
160
"error: a returned value != false");
161
}
162
163
// 4) false -> true
164
argument.setValue(true);
165
if (argument.booleanValue() != true) {
166
exitCode = 2;
167
out.println(sErr2 +
168
"case: false -> true\n" +
169
"error: a returned value != true\n");
170
}
171
172
// 5) true -> true
173
argument.setValue(true);
174
if (argument.booleanValue() != true) {
175
exitCode = 2;
176
out.println(sErr2 +
177
"case: true -> true\n" +
178
"error: a returned value != true\n");
179
}
180
181
if (exitCode != exitCode0)
182
out.println("TEST FAILED");
183
184
return exitCode;
185
}
186
}
187
188