Source Code Cross Referenced for SetValues002Test.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 Anatoly F. Bondarenko
021:         * @version $Revision: 1.6 $
022:         */
023:
024:        /**
025:         * Created on 05.07.2005
026:         */package org.apache.harmony.jpda.tests.jdwp.ClassType;
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 ClassType.SetValues command with incorrect types of values.
038:         */
039:        public class SetValues002Test extends JDWPSyncTestCase {
040:
041:            static final int testStatusPassed = 0;
042:            static final int testStatusFailed = -1;
043:            static final String this CommandName = "ClassType::SetValues command";
044:            static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/ClassType/SetValues002Debuggee;";
045:
046:            protected String getDebuggeeClassName() {
047:                return "org.apache.harmony.jpda.tests.jdwp.ClassType.SetValues002Debuggee";
048:            }
049:
050:            /**
051:             * The test checks ClassType.SetValues command for
052:             * field of Debuggee class with value which has other 
053:             * referenceType than field to set.
054:             * The test expects the field should not be set.
055:             */
056:            public void testSetValues002() {
057:                String this TestName = "testSetValues002";
058:                logWriter.println("==> " + this TestName + " for "
059:                        + this CommandName + ": START...");
060:                synchronizer
061:                        .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
062:
063:                CommandPacket classesBySignatureCommand = new CommandPacket(
064:                        JDWPCommands.VirtualMachineCommandSet.CommandSetID,
065:                        JDWPCommands.VirtualMachineCommandSet.ClassesBySignatureCommand);
066:                classesBySignatureCommand
067:                        .setNextValueAsString(debuggeeSignature);
068:                ReplyPacket classesBySignatureReply = debuggeeWrapper.vmMirror
069:                        .performCommand(classesBySignatureCommand);
070:                classesBySignatureCommand = null;
071:                checkReplyPacket(classesBySignatureReply,
072:                        "VirtualMachine::ClassesBySignature command");
073:
074:                classesBySignatureReply.getNextValueAsInt();
075:                // Number of returned reference types - is NOt used here
076:
077:                classesBySignatureReply.getNextValueAsByte();
078:                // refTypeTag of class - is NOt used here
079:
080:                long refTypeID = classesBySignatureReply
081:                        .getNextValueAsReferenceTypeID();
082:                classesBySignatureReply = null;
083:
084:                logWriter.println("=> Debuggee class = "
085:                        + getDebuggeeClassName());
086:                logWriter.println("=> referenceTypeID for Debuggee class = "
087:                        + refTypeID);
088:
089:                String checkedFieldNames[] = { "SetValues002DebuggeeObject",
090:                        "objectField", };
091:                long checkedFieldIDs[] = checkFields(refTypeID,
092:                        checkedFieldNames);
093:                int checkedFieldsNumber = checkedFieldNames.length;
094:
095:                logWriter
096:                        .println("=> Send ReferenceType::GetValues command and get ObjectID for value to set...");
097:
098:                CommandPacket getValuesCommand = new CommandPacket(
099:                        JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
100:                        JDWPCommands.ReferenceTypeCommandSet.GetValuesCommand);
101:                getValuesCommand.setNextValueAsReferenceTypeID(refTypeID);
102:                getValuesCommand.setNextValueAsInt(1);
103:                getValuesCommand.setNextValueAsFieldID(checkedFieldIDs[0]);
104:                ReplyPacket getValuesReply = debuggeeWrapper.vmMirror
105:                        .performCommand(getValuesCommand);
106:                getValuesCommand = null;
107:                checkReplyPacket(getValuesReply,
108:                        "ReferenceType::GetValues command");
109:
110:                int returnedValuesNumber = getValuesReply.getNextValueAsInt();
111:                logWriter.println("=> Returned values number = "
112:                        + returnedValuesNumber);
113:                assertEquals(
114:                        "ReferenceType::GetValues returned invalid values number,",
115:                        1, returnedValuesNumber);
116:
117:                Value objectFieldValueToSet = getValuesReply
118:                        .getNextValueAsValue();
119:                byte objectFieldValueToSetTag = objectFieldValueToSet.getTag();
120:                logWriter
121:                        .println("=> Returned field value tag for checked object= "
122:                                + objectFieldValueToSetTag
123:                                + "("
124:                                + JDWPConstants.Tag
125:                                        .getName(objectFieldValueToSetTag)
126:                                + ")");
127:                assertEquals(
128:                        "ReferenceType::GetValues returned invalid value tag,",
129:                        JDWPConstants.Tag.OBJECT_TAG,
130:                        objectFieldValueToSetTag,
131:                        JDWPConstants.Tag.getName(JDWPConstants.Tag.OBJECT_TAG),
132:                        JDWPConstants.Tag.getName(objectFieldValueToSetTag));
133:
134:                long objectFieldID = objectFieldValueToSet.getLongValue();
135:                logWriter.println("=> Returned ObjectID = " + objectFieldID);
136:                logWriter
137:                        .println("=> CHECK: send "
138:                                + this CommandName
139:                                + " for Debuggee class with value which has other referenceType than field to set...");
140:
141:                CommandPacket checkedCommand = new CommandPacket(
142:                        JDWPCommands.ClassTypeCommandSet.CommandSetID,
143:                        JDWPCommands.ClassTypeCommandSet.SetValuesCommand);
144:                checkedCommand.setNextValueAsClassID(refTypeID);
145:                checkedCommand.setNextValueAsInt(checkedFieldsNumber - 1);
146:                int fieldIndex = 1;
147:                for (; fieldIndex < checkedFieldsNumber; fieldIndex++) {
148:                    checkedCommand
149:                            .setNextValueAsFieldID(checkedFieldIDs[fieldIndex]);
150:                    switch (fieldIndex) {
151:                    case 1: // objectField
152:                        checkedCommand.setNextValueAsObjectID(objectFieldID);
153:                        break;
154:                    }
155:                }
156:                ReplyPacket checkedReply = debuggeeWrapper.vmMirror
157:                        .performCommand(checkedCommand);
158:                checkedCommand = null;
159:
160:                short errorCode = checkedReply.getErrorCode();
161:                if (errorCode == JDWPConstants.Error.NONE) {
162:                    logWriter.println("=> " + this CommandName
163:                            + " run without any ERROR!");
164:                } else {
165:                    logWriter.println("=> " + this CommandName
166:                            + " returns ERROR = " + errorCode + "("
167:                            + JDWPConstants.Error.getName(errorCode) + ")");
168:                }
169:
170:                logWriter
171:                        .println("=> Wait for Debuggee's status about check for set field...");
172:                synchronizer
173:                        .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
174:                boolean debuggeeStatus = synchronizer.receiveMessage("PASSED");
175:                if (!debuggeeStatus) {
176:                    logWriter.println("## " + this TestName
177:                            + ": Debuggee returned status FAILED");
178:                    fail("Debuggee returned status FAILED");
179:                } else {
180:                    logWriter.println("=> " + this TestName
181:                            + ": Debuggee returned status PASSED");
182:                }
183:
184:                logWriter.println("==> " + this TestName + " for "
185:                        + this CommandName + ": OK");
186:            }
187:
188:            public static void main(String[] args) {
189:                junit.textui.TestRunner.run(SetValues002Test.class);
190:            }
191:        }
ww___w__.j___a_v_a2__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.