Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/BooleanArgument/booleanValue/booleanvalue002.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.booleanValue;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.Connector.BooleanArgument;39import com.sun.jdi.connect.LaunchingConnector;404142/**43* The test for the implementation of an object of the type <BR>44* Connector.BooleanArgument. <BR>45* <BR>46* The test checks up that results of the method <BR>47* <code>com.sun.jdi.connect.Connector.BooleanArgument.BooleanValue()</code> <BR>48* complies with its specification in the following cases: <BR>49<BR>50<BR>51* <BR>52* In case of the method booleanValue() returns a wrong value, <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*/585960public class booleanvalue002 {6162public static void main(String argv[]) {63System.exit(run(argv, System.out) + 95); // JCK-compatible exit status64}6566public static int run(String argv[], PrintStream out) {6768int exitCode = 0;69int exitCode0 = 0;70int exitCode2 = 2;71//72String sErr1 = "WARNING:\n" +73"Method tested: " +74"jdi.Connector.BooleanArgument.booleanValue\n" ;75//76String sErr2 = "INFO:\n" +77"Method tested: " +78"jdi.Connector.BooleanArgument.booleanValue\n" ;798081VirtualMachineManager vmm = Bootstrap.virtualMachineManager();8283List connectorsList = vmm.allConnectors();84Iterator connectorsListIterator = connectorsList.iterator();85//86Connector.BooleanArgument argument = null;8788for ( ; ; ) {89try {90Connector connector =91(Connector) connectorsListIterator.next();9293Map defaultArguments = connector.defaultArguments();94Set keyset = defaultArguments.keySet();95int keysetSize = defaultArguments.size();96Iterator keysetIterator = keyset.iterator();9798for ( ; ; ) {99try {100String argName = (String) keysetIterator.next();101102try {103//104argument = (Connector.BooleanArgument)105defaultArguments.get(argName);106break ;107} catch ( ClassCastException e) {108}109} catch ( NoSuchElementException e) {110break ;111}112}113if (argument != null) {114break ;115}116} catch ( NoSuchElementException e) {117out.println(sErr1 +118"no Connecter with needed BooleanArgument found\n");119return exitCode0;120}121}122123boolean b;124125argument.setValue(true);126argument.setValue("");127b = argument.booleanValue();128if (b) {129exitCode = exitCode2;130out.println(sErr2 +131"check: '' -> true = ? \n" +132"result: booleanValue() == " + b + "\n");133}134135argument.setValue(true);136argument.setValue("tru");137b = argument.booleanValue();138if (b) {139exitCode = exitCode2;140out.println(sErr2 +141"check: 'tru' -> true = ? \n" +142"result: booleanValue() == " + b + "\n");143}144145argument.setValue(false);146argument.setValue("");147b = argument.booleanValue();148if (b) {149exitCode = exitCode2;150out.println(sErr2 +151"check: '' -> false = ? \n" +152"result: booleanValue() == " + b + "\n");153}154155argument.setValue(false);156argument.setValue("fals");157b = argument.booleanValue();158if (b) {159exitCode = exitCode2;160out.println(sErr2 +161"check: '' -> false = ? \n" +162"result: booleanValue() == " + b + "\n");163}164165argument.setValue("true");166argument.setValue("");167b = argument.booleanValue();168if (b) {169exitCode = exitCode2;170out.println(sErr2 +171"check: '' -> 'true' = ? \n" +172"result: booleanValue() == " + b + "\n");173}174175argument.setValue("true");176argument.setValue("tru");177b = argument.booleanValue();178if (b) {179exitCode = exitCode2;180out.println(sErr2 +181"check: 'tru' -> 'true' = ? \n" +182"result: booleanValue() == " + b + "\n");183}184185argument.setValue("false");186argument.setValue("");187b = argument.booleanValue();188if (b) {189exitCode = exitCode2;190out.println(sErr2 +191"check: '' -> 'false' = ? \n" +192"result: booleanValue() == " + b + "\n");193}194195argument.setValue("false");196argument.setValue("fals");197b = argument.booleanValue();198if (b) {199exitCode = exitCode2;200out.println(sErr2 +201"check: 'fals' -> 'false' = ? \n" +202"result: booleanValue() == " + b + "\n");203}204205if (exitCode != exitCode0)206out.println("TEST FAILED");207208return exitCode;209}210}211212213