Source Code Cross Referenced for SingleStepTest.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » jpda » tests » jdwp » Events » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Apache Harmony Java SE » org package » org.apache.harmony.jpda.tests.jdwp.Events 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *
015:         *  See the License for the specific language governing permissions and
016:         *  limitations under the License.
017:         */
018:
019:        /**
020:         * @author Aleksander V. Budniy
021:         * @version $Revision: 1.5 $
022:         */
023:
024:        /**
025:         * Created on 14.07.2005
026:         */package org.apache.harmony.jpda.tests.jdwp.Events;
027:
028:        import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
029:        import org.apache.harmony.jpda.tests.framework.jdwp.EventMod;
030:        import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
031:        import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
032:        import org.apache.harmony.jpda.tests.framework.jdwp.ParsedEvent;
033:        import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
034:        import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
035:
036:        /**
037:         * JDWP Unit test for SINGLE_STEP event.
038:         */
039:        public class SingleStepTest extends JDWPEventTestCase {
040:
041:            private String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/Events/SingleStepDebuggee;";
042:
043:            private String DEBUGGEE_CLASS_NAME = "org.apache.harmony.jpda.tests.jdwp.Events.SingleStepDebuggee";
044:
045:            protected String getDebuggeeClassName() {
046:                return DEBUGGEE_CLASS_NAME;
047:            }
048:
049:            /**
050:             * This test case exercises SINGLE_STEP event.<BR>
051:             * Runs stepFunction() function four times to checks
052:             * SINGLE_STEP event with LINE and OVER steps.
053:             *  
054:             */
055:            public void testSingleStep1() {
056:                stepFunction(JDWPConstants.StepSize.LINE,
057:                        JDWPConstants.StepDepth.OVER);
058:
059:            }
060:
061:            /**
062:             * This test case exercises SINGLE_STEP event.<BR>
063:             * Runs stepFunction() function four times to checks
064:             * SINGLE_STEP event with LINE and INTO steps.
065:             *  
066:             */
067:            public void testSingleStep2() {
068:                stepFunction(JDWPConstants.StepSize.LINE,
069:                        JDWPConstants.StepDepth.INTO);
070:            }
071:
072:            /**
073:             * This test case exercises SINGLE_STEP event.<BR>
074:             * Runs stepFunction() function four times to checks
075:             * SINGLE_STEP event with MIN and OVER steps.
076:             *  
077:             */
078:            public void testSingleStep3() {
079:                stepFunction(JDWPConstants.StepSize.MIN,
080:                        JDWPConstants.StepDepth.OVER);
081:            }
082:
083:            /**
084:             * This test case exercises SINGLE_STEP event.<BR>
085:             * Runs stepFunction() function four times to checks
086:             * SINGLE_STEP event with MIN and INTO steps.
087:             *  
088:             */
089:            public void testSingleStep4() {
090:                stepFunction(JDWPConstants.StepSize.MIN,
091:                        JDWPConstants.StepDepth.INTO);
092:            }
093:
094:            /**
095:             * Runs SingleStepDebuggee and sets breakpoint to its
096:             * breakpointTest method, sends a request for single step event, then
097:             * verifies that requested SINGLE_STEP event with StepSize and StepDepth
098:             * steps occurs.
099:             */
100:
101:            void stepFunction(byte StepSize, byte StepDepth) {
102:                logWriter.println("=> testSingleStep started");
103:
104:                synchronizer
105:                        .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
106:
107:                //find checked method
108:                long refTypeID = getClassIDBySignature(debuggeeSignature);
109:
110:                logWriter.println("=> Debuggee class = "
111:                        + getDebuggeeClassName());
112:                logWriter.println("=> referenceTypeID for Debuggee class = "
113:                        + refTypeID);
114:                logWriter
115:                        .println("=> Send ReferenceType::Methods command and get methodIDs ");
116:
117:                long requestID = debuggeeWrapper.vmMirror
118:                        .setBreakpointAtMethodBegin(refTypeID, "breakpointTest");
119:                logWriter.println("=> breakpointID = " + requestID);
120:                logWriter.println("=> starting thread");
121:
122:                //execute the breakpoint
123:                synchronizer
124:                        .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
125:
126:                long breakpointThreadID = debuggeeWrapper.vmMirror
127:                        .waitForBreakpoint(requestID);
128:
129:                logWriter.println("=> breakpointThreadID = "
130:                        + breakpointThreadID);
131:
132:                // Sending a SINGLE_STEP request
133:
134:                CommandPacket setRequestCommand = new CommandPacket(
135:                        JDWPCommands.EventRequestCommandSet.CommandSetID,
136:                        JDWPCommands.EventRequestCommandSet.SetCommand);
137:
138:                setRequestCommand
139:                        .setNextValueAsByte(JDWPConstants.EventKind.SINGLE_STEP);
140:                setRequestCommand
141:                        .setNextValueAsByte(JDWPConstants.SuspendPolicy.ALL);
142:                setRequestCommand.setNextValueAsInt(1);
143:                setRequestCommand.setNextValueAsByte(EventMod.ModKind.Step);
144:                setRequestCommand.setNextValueAsThreadID(breakpointThreadID);
145:                setRequestCommand.setNextValueAsInt(StepSize);
146:                setRequestCommand.setNextValueAsInt(StepDepth);
147:
148:                ReplyPacket setRequestReply = debuggeeWrapper.vmMirror
149:                        .performCommand(setRequestCommand);
150:
151:                checkReplyPacket(setRequestReply, "Set SINGLE_STEP event");
152:
153:                requestID = setRequestReply.getNextValueAsInt();
154:
155:                logWriter.println("=> RequestID = " + requestID);
156:                assertAllDataRead(setRequestReply);
157:
158:                //resume debuggee
159:                resumeDebuggee();
160:
161:                //receive event
162:                logWriter.println("==> Wait for SINGLE_STEP event");
163:                CommandPacket event = debuggeeWrapper.vmMirror.receiveEvent();
164:                ParsedEvent[] parsedEvents = ParsedEvent
165:                        .parseEventPacket(event);
166:
167:                //check if received event is expected
168:                logWriter.println("==> Received " + parsedEvents.length
169:                        + " events");
170:
171:                // trace events
172:                for (int i = 0; i < parsedEvents.length; i++) {
173:                    logWriter.println("");
174:                    logWriter.println("==> Event #" + i + ";");
175:                    logWriter.println("==> EventKind: "
176:                            + parsedEvents[i].getEventKind()
177:                            + "("
178:                            + JDWPConstants.EventKind.getName(parsedEvents[i]
179:                                    .getEventKind()) + ")");
180:                    logWriter.println("==> RequestID: "
181:                            + parsedEvents[i].getRequestID());
182:                }
183:
184:                // check all
185:                assertEquals("Received wrong number of events,", 1,
186:                        parsedEvents.length);
187:                assertEquals("Received wrong event request ID,", requestID,
188:                        parsedEvents[0].getRequestID());
189:                assertEquals("Invalid event kind,",
190:                        JDWPConstants.EventKind.SINGLE_STEP, parsedEvents[0]
191:                                .getEventKind(), JDWPConstants.EventKind
192:                                .getName(JDWPConstants.EventKind.SINGLE_STEP),
193:                        JDWPConstants.EventKind.getName(parsedEvents[0]
194:                                .getEventKind()));
195:
196:                // clear SINGLE_STEP event
197:                logWriter.println("==> Clearing SINGLE_STEP event..");
198:                //ReplyPacket reply =
199:                debuggeeWrapper.vmMirror.clearEvent(
200:                        JDWPConstants.EventKind.SINGLE_STEP, (int) requestID);
201:                checkReplyPacket(setRequestReply, "Clear SINGLE_STEP event");
202:                logWriter.println("==> SINGLE_STEP event has been cleared");
203:
204:                // resuming debuggee
205:                logWriter.println("==> Resuming debuggee");
206:                resumeDebuggee();
207:                logWriter.println("==> Test PASSED!");
208:            }
209:
210:            public static void main(String[] args) {
211:                junit.textui.TestRunner.run(SingleStepTest.class);
212:            }
213:        }
w_w__w.java__2___s_._c___o__m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.