1 /* 2 * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 package nsk.jdi.Argument.value; 25 26 import nsk.share.*; 27 import nsk.share.jpda.*; 28 import nsk.share.jdi.*; 29 30 import com.sun.jdi.*; 31 import com.sun.jdi.connect.Connector; 32 import java.io.*; 33 import javax.naming.directory.Attribute; 34 import java.util.*; 35 36 /** 37 * Test for the control of 38 * 39 * Interface: com.sun.jdi.connect.Connector.Argument 40 * Method: public java.lang.String setValue() 41 * Assertion: "Returns the current value of the argument." 42 */ 43 44 public class value001 { 45 private static Log log; 46 main( String argv[] )47 public static void main( String argv[] ) { 48 System.exit(run(argv, System.out)+95); // JCK-compatible exit status 49 } 50 run(String argv[], PrintStream out)51 public static int run(String argv[], PrintStream out) { 52 ArgumentHandler argHandler = new ArgumentHandler(argv); 53 log = new Log(out, argHandler); 54 VirtualMachineManager vmm = Bootstrap.virtualMachineManager(); 55 56 List acl = vmm.allConnectors(); 57 if (acl.size() > 0) { 58 log.display("Number of all known JDI connectors: " + acl.size()); 59 } else { 60 log.complain("FAILURE: no JDI connectors found!"); 61 return 2; 62 } 63 64 Iterator aci = acl.iterator(); 65 for (int i = 1; aci.hasNext(); i++) { 66 Connector c = (Connector) aci.next(); 67 Map cdfltArgmnts = c.defaultArguments(); 68 int ksz = cdfltArgmnts.size(); 69 String av[] = new String[ksz + 1]; 70 Set ks = cdfltArgmnts.keySet(); 71 if (ks.isEmpty()) { 72 log.complain("FAILURE: empty default argument set is found " 73 + "for " + c.name() + " connector!"); 74 return 2; 75 } 76 77 log.display("Looking over " + c.name() + " connector arguments: "); 78 79 Iterator argi = ks.iterator(); 80 for (int j = 1; argi.hasNext(); j++) { 81 String argkey = (String) argi.next(); 82 Connector.Argument argval = 83 (Connector.Argument)cdfltArgmnts.get((Object) argkey); 84 85 String ovl = argval.value(); 86 String nvl = null; 87 try { 88 argval.setValue(nvl); 89 nvl = argval.value(); 90 if (nvl != null) { 91 log.complain("FAILURE: Can't set up new argument " 92 + "null-value!"); 93 return 2; 94 } 95 } catch (java.lang.NullPointerException exc) { 96 log.display("Can't set up new argument null-value."); 97 } 98 99 argval.setValue("*"); 100 nvl = argval.value(); 101 if (!nvl.equals("*")) { 102 log.complain("FAILURE: Can't set up new argument " 103 + "'*'"); 104 return 2; 105 } 106 107 argval.setValue(ovl); 108 nvl = argval.value(); 109 if (nvl != ovl) { 110 log.complain("FAILURE: Can't reset old argument value!"); 111 return 2; 112 } 113 114 log.display("Changed " + argval.name() + " argument's value " 115 + "is: " + nvl); 116 }; 117 }; 118 log.display("Test PASSED!"); 119 return 0; 120 } 121 } 122