Source Code Cross Referenced for ConstantPoolTests.java in  » IDE-Eclipse » jdt » org » eclipse » debug » jdi » tests » 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 » IDE Eclipse » jdt » org.eclipse.debug.jdi.tests 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2006 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         * 
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.debug.jdi.tests;
011:
012:        import com.sun.jdi.ArrayType;
013:        import com.sun.jdi.ReferenceType;
014:
015:        /**
016:         * Test cases for the implementation of providing argumebnt information even if 
017:         * no debugging information is present in the new java 1.6 VM
018:         * 
019:         * @since 3.3
020:         */
021:        public class ConstantPoolTests extends AbstractJDITest {
022:
023:            ReferenceType fClass;
024:
025:            /** setup test info locally **/
026:            public void localSetUp() {
027:            }
028:
029:            /**
030:             * test to see if we can get class file version info from a 1.6 VM, and 
031:             * that we cannot from a pre 1.6 VM
032:             */
033:            public void testCanGetClassFileVersion() {
034:                if (fVM.version().indexOf("1.6") > -1) {
035:                    assertTrue("Should have classfile version info", fVM
036:                            .canGetClassFileVersion());
037:                } else {
038:                    assertTrue("Should not have classfile version info", !fVM
039:                            .canGetClassFileVersion());
040:                }
041:            }
042:
043:            /**
044:             * test to make sure we can get constant pool information from a 1.6 VM, and
045:             * that we cannot get it from a pre 1.6 VM 
046:             */
047:            public void testCanGetConstantPool() {
048:                if (fVM.version().indexOf("1.6") > -1) {
049:                    assertTrue("Should have constant pool info", fVM
050:                            .canGetConstantPool());
051:                } else {
052:                    assertFalse("Should not have constant pool info", fVM
053:                            .canGetConstantPool());
054:                }
055:            }
056:
057:            /**
058:             * test to make sure that if majorVersion is unsupported an UnsupportedOperationException is
059:             * thrown.
060:             */
061:            public void testMajorVersionUnsupported() {
062:                triggerAndWait(fVM.eventRequestManager()
063:                        .createClassPrepareRequest(), "refclassload", true);
064:                fClass = getClass("org.eclipse.debug.jdi.tests.program.RefClass1");
065:                assertNotNull("RefClass1 should not be null", fClass);
066:                if (fVM.version().indexOf("1.6") > -1) {
067:                    try {
068:                        fClass.majorVersion();
069:                    } catch (UnsupportedOperationException uoe) {
070:                        assertTrue("Threw unsupported exception in 1.6 VM",
071:                                false);
072:                    }
073:                } else {
074:                    try {
075:                        fClass.majorVersion();
076:                        assertTrue("No exception for non 1.6 VM", false);
077:                    } catch (UnsupportedOperationException uoe) {
078:                    }
079:                }
080:            }
081:
082:            /**
083:             * test to make sure that majorVersion returns 0 for an arrayType.
084:             * this test does not apply to non-16 VMs
085:             */
086:            public void testMajorVersionArrayType() {
087:                if (!fVM.canGetClassFileVersion()) {
088:                    return;
089:                }
090:                ArrayType type = getArrayType();
091:                assertNotNull("type should not be null", type);
092:                int ver = type.majorVersion();
093:                assertTrue("major verison should be 0", ver == 0);
094:            }
095:
096:            /**
097:             * test to make sure majorVerison works.
098:             * this test does not apply to non-1.6VMs 
099:             */
100:            public void testMajorVersion() {
101:                if (!fVM.canGetClassFileVersion()) {
102:                    return;
103:                }
104:                triggerAndWait(fVM.eventRequestManager()
105:                        .createClassPrepareRequest(), "refclassload", true);
106:                fClass = getClass("org.eclipse.debug.jdi.tests.program.RefClass1");
107:                assertNotNull("RefClass1 should not be null", fClass);
108:                int ver = fClass.majorVersion();
109:                assertTrue("version cannot be equal to -1", ver != -1);
110:            }
111:
112:            /**
113:             * test to make sure that if minorVersion is unsupported an UnsupportedIOperationException 
114:             * is thrown
115:             */
116:            public void testMinorVersionUnsupported() {
117:                triggerAndWait(fVM.eventRequestManager()
118:                        .createClassPrepareRequest(), "refclassload", true);
119:                fClass = getClass("org.eclipse.debug.jdi.tests.program.RefClass1");
120:                assertNotNull("RefClass1 should not be null", fClass);
121:                if (fVM.version().indexOf("1.6") > -1) {
122:                    try {
123:                        fClass.minorVersion();
124:                    } catch (UnsupportedOperationException uoe) {
125:                        assertTrue("Threw unsupported exception in 1.6 VM",
126:                                false);
127:                    }
128:                } else {
129:                    try {
130:                        fClass.minorVersion();
131:                        assertTrue("No exception for non 1.6 VM", false);
132:                    } catch (UnsupportedOperationException uoe) {
133:                    }
134:                }
135:            }
136:
137:            /**
138:             * test to make sure minorVerison works.
139:             * this test does not apply to non-1.6VMs 
140:             */
141:            public void testMinorVersion() {
142:                if (!fVM.canGetClassFileVersion()) {
143:                    return;
144:                }
145:                triggerAndWait(fVM.eventRequestManager()
146:                        .createClassPrepareRequest(), "refclassload", true);
147:                fClass = getClass("org.eclipse.debug.jdi.tests.program.RefClass1");
148:                assertNotNull("RefClass1 should not be null", fClass);
149:                int ver = fClass.minorVersion();
150:                assertTrue("version cannot be equal to -1", ver != -1);
151:            }
152:
153:            /**
154:             * test to make sure that if constantPoolCount is unsupported an UnsupportedIOperationException 
155:             * is thrown
156:             */
157:            public void testConstantPoolCountSupported() {
158:                triggerAndWait(fVM.eventRequestManager()
159:                        .createClassPrepareRequest(), "refclassload", true);
160:                fClass = getClass("org.eclipse.debug.jdi.tests.program.RefClass1");
161:                assertNotNull("RefClass1 should not be null", fClass);
162:                if (fVM.version().indexOf("1.6") > -1) {
163:                    try {
164:                        fClass.constantPoolCount();
165:                    } catch (UnsupportedOperationException uoe) {
166:                        assertTrue("Threw unsupported exception in 1.6 VM",
167:                                false);
168:                    }
169:                } else {
170:                    try {
171:                        fClass.constantPoolCount();
172:                        assertTrue("No exception for non 1.6 VM", false);
173:                    } catch (UnsupportedOperationException uoe) {
174:                    }
175:                }
176:            }
177:
178:            /**
179:             * test to ensure the constant pool count is working correctly
180:             * this test does not apply to non-1.6 VMs
181:             */
182:            public void testConstantPoolCount() {
183:                if (!fVM.canGetConstantPool()) {
184:                    return;
185:                }
186:                triggerAndWait(fVM.eventRequestManager()
187:                        .createClassPrepareRequest(), "refclass4load", true);
188:                fClass = getClass("org.eclipse.debug.jdi.tests.program.RefClass4");
189:                assertNotNull("RefClass4 should not be null", fClass);
190:                fClass.constantPoolCount();
191:                //for now we don't care about constant pool counts, not likely to have a useful debug extension for this feature,
192:                //but it is here for completeness
193:            }
194:
195:            /**
196:             * test to make sure that if constantPool is unsupported an UnsupportedIOperationException 
197:             * is thrown
198:             */
199:            public void testConstantPoolSupported() {
200:                triggerAndWait(fVM.eventRequestManager()
201:                        .createClassPrepareRequest(), "refclassload", true);
202:                fClass = getClass("org.eclipse.debug.jdi.tests.program.RefClass1");
203:                assertNotNull("RefClass1 should not be null", fClass);
204:                if (fVM.version().indexOf("1.6") > -1) {
205:                    try {
206:                        fClass.constantPool();
207:                    } catch (UnsupportedOperationException uoe) {
208:                        assertTrue("Threw unsupported exception in 1.6 VM",
209:                                false);
210:                    }
211:                } else {
212:                    try {
213:                        fClass.constantPool();
214:                        assertTrue("No exception for non 1.6 VM", false);
215:                    } catch (UnsupportedOperationException uoe) {
216:                    }
217:                }
218:            }
219:
220:            /**
221:             * test to ensure the constant pool is working correctly
222:             * this test does not apply to non-1.6 VMs
223:             */
224:            public void testConstantPool() {
225:                if (!fVM.canGetConstantPool()) {
226:                    return;
227:                }
228:                triggerAndWait(fVM.eventRequestManager()
229:                        .createClassPrepareRequest(), "refclass4load", true);
230:                fClass = getClass("org.eclipse.debug.jdi.tests.program.RefClass4");
231:                assertNotNull("RefClass4 should not be null", fClass);
232:                byte[] bytes = fClass.constantPool();
233:                assertNotNull("byte array should not be null", bytes);
234:                assertTrue("byte array should not be less than 1",
235:                        bytes.length > 0);
236:                //for now we don't care about constant pool bytes, not likely to have a useful debug extension for this feature,
237:                //but it is here for completeness
238:            }
239:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.