Source Code Cross Referenced for ResumeTest.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » jpda » tests » jdwp » ThreadReference » 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.ThreadReference 
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 Vitaly A. Provodin, Anatoly F. Bondarenko
021:         * @version $Revision: 1.7 $
022:         */
023:
024:        /**
025:         * Created on 15.02.2005
026:         */package org.apache.harmony.jpda.tests.jdwp.ThreadReference;
027:
028:        import org.apache.harmony.jpda.tests.framework.jdwp.exceptions.*;
029:        import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
030:        import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
031:        import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
032:        import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
033:        import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
034:
035:        /**
036:         * JDWP Unit test for ThreadReference.Resume command.
037:         */
038:        public class ResumeTest extends JDWPSyncTestCase {
039:
040:            static final int testStatusPassed = 0;
041:            static final int testStatusFailed = -1;
042:            static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/ThreadReference/ResumeDebuggee;";
043:
044:            protected String getDebuggeeClassName() {
045:                return "org.apache.harmony.jpda.tests.jdwp.ThreadReference.ResumeDebuggee";
046:            }
047:
048:            /**
049:             * This testcase exercises ThreadReference.Resume command.
050:             * <BR>At first the test starts ResumeDebuggee which starts and runs some tested threads. 
051:             * <BR> Then the tests checks that for every tested thread the ThreadReference.Resume
052:             * command acts according to spec:
053:             * <BR>&nbsp;&nbsp; - command does not cause any error if thread is not suspended;
054:             * <BR>&nbsp;&nbsp; - command does not resume thread actually if number of suspendings
055:             *   is greater than number of resumings;
056:             * <BR>&nbsp;&nbsp; - command resumes thread actually if number of suspendings
057:             *   is equal to number of resumings;
058:             */
059:            public void testResume001() {
060:                logWriter.println("==> testResume001: START...");
061:                String debuggeeMessage = synchronizer.receiveMessage();
062:                int testedThreadsNumber = 0;
063:                try {
064:                    testedThreadsNumber = Integer.valueOf(debuggeeMessage)
065:                            .intValue();
066:                } catch (NumberFormatException exception) {
067:                    logWriter
068:                            .println("## FAILURE: Exception while getting number of started threads from debuggee = "
069:                                    + exception);
070:                    setStaticIntField(debuggeeSignature,
071:                            ResumeDebuggee.TO_FINISH_DEBUGGEE_FIELD_NAME, 99);
072:                    printErrorAndFail("\n## Can NOT get number of started threads from debuggee! ");
073:                }
074:                testedThreadsNumber++; // to add debuggee main thread
075:                logWriter
076:                        .println("==>  Number of threads in debuggee to test = "
077:                                + testedThreadsNumber);
078:                String[] testedThreadsNames = new String[testedThreadsNumber];
079:                long[] testedThreadsIDs = new long[testedThreadsNumber];
080:                String debuggeeMainThreadName = synchronizer.receiveMessage();
081:                for (int i = 0; i < testedThreadsNumber; i++) {
082:                    if (i < (testedThreadsNumber - 1)) {
083:                        testedThreadsNames[i] = ResumeDebuggee.THREAD_NAME_PATTERN
084:                                + i;
085:                    } else {
086:                        testedThreadsNames[i] = debuggeeMainThreadName;
087:                    }
088:                    testedThreadsIDs[i] = 0;
089:                }
090:
091:                // getting ID of the tested thread
092:                ReplyPacket allThreadIDReply = null;
093:                try {
094:                    allThreadIDReply = debuggeeWrapper.vmMirror
095:                            .getAllThreadID();
096:                } catch (ReplyErrorCodeException exception) {
097:                    logWriter
098:                            .println("## FAILURE: Exception in vmMirror.getAllThreadID() = "
099:                                    + exception);
100:                    setStaticIntField(debuggeeSignature,
101:                            ResumeDebuggee.TO_FINISH_DEBUGGEE_FIELD_NAME, 99);
102:                    printErrorAndFail("\n## Can NOT get all ThreadID in debuggee! ");
103:                }
104:                int threads = allThreadIDReply.getNextValueAsInt();
105:                logWriter.println("==>  Number of all threads in debuggee = "
106:                        + threads);
107:                for (int i = 0; i < threads; i++) {
108:                    long threadID = allThreadIDReply.getNextValueAsThreadID();
109:                    String threadName = null;
110:                    try {
111:                        threadName = debuggeeWrapper.vmMirror
112:                                .getThreadName(threadID);
113:                    } catch (ReplyErrorCodeException exception) {
114:                        logWriter
115:                                .println("==> WARNING: Can NOT get thread name for threadID = "
116:                                        + threadID);
117:                        continue;
118:                    }
119:                    int k = 0;
120:                    for (; k < testedThreadsNumber; k++) {
121:                        if (threadName.equals(testedThreadsNames[k])) {
122:                            testedThreadsIDs[k] = threadID;
123:                            break;
124:                        }
125:                    }
126:                }
127:
128:                boolean testedThreadNotFound = false;
129:                for (int i = 0; i < testedThreadsNumber; i++) {
130:                    if (testedThreadsIDs[i] == 0) {
131:                        logWriter
132:                                .println("## FAILURE: Tested thread is not found out among debuggee threads!");
133:                        logWriter.println("##          Thread name = "
134:                                + testedThreadsNames[i]);
135:                        testedThreadNotFound = true;
136:                    }
137:                }
138:                if (testedThreadNotFound) {
139:                    setStaticIntField(debuggeeSignature,
140:                            ResumeDebuggee.TO_FINISH_DEBUGGEE_FIELD_NAME, 99);
141:                    printErrorAndFail("\n## Some of tested threads are not found!");
142:                }
143:
144:                CommandPacket packet = null;
145:                ReplyPacket reply = null;
146:                String errorMessage = "";
147:
148:                boolean resumeCommandFailed = false;
149:                boolean statusCommandFailed = false;
150:                boolean suspendStatusFailed = false;
151:                boolean suspendCommandFailed = false;
152:
153:                logWriter
154:                        .println("\n==> Check that ThreadReference.Resume command does not cause any error if thread is not suspended...");
155:
156:                for (int i = 0; i < testedThreadsNumber; i++) {
157:                    logWriter.println("\n==> Check for Thread: threadID = "
158:                            + testedThreadsIDs[i] + "; threadName = "
159:                            + testedThreadsNames[i]);
160:                    logWriter
161:                            .println("==> Send ThreadReference.Resume command...");
162:                    packet = new CommandPacket(
163:                            JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
164:                            JDWPCommands.ThreadReferenceCommandSet.ResumeCommand);
165:                    packet.setNextValueAsThreadID(testedThreadsIDs[i]);
166:                    reply = debuggeeWrapper.vmMirror.performCommand(packet);
167:                    if (!checkReplyPacketWithoutFail(reply,
168:                            "ThreadReference.Resume command")) {
169:                        resumeCommandFailed = true;
170:                    } else {
171:                        logWriter
172:                                .println("==> OK - ThreadReference.Resume command without any error!");
173:                    }
174:                }
175:
176:                if (resumeCommandFailed) {
177:                    setStaticIntField(debuggeeSignature,
178:                            ResumeDebuggee.TO_FINISH_DEBUGGEE_FIELD_NAME, 99);
179:                    printErrorAndFail("\n## Error found out while ThreadReference.Resume command performing!");
180:                }
181:
182:                logWriter
183:                        .println("\n==> Check that ThreadReference.Resume command resumes threads after VirtualMachine.Suspend command...");
184:
185:                logWriter
186:                        .println("\n==> Send VirtualMachine.Suspend command...");
187:                packet = new CommandPacket(
188:                        JDWPCommands.VirtualMachineCommandSet.CommandSetID,
189:                        JDWPCommands.VirtualMachineCommandSet.SuspendCommand);
190:                reply = debuggeeWrapper.vmMirror.performCommand(packet);
191:                int errorCode = reply.getErrorCode();
192:                if (errorCode != JDWPConstants.Error.NONE) {
193:                    setStaticIntField(debuggeeSignature,
194:                            ResumeDebuggee.TO_FINISH_DEBUGGEE_FIELD_NAME, 99);
195:                    logWriter
196:                            .println("## FAILURE: VirtualMachine.Suspend command returns error = "
197:                                    + errorCode
198:                                    + "("
199:                                    + JDWPConstants.Error.getName(errorCode)
200:                                    + ")");
201:                    printErrorAndFail("## VirtualMachine.Suspend command FAILED!");
202:                } else {
203:                    logWriter
204:                            .println("==> VirtualMachine.Suspend command is OK!");
205:                }
206:
207:                for (int i = 0; i < testedThreadsNumber; i++) {
208:                    logWriter.println("\n==> Check for Thread: threadID = "
209:                            + testedThreadsIDs[i] + "; threadName = "
210:                            + testedThreadsNames[i]);
211:
212:                    logWriter
213:                            .println("==> Send ThreadReference.Status command...");
214:                    packet = new CommandPacket(
215:                            JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
216:                            JDWPCommands.ThreadReferenceCommandSet.StatusCommand);
217:                    packet.setNextValueAsReferenceTypeID(testedThreadsIDs[i]);
218:                    reply = debuggeeWrapper.vmMirror.performCommand(packet);
219:                    if (!checkReplyPacketWithoutFail(reply,
220:                            "ThreadReference.Status command")) {
221:                        statusCommandFailed = true;
222:                        continue;
223:                    }
224:
225:                    int threadStatus = reply.getNextValueAsInt();
226:                    int suspendStatus = reply.getNextValueAsInt();
227:
228:                    logWriter.println("==> threadStatus = " + threadStatus
229:                            + "("
230:                            + JDWPConstants.ThreadStatus.getName(threadStatus)
231:                            + ")");
232:                    logWriter.println("==> suspendStatus = "
233:                            + suspendStatus
234:                            + "("
235:                            + JDWPConstants.SuspendStatus
236:                                    .getName(suspendStatus) + ")");
237:                    if (suspendStatus != JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED) {
238:                        logWriter
239:                                .println("## FAILURE: Unexpected suspendStatus for thread!");
240:                        logWriter
241:                                .println("##          Expected suspendStatus  = "
242:                                        + JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED
243:                                        + "("
244:                                        + JDWPConstants.SuspendStatus
245:                                                .getName(JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED)
246:                                        + ")");
247:                        suspendStatusFailed = true;
248:                        continue;
249:                    }
250:
251:                    logWriter
252:                            .println("==> Send ThreadReference.Resume command...");
253:                    packet = new CommandPacket(
254:                            JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
255:                            JDWPCommands.ThreadReferenceCommandSet.ResumeCommand);
256:                    packet.setNextValueAsThreadID(testedThreadsIDs[i]);
257:                    reply = debuggeeWrapper.vmMirror.performCommand(packet);
258:                    if (!checkReplyPacketWithoutFail(reply,
259:                            "ThreadReference.Resume command")) {
260:                        resumeCommandFailed = true;
261:                        continue;
262:                    }
263:
264:                    logWriter
265:                            .println("==> Send ThreadReference.Status command...");
266:                    packet = new CommandPacket(
267:                            JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
268:                            JDWPCommands.ThreadReferenceCommandSet.StatusCommand);
269:                    packet.setNextValueAsReferenceTypeID(testedThreadsIDs[i]);
270:                    reply = debuggeeWrapper.vmMirror.performCommand(packet);
271:                    if (!checkReplyPacketWithoutFail(reply,
272:                            "ThreadReference.Status command")) {
273:                        statusCommandFailed = true;
274:                        continue;
275:                    }
276:
277:                    threadStatus = reply.getNextValueAsInt();
278:                    suspendStatus = reply.getNextValueAsInt();
279:
280:                    logWriter.println("==> threadStatus = " + threadStatus
281:                            + "("
282:                            + JDWPConstants.ThreadStatus.getName(threadStatus)
283:                            + ")");
284:                    logWriter.println("==> suspendStatus = "
285:                            + suspendStatus
286:                            + "("
287:                            + JDWPConstants.SuspendStatus
288:                                    .getName(suspendStatus) + ")");
289:                    if (suspendStatus == JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED) {
290:                        logWriter
291:                                .println("## FAILURE: Thread still is suspended after ThreadReference.Resume command!");
292:                        suspendStatusFailed = true;
293:                    }
294:                }
295:
296:                logWriter
297:                        .println("\n==> Send VirtualMachine.Resume command...");
298:                packet = new CommandPacket(
299:                        JDWPCommands.VirtualMachineCommandSet.CommandSetID,
300:                        JDWPCommands.VirtualMachineCommandSet.ResumeCommand);
301:                reply = debuggeeWrapper.vmMirror.performCommand(packet);
302:                errorCode = reply.getErrorCode();
303:                if (errorCode != JDWPConstants.Error.NONE) {
304:                    setStaticIntField(debuggeeSignature,
305:                            ResumeDebuggee.TO_FINISH_DEBUGGEE_FIELD_NAME, 99);
306:                    logWriter
307:                            .println("## FAILURE: VirtualMachine.Resume command returns error = "
308:                                    + errorCode
309:                                    + "("
310:                                    + JDWPConstants.Error.getName(errorCode)
311:                                    + ")");
312:                    printErrorAndFail("## VirtualMachine.Resume command FAILED!");
313:                } else {
314:                    logWriter
315:                            .println("==> VirtualMachine.Resume command is OK!");
316:                }
317:
318:                if (statusCommandFailed) {
319:                    errorMessage = errorMessage
320:                            + "## Error found out while ThreadReference.Status command performing!\n";
321:                }
322:                if (suspendStatusFailed) {
323:                    errorMessage = errorMessage
324:                            + "## Unexpected suspendStatus found out!\n";
325:                }
326:                if (resumeCommandFailed) {
327:                    errorMessage = errorMessage
328:                            + "## Error found out while ThreadReference.Resume command performing!\n";
329:                }
330:                if (!errorMessage.equals("")) {
331:                    setStaticIntField(debuggeeSignature,
332:                            ResumeDebuggee.TO_FINISH_DEBUGGEE_FIELD_NAME, 99);
333:                    printErrorAndFail("\ntestResume001 FAILED:\n"
334:                            + errorMessage);
335:                }
336:
337:                logWriter
338:                        .println("\n==> Check ThreadReference.Resume command after ThreadReference.Suspend command...");
339:
340:                int suspendNumber = 3;
341:                for (int i = 0; i < testedThreadsNumber; i++) {
342:                    logWriter.println("\n==> Check for Thread: threadID = "
343:                            + testedThreadsIDs[i] + "; threadName = "
344:                            + testedThreadsNames[i]);
345:                    logWriter
346:                            .println("==> Send ThreadReference.Suspend commands: number of commandss = "
347:                                    + suspendNumber + "...");
348:                    int j = 0;
349:                    for (; j < suspendNumber; j++) {
350:                        packet = new CommandPacket(
351:                                JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
352:                                JDWPCommands.ThreadReferenceCommandSet.SuspendCommand);
353:                        packet.setNextValueAsThreadID(testedThreadsIDs[i]);
354:                        reply = debuggeeWrapper.vmMirror.performCommand(packet);
355:                        if (!checkReplyPacketWithoutFail(reply,
356:                                "ThreadReference.Suspend command")) {
357:                            break;
358:                        }
359:                    }
360:                    if (j < suspendNumber) {
361:                        suspendCommandFailed = true;
362:                        continue;
363:                    }
364:
365:                    logWriter
366:                            .println("==> Send ThreadReference.Status command...");
367:                    packet = new CommandPacket(
368:                            JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
369:                            JDWPCommands.ThreadReferenceCommandSet.StatusCommand);
370:                    packet.setNextValueAsReferenceTypeID(testedThreadsIDs[i]);
371:                    reply = debuggeeWrapper.vmMirror.performCommand(packet);
372:                    if (!checkReplyPacketWithoutFail(reply,
373:                            "ThreadReference.Status command")) {
374:                        statusCommandFailed = true;
375:                        continue;
376:                    }
377:
378:                    int threadStatus = reply.getNextValueAsInt();
379:                    int suspendStatus = reply.getNextValueAsInt();
380:
381:                    logWriter.println("==> threadStatus = " + threadStatus
382:                            + "("
383:                            + JDWPConstants.ThreadStatus.getName(threadStatus)
384:                            + ")");
385:                    logWriter.println("==> suspendStatus = "
386:                            + suspendStatus
387:                            + "("
388:                            + JDWPConstants.SuspendStatus
389:                                    .getName(suspendStatus) + ")");
390:                    if (suspendStatus != JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED) {
391:                        logWriter
392:                                .println("## FAILURE: Unexpected suspendStatus for thread!");
393:                        logWriter
394:                                .println("##          Expected suspendStatus  = "
395:                                        + JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED
396:                                        + "("
397:                                        + JDWPConstants.SuspendStatus
398:                                                .getName(JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED)
399:                                        + ")");
400:                        suspendStatusFailed = true;
401:                        continue;
402:                    }
403:
404:                    logWriter
405:                            .println("==> Send ThreadReference.Resume command 1 time - thread must NOT be actually resumed...");
406:                    packet = new CommandPacket(
407:                            JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
408:                            JDWPCommands.ThreadReferenceCommandSet.ResumeCommand);
409:                    packet.setNextValueAsThreadID(testedThreadsIDs[i]);
410:                    reply = debuggeeWrapper.vmMirror.performCommand(packet);
411:                    if (!checkReplyPacketWithoutFail(reply,
412:                            "ThreadReference.Resume command")) {
413:                        resumeCommandFailed = true;
414:                        continue;
415:                    }
416:
417:                    logWriter
418:                            .println("==> Send ThreadReference.Status command...");
419:                    packet = new CommandPacket(
420:                            JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
421:                            JDWPCommands.ThreadReferenceCommandSet.StatusCommand);
422:                    packet.setNextValueAsReferenceTypeID(testedThreadsIDs[i]);
423:                    reply = debuggeeWrapper.vmMirror.performCommand(packet);
424:                    if (!checkReplyPacketWithoutFail(reply,
425:                            "ThreadReference.Status command")) {
426:                        statusCommandFailed = true;
427:                        continue;
428:                    }
429:
430:                    threadStatus = reply.getNextValueAsInt();
431:                    suspendStatus = reply.getNextValueAsInt();
432:
433:                    logWriter.println("==> threadStatus = " + threadStatus
434:                            + "("
435:                            + JDWPConstants.ThreadStatus.getName(threadStatus)
436:                            + ")");
437:                    logWriter.println("==> suspendStatus = "
438:                            + suspendStatus
439:                            + "("
440:                            + JDWPConstants.SuspendStatus
441:                                    .getName(suspendStatus) + ")");
442:                    if (suspendStatus != JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED) {
443:                        logWriter
444:                                .println("## FAILURE: Unexpected suspendStatus for thread!");
445:                        logWriter
446:                                .println("##          Expected suspendStatus  = "
447:                                        + JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED
448:                                        + "("
449:                                        + JDWPConstants.SuspendStatus
450:                                                .getName(JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED)
451:                                        + ")");
452:                        suspendStatusFailed = true;
453:                        continue;
454:                    }
455:
456:                    logWriter
457:                            .println("==> Send ThreadReference.Resume commands: number of commands = "
458:                                    + (suspendNumber - 1)
459:                                    + " - thread must be actually resumed");
460:                    j = 0;
461:                    for (; j < (suspendNumber - 1); j++) {
462:                        packet = new CommandPacket(
463:                                JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
464:                                JDWPCommands.ThreadReferenceCommandSet.ResumeCommand);
465:                        packet.setNextValueAsThreadID(testedThreadsIDs[i]);
466:                        reply = debuggeeWrapper.vmMirror.performCommand(packet);
467:                        if (!checkReplyPacketWithoutFail(reply,
468:                                "ThreadReference.Resume command")) {
469:                            break;
470:                        }
471:                    }
472:                    if (j < (suspendNumber - 1)) {
473:                        resumeCommandFailed = true;
474:                        continue;
475:                    }
476:
477:                    logWriter
478:                            .println("==> Send ThreadReference.Status command...");
479:                    packet = new CommandPacket(
480:                            JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
481:                            JDWPCommands.ThreadReferenceCommandSet.StatusCommand);
482:                    packet.setNextValueAsReferenceTypeID(testedThreadsIDs[i]);
483:                    reply = debuggeeWrapper.vmMirror.performCommand(packet);
484:                    if (!checkReplyPacketWithoutFail(reply,
485:                            "ThreadReference.Status command")) {
486:                        statusCommandFailed = true;
487:                        continue;
488:                    }
489:
490:                    threadStatus = reply.getNextValueAsInt();
491:                    suspendStatus = reply.getNextValueAsInt();
492:
493:                    logWriter.println("==> threadStatus = " + threadStatus
494:                            + "("
495:                            + JDWPConstants.ThreadStatus.getName(threadStatus)
496:                            + ")");
497:                    logWriter.println("==> suspendStatus = "
498:                            + suspendStatus
499:                            + "("
500:                            + JDWPConstants.SuspendStatus
501:                                    .getName(suspendStatus) + ")");
502:                    if (suspendStatus == JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED) {
503:                        logWriter
504:                                .println("## FAILURE: Thread still is suspended after ThreadReference.Resume commands: "
505:                                        + "number of total resume commands = "
506:                                        + suspendNumber + " !");
507:                        suspendStatusFailed = true;
508:                    }
509:                }
510:
511:                if (suspendCommandFailed) {
512:                    errorMessage = errorMessage
513:                            + "## Error found out while ThreadReference.Suspend command performing!\n";
514:                }
515:                if (resumeCommandFailed) {
516:                    errorMessage = errorMessage
517:                            + "## Error found out while ThreadReference.Resume command performing!\n";
518:                }
519:                if (statusCommandFailed) {
520:                    errorMessage = errorMessage
521:                            + "## Error found out while ThreadReference.Status command performing!\n";
522:                }
523:                if (suspendStatusFailed) {
524:                    errorMessage = errorMessage
525:                            + "## Unexpected suspendStatus found out!\n";
526:                }
527:
528:                setStaticIntField(debuggeeSignature,
529:                        ResumeDebuggee.TO_FINISH_DEBUGGEE_FIELD_NAME, 99);
530:                if (!errorMessage.equals("")) {
531:                    printErrorAndFail("\ntestResume001 FAILED:\n"
532:                            + errorMessage);
533:                }
534:
535:                logWriter.println("\n==> testResume001 - OK!");
536:            }
537:
538:            public static void main(String[] args) {
539:                junit.textui.TestRunner.run(ResumeTest.class);
540:            }
541:        }
w_w___w___.__ja___v___a_2_s__.co_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.