Source Code Cross Referenced for SuperClassTest.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » jpda » tests » jdwp » ClassType » 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.ClassType 
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 Anton V. Karnachuk
021:         * @version $Revision: 1.5 $
022:         */
023:
024:        /**
025:         * Created on 09.02.2005
026:         */package org.apache.harmony.jpda.tests.jdwp.ClassType;
027:
028:        import java.io.UnsupportedEncodingException;
029:
030:        import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
031:        import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
032:        import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
033:        import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
034:        import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
035:
036:        /**
037:         * JDWP unit test for ClassType.SuperClass command.
038:         * Contains three testcases: testSuperClass001, testSuperClass002, testSuperClass003.
039:         */
040:        public class SuperClassTest extends JDWPClassTypeTestCase {
041:
042:            /**
043:             * Starts this test by junit.textui.TestRunner.run() method.
044:             */
045:            public static void main(String[] args) {
046:                junit.textui.TestRunner.run(SuperClassTest.class);
047:            }
048:
049:            private ReplyPacket jdwpGetSuperClassReply(long classID,
050:                    int errorExpected) {
051:                CommandPacket packet = new CommandPacket(
052:                        JDWPCommands.ClassTypeCommandSet.CommandSetID,
053:                        JDWPCommands.ClassTypeCommandSet.SuperclassCommand);
054:                packet.setNextValueAsClassID(classID);
055:                ReplyPacket reply = debuggeeWrapper.vmMirror
056:                        .performCommand(packet);
057:                checkReplyPacket(reply, "ClassType.Superclass command",
058:                        errorExpected);
059:                return reply;
060:            }
061:
062:            private void asserSuperClassReplyIsValid(ReplyPacket reply,
063:                    String expectedSignature) {
064:                assertTrue(reply.getErrorCode() == JDWPConstants.Error.NONE);
065:                long super ClassID = reply.getNextValueAsClassID();
066:                logWriter.println("superClassID=" + super ClassID);
067:                if (super ClassID == 0) {
068:                    // for superclass of Object expectedSignature is null
069:                    assertNull(
070:                            "ClassType::Superclass command returned invalid expectedSignature that must be null",
071:                            expectedSignature);
072:                } else {
073:                    String signature = getClassSignature(super ClassID);
074:                    logWriter.println("Signature: " + signature);
075:                    assertString(
076:                            "ClassType::Superclass command returned invalid signature,",
077:                            expectedSignature, signature);
078:                }
079:            }
080:
081:            /**
082:             * This testcase exercises ClassType.Superclass command.
083:             * <BR>Starts <A HREF="ClassTypeDebuggee.html">ClassTypeDebuggee</A>. 
084:             * <BR>Then does the following checks: 
085:             * <BR>&nbsp;&nbsp; - superclass for java.lang.String is java.lang.Object;
086:             * <BR>&nbsp;&nbsp; - superclass for array of Objects is java.lang.Object;
087:             * <BR>&nbsp;&nbsp; - superclass for primitive array is java.lang.Object;
088:             * <BR>&nbsp;&nbsp; - superclass for <A HREF="ClassTypeDebuggee.html">ClassTypeDebuggee</A>
089:             * class is <A HREF="../../share/SyncDebuggee.html">SyncDebuggee</A> class.;
090:             */
091:            public void testSuperClass001() throws UnsupportedEncodingException {
092:                logWriter.println("testSuperClassTest001 started");
093:                synchronizer
094:                        .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
095:
096:                // check that superclass for java.lang.String is java.lang.Object
097:                {
098:                    // test with String[] class
099:                    long classID = getClassIDBySignature("Ljava/lang/String;");
100:
101:                    ReplyPacket reply = jdwpGetSuperClassReply(classID,
102:                            JDWPConstants.Error.NONE);
103:                    // complare returned signature with superclass signature
104:                    asserSuperClassReplyIsValid(reply, "Ljava/lang/Object;");
105:                }
106:
107:                // check that superclass for array is java.lang.Object
108:                {
109:                    // test with String[] class
110:                    long classID = getClassIDBySignature("[Ljava/lang/String;");
111:
112:                    ReplyPacket reply = jdwpGetSuperClassReply(classID,
113:                            JDWPConstants.Error.NONE);
114:                    // complare returned signature with superclass signature
115:                    asserSuperClassReplyIsValid(reply, "Ljava/lang/Object;");
116:                }
117:
118:                // check that superclass for primitive array is java.lang.Object
119:                {
120:                    // test with int[] class
121:                    long classID = getClassIDBySignature("[I");
122:
123:                    ReplyPacket reply = jdwpGetSuperClassReply(classID,
124:                            JDWPConstants.Error.NONE);
125:                    // complare returned signature with superclass signature
126:                    asserSuperClassReplyIsValid(reply, "Ljava/lang/Object;");
127:                }
128:
129:                // check that superclass for Debuggee is SyncDebuggee
130:                {
131:                    long classID = getClassIDBySignature(getDebuggeeSignature());
132:
133:                    ReplyPacket reply = jdwpGetSuperClassReply(classID,
134:                            JDWPConstants.Error.NONE);
135:                    // complare returned signature with superclass signature
136:                    asserSuperClassReplyIsValid(reply,
137:                            "Lorg/apache/harmony/jpda/tests/share/SyncDebuggee;");
138:                }
139:
140:                // check that there is no superclass for java.lang.Object
141:                {
142:                    // test with java.lang.Object class
143:                    long classID = getClassIDBySignature("Ljava/lang/Object;");
144:
145:                    ReplyPacket reply = jdwpGetSuperClassReply(classID,
146:                            JDWPConstants.Error.NONE);
147:                    // complare returned signature with superclass signature 
148:                    // (expects null for this case) 
149:                    asserSuperClassReplyIsValid(reply, null);
150:                }
151:
152:                synchronizer
153:                        .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
154:            }
155:
156:            /**
157:             * This testcase exercises ClassType.Superclass command.
158:             * <BR>Starts <A HREF="ClassTypeDebuggee.html">ClassTypeDebuggee</A>. 
159:             * <BR>Then does the following checks: 
160:             * <BR>&nbsp;&nbsp; - there is no superclass for interface;
161:             * <BR>&nbsp;&nbsp; - INVALID_OBJECT is returned if classID is non-existent;
162:             * <BR>&nbsp;&nbsp; - INVALID_OBJECT is returned if instead of classID FieldID is passed;
163:             */
164:            public void testSuperClass002() throws UnsupportedEncodingException {
165:                logWriter.println("testSuperClassTest002 started");
166:                synchronizer
167:                        .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
168:
169:                // check that there is no superclass for interface objects
170:                {
171:                    long interfaceID = getClassIDBySignature("Ljava/lang/Cloneable;");
172:
173:                    ReplyPacket reply = jdwpGetSuperClassReply(interfaceID,
174:                            JDWPConstants.Error.NONE);
175:                    // compare returned signature with superclass signature
176:                    // (null for interfaces)
177:                    asserSuperClassReplyIsValid(reply, null);
178:                }
179:
180:                // check that INVALID_OBJECT returns if classID is non-existent
181:                {
182:                    jdwpGetSuperClassReply(10000,
183:                            JDWPConstants.Error.INVALID_OBJECT);
184:                }
185:
186:                // check that reply error code is INVALID_OBJECT for a FieldID Out Data
187:                {
188:                    long classID = getClassIDBySignature(getDebuggeeSignature());
189:
190:                    FieldInfo[] fields = jdwpGetFields(classID);
191:                    // assert stringID is not null
192:                    assertTrue("Invalid fields.length: 0", fields.length > 0);
193:                    // test with the first field
194:
195:                    jdwpGetSuperClassReply(fields[0].getFieldID(),
196:                            JDWPConstants.Error.INVALID_OBJECT);
197:                }
198:
199:                synchronizer
200:                        .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
201:            }
202:
203:            /**
204:             * This testcase exercises ClassType.Superclass command.
205:             * <BR>Starts <A HREF="ClassTypeDebuggee.html">ClassTypeDebuggee</A>. 
206:             * <BR>Then does the following check: 
207:             * <BR>&nbsp;&nbsp; - INVALID_CLASS is returned if instead of classID ObjectID is passed;
208:             */
209:            public void testSuperClass003() throws UnsupportedEncodingException {
210:                logWriter.println("testSuperClassTest003 started");
211:                synchronizer
212:                        .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
213:
214:                // check that reply error code is INVALID_CLASS for a StringID Out Data
215:                {
216:                    long stringID = createString("Some test string");
217:                    // assert stringID is not null
218:                    assertFalse("Invalid stringID: 0", stringID == 0);
219:                    jdwpGetSuperClassReply(stringID,
220:                            JDWPConstants.Error.INVALID_CLASS);
221:                }
222:
223:                synchronizer
224:                        .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
225:            }
226:        }
w___w___w___.j_a___va_2_s.c_o__m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.