Source Code Cross Referenced for CombinedEventsTestCase.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 Anatoly F. Bondarenko
021:         * @version $Revision: 1.1 $
022:         */
023:
024:        /**
025:         * Created on 06.10.2006
026:         */package org.apache.harmony.jpda.tests.jdwp.Events;
027:
028:        import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
029:        import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
030:        import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
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.Location;
034:        import org.apache.harmony.jpda.tests.framework.jdwp.ParsedEvent;
035:
036:        /**
037:         * CombinedEventsTestCase class provides auxiliary methods 
038:         * for JDWP unit tests for Co-located events.
039:         */
040:        public abstract class CombinedEventsTestCase extends JDWPSyncTestCase {
041:
042:            static Object waitTimeObject = new Object();
043:
044:            static protected void waitMlsecsTime(long mlsecsTime) {
045:                synchronized (waitTimeObject) {
046:                    try {
047:                        waitTimeObject.wait(mlsecsTime);
048:                    } catch (Throwable throwable) {
049:                        // ignore
050:                    }
051:                }
052:            }
053:
054:            void printMethodLineTable(long classID,
055:                    String className /* may be null */, String methodName) {
056:                long methodID = debuggeeWrapper.vmMirror.getMethodID(classID,
057:                        methodName);
058:                if (methodID == -1) {
059:                    logWriter
060:                            .println("## printMethodLineTable(): Can NOT get methodID for classID = "
061:                                    + classID + "; Method name = " + methodName);
062:                    return;
063:                }
064:
065:                CommandPacket packet = new CommandPacket(
066:                        JDWPCommands.MethodCommandSet.CommandSetID,
067:                        JDWPCommands.MethodCommandSet.LineTableCommand);
068:                packet.setNextValueAsClassID(classID);
069:                packet.setNextValueAsMethodID(methodID);
070:                ReplyPacket lineTableReply = debuggeeWrapper.vmMirror
071:                        .performCommand(packet);
072:                if (!checkReplyPacketWithoutFail(lineTableReply,
073:                        "printMethodLineTable(): Method.LineTable command")) {
074:                    return;
075:                }
076:                if (className == null) {
077:                    logWriter.println("=== Line Table for method: "
078:                            + methodName + " ===");
079:                } else {
080:                    logWriter.println("=== Line Table for method: "
081:                            + methodName + " of class: " + className + " ===");
082:                }
083:                long methodStartCodeIndex = lineTableReply.getNextValueAsLong();
084:                logWriter.println("==> Method Start Code Index = "
085:                        + methodStartCodeIndex);
086:                long methodEndCodeIndex = lineTableReply.getNextValueAsLong();
087:                logWriter.println("==> Method End Code Index = "
088:                        + methodEndCodeIndex);
089:
090:                int linesNumber = lineTableReply.getNextValueAsInt();
091:                logWriter.println("==> Number of lines = " + linesNumber);
092:                for (int i = 0; i < linesNumber; i++) {
093:                    long lineCodeIndex = lineTableReply.getNextValueAsLong();
094:                    int lineNumber = lineTableReply.getNextValueAsInt();
095:                    logWriter.println("====> Line Number " + lineNumber
096:                            + " : Initial code index = " + lineCodeIndex);
097:                }
098:                logWriter.println("=== End of Line Table " + methodName
099:                        + " ===");
100:            }
101:
102:            long getMethodStartCodeIndex(long classID, String methodName) {
103:                long methodID = debuggeeWrapper.vmMirror.getMethodID(classID,
104:                        methodName);
105:                if (methodID == -1) {
106:                    logWriter
107:                            .println("## getMethodStartCodeIndex(): Can NOT get methodID for classID = "
108:                                    + classID + "; Method name = " + methodName);
109:                    return -1;
110:                }
111:
112:                CommandPacket packet = new CommandPacket(
113:                        JDWPCommands.MethodCommandSet.CommandSetID,
114:                        JDWPCommands.MethodCommandSet.LineTableCommand);
115:                packet.setNextValueAsClassID(classID);
116:                packet.setNextValueAsMethodID(methodID);
117:                ReplyPacket lineTableReply = debuggeeWrapper.vmMirror
118:                        .performCommand(packet);
119:                if (!checkReplyPacketWithoutFail(lineTableReply,
120:                        "getMethodStartCodeIndex(): Method.LineTable command")) {
121:                    return -1;
122:                }
123:                long methodStartCodeIndex = lineTableReply.getNextValueAsLong();
124:                return methodStartCodeIndex;
125:            }
126:
127:            @SuppressWarnings("unused")
128:            long getMethodEndCodeIndex(long classID, String methodName) {
129:                long methodID = debuggeeWrapper.vmMirror.getMethodID(classID,
130:                        methodName);
131:                if (methodID == -1) {
132:                    logWriter
133:                            .println("## getMethodEndCodeIndex(): Can NOT get methodID for classID = "
134:                                    + classID + "; Method name = " + methodName);
135:                    return -1;
136:                }
137:
138:                CommandPacket packet = new CommandPacket(
139:                        JDWPCommands.MethodCommandSet.CommandSetID,
140:                        JDWPCommands.MethodCommandSet.LineTableCommand);
141:                packet.setNextValueAsClassID(classID);
142:                packet.setNextValueAsMethodID(methodID);
143:                ReplyPacket lineTableReply = debuggeeWrapper.vmMirror
144:                        .performCommand(packet);
145:                if (!checkReplyPacketWithoutFail(lineTableReply,
146:                        "getMethodEndCodeIndex(): Method.LineTable command")) {
147:                    return -1;
148:                }
149:                long methodStartCodeIndex = lineTableReply.getNextValueAsLong();
150:                long methodEndCodeIndex = lineTableReply.getNextValueAsLong();
151:                return methodEndCodeIndex;
152:            }
153:
154:            protected Location getMethodEntryLocation(long classID,
155:                    String methodName) {
156:                long methodID = debuggeeWrapper.vmMirror.getMethodID(classID,
157:                        methodName);
158:                if (methodID == -1) {
159:                    logWriter
160:                            .println("## getClassMethodEntryLocation(): Can NOT get methodID for classID = "
161:                                    + classID + "; Method name = " + methodName);
162:                    return null;
163:                }
164:
165:                CommandPacket packet = new CommandPacket(
166:                        JDWPCommands.MethodCommandSet.CommandSetID,
167:                        JDWPCommands.MethodCommandSet.LineTableCommand);
168:                packet.setNextValueAsClassID(classID);
169:                packet.setNextValueAsMethodID(methodID);
170:                ReplyPacket reply = debuggeeWrapper.vmMirror
171:                        .performCommand(packet);
172:                if (!checkReplyPacketWithoutFail(reply,
173:                        "getMethodEntryLocation(): Method.LineTable command")) {
174:                    return null;
175:                }
176:                long methodStartCodeIndex = reply.getNextValueAsLong();
177:                Location location = new Location();
178:                location.tag = JDWPConstants.TypeTag.CLASS;
179:                location.classID = classID;
180:                location.methodID = methodID;
181:                location.index = methodStartCodeIndex;
182:                return location;
183:            }
184:
185:            @SuppressWarnings("unused")
186:            protected Location getMethodEndLocation(long classID,
187:                    String methodName) {
188:                long methodID = debuggeeWrapper.vmMirror.getMethodID(classID,
189:                        methodName);
190:                if (methodID == -1) {
191:                    logWriter
192:                            .println("## getClassMethodEndLocation(): Can NOT get methodID for classID = "
193:                                    + classID + "; Method name = " + methodName);
194:                    return null;
195:                }
196:
197:                CommandPacket packet = new CommandPacket(
198:                        JDWPCommands.MethodCommandSet.CommandSetID,
199:                        JDWPCommands.MethodCommandSet.LineTableCommand);
200:                packet.setNextValueAsClassID(classID);
201:                packet.setNextValueAsMethodID(methodID);
202:                ReplyPacket reply = debuggeeWrapper.vmMirror
203:                        .performCommand(packet);
204:                if (!checkReplyPacketWithoutFail(reply,
205:                        "getMethodEndLocation(): Method.LineTable command")) {
206:                    return null;
207:                }
208:                long methodStartCodeIndex = reply.getNextValueAsLong();
209:                long methodEndCodeIndex = reply.getNextValueAsLong();
210:                Location location = new Location();
211:                location.tag = JDWPConstants.TypeTag.CLASS;
212:                location.classID = classID;
213:                location.methodID = methodID;
214:                location.index = methodEndCodeIndex;
215:                return location;
216:            }
217:
218:            protected boolean checkEventsLocation(ParsedEvent[] parsedEvents,
219:                    Location expectedLocation) {
220:                boolean success = true;
221:                for (int i = 0; i < parsedEvents.length; i++) {
222:                    byte eventKind = parsedEvents[i].getEventKind();
223:                    long eventThreadID = 0;
224:                    Location eventLocation = null;
225:                    switch (eventKind) {
226:                    case JDWPConstants.EventKind.METHOD_ENTRY:
227:                        eventLocation = ((ParsedEvent.Event_METHOD_ENTRY) parsedEvents[i])
228:                                .getLocation();
229:                        eventThreadID = ((ParsedEvent.EventThread) parsedEvents[i])
230:                                .getThreadID();
231:                        break;
232:                    case JDWPConstants.EventKind.SINGLE_STEP:
233:                        eventLocation = ((ParsedEvent.Event_SINGLE_STEP) parsedEvents[i])
234:                                .getLocation();
235:                        eventThreadID = ((ParsedEvent.EventThread) parsedEvents[i])
236:                                .getThreadID();
237:                        break;
238:                    case JDWPConstants.EventKind.BREAKPOINT:
239:                        eventLocation = ((ParsedEvent.Event_BREAKPOINT) parsedEvents[i])
240:                                .getLocation();
241:                        eventThreadID = ((ParsedEvent.EventThread) parsedEvents[i])
242:                                .getThreadID();
243:                        break;
244:                    case JDWPConstants.EventKind.METHOD_EXIT:
245:                        eventLocation = ((ParsedEvent.Event_METHOD_EXIT) parsedEvents[i])
246:                                .getLocation();
247:                        eventThreadID = ((ParsedEvent.EventThread) parsedEvents[i])
248:                                .getThreadID();
249:                        break;
250:                    default:
251:                        logWriter.println("");
252:                        logWriter.println("=> Chcek location for event "
253:                                + ": Event kind = " + eventKind + "("
254:                                + JDWPConstants.EventKind.getName(eventKind)
255:                                + ")");
256:                        logWriter
257:                                .println("=> WARNING: This event is not suitable to check location!");
258:                        continue;
259:                    }
260:                    logWriter.println("");
261:                    logWriter.println("=> Chcek location for event "
262:                            + ": Event kind = " + eventKind + "("
263:                            + JDWPConstants.EventKind.getName(eventKind)
264:                            + "); eventThreadID = " + eventThreadID);
265:                    long eventClassID = eventLocation.classID;
266:                    logWriter.println("=> ClassID in event = " + eventClassID);
267:                    if (expectedLocation != null) {
268:                        if (expectedLocation.classID != eventClassID) {
269:                            logWriter
270:                                    .println("## FAILURE: Unexpected ClassID in event!");
271:                            logWriter
272:                                    .println("##          Expected ClassID  = "
273:                                            + expectedLocation.classID);
274:                            success = false;
275:                        } else {
276:                            logWriter.println("=> OK - it is expected ClassID");
277:                        }
278:                    }
279:                    long eventMethodID = eventLocation.methodID;
280:                    logWriter
281:                            .println("=> MethodID in event = " + eventMethodID);
282:                    if (expectedLocation != null) {
283:                        if (expectedLocation.methodID != eventMethodID) {
284:                            logWriter
285:                                    .println("## FAILURE: Unexpected MethodID in event!");
286:                            logWriter
287:                                    .println("##          Expected MethodID = "
288:                                            + expectedLocation.methodID);
289:                            success = false;
290:                        } else {
291:                            logWriter
292:                                    .println("=> OK - it is expected MethodID");
293:                        }
294:                    }
295:                    long eventCodeIndex = eventLocation.index;
296:                    logWriter.println("=> CodeIndex in event = "
297:                            + eventCodeIndex);
298:                    if (expectedLocation != null) {
299:                        if (expectedLocation.index != eventCodeIndex) {
300:                            logWriter
301:                                    .println("## FAILURE: Unexpected CodeIndex in event!");
302:                            logWriter
303:                                    .println("##          Expected CodeIndex = "
304:                                            + expectedLocation.index);
305:                            success = false;
306:                        } else {
307:                            logWriter
308:                                    .println("=> OK - it is expected CodeIndex)");
309:                        }
310:                    }
311:                }
312:                logWriter.println("");
313:                if (expectedLocation != null) {
314:                    if (!success) {
315:                        String failureMessage = "## FAILURE: Unexpected events' locations are found out!";
316:                        logWriter.println(failureMessage);
317:                    } else {
318:                        logWriter
319:                                .println("=> OK - all checked events have expected location!");
320:                    }
321:                }
322:                return success;
323:            }
324:
325:        }
w__w___w.__j__a_v___a2s___.__c_o_m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.