Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/IntegerArgument/min/min001.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.IntegerArgument.min;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_IntegerArgument. <BR>43* <BR>44* The test checks up that results of the method <BR>45* <code>com.sun.jdi.connect.Connector.IntegerArgument.min()</code> <BR>46* complies with the following requirement: <BR>47* -2147483648 <= min() <= 2147483647 <BR>48* <BR>49* In case of wrong values, <BR>50* the test produces the return value 97 and <BR>51* a corresponding error message. <BR>52* Otherwise, the test is passed and produces <BR>53* the return value 95 and no message. <BR>54*/555657public class min001 {5859public static void main(String argv[]) {60System.exit(run(argv, System.out) + 95); // JCK-compatible exit status61}6263public static int run(String argv[], PrintStream out) {6465int exitCode = 0;66int exitCode0 = 0;67int exitCode2 = 2;68//69String sErr1 = "WARNING\n" +70"Method tested: " +71"jdi.Connector.IntegerArgument.min\n" ;72//73String sErr2 = "ERROR\n" +74"Method tested: " +75"jdi.Connector.IntegerArgument.min\n" ;7677VirtualMachineManager vmm = Bootstrap.virtualMachineManager();7879List connectorsList = vmm.allConnectors();80Iterator connectorsListIterator = connectorsList.iterator();81//82Connector.IntegerArgument argument = null;8384for ( ; ; ) {85try {86Connector connector =87(Connector) connectorsListIterator.next();8889Map defaultArguments = connector.defaultArguments();90Set keyset = defaultArguments.keySet();91int keysetSize = defaultArguments.size();92Iterator keysetIterator = keyset.iterator();9394for ( ; ; ) {95try {96String argName = (String) keysetIterator.next();9798try {99//100argument = (Connector.IntegerArgument)101defaultArguments.get(argName);102break ;103} catch ( ClassCastException e) {104}105} catch ( NoSuchElementException e) {106break ;107}108}109if (argument != null) {110break ;111}112} catch ( NoSuchElementException e) {113out.println(sErr1 +114"no Connector with IntegerArgument found\n");115return exitCode0;116}117}118119int iMin = argument.min();120121if (iMin < -2147483648) {122exitCode = exitCode2;123out.println(sErr2 +124"check: iMin < -2147483648\n");125}126127if (iMin > 2147483647) {128exitCode = exitCode2;129out.println(sErr2 +130"check: iMin > 2147483647\n");131}132133if (exitCode != exitCode0)134out.println("TEST FAILED");135136return exitCode;137}138}139140141