Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/Connector/name/name001.java
41813 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.Connector.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.PrintStream;32import java.util.*;3334/**35* Test for control of36*37* Interface: com.sun.jdi.connect.Connector38* Method: public java.lang.String name()39* Assertion: "Returns a short identifier for the connector."40*/4142public class name001 {43private static Log log;4445public static void main( String argv[] ) {46System.exit(run(argv, System.out)+95); // JCK-compatible exit status47}4849public static int run(String argv[], PrintStream out) {50ArgumentHandler argHandler = new ArgumentHandler(argv);51log = new Log(out, argHandler);52VirtualMachineManager vmm = Bootstrap.virtualMachineManager();5354List acl = vmm.allConnectors();55if (acl.size() > 0) {56log.display("Number of all known JDI connectors: " + acl.size());57} else {58log.complain("FAILURE: no JDI connectors found!");59return 2;60}6162Iterator aci = acl.iterator();63for (int i = 1; aci.hasNext(); i++) {64Connector c = (Connector) aci.next();65String cnm = c.name();66if (cnm == null) {67log.complain("FAILURE: connector name is null.");68log.complain(" Description: " + c.description());69log.complain(" Transport: " + c.transport().name());70return 2;71}7273if (cnm.length() == 0) {74log.complain("FAILURE: connector with empty-name is found.");75log.complain(" Description: " + c.description());76log.complain(" Transport: " + c.transport().name());77return 2;78}7980log.display("Next (" + i + ") connector's name is: " + cnm);81};82log.display("Test PASSED!");83return 0;84}85}868788