Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/Argument/mustSpecify/mustspecify001.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.mustSpecify;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.IntegerArgument;383940/**41* The test for the implementation of an object of the type <BR>42* Connector_Argument. <BR>43* <BR>44* The test checks up that the method <BR>45* <code>com.sun.jdi.connect.Connector.Argument.mustSpecify()</code> <BR>46* complies with its specification. <BR>47* <BR>48* In case of Connector has no Argument needed to be specified, <BR>49* the test prints warning message. <BR>50* The test is always passed and produces <BR>51* the return value 95. <BR>52*/5354//55public class mustspecify001 {5657public static void main(String argv[]) {58System.exit(run(argv, System.out) + 95); // JCK-compatible exit status59}6061public static int run(String argv[], PrintStream out) {6263int exitCode = 0;64int exitCode0 = 0;65int exitCode2 = 2;66//67String sErr1 = "WARNING\n" +68"Method tested: " +69"jdi.Connector.IntegerArgument.intValue\n" ;70//71String sErr2 = "ERROR\n" +72"Method tested: " +73"jdi.Connector.IntegerArgument.intValue()\n" ;7475VirtualMachineManager vmm = Bootstrap.virtualMachineManager();7677List connectorsList = vmm.allConnectors();78Iterator connectorsListIterator = connectorsList.iterator();79//80Connector.Argument argument = null;8182for ( ; ; ) {83try {84Connector connector =85(Connector) connectorsListIterator.next();8687Map defaultArguments = connector.defaultArguments();88Set keyset = defaultArguments.keySet();89int keysetSize = defaultArguments.size();90Iterator keysetIterator = keyset.iterator();9192for ( ; ; ) {93try {94String argName = (String) keysetIterator.next();9596try {97//98argument = (Connector.Argument)99defaultArguments.get(argName);100break ;101} catch ( ClassCastException e) {102}103} catch ( NoSuchElementException e) {104break ;105}106}107if ((argument != null) && argument.mustSpecify()) {108break ;109}110} catch ( NoSuchElementException e) {111out.println(sErr1 +112//113"no Connector with Argument must be specified, found\n");114return exitCode0;115}116}117/*118argument.setValue("0");119if (argument.mustSpecify()) {120out.println("mustSpecify is the same\n");121} else {122out.println("mustSpecify is changed\n");123}124125if (exitCode != exitCode0) {126out.println("TEST FAILED");127}128*/129return exitCode0;130}131}132133134