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 value()
41  *      Assertion:      "Initially, the default value is returned."
42  */
43 
44 public class value002 {
45 
46     private static Log log;
47 
main( String argv[] )48     public static void main( String argv[] ) {
49         System.exit(run(argv, System.out)+95); // JCK-compatible exit status
50     }
51 
run(String argv[], PrintStream out)52     public static int run(String argv[], PrintStream out) {
53         ArgumentHandler argHandler = new ArgumentHandler(argv);
54         log = new Log(out, argHandler);
55         VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
56 
57         List acl = vmm.allConnectors();
58         if (acl.size() > 0) {
59             log.display("Number of all known JDI connectors: " + acl.size());
60         } else {
61             log.complain("FAILURE: no JDI connectors found!");
62             return 2;
63         }
64 
65         Iterator aci = acl.iterator();
66         for (int i=1; aci.hasNext(); i++) {
67             Connector c = (Connector) aci.next();
68             Map cdfltArgmnts = c.defaultArguments();
69             Set ks = cdfltArgmnts.keySet();
70             if (ks.isEmpty()) {
71                 log.complain("FAILURE: empty default argument set is found "
72                            + "for " + c.name() + " connector!");
73                 return 2;
74             }
75 
76             log.display("Looking over " + c.name() + " connector arguments: ");
77 
78             Iterator argi = ks.iterator();
79             for (int j = 1; argi.hasNext(); j++) {
80                 String argkey = (String) argi.next();
81                 Connector.Argument argval =
82                     (Connector.Argument)cdfltArgmnts.get((Object) argkey);
83                 String vl = argval.value();
84                 if (vl == null) {
85                     log.display("The default argument value is null.");
86                 }
87                 if (vl.length() < 1) {
88                     log.display("The default argument value is empty.");
89                 }
90                 log.display("Next (" + j + "," + argval.name() + ") "
91                           + "argument's value is: " + vl);
92             };
93         };
94 
95         log.display("Test PASSED!");
96         return 0;
97     }
98 }
99