Source Code Cross Referenced for EnableCollectionTest.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » jpda » tests » jdwp » ObjectReference » 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.ObjectReference 
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 Anatoly F. Bondarenko
021:         * @version $Revision: 1.6 $
022:         */
023:
024:        /**
025:         * Created on 04.03.2005
026:         */package org.apache.harmony.jpda.tests.jdwp.ObjectReference;
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.framework.jdwp.Value;
033:        import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
034:        import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
035:
036:        /**
037:         * JDWP Unit test for ObjectReference.EnableCollection command.
038:         */
039:        public class EnableCollectionTest extends JDWPSyncTestCase {
040:
041:            static final int testStatusPassed = 0;
042:            static final int testStatusFailed = -1;
043:            static final String this CommandName = "ObjectReference::EnableCollection command";
044:            static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/ObjectReference/EnableCollectionDebuggee;";
045:
046:            protected String getDebuggeeClassName() {
047:                return "org.apache.harmony.jpda.tests.jdwp.ObjectReference.EnableCollectionDebuggee";
048:            }
049:
050:            /**
051:             * This testcase exercises ObjectReference.EnableCollection command.
052:             * <BR>The test starts EnableCollectionDebuggee class, gets objectID
053:             * as value of static field of this class which (field) represents checked object.
054:             * Then for this objectID test executes ObjectReference::DisableCollection command 
055:             * and ObjectReference.EnableCollection command. After that Debuggee tries to
056:             * unload checked object and checks if checked object is unloaded.
057:             * <BR>If so the test passes. Otherwise it fails in case when pattern object is unloaded.
058:             */
059:            public void testEnableCollection001() {
060:                String this TestName = "testEnableCollection001";
061:                logWriter.println("==> " + this TestName + " for "
062:                        + this CommandName + ": START...");
063:                synchronizer
064:                        .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
065:                finalSyncMessage = "TO_FINISH";
066:
067:                long refTypeID = getClassIDBySignature(debuggeeSignature);
068:
069:                logWriter.println("=> Debuggee class = "
070:                        + getDebuggeeClassName());
071:                logWriter.println("=> referenceTypeID for Debuggee class = "
072:                        + refTypeID);
073:
074:                logWriter
075:                        .println("=> Send ReferenceType::Fields command and get fieldID for field representing checked object...");
076:
077:                long checkedFieldID = checkFields(refTypeID,
078:                        new String[] { "checkedObject" })[0];
079:
080:                logWriter
081:                        .println("=> Send ReferenceType::GetValues command for received fieldID and get ObjectID to check...");
082:
083:                CommandPacket getValuesCommand = new CommandPacket(
084:                        JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
085:                        JDWPCommands.ReferenceTypeCommandSet.GetValuesCommand);
086:                getValuesCommand.setNextValueAsReferenceTypeID(refTypeID);
087:                getValuesCommand.setNextValueAsInt(1);
088:                getValuesCommand.setNextValueAsFieldID(checkedFieldID);
089:
090:                ReplyPacket getValuesReply = debuggeeWrapper.vmMirror
091:                        .performCommand(getValuesCommand);
092:                getValuesCommand = null;
093:                checkReplyPacket(getValuesReply,
094:                        "ReferenceType::GetValues command");
095:
096:                int returnedValuesNumber = getValuesReply.getNextValueAsInt();
097:                logWriter.println("=> Returned values number = "
098:                        + returnedValuesNumber);
099:                assertEquals("Invalid number of values,", 1,
100:                        returnedValuesNumber);
101:
102:                Value checkedObjectFieldValue = getValuesReply
103:                        .getNextValueAsValue();
104:                byte checkedObjectFieldTag = checkedObjectFieldValue.getTag();
105:                logWriter
106:                        .println("=> Returned field value tag for checked object= "
107:                                + checkedObjectFieldTag
108:                                + "("
109:                                + JDWPConstants.Tag
110:                                        .getName(checkedObjectFieldTag) + ")");
111:                assertEquals(
112:                        "invalid value tag for checked object,",
113:                        JDWPConstants.Tag.OBJECT_TAG,
114:                        checkedObjectFieldTag,
115:                        JDWPConstants.Tag.getName(JDWPConstants.Tag.OBJECT_TAG),
116:                        JDWPConstants.Tag.getName(checkedObjectFieldTag));
117:
118:                long checkedObjectID = checkedObjectFieldValue.getLongValue();
119:                logWriter.println("=> Returned checked ObjectID = "
120:                        + checkedObjectID);
121:
122:                logWriter
123:                        .println("\n=> Send ObjectReference::DisableCollection command for checked ObjectID...");
124:
125:                CommandPacket disableCollectionCommand = new CommandPacket(
126:                        JDWPCommands.ObjectReferenceCommandSet.CommandSetID,
127:                        JDWPCommands.ObjectReferenceCommandSet.DisableCollectionCommand);
128:                disableCollectionCommand
129:                        .setNextValueAsObjectID(checkedObjectID);
130:
131:                ReplyPacket disableCollectionReply = debuggeeWrapper.vmMirror
132:                        .performCommand(disableCollectionCommand);
133:                disableCollectionCommand = null;
134:                checkReplyPacket(disableCollectionReply,
135:                        "ObjectReference::DisableCollection command");
136:
137:                logWriter.println("\n=> CHECK: Send " + this CommandName
138:                        + " for checked ObjectID...");
139:
140:                CommandPacket checkedCommand = new CommandPacket(
141:                        JDWPCommands.ObjectReferenceCommandSet.CommandSetID,
142:                        JDWPCommands.ObjectReferenceCommandSet.EnableCollectionCommand);
143:                checkedCommand.setNextValueAsObjectID(checkedObjectID);
144:
145:                ReplyPacket checkedReply = debuggeeWrapper.vmMirror
146:                        .performCommand(checkedCommand);
147:                checkedCommand = null;
148:                checkReplyPacket(checkedReply, this CommandName);
149:
150:                logWriter
151:                        .println("=> CHECK: Reply is received without any error");
152:
153:                logWriter
154:                        .println("=> Send to Debuggee signal to continue and try to unload checked ObjectID...");
155:                finalSyncMessage = null;
156:                synchronizer
157:                        .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
158:                String messageFromDebuggee = synchronizer.receiveMessage();
159:                logWriter.println("\n=> Received message from Debuggee = \""
160:                        + messageFromDebuggee + "\"");
161:                if (messageFromDebuggee
162:                        .equals("Checked Object is NOT UNLOADed; Pattern Object is UNLOADed;")) {
163:                    logWriter
164:                            .println("## FAILURE: Checked Object is NOT UNLOADed after "
165:                                    + this CommandName);
166:                    fail("Checked Object is NOT UNLOADed after "
167:                            + this CommandName);
168:                } else {
169:                    logWriter.println("=> PASSED: It is expected result");
170:                }
171:
172:                assertAllDataRead(checkedReply);
173:
174:                logWriter.println("=> Send to Debuggee signal to funish ...");
175:                synchronizer
176:                        .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
177:                logWriter.println("==> " + this TestName + " for "
178:                        + this CommandName + ": FINISH");
179:            }
180:
181:            public static void main(String[] args) {
182:                junit.textui.TestRunner.run(EnableCollectionTest.class);
183:            }
184:        }
w_w__w___.j___ava_2s._c__o_m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.