Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/Argument/name/name001.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.Argument.name;2425import nsk.share.*;26import nsk.share.jpda.*;27import nsk.share.jdi.*;2829import com.sun.jdi.*;30import com.sun.jdi.connect.Connector;31import java.io.*;32import javax.naming.directory.Attribute;33import java.util.*;3435/**36* Test for the control of37*38* Interface: com.sun.jdi.connect.Connector.Argument39* Method: public java.lang.String name()40* Assertion: "Returns a short, unique identifier for the argument."41*/4243public class name001 {44private static Log log;4546public static void main( String argv[] ) {47System.exit(run(argv, System.out)+95); // JCK-compatible exit status48}4950public static int run(String argv[],PrintStream out) {51ArgumentHandler argHandler = new ArgumentHandler(argv);52log = new Log(out, argHandler);53VirtualMachineManager vmm = Bootstrap.virtualMachineManager();5455List acl = vmm.allConnectors();56if (acl.size() > 0) {57log.display("Number of all known JDI connectors: " + acl.size());58} else {59log.complain("FAILURE: no JDI connectors found!");60return 2;61}6263Iterator aci = acl.iterator();64for (int i = 1; aci.hasNext(); i++) {65Connector c = (Connector) aci.next();66Map cdfltArgmnts = c.defaultArguments();67int ksz = cdfltArgmnts.size();68String ids[] = new String[ksz + 1];69Set ks = cdfltArgmnts.keySet();70if (ks.isEmpty()) {71log.complain("FAILURE: empty default arguments set is found "72+ "for " + c.name() + " connector!");73return 2;74}7576log.display("Looking over " + c.name() + " connector arguments: ");7778Iterator argi = ks.iterator();79for (int j = 1; argi.hasNext(); j++) {80String argkey = (String) argi.next();81Connector.Argument argval =82(Connector.Argument)cdfltArgmnts.get((Object) argkey);83String idntfr = argval.name();8485if (idntfr == null) {86log.complain("FAILURE: argument identifier is null "87+ "for " + argkey + " argument of " + c.name()88+ " connector!");89return 2;90}91if (idntfr.length() < 1) {92log.complain("FAILURE: empty argument identifier is found "93+ "for " + argkey + " argument of " + c.name()94+ " connector!");95return 2;96}9798for (int k = 1; k < j && j > 1; k++) {99log.display("ids[" + k + "] = " + ids[k]);100if (ids[k].equals(idntfr)) {101log.complain("FAILURE: identifier of argument "102+ "value isn't unique ( " + idntfr + ")!");103return 2;104}105}106ids[j] = idntfr;107log.display("Next (" + j + ") argument's identifier is: "108+ argval.name());109};110};111log.display("Test PASSED!");112return 0;113}114}115116117