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/isvalid005.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.IntegerArgument;
39
40
41
/**
42
* The test for the implementation of an object of the type <BR>
43
* Connector_IntegerArgument. <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 IntegerArgument <BR>
50
* and its parameter is one of the following: "a", "", null, null-string. <BR> <BR>
51
* <BR>
52
* In case of a wrong result returned, <BR>
53
* the test produces the return value 97 and <BR>
54
* a corresponding error message. <BR>
55
* Otherwise, the test is passed and produces <BR>
56
* the return value 95 and no message. <BR>
57
*/
58
59
//
60
public class isvalid005 {
61
62
public static void main(String argv[]) {
63
System.exit(run(argv, System.out) + 95); // JCK-compatible exit status
64
}
65
66
public static int run(String argv[], PrintStream out) {
67
68
int exitCode = 0;
69
int exitCode0 = 0;
70
int exitCode2 = 2;
71
//
72
String sErr1 = "WARNING\n" +
73
"Method tested: " +
74
"jdi.Connector.Argument.isValid\n" ;
75
//
76
String sErr2 = "ERROR\n" +
77
"Method tested: " +
78
"jdi.Connector.Argument.isValid\n" ;
79
80
VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
81
82
List connectorsList = vmm.allConnectors();
83
Iterator connectorsListIterator = connectorsList.iterator();
84
//
85
Connector.Argument argument = null;
86
Connector.IntegerArgument intArgument = null;
87
88
for ( ; ; ) {
89
try {
90
Connector connector =
91
(Connector) connectorsListIterator.next();
92
93
Map defaultArguments = connector.defaultArguments();
94
Set keyset = defaultArguments.keySet();
95
int keysetSize = defaultArguments.size();
96
Iterator keysetIterator = keyset.iterator();
97
98
for ( ; ; ) {
99
try {
100
String argName = (String) keysetIterator.next();
101
102
try {
103
//
104
argument = (Connector.IntegerArgument)
105
defaultArguments.get(argName);
106
try {
107
intArgument = (Connector.IntegerArgument)
108
defaultArguments.get(argName);
109
break ;
110
} catch ( ClassCastException e) {
111
}
112
} catch ( ClassCastException e) {
113
}
114
} catch ( NoSuchElementException e) {
115
break ;
116
}
117
}
118
if (intArgument != null) {
119
break ;
120
}
121
} catch ( NoSuchElementException e) {
122
out.println(sErr1 +
123
//
124
"no Connector with IntegerArgument found\n");
125
return exitCode0;
126
}
127
}
128
129
if (!argument.isValid("")) {
130
} else {
131
exitCode = exitCode2;
132
out.println(sErr2 +
133
"check: super.isValid('')\n" +
134
"result: true\n");
135
}
136
137
if (!argument.isValid("a")) {
138
} else {
139
exitCode = exitCode2;
140
out.println(sErr2 +
141
"check: super.isValid('a')\n" +
142
"result: true\n");
143
}
144
145
if (!argument.isValid((String) null)) {
146
} else {
147
exitCode = exitCode2;
148
out.println(sErr2 +
149
"check: super.isValid((String) null))\n" +
150
"result: true\n");
151
}
152
153
String s = null;
154
if (!argument.isValid(s)) {
155
} else {
156
exitCode = exitCode2;
157
out.println(sErr2 +
158
"check: super.isValid(String s = null)\n" +
159
"result: true\n");
160
}
161
162
163
if (exitCode != exitCode0) {
164
out.println("TEST FAILED");
165
}
166
return exitCode;
167
}
168
}
169
170