Source Code Cross Referenced for SingleStepTest.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » jpda » tests » jdwp » MultiSession » 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.MultiSession 
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.6 $
022:         */
023:
024:        /**
025:         * Created on 8.7.2005
026:         */package org.apache.harmony.jpda.tests.jdwp.MultiSession;
027:
028:        import org.apache.harmony.jpda.tests.framework.TestOptions;
029:        import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
030:        import org.apache.harmony.jpda.tests.framework.jdwp.EventMod;
031:        import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
032:        import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
033:        import org.apache.harmony.jpda.tests.framework.jdwp.ParsedEvent;
034:        import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
035:        import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
036:        import org.apache.harmony.jpda.tests.jdwp.share.JDWPUnitDebuggeeWrapper;
037:        import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
038:
039:        /**
040:         * JDWP Unit test for verifying canceling of SINGLE_STEP event after re-connection.
041:         */
042:        public class SingleStepTest extends JDWPSyncTestCase {
043:
044:            private String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/MultiSession/SingleStepDebuggee;";
045:
046:            private String DEBUGGEE_CLASS_NAME = "org.apache.harmony.jpda.tests.jdwp.MultiSession.SingleStepDebuggee";
047:
048:            protected String getDebuggeeClassName() {
049:                return DEBUGGEE_CLASS_NAME;
050:            }
051:
052:            /**
053:             * This testcase verifies canceling of SINGLE_STEP event after re-connection.
054:             * <BR>It runs SingleStepDebuggee and sets request for BREAKPOINT event.
055:             * After BREAKPOINT event occurs the testcase sets request for SINGLE_STEP event
056:             * and re-connects.
057:             * <BR>It is expected that only auto VM_DEATH event occurs after re-connection,
058:             * but no any other event, including SINGLE_STEP event.
059:             */
060:            public void testSingleStep001() {
061:                stepFunction(JDWPConstants.StepSize.LINE,
062:                        JDWPConstants.StepDepth.OVER);
063:            }
064:
065:            void stepFunction(byte StepSize, byte StepDepth) {
066:                logWriter.println("=> testSingleStep started");
067:
068:                synchronizer
069:                        .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
070:
071:                //find checked method
072:                long refTypeID = debuggeeWrapper.vmMirror
073:                        .getClassID(debuggeeSignature);
074:
075:                logWriter.println("=> Debuggee class = "
076:                        + getDebuggeeClassName());
077:                logWriter.println("=> referenceTypeID for Debuggee class = "
078:                        + refTypeID);
079:                logWriter
080:                        .println("=> Send ReferenceType::Methods command and get methodIDs ");
081:
082:                long requestID = debuggeeWrapper.vmMirror
083:                        .setBreakpointAtMethodBegin(refTypeID, "breakpointTest");
084:                logWriter.println("=> breakpointID = " + requestID);
085:                logWriter.println("=> starting thread");
086:
087:                //execute the breakpoint
088:                synchronizer
089:                        .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
090:
091:                long breakpointThreadID = debuggeeWrapper.vmMirror
092:                        .waitForBreakpoint(requestID);
093:
094:                logWriter.println("=> breakpointThreadID = "
095:                        + breakpointThreadID);
096:
097:                // Sending a SINGLE_STEP request
098:
099:                CommandPacket setRequestCommand = new CommandPacket(
100:                        JDWPCommands.EventRequestCommandSet.CommandSetID,
101:                        JDWPCommands.EventRequestCommandSet.SetCommand);
102:
103:                setRequestCommand
104:                        .setNextValueAsByte(JDWPConstants.EventKind.SINGLE_STEP);
105:                setRequestCommand
106:                        .setNextValueAsByte(JDWPConstants.SuspendPolicy.ALL);
107:                setRequestCommand.setNextValueAsInt(1);
108:                setRequestCommand.setNextValueAsByte(EventMod.ModKind.Step);
109:                setRequestCommand.setNextValueAsThreadID(breakpointThreadID);
110:                setRequestCommand.setNextValueAsInt(StepSize);
111:                setRequestCommand.setNextValueAsInt(StepDepth);
112:
113:                ReplyPacket setRequestReply = debuggeeWrapper.vmMirror
114:                        .performCommand(setRequestCommand);
115:
116:                checkReplyPacket(setRequestReply, "Set SINGLE_STEP event");
117:
118:                requestID = setRequestReply.getNextValueAsInt();
119:                logWriter.println("=> RequestID = " + requestID);
120:
121:                assertAllDataRead(setRequestReply);
122:
123:                logWriter.println("");
124:                logWriter.println("=> CLOSE CONNECTION..");
125:                closeConnection();
126:                logWriter.println("=> CONNECTION IS CLOSED");
127:
128:                logWriter.println("");
129:                logWriter.println("=> OPEN NEW CONNECTION..");
130:                openConnection();
131:                logWriter.println("=> CONNECTION IS OPENED");
132:
133:                //resume debuggee
134:                //ReplyPacket reply = debuggeeWrapper.vmMirror.resume();
135:                synchronizer
136:                        .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
137:
138:                //      receive event
139:                logWriter.println("=> Wait for event..");
140:                CommandPacket eventPacket = debuggeeWrapper.vmMirror
141:                        .receiveEvent();
142:                ParsedEvent[] parsedEvents = ParsedEvent
143:                        .parseEventPacket(eventPacket);
144:                int eventsCount = parsedEvents.length;
145:                logWriter
146:                        .println("=> Received event set: count=" + eventsCount);
147:
148:                //ckeck if received events are expected
149:                int result = 0;
150:                int autoEvents = 0;
151:                int wrongEvents = 0;
152:                for (int i = 0; i < eventsCount; i++) {
153:                    ParsedEvent event = parsedEvents[i];
154:                    logWriter.println("=> Event #" + i + ";");
155:
156:                    // print event info
157:                    byte eventSuspendPolicy = event.getSuspendPolicy();
158:                    logWriter.println("=> SuspendPolicy="
159:                            + eventSuspendPolicy
160:                            + "/"
161:                            + JDWPConstants.SuspendPolicy
162:                                    .getName(eventSuspendPolicy));
163:                    byte eventKind = event.getEventKind();
164:                    logWriter.println("=> EventKind=" + eventKind + "/"
165:                            + JDWPConstants.EventKind.getName(eventKind));
166:                    int eventRequestID = event.getRequestID();
167:                    logWriter.println("=> RequestID=" + eventRequestID);
168:
169:                    // check if event is expected
170:                    if (eventKind == JDWPConstants.EventKind.VM_DEATH) {
171:                        if (parsedEvents[i].getRequestID() == 0) {
172:                            autoEvents++;
173:                            logWriter.println("=> found auto VM_DEATH event!");
174:                            // for automatical event suspend policy can be changed
175:                        } else {
176:                            logWriter.println("## FAILURE: VM_DEATH event "
177:                                    + "with unexpected RequestID: "
178:                                    + eventRequestID);
179:                            result = 1;
180:                        }
181:                    } else {
182:                        wrongEvents++;
183:                        logWriter.println("## FAILURE: unexpected event kind: "
184:                                + eventKind);
185:                        result = 2;
186:                    }
187:                }
188:
189:                if (1 == result)
190:                    fail("VM_DEATH event with unexpected RequestID");
191:                else if (2 == result)
192:                    fail("Unexpected event kind");
193:
194:                logWriter.println("==> testSingleStep001 PASSED!");
195:            }
196:
197:            protected void beforeDebuggeeStart(
198:                    JDWPUnitDebuggeeWrapper debuggeeWrapper) {
199:                settings.setAttachConnectorKind();
200:                if (settings.getTransportAddress() == null) {
201:                    settings
202:                            .setTransportAddress(TestOptions.DEFAULT_ATTACHING_ADDRESS);
203:                }
204:                logWriter.println("ATTACH connector kind");
205:                super .beforeDebuggeeStart(debuggeeWrapper);
206:            }
207:
208:            public static void main(String[] args) {
209:                junit.textui.TestRunner.run(SingleStepTest.class);
210:            }
211:        }
w_w___w__._j_a___v_a2s___.c_o___m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.