Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/Argument/setValue/setvalue002.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.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.LaunchingConnector;
40
41
42
/**
43
* The test for the implementation of an object of the type <BR>
44
* Connector.Argument. <BR>
45
*
46
* The test checks up that results of the method <BR>
47
* <code>com.sun.jdi.connect.Connector.Argument.setValue()</code> <BR>
48
* complies with its specification, when a string value to be set <BR>
49
* is the empty or non-empty string. <BR>
50
* <BR>
51
* In case of the method Arguemnt.value() returns the value, <BR>
52
* not equal to one has been set, <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 setvalue002 {
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.IntegerArgument.max\n" ;
75
//
76
String sErr2 = "ERROR\n" +
77
"Method tested: " +
78
"jdi.Connector.Argument.setValue()\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
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
//
103
argument = (Connector.Argument)
104
defaultArguments.get(argName);
105
break ;
106
} catch ( ClassCastException e) {
107
}
108
} catch ( NoSuchElementException e) {
109
break ;
110
}
111
}
112
if (argument != null) {
113
break ;
114
}
115
} catch ( NoSuchElementException e) {
116
out.println(sErr1 +
117
"no Connecter with Argument found\n");
118
return exitCode0;
119
}
120
}
121
122
argument.setValue("");
123
if (argument.value() != "") {
124
exitCode = exitCode2;
125
out.println(sErr2 +
126
"check: setValue('');\n" +
127
"result: argument.value != ''\n");
128
}
129
130
argument.setValue("a");
131
if (argument.value() != "a") {
132
exitCode = exitCode2;
133
out.println(sErr2 +
134
"check: argument.setValue('a');\n" +
135
"result: argument.value != 'a'\n");
136
}
137
138
if (exitCode != exitCode0)
139
out.println("TEST FAILED");
140
141
return exitCode;
142
}
143
}
144
145