Source Code Cross Referenced for ClassUnloadTest.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » jpda » tests » jdwp » Events » 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.Events 
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.4 $
022:         */
023:
024:        /**
025:         * Created on 06.04.2005
026:         */package org.apache.harmony.jpda.tests.jdwp.Events;
027:
028:        import org.apache.harmony.jpda.tests.framework.TestErrorException;
029:        import org.apache.harmony.jpda.tests.framework.jdwp.EventPacket;
030:        import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
031:        import org.apache.harmony.jpda.tests.framework.jdwp.ParsedEvent;
032:        import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
033:        import org.apache.harmony.jpda.tests.framework.jdwp.exceptions.TimeoutException;
034:        import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
035:
036:        /**
037:         * JDWP Unit test for CLASS_UNLOAD event.
038:         */
039:        public class ClassUnloadTest extends JDWPEventTestCase {
040:
041:            public static final String TESTED_CLASS_NAME = "org.apache.harmony.jpda.tests.jdwp.Events.ClassUnloadTestedClass";
042:
043:            public static final String TESTED_CLASS_SIGNATURE = "L"
044:                    + TESTED_CLASS_NAME.replace('.', '/') + ";";
045:
046:            protected String getDebuggeeClassName() {
047:                return ClassUnloadDebuggee.class.getName();
048:            }
049:
050:            public static void main(String[] args) {
051:                junit.textui.TestRunner.run(ClassUnloadTest.class);
052:            }
053:
054:            /**
055:             * This testcase is for CLASS_UNLOAD event.
056:             */
057:            public void testClassUnloadEvent() {
058:                logWriter.println("==> testClassUnloadEvent started");
059:
060:                synchronizer
061:                        .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
062:
063:                ReplyPacket reply = null;
064:                int foundClasses = 0;
065:
066:                // commented out because it may leave JNI references to the tested class,
067:                //   which will prevent it from garbage collecting and unloading
068:                /*        
069:                 // check that tested class is loaded before unloading it
070:                 logWriter.println("=> Find tested class by signature: " + TESTED_CLASS_SIGNATURE);
071:                 reply = debuggeeWrapper.vmMirror.getClassBySignature(TESTED_CLASS_SIGNATURE);
072:                 foundClasses = reply.getNextValueAsInt();
073:                 logWriter.println("=> Found clases: " + foundClasses);
074:
075:                 if (foundClasses <= 0) {
076:                 fail("Tested class was not found: count=" + foundClasses);
077:                 }
078:                 */
079:
080:                logWriter.println("=> Set request for ClasUnload event: "
081:                        + TESTED_CLASS_NAME);
082:                reply = debuggeeWrapper.vmMirror
083:                        .setClassUnload(TESTED_CLASS_NAME);
084:                checkReplyPacket(reply, "Set CLASS_UNLOAD event");
085:                int requestID = reply.getNextValueAsInt();
086:                logWriter
087:                        .println("=> Created requestID for ClassUnload event: "
088:                                + requestID);
089:
090:                logWriter.println("=> Release debuggee");
091:                synchronizer
092:                        .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
093:
094:                logWriter.println("=> Wait for class unload event");
095:                EventPacket event = null;
096:                try {
097:                    event = debuggeeWrapper.vmMirror.receiveEvent(settings
098:                            .getTimeout());
099:                    logWriter.println("=> Event received");
100:                } catch (TimeoutException e) {
101:                    logWriter
102:                            .println("=> ClassUnload event was not received (class might be not really unloaded)");
103:                } catch (Exception e) {
104:                    logWriter
105:                            .println("=> Exception during receiving ClassUnload event: "
106:                                    + e);
107:                    throw new TestErrorException(e);
108:                }
109:
110:                logWriter.println("=> Clear request for ClassUnload event");
111:                reply = debuggeeWrapper.vmMirror.clearEvent(
112:                        JDWPConstants.EventKind.CLASS_UNLOAD, requestID);
113:
114:                logWriter.println("=> Try to find tested class by signature: "
115:                        + TESTED_CLASS_SIGNATURE);
116:                reply = debuggeeWrapper.vmMirror
117:                        .getClassBySignature(TESTED_CLASS_SIGNATURE);
118:                foundClasses = reply.getNextValueAsInt();
119:                logWriter.println("=> Found clases: " + foundClasses);
120:
121:                logWriter
122:                        .println("=> Wait for class status message from debuggee");
123:                String status = synchronizer.receiveMessage();
124:                logWriter.println("=> Debuggee reported class status: "
125:                        + status);
126:
127:                if (event != null) {
128:                    // check event data
129:                    ParsedEvent[] parsedEvents = ParsedEvent
130:                            .parseEventPacket(event);
131:
132:                    assertEquals("Invalid number of events,", 1,
133:                            parsedEvents.length);
134:                    assertEquals(
135:                            "Invalid event kind,",
136:                            JDWPConstants.EventKind.CLASS_UNLOAD,
137:                            parsedEvents[0].getEventKind(),
138:                            JDWPConstants.EventKind
139:                                    .getName(JDWPConstants.EventKind.CLASS_UNLOAD),
140:                            JDWPConstants.EventKind.getName(parsedEvents[0]
141:                                    .getEventKind()));
142:                    assertEquals("Invalid event request,", requestID,
143:                            parsedEvents[0].getRequestID());
144:
145:                    // check that unloaded class was not found after event
146:                    if (foundClasses > 0) {
147:                        fail("Tested class was found after ClasUnload event: count="
148:                                + foundClasses);
149:                    }
150:
151:                    logWriter.println("=> Resume debuggee on event");
152:                    debuggeeWrapper.resume();
153:                } else {
154:                    // check if tested class not found without event
155:                    if (foundClasses <= 0) {
156:                        fail("No ClassUnload event, but tested class not found: count="
157:                                + foundClasses);
158:                    }
159:
160:                    // check if debuggee reported tested class unloaded without event
161:                    if ("UNLOADED".equals(status)) {
162:                        fail("No ClassUnload event, but tested class was unloaded");
163:                    }
164:                }
165:
166:                logWriter.println("=> Release debuggee");
167:                synchronizer
168:                        .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
169:                logWriter.println("==> testClassUnloadEvent ended");
170:            }
171:        }
www_._j___a_va2s___.___c__o___m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.