Source Code Cross Referenced for PopFramesTest.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » jpda » tests » jdwp » StackFrame » 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.StackFrame 
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 Anton V. Karnachuk, Aleksander V. Budniy
021:         * @version $Revision: 1.5 $
022:         */
023:
024:        /**
025:         * Created on 16.02.2005
026:         */package org.apache.harmony.jpda.tests.jdwp.StackFrame;
027:
028:        import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
029:        import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
030:        import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
031:        import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
032:
033:        /**
034:         * JDWP Unit test for StackFrame.PopFrames command.
035:         */
036:        public class PopFramesTest extends JDWPStackFrameTestCase {
037:
038:            private String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/StackFrame/PopFramesDebuggee;";
039:
040:            private String breakpointMethodName = "nestledMethod4";
041:
042:            private String methodToPop = "nestledMethod4";
043:
044:            protected String getDebuggeeClassName() {
045:                return PopFramesDebuggee.class.getName();
046:            }
047:
048:            /**
049:             * This testcase exercises StackFrame.PopFrames command to discard one top frame.
050:             * <BR>The test starts PopFramesDebuggee class, sets a breakpoint
051:             * in 'nestledMethod4', stops at breakpoint and prints stack.
052:             * <BR>Then the test performs StackFrame.PopFrame command for one top frame,
053:             * prints stack and checks that discarded frame is not returned 
054:             * by ThreadReference.Frames command. 
055:             * <BR>Then the test resumes debuggee and checks stop on the same breakpoint.
056:             */
057:            public void testPopFramesTest001() {
058:                logWriter.println("==> testPopFramesTest001 started");
059:
060:                //check capability, relevant for this test
061:                logWriter.println("=> Check capability: canPopFrames");
062:                debuggeeWrapper.vmMirror.capabilities();
063:                boolean isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canPopFrames;
064:                if (!isCapability) {
065:                    logWriter
066:                            .println("##WARNING: this VM doesn't possess capability: canPopFrames");
067:                    return;
068:                }
069:
070:                synchronizer
071:                        .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
072:
073:                // find checked method
074:                long refTypeID = getClassIDBySignature(debuggeeSignature);
075:
076:                logWriter.println("=> Debuggee class = "
077:                        + getDebuggeeClassName());
078:
079:                logWriter.println("=> Set breakpoint at the beginning of "
080:                        + breakpointMethodName);
081:                long requestID = debuggeeWrapper.vmMirror
082:                        .setBreakpointAtMethodBegin(refTypeID,
083:                                breakpointMethodName);
084:
085:                synchronizer
086:                        .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
087:
088:                // receive event
089:                logWriter.println("=> Wait for breakpoint in "
090:                        + breakpointMethodName);
091:                long breakpointThreadID = debuggeeWrapper.vmMirror
092:                        .waitForBreakpoint(requestID);
093:
094:                logWriter.println("=> breakpointThreadID = "
095:                        + breakpointThreadID);
096:
097:                // print stack frames
098:                logWriter.println("");
099:                logWriter
100:                        .println("=> Get frames before PopFrames command, thread = "
101:                                + breakpointThreadID);
102:                FrameInfo[] frameInfos = jdwpGetFrames(breakpointThreadID, 0,
103:                        -1);
104:                logWriter.println("=> Frames before popFrame");
105:                printStackFrame(frameInfos.length, frameInfos);
106:                logWriter.println("=> Number of frames before command: "
107:                        + frameInfos.length);
108:
109:                // find stack frame for popped method
110:                logWriter.println("");
111:                logWriter.println("=> Find frameID of method = " + methodToPop
112:                        + " for PopFrames command");
113:                long frameID = 0;
114:                long methodID = getMethodID(refTypeID, methodToPop);
115:                if (methodID == -1) {
116:                    logWriter
117:                            .println("##FAILURE: error during getting methodID of "
118:                                    + methodToPop);
119:                }
120:                boolean isMethodFound = false;
121:                for (int i = 0; i < frameInfos.length; i++) {
122:                    if (frameInfos[i].location.methodID == methodID) {
123:                        frameID = frameInfos[i].getFrameID();
124:                        isMethodFound = true;
125:                        break;
126:                    }
127:                }
128:                if (!isMethodFound) {
129:                    logWriter
130:                            .println("##FAILURE: there is no frame for checked method");
131:                    fail("There is no frame for checked method");
132:                }
133:
134:                logWriter.println("=> frameID for PopFrames command = "
135:                        + frameID);
136:
137:                logWriter.println("");
138:                logWriter.println("=> Perform PopFrames command for method = "
139:                        + methodToPop + " with frameID = " + frameID);
140:                // pop stack frame
141:                CommandPacket popFramesCommand = new CommandPacket(
142:                        JDWPCommands.StackFrameCommandSet.CommandSetID,
143:                        JDWPCommands.StackFrameCommandSet.PopFramesCommand);
144:                popFramesCommand.setNextValueAsThreadID(breakpointThreadID);
145:                popFramesCommand.setNextValueAsFrameID(frameID);
146:
147:                ReplyPacket err = debuggeeWrapper.vmMirror
148:                        .performCommand(popFramesCommand);
149:                checkReplyPacket(err, "StackFrame::PopFrames command");
150:
151:                logWriter
152:                        .println("=> Get frames after PopFrames command, thread = "
153:                                + breakpointThreadID);
154:                FrameInfo[] newFrameInfos = jdwpGetFrames(breakpointThreadID,
155:                        0, -1);
156:
157:                logWriter.println("");
158:                logWriter.println("=> Frames after popFrame");
159:                logWriter.println("=> newNumberOfFrames = "
160:                        + newFrameInfos.length);
161:
162:                printStackFrame(newFrameInfos.length, newFrameInfos);
163:
164:                // check if expected frames are popped
165:                logWriter
166:                        .println("=> Check that only one frame was discarded: frameID = "
167:                                + frameID + ", method = " + methodToPop);
168:                int numberOfPoppedFrames = frameInfos.length
169:                        - newFrameInfos.length;
170:                assertEquals("frame is not discarded", numberOfPoppedFrames, 1);
171:
172:                for (int i = numberOfPoppedFrames; i < (frameInfos.length); i++) {
173:                    if (frameInfos[i].location.methodID != newFrameInfos[i
174:                            - numberOfPoppedFrames].location.methodID) {
175:                        logWriter.println("## FAILURE: frames number " + i
176:                                + " and " + (i - numberOfPoppedFrames)
177:                                + " are not equal");
178:                        fail("frames number are not equal");
179:                    }
180:                }
181:                logWriter.println("=> Ckeck PASSED");
182:                logWriter.println("=> Resume debuggee");
183:                debuggeeWrapper.vmMirror.resume();
184:
185:                logWriter.println("=> Wait for breakpoint in "
186:                        + breakpointMethodName);
187:                breakpointThreadID = debuggeeWrapper.vmMirror
188:                        .waitForBreakpoint(requestID);
189:
190:                logWriter.println("=> Resume debuggee");
191:                debuggeeWrapper.vmMirror.resume();
192:
193:                synchronizer
194:                        .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
195:                synchronizer
196:                        .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
197:
198:                logWriter.println("==> TEST PASSED");
199:
200:            }
201:
202:            void printStackFrame(int NumberOfFrames, FrameInfo[] frameInfos) {
203:                for (int i = 0; i < NumberOfFrames; i++) {
204:                    logWriter.println(" ");
205:                    logWriter.println("=> #" + i + " frameID="
206:                            + frameInfos[i].frameID);
207:                    String methodName = getMethodName(
208:                            frameInfos[i].location.classID,
209:                            frameInfos[i].location.methodID);
210:                    logWriter.println("=> method name=" + methodName);
211:                }
212:                logWriter.println(" ");
213:            }
214:
215:            public static void main(String[] args) {
216:                junit.textui.TestRunner.run(PopFramesTest.class);
217:            }
218:        }
www___.__j__a__va___2s__._co_m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.