Source Code Cross Referenced for Signature002Test.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » jpda » tests » jdwp » ReferenceType » 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.ReferenceType 
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.7 $
022:         */
023:
024:        /**
025:         * Created on 04.03.2005
026:         */package org.apache.harmony.jpda.tests.jdwp.ReferenceType;
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 ReferenceType..Signature command with incorrect ReferenceTypeIDs.
038:         */
039:        public class Signature002Test extends JDWPSyncTestCase {
040:
041:            static final String this CommandName = "ReferenceType.Signature command";
042:            static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/ReferenceType/Signature002Debuggee;";
043:
044:            protected String getDebuggeeClassName() {
045:                return "org.apache.harmony.jpda.tests.jdwp.ReferenceType.Signature002Debuggee";
046:            }
047:
048:            /**
049:             * This testcase exercises ReferenceType.Signature command with incorrect ReferenceTypeIDs.
050:             * <BR>The test starts >Signature002Debuggee class, gets objectID
051:             * as value of static field of this class which (field) represents checked object.
052:             * Then the test performs three variants of ReferenceType.Signature commands
053:             * and checks that commands return: 
054:             * <BR>&nbsp;&nbsp; - JDWP_ERROR_INVALID_CLASS, if objectID is passed as ReferenceTypeID;
055:             * <BR>&nbsp;&nbsp; - JDWP_ERROR_INVALID_OBJECT, if fieldID is passed as ReferenceTypeID;
056:             * <BR>&nbsp;&nbsp; - JDWP_ERROR_INVALID_OBJECT, if unknown ID is passed as ReferenceTypeID;
057:             */
058:            public void testSignature002() {
059:                String this TestName = "testSignature002";
060:                logWriter.println("==> " + this TestName + " for "
061:                        + this CommandName + ": START...");
062:                synchronizer
063:                        .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
064:                finalSyncMessage = "TO_FINISH";
065:
066:                long debuggeeRefTypeID = getClassIDBySignature(debuggeeSignature);
067:
068:                logWriter.println("=> Debuggee class = "
069:                        + getDebuggeeClassName());
070:                logWriter.println("=> referenceTypeID for Debuggee class = "
071:                        + debuggeeRefTypeID);
072:
073:                long checkedFieldID = checkField(debuggeeRefTypeID,
074:                        "checkedObject");
075:
076:                logWriter
077:                        .println("=> Send ReferenceType::GetValues command for received fieldID and get ObjectID to check...");
078:
079:                CommandPacket getValuesCommand = new CommandPacket(
080:                        JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
081:                        JDWPCommands.ReferenceTypeCommandSet.GetValuesCommand);
082:                getValuesCommand
083:                        .setNextValueAsReferenceTypeID(debuggeeRefTypeID);
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:                if (returnedValuesNumber != 1) {
097:                    logWriter
098:                            .println("\n## FAILURE: ReferenceType::GetValues command returned unexpected number of values:");
099:                    logWriter.println("## Expected number = 1");
100:                    logWriter.println("## Returned number = "
101:                            + returnedValuesNumber);
102:                    logWriter.println("==> " + this TestName + " for "
103:                            + this CommandName + ": FINISH");
104:                    synchronizer.sendMessage("TO_FINISH");
105:                    assertEquals(
106:                            "ReferenceType::GetValues command returned unexpected number of values,",
107:                            1, returnedValuesNumber);
108:                }
109:
110:                Value checkedObjectFieldValue = getValuesReply
111:                        .getNextValueAsValue();
112:                byte checkedObjectFieldTag = checkedObjectFieldValue.getTag();
113:                logWriter
114:                        .println("=> Returned field value tag for checked object= "
115:                                + checkedObjectFieldTag
116:                                + "("
117:                                + JDWPConstants.Tag
118:                                        .getName(checkedObjectFieldTag) + ")");
119:                if (checkedObjectFieldTag != JDWPConstants.Tag.OBJECT_TAG) {
120:                    finalSyncMessage = "TO_FINISH";
121:                    printErrorAndFail("ReferenceType::GetValues command returned unexpected tag: "
122:                            + checkedObjectFieldTag
123:                            + "("
124:                            + JDWPConstants.Tag.getName(checkedObjectFieldTag)
125:                            + ")"
126:                            + ", Expected tag = "
127:                            + JDWPConstants.Tag.OBJECT_TAG + "(OBJECT_TAG)");
128:                }
129:
130:                long checkedObjectID = checkedObjectFieldValue.getLongValue();
131:                logWriter.println("=> Returned checked ObjectID = "
132:                        + checkedObjectID);
133:
134:                logWriter
135:                        .println("\n=> CHECK: send "
136:                                + this CommandName
137:                                + " for checked ObjectID: INVALID_CLASS is expected...");
138:
139:                CommandPacket checkedCommand = new CommandPacket(
140:                        JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
141:                        JDWPCommands.ReferenceTypeCommandSet.SignatureCommand);
142:                checkedCommand.setNextValueAsReferenceTypeID(checkedObjectID);
143:
144:                ReplyPacket checkedReply = debuggeeWrapper.vmMirror
145:                        .performCommand(checkedCommand);
146:                checkedCommand = null;
147:
148:                short errorCode = checkedReply.getErrorCode();
149:                if (errorCode != JDWPConstants.Error.NONE) {
150:                    if (errorCode != JDWPConstants.Error.INVALID_CLASS) {
151:                        logWriter.println("## CHECK: FAILURE: "
152:                                + this CommandName
153:                                + " returns unexpected ERROR = " + errorCode
154:                                + "(" + JDWPConstants.Error.getName(errorCode)
155:                                + ")");
156:                        fail(this CommandName + " returns unexpected ERROR = "
157:                                + errorCode + "("
158:                                + JDWPConstants.Error.getName(errorCode) + ")");
159:                    } else {
160:                        logWriter
161:                                .println("=> CHECK PASSED: Expected error (INVALID_CLASS) is returned");
162:                    }
163:                } else {
164:                    logWriter
165:                            .println("\n## FAILURE: "
166:                                    + this CommandName
167:                                    + " does NOT return expected error - INVALID_CLASS");
168:                    fail(this CommandName
169:                            + " does NOT return expected error - INVALID_CLASS");
170:                }
171:
172:                logWriter
173:                        .println("\n=> CHECK: send "
174:                                + this CommandName
175:                                + " for checked fieldID: INVALID_OBJECT is expected...");
176:
177:                checkedCommand = new CommandPacket(
178:                        JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
179:                        JDWPCommands.ReferenceTypeCommandSet.SignatureCommand);
180:                checkedCommand.setNextValueAsReferenceTypeID(checkedFieldID);
181:
182:                checkedReply = debuggeeWrapper.vmMirror
183:                        .performCommand(checkedCommand);
184:                checkedCommand = null;
185:
186:                errorCode = checkedReply.getErrorCode();
187:                if (errorCode != JDWPConstants.Error.NONE) {
188:                    if (errorCode != JDWPConstants.Error.INVALID_OBJECT) {
189:                        logWriter.println("## CHECK: FAILURE: "
190:                                + this CommandName
191:                                + " returns unexpected ERROR = " + errorCode
192:                                + "(" + JDWPConstants.Error.getName(errorCode)
193:                                + ")");
194:                        fail(this CommandName + " returns unexpected ERROR = "
195:                                + errorCode + "("
196:                                + JDWPConstants.Error.getName(errorCode) + ")");
197:                    } else {
198:                        logWriter
199:                                .println("=> CHECK PASSED: Expected error (INVALID_OBJECT) is returned");
200:                    }
201:                } else {
202:                    logWriter
203:                            .println("\n## FAILURE: "
204:                                    + this CommandName
205:                                    + " does NOT return expected error - INVALID_OBJECT");
206:                    fail(this CommandName
207:                            + " does NOT return expected error - INVALID_OBJECT");
208:                }
209:
210:                logWriter.println("\n=> CHECK: send " + this CommandName
211:                        + " for unknown ID: INVALID_OBJECT is expected...");
212:
213:                long unknownID = debuggeeRefTypeID + 10;
214:                if (unknownID == checkedFieldID) {
215:                    unknownID = unknownID + 100;
216:                }
217:                logWriter.println("=> unknown ID = " + unknownID);
218:                checkedCommand = new CommandPacket(
219:                        JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
220:                        JDWPCommands.ReferenceTypeCommandSet.SignatureCommand);
221:                checkedCommand.setNextValueAsReferenceTypeID(unknownID);
222:
223:                checkedReply = debuggeeWrapper.vmMirror
224:                        .performCommand(checkedCommand);
225:                checkedCommand = null;
226:
227:                errorCode = checkedReply.getErrorCode();
228:                if (errorCode != JDWPConstants.Error.NONE) {
229:                    if (errorCode != JDWPConstants.Error.INVALID_OBJECT) {
230:                        logWriter.println("## CHECK: FAILURE: "
231:                                + this CommandName
232:                                + " returns unexpected ERROR = " + errorCode
233:                                + "(" + JDWPConstants.Error.getName(errorCode)
234:                                + ")");
235:                        fail(this CommandName + " returns unexpected ERROR = "
236:                                + errorCode + "("
237:                                + JDWPConstants.Error.getName(errorCode) + ")");
238:                    } else {
239:                        logWriter
240:                                .println("=> CHECK PASSED: Expected error (INVALID_OBJECT) is returned");
241:                    }
242:                } else {
243:                    logWriter
244:                            .println("\n## FAILURE: "
245:                                    + this CommandName
246:                                    + " does NOT return expected error - INVALID_OBJECT");
247:                    fail(this CommandName
248:                            + " does NOT return expected error - INVALID_OBJECT");
249:                }
250:
251:                finalSyncMessage = null;
252:                synchronizer
253:                        .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
254:                logWriter.println("\n==> " + this TestName + " for "
255:                        + this CommandName + ": FINISH");
256:            }
257:
258:            public static void main(String[] args) {
259:                junit.textui.TestRunner.run(Signature002Test.class);
260:            }
261:        }
w__ww.__j_a_va__2s__.c_om | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.