Source Code Cross Referenced for StopDebuggee.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
021:         * @version $Revision: 1.2 $
022:         */
023:
024:        /**
025:         * Created on 22.02.2005
026:         */package org.apache.harmony.jpda.tests.jdwp.ThreadReference;
027:
028:        import org.apache.harmony.jpda.tests.framework.DebuggeeSynchronizer;
029:        import org.apache.harmony.jpda.tests.framework.LogWriter;
030:        import org.apache.harmony.jpda.tests.framework.TestOptions;
031:        import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
032:        import org.apache.harmony.jpda.tests.share.SyncDebuggee;
033:
034:        /**
035:         * The class specifies debuggee for <code>org.apache.harmony.jpda.tests.jdwp.ThreadReference.StopTest</code>.
036:         * This debuggee starts the tested thread <code>TESTED_THREAD</code> which waits for 
037:         * 'Stop' command with NullPointerException exception.
038:         */
039:        public class StopDebuggee extends SyncDebuggee {
040:
041:            static Object waitTimeObject = new Object();
042:
043:            static void waitMlsecsTime(long mlsecsTime) {
044:                synchronized (waitTimeObject) {
045:                    try {
046:                        waitTimeObject.wait(mlsecsTime);
047:                    } catch (Throwable throwable) {
048:                        // ignore
049:                    }
050:                }
051:            }
052:
053:            static Object waitTimeObjectWithException = new Object();
054:
055:            static void waitMlsecsTimeWithException(long mlsecsTime)
056:                    throws Throwable {
057:                synchronized (waitTimeObject) {
058:                    try {
059:                        waitTimeObject.wait(mlsecsTime);
060:                    } catch (Throwable throwable) {
061:                        throw throwable;
062:                    }
063:                }
064:            }
065:
066:            public static String testStatus = "PASSED";
067:            public static final String TESTED_THREAD = "TestedThread";
068:            public static final String FIELD_NAME = "exception";
069:            //    public static final String EXCEPTION_SIGNATURE = "Ljava/lang/NullPointerException;";
070:            public static NullPointerException exception = new NullPointerException();
071:
072:            static Object waitForStart = new Object();
073:
074:            public void run() {
075:                logWriter.println("StopDebuggee: started");
076:                DebuggeeThread thrd = new DebuggeeThread(TESTED_THREAD,
077:                        logWriter, synchronizer);
078:
079:                synchronized (waitForStart) {
080:                    thrd.start();
081:                    try {
082:                        waitForStart.wait();
083:                    } catch (InterruptedException e) {
084:                        logWriter.println("StopDebuggee:" + e
085:                                + " is cought while waitForStart.wait()");
086:                    }
087:                }
088:
089:                logWriter
090:                        .println("StopDebuggee: Wait for TestedThread to finish...");
091:                while (thrd.isAlive()) {
092:                    waitMlsecsTime(1000);
093:                }
094:                logWriter.println("StopDebuggee: TestedThread finished");
095:
096:                synchronizer.sendMessage(testStatus);
097:                logWriter.println("StopDebuggee: finishing...");
098:            }
099:
100:            class DebuggeeThread extends Thread {
101:
102:                LogWriter logWriter;
103:                DebuggeeSynchronizer synchronizer;
104:
105:                public DebuggeeThread(String name, LogWriter logWriter,
106:                        DebuggeeSynchronizer synchronizer) {
107:                    super (name);
108:                    this .logWriter = logWriter;
109:                    this .synchronizer = synchronizer;
110:                }
111:
112:                public void run() {
113:                    logWriter.println(getName() + ": started");
114:                    synchronized (waitForStart) {
115:                        waitForStart.notifyAll();
116:                    }
117:
118:                    logWriter
119:                            .println(getName()
120:                                    + ": Wait for 'Stop' command with NullPointerException...");
121:                    try {
122:                        synchronizer
123:                                .sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
124:                        waitMlsecsTimeWithException(TestOptions.DEFAULT_TIMEOUT);
125:                        logWriter
126:                                .println(getName()
127:                                        + ": FAILED: TIMEOUT is run out - No any exception is caught");
128:                        testStatus = "FAILED";
129:                    } catch (Throwable thrown) {
130:                        logWriter.println(getName() + ": Exception is caught: "
131:                                + thrown);
132:                        if (thrown.equals(exception)) {
133:                            logWriter.println(getName()
134:                                    + ": PASSED: It is expected Exception");
135:                        } else {
136:                            logWriter.println(getName()
137:                                    + ": FAILED: It is unexpected Exception");
138:                            testStatus = "FAILED";
139:                        }
140:                    }
141:                }
142:            }
143:
144:            public static void main(String[] args) {
145:                runDebuggee(StopDebuggee.class);
146:            }
147:        }
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.