Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/BooleanArgument/isValid/isvalid002.java
41161 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.BooleanArgument.isValid;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.LaunchingConnector;383940/**41* The test for the implementation of an object of the type <BR>42* Connector.BooleanArgument. <BR>43* <BR>44* The test checks up that results of the method <BR>45* <code>com.sun.jdi.connect.Connector.BooleanArgument.isValid()</code> <BR>46* complies with its specification when its parameter is null-string. <BR>47* <BR>48* The case for testing includes throwing NullPointerException as <BR>49* correct reaction to the null-parameter. <BR>50*/515253public class isvalid002 {5455public static void main(String argv[]) {56System.exit(run(argv, System.out) + 95); // JCK-compatible exit status57}5859public static int run(String argv[], PrintStream out) {6061int exitCode = 0;62int exitCode0 = 0;63int exitCode2 = 2;64//65String sErr1 = "WARNING\n" +66"Method tested: " +67"jdi.Connector.BooleanArgument.isValid\n" ;68//69String sErr2 = "ERROR\n" +70"Method tested: " +71"jdi.Connector.BooleanArgument.isValid\n" ;7273VirtualMachineManager vmm = Bootstrap.virtualMachineManager();7475List connectorsList = vmm.allConnectors();76Iterator connectorsListIterator = connectorsList.iterator();77//78Connector.BooleanArgument argument = null;7980for ( ; ; ) {81try {82Connector connector =83(Connector) connectorsListIterator.next();8485Map defaultArguments = connector.defaultArguments();86Set keyset = defaultArguments.keySet();87int keysetSize = defaultArguments.size();88Iterator keysetIterator = keyset.iterator();8990for ( ; ; ) {91try {92String argName = (String) keysetIterator.next();9394try {95//96argument = (Connector.BooleanArgument)97defaultArguments.get(argName);98break ;99} catch ( ClassCastException e) {100}101} catch ( NoSuchElementException e) {102break ;103}104}105if (argument != null) {106break ;107}108} catch ( NoSuchElementException e) {109out.println(sErr1 +110"no Connecter with BooleanArgument found\n");111return exitCode0;112}113}114115try {116argument.isValid(null);117exitCode = exitCode2;118out.println(sErr2 +119"check: isValid(null)\n" +120"error: no NullPointerException thrown \n");121} catch (NullPointerException e) {122}123124if (exitCode != exitCode0)125out.println("TEST FAILED");126127return exitCode;128}129}130131132