Source Code Cross Referenced for DisposeObjectsTest.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » jpda » tests » jdwp » VirtualMachine » 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.VirtualMachine 
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.4 $
022:         */
023:
024:        /**
025:         * Created on 28.02.2005
026:         */package org.apache.harmony.jpda.tests.jdwp.VirtualMachine;
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 VirtualMachine.DisposeObjects command.
037:         */
038:        public class DisposeObjectsTest extends JDWPSyncTestCase {
039:
040:            static final String CHECKED_STRING = "Hello World!";
041:
042:            protected String getDebuggeeClassName() {
043:                return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
044:            }
045:
046:            /**
047:             * This testcase exercises VirtualMachine.DisposeObjects command.
048:             * <BR>At first the test starts HelloWorld debuggee.
049:             * <BR> Then the test performs VirtualMachine.CreateString command 
050:             * for some string and checks that VirtualMachine.DisposeObjects command
051:             * for returned by CreateString command stringID with refCount = 0
052:             * does not dispose that stringID - ObjectReference::ReferenceType
053:             * command should return some referenceTypeID without any error.
054:             * <BR>Then the test check that repeated VirtualMachine.DisposeObjects command
055:             * with refCount = 1 disposes that stringID - ObjectReference::ReferenceType
056:             * command should return INVALID_OBJECT error. 
057:             */
058:            public void testDisposeObjects001() {
059:                synchronizer
060:                        .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
061:
062:                CommandPacket packet = new CommandPacket(
063:                        JDWPCommands.VirtualMachineCommandSet.CommandSetID,
064:                        JDWPCommands.VirtualMachineCommandSet.CreateStringCommand);
065:                packet.setNextValueAsString(CHECKED_STRING);
066:                logWriter.println("\tcreate string: " + CHECKED_STRING);
067:                ReplyPacket reply = debuggeeWrapper.vmMirror
068:                        .performCommand(packet);
069:
070:                long stringID = reply.getNextValueAsStringID();
071:                logWriter.println("\tstring creared: stringID = " + stringID);
072:
073:                logWriter
074:                        .println("\tsend DisposeObjects for created string with refCount = 0"
075:                                + " - string should not be disposed...");
076:                packet = new CommandPacket(
077:                        JDWPCommands.VirtualMachineCommandSet.CommandSetID,
078:                        JDWPCommands.VirtualMachineCommandSet.DisposeObjectsCommand);
079:                packet.setNextValueAsInt(1);
080:                packet.setNextValueAsObjectID(stringID);
081:                packet.setNextValueAsInt(0);
082:                reply = debuggeeWrapper.vmMirror.performCommand(packet);
083:                checkReplyPacket(reply,
084:                        "VirtualMachine::DisposeObjects command");
085:
086:                logWriter
087:                        .println("\tsend ObjectReference::ReferenceType command for created string"
088:                                + " to make sure that string is not disposed...");
089:                packet = new CommandPacket(
090:                        JDWPCommands.ObjectReferenceCommandSet.CommandSetID,
091:                        JDWPCommands.ObjectReferenceCommandSet.ReferenceTypeCommand);
092:                packet.setNextValueAsObjectID(stringID);
093:                reply = debuggeeWrapper.vmMirror.performCommand(packet);
094:                checkReplyPacket(reply,
095:                        "ObjectReference::ReferenceType command");
096:
097:                byte refTypeTag = reply.getNextValueAsByte();
098:                long refTypeID = reply.getNextValueAsReferenceTypeID();
099:                logWriter.println("\tReturned refTypeTag = " + refTypeTag + "("
100:                        + JDWPConstants.TypeTag.getName(refTypeTag) + ")");
101:                logWriter.println("\tReturned ReferenceTypeID for string = "
102:                        + refTypeID);
103:
104:                logWriter
105:                        .println("\tsend DisposeObjects for created string with refCount = 1"
106:                                + " - string should be disposed...");
107:                packet = new CommandPacket(
108:                        JDWPCommands.VirtualMachineCommandSet.CommandSetID,
109:                        JDWPCommands.VirtualMachineCommandSet.DisposeObjectsCommand);
110:                packet.setNextValueAsInt(1);
111:                packet.setNextValueAsObjectID(stringID);
112:                packet.setNextValueAsInt(1);
113:                reply = debuggeeWrapper.vmMirror.performCommand(packet);
114:                checkReplyPacket(reply,
115:                        "VirtualMachine::DisposeObjects command");
116:
117:                logWriter
118:                        .println("\tsend ObjectReference::ReferenceType command for disposed string"
119:                                + " - INVALID_OBJECT should be...");
120:                packet = new CommandPacket(
121:                        JDWPCommands.ObjectReferenceCommandSet.CommandSetID,
122:                        JDWPCommands.ObjectReferenceCommandSet.ReferenceTypeCommand);
123:                packet.setNextValueAsObjectID(stringID);
124:                reply = debuggeeWrapper.vmMirror.performCommand(packet);
125:
126:                checkReplyPacket(reply,
127:                        "ObjectReference::ReferenceType command",
128:                        JDWPConstants.Error.INVALID_OBJECT);
129:
130:                synchronizer
131:                        .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
132:            }
133:
134:            public static void main(String[] args) {
135:                junit.textui.TestRunner.run(DisposeObjectsTest.class);
136:            }
137:        }
w__w___w_._j__a___v_a___2___s__.__c_om__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.