Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/Argument/setValue/setvalue001.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 java.lang.NullPointerException;3536import com.sun.jdi.VirtualMachineManager;37import com.sun.jdi.Bootstrap;38import com.sun.jdi.connect.Connector;39import com.sun.jdi.connect.Connector.Argument;404142/**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. <BR>49* The case for testing includes throwing NullPointerException <BR>50* if a parameter is null-string. <BR>51* <BR>52*/535455public class setvalue001 {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.Argument.setValue()\n" ;70//71String sErr2 = "ERROR\n" +72"Method tested: " +73"jdi.Connector.Argument.setValue()\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) {108break ;109}110} catch ( NoSuchElementException e) {111out.println(sErr1 +112"no Connecter with Argument found\n");113return exitCode0;114}115}116117try {118argument.setValue(null);119exitCode = exitCode2;120out.println(sErr2 +121"check: setValue(null); \n" +122"error: no NullPointerException thrown\n");123} catch ( java.lang.NullPointerException e ) {124}125126if (exitCode != exitCode0)127out.println("TEST FAILED");128129return exitCode;130}131}132133134