Source Code Cross Referenced for EnableCollectionTest.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.JDWPCommands;
031:        import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
032:        import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
033:        import org.apache.harmony.jpda.tests.framework.jdwp.Value;
034:        import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
035:        import org.apache.harmony.jpda.tests.jdwp.share.JDWPUnitDebuggeeWrapper;
036:        import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
037:
038:        /**
039:         * JDWP Unit test for verifying re-enabling of garbage collecting after re-connection.
040:         */
041:        public class EnableCollectionTest extends JDWPSyncTestCase {
042:
043:            String checkedFieldName = "checkedObject";
044:            static final int testStatusPassed = 0;
045:            static final int testStatusFailed = -1;
046:            static final String this CommandName = "MultiSession::EnableCollection command";
047:
048:            static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/MultiSession/EnableCollectionDebuggee;";
049:
050:            protected String getDebuggeeClassName() {
051:                return "org.apache.harmony.jpda.tests.jdwp.MultiSession.EnableCollectionDebuggee";
052:            }
053:
054:            /**
055:             * This testcase verifies re-enabling of garbage collecting after re-connection.
056:             * <BR>It runs EnableCollectionDebuggee, disables garbage collecting for checked object
057:             * with ObjectReference.DisableCollection command and re-connects.
058:             * <BR>It is expected that checked object is garbage collected after re-connection.
059:             */
060:            public void testEnableCollection001() {
061:                String this TestName = "testEnableCollection001";
062:                logWriter.println("==> testEnableCollection001 started..");
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:                long checkedFieldID = debuggeeWrapper.vmMirror.getFieldID(
075:                        refTypeID, checkedFieldName);
076:
077:                logWriter
078:                        .println("=> Send ReferenceType::GetValues command for received fieldID and get ObjectID to check...");
079:
080:                CommandPacket getValuesCommand = new CommandPacket(
081:                        JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
082:                        JDWPCommands.ReferenceTypeCommandSet.GetValuesCommand);
083:                getValuesCommand.setNextValueAsReferenceTypeID(refTypeID);
084:                getValuesCommand.setNextValueAsInt(1);
085:                getValuesCommand.setNextValueAsFieldID(checkedFieldID);
086:
087:                ReplyPacket getValuesReply = debuggeeWrapper.vmMirror
088:                        .performCommand(getValuesCommand);
089:                getValuesCommand = null;
090:                checkReplyPacket(getValuesReply,
091:                        "ReferenceType::GetValues command");
092:
093:                int returnedValuesNumber = getValuesReply.getNextValueAsInt();
094:                logWriter.println("=> Returned values number = "
095:                        + returnedValuesNumber);
096:                assertEquals("Invalid returned number of values,", 1,
097:                        returnedValuesNumber);
098:
099:                Value checkedObjectFieldValue = getValuesReply
100:                        .getNextValueAsValue();
101:                byte checkedObjectFieldTag = checkedObjectFieldValue.getTag();
102:                logWriter
103:                        .println("=> Returned field value tag for checked object= "
104:                                + checkedObjectFieldTag
105:                                + "("
106:                                + JDWPConstants.Tag
107:                                        .getName(checkedObjectFieldTag) + ")");
108:                assertEquals("Invalid object tag,",
109:                        JDWPConstants.Tag.OBJECT_TAG, checkedObjectFieldTag);
110:
111:                long checkedObjectID = checkedObjectFieldValue.getLongValue();
112:                logWriter.println("=> Returned checked ObjectID = "
113:                        + checkedObjectID);
114:
115:                logWriter.println("\n=> CHECK: send " + this CommandName
116:                        + " for checked ObjectID...");
117:
118:                CommandPacket checkedCommand = new CommandPacket(
119:                        JDWPCommands.ObjectReferenceCommandSet.CommandSetID,
120:                        JDWPCommands.ObjectReferenceCommandSet.DisableCollectionCommand);
121:                checkedCommand.setNextValueAsObjectID(checkedObjectID);
122:
123:                ReplyPacket checkedReply = debuggeeWrapper.vmMirror
124:                        .performCommand(checkedCommand);
125:                checkedCommand = null;
126:                checkReplyPacket(checkedReply,
127:                        "ObjectReference::DisableCollection command");
128:
129:                logWriter
130:                        .println("=> CHECK: Reply is received without any error");
131:
132:                logWriter.println("");
133:                logWriter.println("=> CLOSE CONNECTION..");
134:                closeConnection();
135:                logWriter.println("=> CONNECTION CLOSED");
136:                logWriter.println("");
137:                logWriter.println("=> OPEN NEW CONNECTION..");
138:                openConnection();
139:                logWriter.println("=> CONNECTION OPENED");
140:
141:                logWriter.println("=> Resuming debuggee");
142:
143:                // start the thread
144:                finalSyncMessage = null;
145:                synchronizer
146:                        .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
147:
148:                String messageFromDebuggee = synchronizer.receiveMessage();
149:                logWriter.println("\n=> Received message from Debuggee = \""
150:                        + messageFromDebuggee + "\"");
151:                if (messageFromDebuggee
152:                        .equals("Checked Object is NOT UNLOADed; Pattern Object is UNLOADed;")) {
153:                    logWriter
154:                            .println("## FAILURE: Checked Object is NOT UNLOADed after "
155:                                    + this CommandName);
156:                    fail("Invalid message from debuggee.");
157:                } else {
158:                    logWriter.println("=> PASSED: It is expected result");
159:                }
160:
161:                assertAllDataRead(checkedReply);
162:
163:                logWriter.println("=> Send to Debuggee signal to finish ...");
164:                synchronizer
165:                        .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
166:                logWriter.println("==> " + this TestName + " for "
167:                        + this CommandName + ": FINISH");
168:                logWriter.println("==> testEnableCollection001 PASSED!");
169:            }
170:
171:            protected void beforeDebuggeeStart(
172:                    JDWPUnitDebuggeeWrapper debuggeeWrapper) {
173:                settings.setAttachConnectorKind();
174:                if (settings.getTransportAddress() == null) {
175:                    settings
176:                            .setTransportAddress(TestOptions.DEFAULT_ATTACHING_ADDRESS);
177:                }
178:                logWriter.println("ATTACH connector kind");
179:                super .beforeDebuggeeStart(debuggeeWrapper);
180:            }
181:
182:            public static void main(String[] args) {
183:                junit.textui.TestRunner.run(EnableCollectionTest.class);
184:            }
185:        }
w__w___w._j__av___a___2s_.___c__om_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.