summaryrefslogtreecommitdiff
path: root/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/StackFrame/GetValues002Test.java
blob: 02d234b813e264b852af2cd8799f03e9a5d60473 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package org.apache.harmony.jpda.tests.jdwp.StackFrame;

import org.apache.harmony.jpda.tests.framework.jdwp.Value;

/**
 * JDWP Unit test for StackFrame.GetValues command.
 */
public class GetValues002Test extends JDWPStackFrameAccessTest {
    /**
     * Tests we correctly read value of boolean variable in the stack.
     *
     * Refer to {@link JDWPStackFrameAccessTest#runStackFrameTest}
     * method for the sequence of the test.
     */
    public void testGetValues001_Boolean() {
        StackFrameTester tester = new StackFrameTester(StackTrace002Debuggee.BOOLEAN_SIGNAL);
        Value oldValue = new Value(StackTrace002Debuggee.BOOLEAN_PARAM_VALUE);
        MethodInfo suspensionMethodInfo = tester.addTestMethod("breakpointBoolean");
        suspensionMethodInfo.addVariable("param", oldValue);
        MethodInfo methodInfo = tester.addTestMethod("runBreakpointBoolean");
        methodInfo.addVariable("param", oldValue);
        runStackFrameTest(tester, suspensionMethodInfo);
    }

    /**
     * Tests we correctly read value of byte variable in the stack.
     *
     * Refer to {@link JDWPStackFrameAccessTest#runStackFrameTest}
     * method for the sequence of the test.
     */
    public void testGetValues002_Byte() {
        StackFrameTester tester = new StackFrameTester(StackTrace002Debuggee.BYTE_SIGNAL);
        Value expectedValue = new Value(StackTrace002Debuggee.BYTE_PARAM_VALUE);
        MethodInfo suspensionMethodInfo = tester.addTestMethod("breakpointByte");
        suspensionMethodInfo.addVariable("param", expectedValue);
        MethodInfo methodInfo = tester.addTestMethod("runBreakpointByte");
        methodInfo.addVariable("param", expectedValue);
        runStackFrameTest(tester, suspensionMethodInfo);
    }

    /**
     * Tests we correctly read value of char variable in the stack.
     *
     * Refer to {@link JDWPStackFrameAccessTest#runStackFrameTest}
     * method for the sequence of the test.
     */
    public void testGetValues003_Char() {
        StackFrameTester tester = new StackFrameTester(StackTrace002Debuggee.CHAR_SIGNAL);
        Value expectedValue = new Value(StackTrace002Debuggee.CHAR_PARAM_VALUE);
        MethodInfo suspensionMethodInfo = tester.addTestMethod("breakpointChar");
        suspensionMethodInfo.addVariable("param", expectedValue);
        MethodInfo methodInfo = tester.addTestMethod("runBreakpointChar");
        methodInfo.addVariable("param", expectedValue);
        runStackFrameTest(tester, suspensionMethodInfo);
    }

    /**
     * Tests we correctly read value of short variable in the stack.
     *
     * Refer to {@link JDWPStackFrameAccessTest#runStackFrameTest}
     * method for the sequence of the test.
     */
    public void testGetValues004_Short() {
        StackFrameTester tester = new StackFrameTester(StackTrace002Debuggee.SHORT_SIGNAL);
        Value oldValue = new Value(StackTrace002Debuggee.SHORT_PARAM_VALUE);
        MethodInfo suspensionMethodInfo = tester.addTestMethod("breakpointShort");
        suspensionMethodInfo.addVariable("param", oldValue);
        MethodInfo methodInfo = tester.addTestMethod("runBreakpointShort");
        methodInfo.addVariable("param", oldValue);
        runStackFrameTest(tester, suspensionMethodInfo);
    }

    /**
     * Tests we correctly read value of int variable in the stack.
     *
     * Refer to {@link JDWPStackFrameAccessTest#runStackFrameTest}
     * method for the sequence of the test.
     */
    public void testGetValues005_Int() {
        StackFrameTester tester = new StackFrameTester(StackTrace002Debuggee.INT_SIGNAL);
        Value oldValue = new Value(StackTrace002Debuggee.INT_PARAM_VALUE);
        MethodInfo suspensionMethodInfo = tester.addTestMethod("breakpointInt");
        suspensionMethodInfo.addVariable("param", oldValue);
        MethodInfo methodInfo = tester.addTestMethod("runBreakpointInt");
        methodInfo.addVariable("param", oldValue);
        runStackFrameTest(tester, suspensionMethodInfo);
    }

    /**
     * Tests we correctly read value of int variables in the stack: one param and one local.
     *
     * Refer to {@link JDWPStackFrameAccessTest#runStackFrameTest}
     * method for the sequence of the test.
     */
    public void testGetValues005_Int2() {
        StackFrameTester tester = new StackFrameTester(StackTrace002Debuggee.INT_METHOD2_SIGNAL);
        Value oldValue = new Value(StackTrace002Debuggee.INT_PARAM_VALUE);
        Value nextValue = new Value(StackTrace002Debuggee.INT_PARAM_VALUE * 2);
        MethodInfo suspensionMethodInfo = tester.addTestMethod("breakpointInt2");
        suspensionMethodInfo.addVariable("param", oldValue, null /* no set value */, nextValue);
        MethodInfo methodInfo = tester.addTestMethod("runBreakpointInt2");
        methodInfo.addVariable("param", oldValue);
        methodInfo.addVariable("local", oldValue, null /* no set value */, nextValue);
        runStackFrameTest(tester, suspensionMethodInfo);
    }

    /**
     * Tests we correctly read value of long variable in the stack.
     *
     * Refer to {@link JDWPStackFrameAccessTest#runStackFrameTest}
     * method for the sequence of the test.
     */
    public void testGetValues006_Long() {
        StackFrameTester tester = new StackFrameTester(StackTrace002Debuggee.LONG_METHOD_SIGNAL);
        Value oldValue = new Value(StackTrace002Debuggee.LONG_PARAM_VALUE);
        MethodInfo suspensionMethodInfo = tester.addTestMethod("breakpointLong");
        suspensionMethodInfo.addVariable("param", oldValue);
        MethodInfo methodInfo = tester.addTestMethod("runBreakpointLong");
        methodInfo.addVariable("param", oldValue);
        runStackFrameTest(tester, suspensionMethodInfo);
    }

    /**
     * Tests we correctly read value of float variable in the stack.
     *
     * Refer to {@link JDWPStackFrameAccessTest#runStackFrameTest}
     * method for the sequence of the test.
     */
    public void testGetValues007_Float() {
        StackFrameTester tester = new StackFrameTester(StackTrace002Debuggee.FLOAT_METHOD);
        Value oldValue = new Value(StackTrace002Debuggee.FLOAT_PARAM_VALUE);
        MethodInfo suspensionMethodInfo = tester.addTestMethod("breakpointFloat");
        suspensionMethodInfo.addVariable("param", oldValue);
        MethodInfo methodInfo = tester.addTestMethod("runBreakpointFloat");
        methodInfo.addVariable("param", oldValue);
        runStackFrameTest(tester, suspensionMethodInfo);
    }

    /**
     * Tests we correctly read value of double variable in the stack.
     *
     * Refer to {@link JDWPStackFrameAccessTest#runStackFrameTest}
     * method for the sequence of the test.
     */
    public void testGetValues008_Double() {
        StackFrameTester tester = new StackFrameTester(StackTrace002Debuggee.DOUBLE_METHOD);
        Value oldValue = new Value(StackTrace002Debuggee.DOUBLE_PARAM_VALUE);
        MethodInfo suspensionMethodInfo = tester.addTestMethod("breakpointDouble");
        suspensionMethodInfo.addVariable("param", oldValue);
        MethodInfo methodInfo = tester.addTestMethod("runBreakpointDouble");
        methodInfo.addVariable("param", oldValue);
        runStackFrameTest(tester, suspensionMethodInfo);
    }

    /**
     * Tests we correctly read value of java.lang.Object variable 'this' in the stack.
     *
     * Refer to {@link JDWPStackFrameAccessTest#runStackFrameTest}
     * method for the sequence of the test.
     */
    public void testGetValues009_ThisObject() {
        long classID = getClassIDBySignature(getDebuggeeClassSignature());
        Value thisValue = getStaticFieldValue(classID, "THIS_OBJECT");

        StackFrameTester tester = new StackFrameTester(StackTrace002Debuggee.OBJECT_SIGNAL);
        MethodInfo suspensionMethodInfo = tester.addTestMethod("breakpointObject");
        suspensionMethodInfo.addVariable("this", thisValue);
        MethodInfo methodInfo = tester.addTestMethod("runBreakpointObject");
        methodInfo.addVariable("this", thisValue);
        runStackFrameTest(tester, suspensionMethodInfo);
    }

    /**
     * Tests we correctly read value of java.lang.Object variable in the stack.
     *
     * Refer to {@link JDWPStackFrameAccessTest#runStackFrameTest}
     * method for the sequence of the test.
     */
    public void testGetValues009_Object() {
        long classID = getClassIDBySignature(getDebuggeeClassSignature());
        Value oldValue = getStaticFieldValue(classID, "OBJECT_PARAM_VALUE");

        StackFrameTester tester = new StackFrameTester(StackTrace002Debuggee.OBJECT_SIGNAL);
        MethodInfo suspensionMethodInfo = tester.addTestMethod("breakpointObject");
        suspensionMethodInfo.addVariable("param", oldValue);
        MethodInfo methodInfo = tester.addTestMethod("runBreakpointObject");
        methodInfo.addVariable("param", oldValue);
        runStackFrameTest(tester, suspensionMethodInfo);
    }

    /**
     * Tests we correctly read value of Array variable in the stack.
     *
     * Refer to {@link JDWPStackFrameAccessTest#runStackFrameTest}
     * method for the sequence of the test.
     */
    public void testGetValues010_Array() {
        long classID = getClassIDBySignature(getDebuggeeClassSignature());
        Value oldValue = getStaticFieldValue(classID, "ARRAY_PARAM_VALUE");
        StackFrameTester tester = new StackFrameTester(StackTrace002Debuggee.ARRAY_SIGNAL);
        MethodInfo suspensionMethodInfo = tester.addTestMethod("breakpointArray");
        suspensionMethodInfo.addVariable("param", oldValue);
        MethodInfo methodInfo = tester.addTestMethod("runBreakpointArray");
        methodInfo.addVariable("param", oldValue);
        runStackFrameTest(tester, suspensionMethodInfo);
    }

    /**
     * Tests we correctly read value of java.lang.Object variable containing
     * Array in the stack.
     *
     * Refer to {@link JDWPStackFrameAccessTest#runStackFrameTest}
     * method for the sequence of the test.
     */
    public void testGetValues010_ArrayAsObject() {
        long classID = getClassIDBySignature(getDebuggeeClassSignature());
        Value oldValue = getStaticFieldValue(classID, "ARRAY_PARAM_VALUE");
        StackFrameTester tester = new StackFrameTester(StackTrace002Debuggee.ARRAY_AS_OBJECT_SIGNAL);
        MethodInfo suspensionMethodInfo = tester.addTestMethod("breakpointObject");
        suspensionMethodInfo.addVariable("param", oldValue);
        MethodInfo methodInfo = tester.addTestMethod("runBreakpointObject");
        methodInfo.addVariable("param", oldValue);
        runStackFrameTest(tester, suspensionMethodInfo);
    }

    /**
     * Tests we correctly read value of java.lang.Class variable in the stack.
     *
     * Refer to {@link JDWPStackFrameAccessTest#runStackFrameTest}
     * method for the sequence of the test.
     */
    public void testGetValues011_Class() {
        long classID = getClassIDBySignature(getDebuggeeClassSignature());
        Value oldValue = getStaticFieldValue(classID, "CLASS_PARAM_VALUE");
        StackFrameTester tester = new StackFrameTester(StackTrace002Debuggee.CLASS_SIGNAL);
        MethodInfo suspensionMethodInfo = tester.addTestMethod("breakpointClass");
        suspensionMethodInfo.addVariable("param", oldValue);
        MethodInfo methodInfo = tester.addTestMethod("runBreakpointClass");
        methodInfo.addVariable("param", oldValue);
        runStackFrameTest(tester, suspensionMethodInfo);
    }

    /**
     * Tests we correctly read value of java.lang.Object variable containing
     * java.lang.Class in the stack.
     *
     * Refer to {@link JDWPStackFrameAccessTest#runStackFrameTest}
     * method for the sequence of the test.
     */
    public void testGetValues011_ClassAsObject() {
        long classID = getClassIDBySignature(getDebuggeeClassSignature());
        Value oldValue = getStaticFieldValue(classID, "CLASS_PARAM_VALUE");
        StackFrameTester tester = new StackFrameTester(StackTrace002Debuggee.CLASS_AS_OBJECT_SIGNAL);
        MethodInfo suspensionMethodInfo = tester.addTestMethod("breakpointObject");
        suspensionMethodInfo.addVariable("param", oldValue);
        MethodInfo methodInfo = tester.addTestMethod("runBreakpointObject");
        methodInfo.addVariable("param", oldValue);
        runStackFrameTest(tester, suspensionMethodInfo);
    }

    /**
     * Tests we correctly read value of java.lang.ClassLoader variable in the stack.
     *
     * Refer to {@link JDWPStackFrameAccessTest#runStackFrameTest}
     * method for the sequence of the test.
     */
    public void testGetValues012_ClassLoader() {
        long classID = getClassIDBySignature(getDebuggeeClassSignature());
        Value oldValue = getStaticFieldValue(classID, "CLASS_LOADER_PARAM_VALUE");
        StackFrameTester tester = new StackFrameTester(StackTrace002Debuggee.CLASS_LOADER_SIGNAL);
        MethodInfo suspensionMethodInfo = tester.addTestMethod("breakpointClassLoader");
        suspensionMethodInfo.addVariable("param", oldValue);
        MethodInfo methodInfo = tester.addTestMethod("runBreakpointClassLoader");
        methodInfo.addVariable("param", oldValue);
        runStackFrameTest(tester, suspensionMethodInfo);
    }

    /**
     * Tests we correctly read value of java.lang.Object variable containing
     * java.lang.ClassLoader in the stack.
     *
     * Refer to {@link JDWPStackFrameAccessTest#runStackFrameTest}
     * method for the sequence of the test.
     */
    public void testGetValues012_ClassLoaderAsObject() {
        long classID = getClassIDBySignature(getDebuggeeClassSignature());
        Value oldValue = getStaticFieldValue(classID, "CLASS_LOADER_PARAM_VALUE");
        StackFrameTester tester = new StackFrameTester(StackTrace002Debuggee.CLASS_LOADER_AS_OBJECT_SIGNAL);
        MethodInfo suspensionMethodInfo = tester.addTestMethod("breakpointObject");
        suspensionMethodInfo.addVariable("param", oldValue);
        MethodInfo methodInfo = tester.addTestMethod("runBreakpointObject");
        methodInfo.addVariable("param", oldValue);
        runStackFrameTest(tester, suspensionMethodInfo);
    }

    /**
     * Tests we correctly read value of java.lang.String variable in the stack.
     *
     * Refer to {@link JDWPStackFrameAccessTest#runStackFrameTest}
     * method for the sequence of the test.
     */
    public void testGetValues013_String() {
        long classID = getClassIDBySignature(getDebuggeeClassSignature());
        Value oldValue = getStaticFieldValue(classID, "STRING_PARAM_VALUE");
        StackFrameTester tester = new StackFrameTester(StackTrace002Debuggee.STRING_SIGNAL);
        MethodInfo suspensionMethodInfo = tester.addTestMethod("breakpointString");
        suspensionMethodInfo.addVariable("param", oldValue);
        MethodInfo methodInfo = tester.addTestMethod("runBreakpointString");
        methodInfo.addVariable("param", oldValue);
        runStackFrameTest(tester, suspensionMethodInfo);
    }

    /**
     * Tests we correctly read value of java.lang.Object variable containing
     * java.lang.String in the stack.
     *
     * Refer to {@link JDWPStackFrameAccessTest#runStackFrameTest}
     * method for the sequence of the test.
     */
    public void testGetValues013_StringAsObject() {
        long classID = getClassIDBySignature(getDebuggeeClassSignature());
        Value oldValue = getStaticFieldValue(classID, "STRING_PARAM_VALUE");
        StackFrameTester tester = new StackFrameTester(StackTrace002Debuggee.STRING_AS_OBJECT_SIGNAL);
        MethodInfo suspensionMethodInfo = tester.addTestMethod("breakpointObject");
        suspensionMethodInfo.addVariable("param", oldValue);
        MethodInfo methodInfo = tester.addTestMethod("runBreakpointObject");
        methodInfo.addVariable("param", oldValue);
        runStackFrameTest(tester, suspensionMethodInfo);
    }

    /**
     * Tests we correctly read value of java.lang.Thread variable in the stack.
     *
     * Refer to {@link JDWPStackFrameAccessTest#runStackFrameTest}
     * method for the sequence of the test.
     */
    public void testGetValues014_Thread() {
        long classID = getClassIDBySignature(getDebuggeeClassSignature());
        Value oldValue = getStaticFieldValue(classID, "THREAD_PARAM_VALUE");
        StackFrameTester tester = new StackFrameTester(StackTrace002Debuggee.THREAD_SIGNAL);
        MethodInfo suspensionMethodInfo = tester.addTestMethod("breakpointThread");
        suspensionMethodInfo.addVariable("param", oldValue);
        MethodInfo methodInfo = tester.addTestMethod("runBreakpointThread");
        methodInfo.addVariable("param", oldValue);
        runStackFrameTest(tester, suspensionMethodInfo);
    }

    /**
     * Tests we correctly read value of java.lang.Object variable containing
     * java.lang.Thread in the stack.
     *
     * Refer to {@link JDWPStackFrameAccessTest#runStackFrameTest}
     * method for the sequence of the test.
     */
    public void testGetValues014_ThreadAsObject() {
        long classID = getClassIDBySignature(getDebuggeeClassSignature());
        Value oldValue = getStaticFieldValue(classID, "THREAD_PARAM_VALUE");
        StackFrameTester tester = new StackFrameTester(StackTrace002Debuggee.THREAD_AS_OBJECT_SIGNAL);
        MethodInfo suspensionMethodInfo = tester.addTestMethod("breakpointObject");
        suspensionMethodInfo.addVariable("param", oldValue);
        MethodInfo methodInfo = tester.addTestMethod("runBreakpointObject");
        methodInfo.addVariable("param", oldValue);
        runStackFrameTest(tester, suspensionMethodInfo);
    }

    /**
     * Tests we correctly read value of java.lang.ThreadGroup variable in the stack.
     *
     * Refer to {@link JDWPStackFrameAccessTest#runStackFrameTest}
     * method for the sequence of the test.
     */
    public void testGetValues015_ThreadGroup() {
        long classID = getClassIDBySignature(getDebuggeeClassSignature());
        Value oldValue = getStaticFieldValue(classID, "THREAD_GROUP_PARAM_VALUE");
        StackFrameTester tester = new StackFrameTester(StackTrace002Debuggee.THREAD_GROUP_SIGNAL);
        MethodInfo suspensionMethodInfo = tester.addTestMethod("breakpointThreadGroup");
        suspensionMethodInfo.addVariable("param", oldValue);
        MethodInfo methodInfo = tester.addTestMethod("runBreakpointThreadGroup");
        methodInfo.addVariable("param", oldValue);
        runStackFrameTest(tester, suspensionMethodInfo);
    }

    /**
     * Tests we correctly read value of java.lang.Object variable containing
     * java.lang.ThreadGroup in the stack.
     *
     * Refer to {@link JDWPStackFrameAccessTest#runStackFrameTest}
     * method for the sequence of the test.
     */
    public void testGetValues015_ThreadGroupAsObject() {
        long classID = getClassIDBySignature(getDebuggeeClassSignature());
        Value oldValue = getStaticFieldValue(classID, "THREAD_GROUP_PARAM_VALUE");
        StackFrameTester tester = new StackFrameTester(StackTrace002Debuggee.THREAD_GROUP_AS_OBJECT_SIGNAL);
        MethodInfo suspensionMethodInfo = tester.addTestMethod("breakpointObject");
        suspensionMethodInfo.addVariable("param", oldValue);
        MethodInfo methodInfo = tester.addTestMethod("runBreakpointObject");
        methodInfo.addVariable("param", oldValue);
        runStackFrameTest(tester, suspensionMethodInfo);
    }
}