Source Code Cross Referenced for ReflectedTypeTest.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » jpda » tests » jdwp » ClassObjectReference » 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.ClassObjectReference 
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 Viacheslav G. Rybalov
021:         * @version $Revision: 1.4 $
022:         */
023:
024:        /**
025:         * Created on 05.03.2005
026:         */package org.apache.harmony.jpda.tests.jdwp.ClassObjectReference;
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 ClassObjectReference.ReflectedType command.
037:         */
038:
039:        public class ReflectedTypeTest extends JDWPSyncTestCase {
040:
041:            /**
042:             * Returns full name of debuggee class which is used by this test.
043:             * @return full name of debuggee class.
044:             */
045:            protected String getDebuggeeClassName() {
046:                return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
047:            }
048:
049:            /**
050:             * This testcase exercises ClassObjectReference.ReflectedType command.
051:             * <BR>Starts <A HREF="../share/debuggee/HelloWorld.html">HelloWorld</A> debuggee. 
052:             * <BR>Then checks the following four classes: 
053:             * <BR>&nbsp;&nbsp; - java/lang/Object; 
054:             * <BR>&nbsp;&nbsp; - java/lang/String;
055:             * <BR>&nbsp;&nbsp; - java/lang/Runnable; 
056:             * <BR>&nbsp;&nbsp; - HelloWorld.
057:             * <BR>&nbsp;&nbsp;
058:             * <BR>The following statements are checked: 
059:             * <BR>&nbsp;It is expected:
060:             * <BR>&nbsp;&nbsp; - refTypeTag takes one of the TypeTag constants: CLASS, INTERFACE;
061:             * <BR>&nbsp;&nbsp; - refTypeTag equals to refTypeTag returned by command 
062:             *  VirtualMachine.ClassesBySignature;
063:             * <BR>&nbsp;&nbsp; - typeID equals to typeID returned by the JDWP command 
064:             * VirtualMachine.ClassesBySignature;
065:             * <BR>&nbsp;&nbsp; - All data were read; 
066:             */
067:            public void testReflectedType001() {
068:                logWriter.println("==> testReflectedType001 START...");
069:                synchronizer
070:                        .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
071:
072:                String[] testedClasses = {
073:                        "java/lang/Object",
074:                        "java/lang/String",
075:                        "java/lang/Runnable",
076:                        "org/apache/harmony/jpda/tests/jdwp/share/debuggee/HelloWorld", };
077:
078:                byte expectedRefTypeTags[] = { JDWPConstants.TypeTag.CLASS,
079:                        JDWPConstants.TypeTag.CLASS,
080:                        JDWPConstants.TypeTag.INTERFACE,
081:                        JDWPConstants.TypeTag.CLASS, };
082:
083:                for (int i = 0; i < testedClasses.length; i++) {
084:                    logWriter.println("\n==> Checked class: "
085:                            + testedClasses[i]);
086:
087:                    // Get referenceTypeID
088:                    logWriter
089:                            .println("==> Send VirtualMachine::ClassesBySignature command for checked class...");
090:                    CommandPacket packet = new CommandPacket(
091:                            JDWPCommands.VirtualMachineCommandSet.CommandSetID,
092:                            JDWPCommands.VirtualMachineCommandSet.ClassesBySignatureCommand);
093:                    packet.setNextValueAsString("L" + testedClasses[i] + ";");
094:                    ReplyPacket reply = debuggeeWrapper.vmMirror
095:                            .performCommand(packet);
096:                    checkReplyPacket(reply,
097:                            "VirtualMachine::ClassesBySignature command");
098:
099:                    int classes = reply.getNextValueAsInt();
100:                    logWriter.println("==> Number of returned classes = "
101:                            + classes);
102:                    //this class may be loaded only once
103:                    byte refInitTypeTag = 0;
104:                    long typeInitID = 0;
105:                    int status = 0;
106:
107:                    for (int j = 0; j < classes; j++) {
108:                        refInitTypeTag = reply.getNextValueAsByte();
109:                        typeInitID = reply.getNextValueAsReferenceTypeID();
110:                        status = reply.getNextValueAsInt();
111:                        logWriter.println("==> refTypeId[" + j + "] = "
112:                                + typeInitID);
113:                        logWriter.println("==> refTypeTag[" + j + "] = "
114:                                + refInitTypeTag + "("
115:                                + JDWPConstants.TypeTag.getName(refInitTypeTag)
116:                                + ")");
117:                        logWriter.println("==> classStatus[" + j + "] = "
118:                                + status + "("
119:                                + JDWPConstants.ClassStatus.getName(status)
120:                                + ")");
121:
122:                        String classSignature = debuggeeWrapper.vmMirror
123:                                .getClassSignature(typeInitID);
124:                        logWriter.println("==> classSignature[" + j + "] = "
125:                                + classSignature);
126:
127:                        packet = new CommandPacket(
128:                                JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
129:                                JDWPCommands.ReferenceTypeCommandSet.ClassLoaderCommand);
130:                        packet.setNextValueAsReferenceTypeID(typeInitID);
131:                        ReplyPacket reply2 = debuggeeWrapper.vmMirror
132:                                .performCommand(packet);
133:                        checkReplyPacket(reply,
134:                                "ReferenceType::ClassLoader command");
135:
136:                        long classLoaderID = reply2.getNextValueAsObjectID();
137:                        logWriter.println("==> classLoaderID[" + j + "] = "
138:                                + classLoaderID);
139:
140:                        if (classLoaderID != 0) {
141:                            String classLoaderSignature = getObjectSignature(classLoaderID);
142:                            logWriter.println("==> classLoaderSignature[" + j
143:                                    + "] = " + classLoaderSignature);
144:                        } else {
145:                            logWriter
146:                                    .println("==> classLoader is system class loader");
147:                        }
148:                    }
149:
150:                    assertEquals(
151:                            "VirtualMachine::ClassesBySignature returned invalid number of classes,",
152:                            1, classes);
153:                    assertEquals(
154:                            "VirtualMachine::ClassesBySignature returned invalid TypeTag,",
155:                            expectedRefTypeTags[i], refInitTypeTag,
156:                            JDWPConstants.TypeTag
157:                                    .getName(expectedRefTypeTags[i]),
158:                            JDWPConstants.TypeTag.getName(refInitTypeTag));
159:
160:                    // Get ClassObject
161:                    logWriter
162:                            .println("==> Send ReferenceType::ClassObject command for checked class...");
163:                    packet = new CommandPacket(
164:                            JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
165:                            JDWPCommands.ReferenceTypeCommandSet.ClassObjectCommand);
166:                    packet.setNextValueAsReferenceTypeID(typeInitID);
167:                    reply = debuggeeWrapper.vmMirror.performCommand(packet);
168:                    checkReplyPacket(reply,
169:                            "ReferenceType::ClassObject command");
170:
171:                    long classObject = reply.getNextValueAsClassObjectID();
172:                    assertAllDataRead(reply);
173:                    logWriter.println("==> classObjectID=" + classObject);
174:
175:                    // Get ReflectedType
176:                    logWriter
177:                            .println("==> Send ClassObjectReference::ReflectedType command for classObjectID...");
178:                    packet = new CommandPacket(
179:                            JDWPCommands.ClassObjectReferenceCommandSet.CommandSetID,
180:                            JDWPCommands.ClassObjectReferenceCommandSet.ReflectedTypeCommand);
181:                    packet.setNextValueAsObjectID(classObject);
182:                    reply = debuggeeWrapper.vmMirror.performCommand(packet);
183:                    checkReplyPacket(reply,
184:                            "ClassObjectReference::ReflectedType command");
185:
186:                    byte refTypeTag = reply.getNextValueAsByte();
187:                    long typeID = reply.getNextValueAsReferenceTypeID();
188:                    logWriter.println("==> reflectedTypeId = " + typeID);
189:                    logWriter.println("==> reflectedTypeTag = " + refTypeTag
190:                            + "(" + JDWPConstants.TypeTag.getName(refTypeTag)
191:                            + ")");
192:
193:                    assertEquals(
194:                            "ClassObjectReference::ReflectedType returned invalid reflected TypeTag,",
195:                            expectedRefTypeTags[i], refTypeTag,
196:                            JDWPConstants.TypeTag
197:                                    .getName(expectedRefTypeTags[i]),
198:                            JDWPConstants.TypeTag.getName(refTypeTag));
199:                    assertEquals(
200:                            "ClassObjectReference::ReflectedType returned invalid reflected typeID,",
201:                            typeInitID, typeID);
202:                    assertAllDataRead(reply);
203:                }
204:
205:                synchronizer
206:                        .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
207:            }
208:
209:            /**
210:             * Starts this test by junit.textui.TestRunner.run() method.
211:             */
212:            public static void main(String[] args) {
213:                junit.textui.TestRunner.run(ReflectedTypeTest.class);
214:            }
215:        }
w___ww__.___j__a__va_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.