Source Code Cross Referenced for FieldModification002Test.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 Ruslan A. Scherbakov
021:         * @version $Revision: 1.4 $
022:         */
023:
024:        /**
025:         * Created on 14.06.2006
026:         */package org.apache.harmony.jpda.tests.jdwp.Events;
027:
028:        import org.apache.harmony.jpda.tests.framework.jdwp.EventPacket;
029:        import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
030:        import org.apache.harmony.jpda.tests.framework.jdwp.ParsedEvent;
031:        import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
032:        import org.apache.harmony.jpda.tests.framework.jdwp.TaggedObject;
033:        import org.apache.harmony.jpda.tests.framework.jdwp.Value;
034:        import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
035:
036:        /**
037:         * JDWP Unit test for FIELD_MODIFICATION event.
038:         */
039:        public class FieldModification002Test extends JDWPEventTestCase {
040:
041:            public static void main(String[] args) {
042:                junit.textui.TestRunner.run(FieldModification002Test.class);
043:            }
044:
045:            protected String getDebuggeeClassName() {
046:                return FieldModification002Debuggee.class.getName();
047:            }
048:
049:            /**
050:             * This testcase is for FIELD_MODIFICATION event.
051:             * <BR>It FieldModification002Debuggee that modifies the value of its own fields 
052:             * and verifies that requested FIELD_MODIFICATION events occur and
053:             * correct type tag is returned for each event.
054:             */
055:            public void testFieldModifyEvent() {
056:
057:                logWriter.println("FieldModification002Test started");
058:
059:                //check capability, relevant for this test
060:                logWriter
061:                        .println("=> Check capability: canWatchFieldModification");
062:                debuggeeWrapper.vmMirror.capabilities();
063:                boolean isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canWatchFieldModification;
064:                if (!isCapability) {
065:                    logWriter
066:                            .println("##WARNING: this VM doesn't possess capability: canWatchFieldModification");
067:                    return;
068:                }
069:
070:                synchronizer
071:                        .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
072:                String classSignature = "L"
073:                        + getDebuggeeClassName().replace('.', '/') + ";";
074:
075:                hookFieldModification(classSignature, "testBoolField",
076:                        JDWPConstants.Tag.BOOLEAN_TAG);
077:                hookFieldModification(classSignature, "testByteField",
078:                        JDWPConstants.Tag.BYTE_TAG);
079:                hookFieldModification(classSignature, "testCharField",
080:                        JDWPConstants.Tag.CHAR_TAG);
081:                hookFieldModification(classSignature, "testShortField",
082:                        JDWPConstants.Tag.SHORT_TAG);
083:                hookFieldModification(classSignature, "testIntField",
084:                        JDWPConstants.Tag.INT_TAG);
085:                hookFieldModification(classSignature, "testLongField",
086:                        JDWPConstants.Tag.LONG_TAG);
087:                hookFieldModification(classSignature, "testFloatField",
088:                        JDWPConstants.Tag.FLOAT_TAG);
089:                hookFieldModification(classSignature, "testDoubleField",
090:                        JDWPConstants.Tag.DOUBLE_TAG);
091:                hookFieldModification(classSignature, "testObjectField",
092:                        JDWPConstants.Tag.OBJECT_TAG);
093:                hookFieldModification(classSignature, "testThreadField",
094:                        JDWPConstants.Tag.THREAD_TAG);
095:                hookFieldModification(classSignature, "testThreadGroupField",
096:                        JDWPConstants.Tag.THREAD_GROUP_TAG);
097:                hookFieldModification(classSignature, "testClassField",
098:                        JDWPConstants.Tag.CLASS_OBJECT_TAG);
099:                hookFieldModification(classSignature, "testClassLoaderField",
100:                        JDWPConstants.Tag.CLASS_LOADER_TAG);
101:                hookFieldModification(classSignature, "testStringField",
102:                        JDWPConstants.Tag.STRING_TAG);
103:                hookFieldModification(classSignature, "testIntArrayField",
104:                        JDWPConstants.Tag.ARRAY_TAG);
105:                hookFieldModification(classSignature, "testStringArrayField",
106:                        JDWPConstants.Tag.ARRAY_TAG);
107:                hookFieldModification(classSignature, "testObjectArrayField",
108:                        JDWPConstants.Tag.ARRAY_TAG);
109:
110:                logWriter.println("FieldModification002Test done");
111:            }
112:
113:            /**
114:             * Sets FIELD_MODIFICATION breakpoint,
115:             * synchrinizes debuggee,
116:             * expects field notification event,
117:             * verifies new value assigned to the field
118:             * and clears set breakpoint.
119:             * 
120:             * @param classSignature signature of class containing the given field
121:             * @param fieldName the name of field to break on modification
122:             * @param expectedTag expected type tag of new values assigned to the field
123:             */
124:            public void hookFieldModification(String classSignature,
125:                    String fieldName, byte expectedTag) {
126:
127:                // set breakpoint
128:                logWriter.println("Set hook for: " + fieldName);
129:                ReplyPacket reply = debuggeeWrapper.vmMirror
130:                        .setFieldModification(classSignature,
131:                                JDWPConstants.TypeTag.CLASS, fieldName);
132:                checkReplyPacket(reply, "Set FIELD_MODIFICATION event");
133:                int requestID = reply.getNextValueAsInt();
134:                assertAllDataRead(reply);
135:
136:                synchronizer
137:                        .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
138:
139:                EventPacket event = debuggeeWrapper.vmMirror.receiveEvent();
140:                ParsedEvent[] parsedEvents = ParsedEvent
141:                        .parseEventPacket(event);
142:
143:                // assert that event is the expected one
144:                assertEquals("Invalid number of events,", 1,
145:                        parsedEvents.length);
146:                assertEquals(
147:                        "Invalid event kind,",
148:                        JDWPConstants.EventKind.FIELD_MODIFICATION,
149:                        parsedEvents[0].getEventKind(),
150:                        JDWPConstants.EventKind
151:                                .getName(JDWPConstants.EventKind.FIELD_MODIFICATION),
152:                        JDWPConstants.EventKind.getName(parsedEvents[0]
153:                                .getEventKind()));
154:
155:                Value value = ((ParsedEvent.Event_FIELD_MODIFICATION) parsedEvents[0])
156:                        .getValueToBe();
157:                byte tag = value.getTag();
158:                assertEquals("Invalid value tag,", expectedTag, tag,
159:                        JDWPConstants.Tag.getName(expectedTag),
160:                        JDWPConstants.Tag.getName(tag));
161:
162:                TaggedObject modifiedField = ((ParsedEvent.Event_FIELD_MODIFICATION) parsedEvents[0])
163:                        .getObject();
164:
165:                // assert that exception class is the expected one
166:                long typeID = getObjectReferenceType(modifiedField.objectID);
167:                String returnedExceptionSignature = getClassSignature(typeID);
168:                assertString("Invalid class signature,", classSignature,
169:                        returnedExceptionSignature);
170:
171:                logWriter.println("Field: " + fieldName
172:                        + ", tag of new value: " + value + ", tag: "
173:                        + (char) tag + " - OK");
174:
175:                // clear breakpoint
176:                clearEvent(JDWPConstants.EventKind.FIELD_MODIFICATION,
177:                        requestID, false);
178:
179:                // and resume target VM
180:                resumeDebuggee();
181:            }
182:        }
w___w___w_._j_a___v___a__2_s_.___c__om | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.