annotate test/serviceability/ParserTest.java @ 6810:a3fd4914ac81

Added tag jdk8-b59 for changeset 8a1a6b9b4f20
author katleman
date Thu, 04 Oct 2012 14:34:51 -0700
parents 5a1f452f8f90
children 1b0dc9f87e75
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5978
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
1 /*
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
2 * @test ParserTest
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
3 * @summary verify that whitebox functions can be linked and executed
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
4 * @run compile -J-XX:+UnlockDiagnosticVMOptions -J-XX:+WhiteBoxAPI ParserTest.java
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
5 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI ParserTest
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
6 */
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
7
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
8 import java.math.BigInteger;
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
9
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
10 import sun.hotspot.parser.DiagnosticCommand;
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
11 import sun.hotspot.parser.DiagnosticCommand.DiagnosticArgumentType;
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
12 import sun.hotspot.WhiteBox;
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
13
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
14 public class ParserTest {
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
15 WhiteBox wb;
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
16
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
17 public ParserTest() throws Exception {
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
18 wb = WhiteBox.getWhiteBox();
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
19
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
20 testNanoTime();
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
21 testJLong();
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
22 testBool();
6202
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
23 testQuotes();
5978
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
24 testMemorySize();
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
25 }
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
26
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
27 public static void main(String... args) throws Exception {
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
28 new ParserTest();
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
29 }
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
30
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
31 public void testNanoTime() throws Exception {
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
32 String name = "name";
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
33 DiagnosticCommand arg = new DiagnosticCommand(name,
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
34 "desc", DiagnosticArgumentType.NANOTIME,
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
35 false, "0");
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
36 DiagnosticCommand[] args = {arg};
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
37
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
38 BigInteger bi = new BigInteger("7");
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
39 //These should work
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
40 parse(name, bi.toString(), name + "=7ns", args);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
41
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
42 bi = bi.multiply(BigInteger.valueOf(1000));
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
43 parse(name, bi.toString(), name + "=7us", args);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
44
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
45 bi = bi.multiply(BigInteger.valueOf(1000));
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
46 parse(name, bi.toString(), name + "=7ms", args);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
47
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
48 bi = bi.multiply(BigInteger.valueOf(1000));
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
49 parse(name, bi.toString(), name + "=7s", args);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
50
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
51 bi = bi.multiply(BigInteger.valueOf(60));
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
52 parse(name, bi.toString() , name + "=7m", args);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
53
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
54 bi = bi.multiply(BigInteger.valueOf(60));
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
55 parse(name, bi.toString() , name + "=7h", args);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
56
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
57 bi = bi.multiply(BigInteger.valueOf(24));
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
58 parse(name, bi.toString() , name + "=7d", args);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
59
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
60 parse(name, "0", name + "=0", args);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
61
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
62 shouldFail(name + "=7xs", args);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
63 shouldFail(name + "=7mms", args);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
64 shouldFail(name + "=7f", args);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
65 //Currently, only value 0 is allowed without unit
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
66 shouldFail(name + "=7", args);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
67 }
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
68
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
69 public void testJLong() throws Exception {
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
70 String name = "name";
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
71 DiagnosticCommand arg = new DiagnosticCommand(name,
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
72 "desc", DiagnosticArgumentType.JLONG,
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
73 false, "0");
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
74 DiagnosticCommand[] args = {arg};
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
75
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
76 wb.parseCommandLine(name + "=10", args);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
77 parse(name, "10", name + "=10", args);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
78 parse(name, "-5", name + "=-5", args);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
79
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
80 //shouldFail(name + "=12m", args); <-- should fail, doesn't
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
81 }
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
82
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
83 public void testBool() throws Exception {
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
84 String name = "name";
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
85 DiagnosticCommand arg = new DiagnosticCommand(name,
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
86 "desc", DiagnosticArgumentType.BOOLEAN,
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
87 false, "false");
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
88 DiagnosticCommand[] args = {arg};
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
89
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
90 parse(name, "true", name + "=true", args);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
91 parse(name, "false", name + "=false", args);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
92 parse(name, "true", name, args);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
93
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
94 //Empty commandline to parse, tests default value
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
95 //of the parameter "name"
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
96 parse(name, "false", "", args);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
97 }
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
98
6202
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
99 public void testQuotes() throws Exception {
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
100 String name = "name";
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
101 DiagnosticCommand arg1 = new DiagnosticCommand(name,
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
102 "desc", DiagnosticArgumentType.STRING,
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
103 false, null);
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
104 DiagnosticCommand arg2 = new DiagnosticCommand("arg",
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
105 "desc", DiagnosticArgumentType.STRING,
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
106 false, null);
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
107 DiagnosticCommand[] args = {arg1, arg2};
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
108
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
109 // try with a quoted value
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
110 parse(name, "Recording 1", name + "=\"Recording 1\"", args);
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
111 // try with a quoted argument
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
112 parse(name, "myrec", "\"" + name + "\"" + "=myrec", args);
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
113 // try with both a quoted value and a quoted argument
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
114 parse(name, "Recording 1", "\"" + name + "\"" + "=\"Recording 1\"", args);
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
115
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
116 // now the same thing but with other arguments after
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
117
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
118 // try with a quoted value
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
119 parse(name, "Recording 1", name + "=\"Recording 1\",arg=value", args);
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
120 // try with a quoted argument
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
121 parse(name, "myrec", "\"" + name + "\"" + "=myrec,arg=value", args);
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
122 // try with both a quoted value and a quoted argument
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
123 parse(name, "Recording 1", "\"" + name + "\"" + "=\"Recording 1\",arg=value", args);
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
124 }
5a1f452f8f90 7178703: Fix handling of quoted arguments and better error messages in dcmd
sla
parents: 5978
diff changeset
125
5978
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
126 public void testMemorySize() throws Exception {
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
127 String name = "name";
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
128 String defaultValue = "1024";
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
129 DiagnosticCommand arg = new DiagnosticCommand(name,
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
130 "desc", DiagnosticArgumentType.MEMORYSIZE,
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
131 false, defaultValue);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
132 DiagnosticCommand[] args = {arg};
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
133
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
134 BigInteger bi = new BigInteger("7");
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
135 parse(name, bi.toString(), name + "=7b", args);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
136
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
137 bi = bi.multiply(BigInteger.valueOf(1024));
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
138 parse(name, bi.toString(), name + "=7k", args);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
139
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
140 bi = bi.multiply(BigInteger.valueOf(1024));
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
141 parse(name, bi.toString(), name + "=7m", args);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
142
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
143 bi = bi.multiply(BigInteger.valueOf(1024));
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
144 parse(name, bi.toString(), name + "=7g", args);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
145 parse(name, defaultValue, "", args);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
146
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
147 //shouldFail(name + "=7gg", args); <---- should fail, doesn't
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
148 //shouldFail(name + "=7t", args); <----- should fail, doesn't
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
149 }
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
150
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
151 public void parse(String searchName, String expectedValue,
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
152 String cmdLine, DiagnosticCommand[] argumentTypes) throws Exception {
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
153 //parseCommandLine will return an object array that looks like
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
154 //{<name of parsed object>, <of parsed object> ... }
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
155 Object[] res = wb.parseCommandLine(cmdLine, argumentTypes);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
156 for (int i = 0; i < res.length-1; i+=2) {
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
157 String parsedName = (String) res[i];
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
158 if (searchName.equals(parsedName)) {
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
159 String parsedValue = (String) res[i+1];
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
160 if (expectedValue.equals(parsedValue)) {
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
161 return;
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
162 } else {
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
163 throw new Exception("Parsing of cmdline '" + cmdLine + "' failed!\n"
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
164 + searchName + " parsed as " + parsedValue
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
165 + "! Expected: " + expectedValue);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
166 }
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
167 }
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
168 }
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
169 throw new Exception(searchName + " not found as a parsed Argument!");
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
170 }
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
171
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
172 private void shouldFail(String argument, DiagnosticCommand[] argumentTypes) throws Exception {
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
173 try {
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
174 wb.parseCommandLine(argument, argumentTypes);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
175 throw new Exception("Parser accepted argument: " + argument);
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
176 } catch (IllegalArgumentException e) {
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
177 //expected
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
178 }
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
179 }
51612f0c0a79 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
180 }