Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/IntegerArgument/max/max001.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.max;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.max()</code> <BR>46* complies with the following requirements: <BR>47* -2147483648 <= max() <= 2147483647 <BR>48* min() <= max() <BR>49* <BR>50* In case of wrong values, <BR>51* the test produces the return value 97 and <BR>52* a corresponding error message. <BR>53* Otherwise, the test is passed and produces <BR>54* the return value 95 and no message. <BR>55*/565758public class max001 {5960public static void main(String argv[]) {61System.exit(run(argv, System.out) + 95); // JCK-compatible exit status62}6364public static int run(String argv[], PrintStream out) {6566int exitCode = 0;67int exitCode0 = 0;68int exitCode2 = 2;69//70String sErr1 = "WARNING\n" +71"Method tested: " +72"jdi.Connector.IntegerArgument.max\n" ;73//74String sErr2 = "ERROR\n" +75"Method tested: " +76"jdi.Connector.IntegerArgument.max\n" ;777879VirtualMachineManager vmm = Bootstrap.virtualMachineManager();8081List connectorsList = vmm.allConnectors();82Iterator connectorsListIterator = connectorsList.iterator();83//84Connector.IntegerArgument argument = null;8586for ( ; ; ) {87try {88Connector connector =89(Connector) connectorsListIterator.next();9091Map defaultArguments = connector.defaultArguments();92Set keyset = defaultArguments.keySet();93int keysetSize = defaultArguments.size();94Iterator keysetIterator = keyset.iterator();9596for ( ; ; ) {97try {98String argName = (String) keysetIterator.next();99100try {101//102argument = (Connector.IntegerArgument)103defaultArguments.get(argName);104break ;105} catch ( ClassCastException e) {106}107} catch ( NoSuchElementException e) {108break ;109}110}111if (argument != null) {112break ;113}114} catch ( NoSuchElementException e) {115out.println(sErr1 +116"no Connector with IntegerArgument found\n");117return exitCode0;118}119}120121int iMax = argument.max();122123if (iMax < -2147483648) {124exitCode = exitCode2;125out.println(sErr2 +126"check: argument.max() >= -2147483648\n");127}128129if (iMax > 2147483647) {130exitCode = exitCode2;131out.println(sErr2 +132"check: argument.max <= 2147483647\n");133}134135if (iMax < argument.min()) {136exitCode = exitCode2;137out.println(sErr2 +138"check: argument.max >= argument.min\n");139}140141if (exitCode != exitCode0)142out.println("TEST FAILED");143144return exitCode;145}146}147148149