1 | /*
|
---|
2 | * Copyright (c) 2002, 2004, 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 |
|
---|
25 | /**
|
---|
26 | * @test
|
---|
27 | * @bug 0000000
|
---|
28 | * @summary This is just an exercise of various JDI elements for use in
|
---|
29 | * testing the SA/JDI client
|
---|
30 | *
|
---|
31 | * @author jjh
|
---|
32 | *
|
---|
33 | * @run build TestScaffold VMConnection TargetListener TargetAdapter sagdoit
|
---|
34 | * @run compile -g -source 1.5 sagtarg.java
|
---|
35 | * @run main sagtest
|
---|
36 | */
|
---|
37 | import com.sun.jdi.*;
|
---|
38 | import com.sun.jdi.event.*;
|
---|
39 | import com.sun.jdi.request.*;
|
---|
40 |
|
---|
41 | import java.util.*;
|
---|
42 |
|
---|
43 | /********** target program **********/
|
---|
44 |
|
---|
45 | // The target program is sagtarg.java
|
---|
46 |
|
---|
47 | /********** test program **********/
|
---|
48 |
|
---|
49 | public class sagtest extends TestScaffold {
|
---|
50 | ReferenceType targetClass;
|
---|
51 | ThreadReference mainThread;
|
---|
52 |
|
---|
53 | sagtest (String args[]) {
|
---|
54 | super(args);
|
---|
55 | }
|
---|
56 |
|
---|
57 | public static void main(String[] args) throws Exception {
|
---|
58 | new sagtest(args).startTests();
|
---|
59 | }
|
---|
60 |
|
---|
61 | /********** event handlers **********/
|
---|
62 |
|
---|
63 |
|
---|
64 | /********** test core **********/
|
---|
65 |
|
---|
66 | protected void runTests() throws Exception {
|
---|
67 | /*
|
---|
68 | * Get to the top of main()
|
---|
69 | * to determine targetClass and mainThread
|
---|
70 | */
|
---|
71 | BreakpointEvent bpe = startToMain("sagtarg");
|
---|
72 | targetClass = bpe.location().declaringType();
|
---|
73 | mainThread = bpe.thread();
|
---|
74 | EventRequestManager erm = vm().eventRequestManager();
|
---|
75 | stepOverLine(mainThread); //stop on 18
|
---|
76 | stepOverLine(mainThread); //stop on 19
|
---|
77 | stepOverLine(mainThread); //stop on 20
|
---|
78 | stepOverLine(mainThread); //stop on 21
|
---|
79 | stepOverLine(mainThread); //stop on 22
|
---|
80 |
|
---|
81 | sagdoit mine = new sagdoit(vm());
|
---|
82 | mine.doAll();
|
---|
83 |
|
---|
84 | if (!testFailed) {
|
---|
85 | println("sagtest: passed");
|
---|
86 | } else {
|
---|
87 | throw new Exception("sagtest: failed");
|
---|
88 | }
|
---|
89 | }
|
---|
90 | }
|
---|