Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/BooleanArgument/stringValueOf/stringvalueof002.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.stringValueOf;
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 an object of the type <BR>
44
* Connector.BooleanArgument. <BR>
45
* <BR>
46
* The test checks up that results of the method <BR>
47
* <code>com.sun.jdi.connect.Connector.BooleanArgument.stringValueOf()</code> <BR>
48
* complies with the following statement in its specification: <BR>
49
* "Does not set the value of the argument." <BR>
50
* <BR>
51
* In case of the method does set the value, <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 stringvalueof002 {
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.BooleanArgument.stringValueOf\n" ;
74
//
75
String sErr2 = "ERROR\n" +
76
"Method tested: " +
77
"jdi.Connector.BooleanArgument.stringValueOf\n" ;
78
79
VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
80
81
List connectorsList = vmm.allConnectors();
82
Iterator connectorsListIterator = connectorsList.iterator();
83
//
84
Connector.BooleanArgument argument = null;
85
86
for ( ; ; ) {
87
try {
88
Connector connector =
89
(Connector) connectorsListIterator.next();
90
91
Map defaultArguments = connector.defaultArguments();
92
Set keyset = defaultArguments.keySet();
93
int keysetSize = defaultArguments.size();
94
Iterator keysetIterator = keyset.iterator();
95
96
for ( ; ; ) {
97
try {
98
String argName = (String) keysetIterator.next();
99
100
try {
101
//
102
argument = (Connector.BooleanArgument)
103
defaultArguments.get(argName);
104
break ;
105
} catch ( ClassCastException e) {
106
}
107
} catch ( NoSuchElementException e) {
108
break ;
109
}
110
}
111
if (argument != null) {
112
break ;
113
}
114
} catch ( NoSuchElementException e) {
115
out.println(sErr1 +
116
"no Connector with BooleanArgument found\n");
117
return exitCode0;
118
}
119
}
120
121
String argumentValue;
122
// 1)
123
argument.setValue(true);
124
argumentValue = argument.stringValueOf(true);
125
if (argument.booleanValue() != true) {
126
exitCode = 2;
127
out.println(sErr2 +
128
"case: stringValueOf(true) doesn't change value true\n" +
129
"error: argument's value != true\n");
130
}
131
132
// 2)
133
argument.setValue(true);
134
argumentValue = argument.stringValueOf(false);
135
if (argument.booleanValue() != true) {
136
exitCode = 2;
137
out.println(sErr2 +
138
"case: stringValueOf(false) doesn't change value true\n" +
139
"error: argument's value != true\n");
140
}
141
142
// 3)
143
argument.setValue(false);
144
argumentValue = argument.stringValueOf(true);
145
if (argument.booleanValue() != false) {
146
exitCode = 2;
147
out.println(sErr2 +
148
"case: stringValueOf(true) doesn't change value false\n" +
149
"error: a returned value != false\n");
150
}
151
152
// 4)
153
argument.setValue(false);
154
argumentValue = argument.stringValueOf(false);
155
if (argument.booleanValue() != false) {
156
exitCode = 2;
157
out.println(sErr2 +
158
"case: stringValueOf(false) doesn't change value false\n" +
159
"error: a returned value != false\n");
160
}
161
162
if (exitCode != exitCode0)
163
out.println("TEST FAILED");
164
165
return exitCode;
166
}
167
}
168
169