Source Code Cross Referenced for FrameCountTest.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » jpda » tests » jdwp » ThreadReference » 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.ThreadReference 
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 Vitaly A. Provodin
021:         * @version $Revision: 1.5 $
022:         */
023:
024:        /**
025:         * Created on 18.02.2005
026:         */package org.apache.harmony.jpda.tests.jdwp.ThreadReference;
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.JDWPConstants;
031:        import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
032:        import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
033:        import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
034:
035:        /**
036:         * JDWP Unit test for ThreadReference.FrameCount command.
037:         */
038:        public class FrameCountTest extends JDWPSyncTestCase {
039:
040:            protected String getDebuggeeClassName() {
041:                return "org.apache.harmony.jpda.tests.jdwp.ThreadReference.FramesDebuggee";
042:            }
043:
044:            /**
045:             * This testcase exercises ThreadReference.CurrentContendedMonitor command.
046:             * <BR>At first the test starts FramesDebuggee which recursively invokes 
047:             * the method 'FramesDebuggee.recursiveMethod' thereby the specified depth 
048:             * 'FramesDebuggee.DEPTH' of recursion is reached. 
049:             * <BR> Then the tests requests list of frames for main thread by invoking
050:             * the JDWP command ThreadReference.Frames and compares size of
051:             * this list with the value got via invoking ThreadReference.FrameCount command.
052:             * <BR>The test expects that these values are equal, otherwise the test fail.
053:             *  
054:             */
055:            public void testFrameCount001() {
056:                logWriter.println("==> testFrameCount001 START ");
057:                String testedThreadName = synchronizer.receiveMessage();
058:
059:                logWriter.println("==> testedThreadName = |" + testedThreadName
060:                        + "|");
061:                long threadID = debuggeeWrapper.vmMirror
062:                        .getThreadID(testedThreadName);
063:                logWriter.println("==> threadID = " + threadID);
064:                debuggeeWrapper.vmMirror.suspendThread(threadID);
065:
066:                int expectedCount = getFramesCount(threadID);
067:                logWriter.println("\texpected count = " + expectedCount);
068:
069:                CommandPacket packet = new CommandPacket(
070:                        JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
071:                        JDWPCommands.ThreadReferenceCommandSet.FrameCountCommand);
072:                packet.setNextValueAsThreadID(threadID);
073:                ReplyPacket reply = debuggeeWrapper.vmMirror
074:                        .performCommand(packet);
075:                checkReplyPacket(reply, "ThreadReference::FrameCount command");
076:
077:                int frameCount = reply.getNextValueAsInt();
078:                logWriter.println("\tframe count = " + frameCount);
079:
080:                if (frameCount != expectedCount) {
081:                    printErrorAndFail("Unexpected frame count = " + frameCount
082:                            + ", expected value " + expectedCount);
083:                }
084:                debuggeeWrapper.vmMirror.resumeThread(threadID);
085:                synchronizer
086:                        .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
087:            }
088:
089:            private int getFramesCount(long threadID) {
090:
091:                logWriter.println("getting frames of the thread");
092:
093:                short err;
094:
095:                // getting frames of the thread
096:                CommandPacket packet = new CommandPacket(
097:                        JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
098:                        JDWPCommands.ThreadReferenceCommandSet.FramesCommand);
099:                packet.setNextValueAsThreadID(threadID);
100:                packet.setNextValueAsInt(0);
101:                packet.setNextValueAsInt(-1);
102:                ReplyPacket reply = debuggeeWrapper.vmMirror
103:                        .performCommand(packet);
104:                err = reply.getErrorCode();
105:                if (err != JDWPConstants.Error.NONE) {
106:                    logWriter.println("\tthreadID=" + threadID + " - "
107:                            + JDWPConstants.Error.getName(err));
108:                    return 0;
109:                }
110:                int framesCount = reply.getNextValueAsInt();
111:                return framesCount;
112:            }
113:
114:            public static void main(String[] args) {
115:                junit.textui.TestRunner.run(FrameCountTest.class);
116:            }
117:        }
w__w__w___.___j_a___v__a__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.