Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/Argument/setValue/setvalue002.java
41160 views
/*1* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223package nsk.jdi.Argument.setValue;2425import java.io.PrintStream;26import java.io.Serializable;2728import java.util.Map;29import java.util.Set;30import java.util.List;31import java.util.Iterator;32import java.util.NoSuchElementException;3334import com.sun.jdi.VirtualMachineManager;35import com.sun.jdi.Bootstrap;36import com.sun.jdi.connect.Connector;37import com.sun.jdi.connect.Connector.Argument;38import com.sun.jdi.connect.LaunchingConnector;394041/**42* The test for the implementation of an object of the type <BR>43* Connector.Argument. <BR>44*45* The test checks up that results of the method <BR>46* <code>com.sun.jdi.connect.Connector.Argument.setValue()</code> <BR>47* complies with its specification, when a string value to be set <BR>48* is the empty or non-empty string. <BR>49* <BR>50* In case of the method Arguemnt.value() returns the value, <BR>51* not equal to one has been set, <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*/575859public class setvalue002 {6061public static void main(String argv[]) {62System.exit(run(argv, System.out) + 95); // JCK-compatible exit status63}6465public static int run(String argv[], PrintStream out) {6667int exitCode = 0;68int exitCode0 = 0;69int exitCode2 = 2;70//71String sErr1 = "WARNING\n" +72"Method tested: " +73"jdi.Connector.IntegerArgument.max\n" ;74//75String sErr2 = "ERROR\n" +76"Method tested: " +77"jdi.Connector.Argument.setValue()\n" ;7879VirtualMachineManager vmm = Bootstrap.virtualMachineManager();8081List connectorsList = vmm.allConnectors();82Iterator connectorsListIterator = connectorsList.iterator();83//84Connector.Argument argument = null;8586for ( ; ; ) {87try {88Connector connector =89(Connector) connectorsListIterator.next();9091Map defaultArguments = connector.defaultArguments();92Set keyset = defaultArguments.keySet();93int keysetSize = defaultArguments.size();94Iterator keysetIterator = keyset.iterator();9596for ( ; ; ) {97try {98String argName = (String) keysetIterator.next();99100try {101//102argument = (Connector.Argument)103defaultArguments.get(argName);104break ;105} catch ( ClassCastException e) {106}107} catch ( NoSuchElementException e) {108break ;109}110}111if (argument != null) {112break ;113}114} catch ( NoSuchElementException e) {115out.println(sErr1 +116"no Connecter with Argument found\n");117return exitCode0;118}119}120121argument.setValue("");122if (argument.value() != "") {123exitCode = exitCode2;124out.println(sErr2 +125"check: setValue('');\n" +126"result: argument.value != ''\n");127}128129argument.setValue("a");130if (argument.value() != "a") {131exitCode = exitCode2;132out.println(sErr2 +133"check: argument.setValue('a');\n" +134"result: argument.value != 'a'\n");135}136137if (exitCode != exitCode0)138out.println("TEST FAILED");139140return exitCode;141}142}143144145