Source Code Cross Referenced for HeapWalkingTests.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 java.util.ArrayList;
013:        import java.util.List;
014:
015:        import com.sun.jdi.ObjectReference;
016:        import com.sun.jdi.ReferenceType;
017:
018:        /**
019:         * Test cases for the implementation of heap walking in the new java 1.6 VM
020:         * 
021:         * @since 3.3
022:         */
023:        public class HeapWalkingTests extends AbstractJDITest {
024:
025:            private ReferenceType fClass, fClass1;
026:            private ObjectReference fObject;
027:
028:            /**	 setup our tests */
029:            public void localSetUp() {
030:            }
031:
032:            /** tear down our tests */
033:            public void localTearDown() {
034:                super .localTearDown();
035:                fClass = null;
036:                fClass1 = null;
037:                fObject = null;
038:            }
039:
040:            /**
041:             * test to make sure that the vm supports getting instance info for heap walking if it is a 1.6 VM
042:             */
043:            public void testCanGetInstanceInfo() {
044:                if (fVM.version().indexOf("1.6") > -1) {
045:                    assertTrue("Should have instance info", fVM
046:                            .canGetInstanceInfo());
047:                } else {
048:                    assertTrue("Should not have instance info", !fVM
049:                            .canGetInstanceInfo());
050:                }
051:            }
052:
053:            /**
054:             * tests the new method instanceCounts, to make sure it throws an NPE when required.
055:             * test is not applicable to non 1.6 VMs
056:             */
057:            public void testGetInstanceCountsNullAttrib() {
058:                if (!fVM.canGetInstanceInfo()) {
059:                    return;
060:                }
061:                try {
062:                    fVM.instanceCounts(null);
063:                    assertTrue("No excpetion thrown", false);
064:                } catch (NullPointerException npe) {
065:                }
066:            }
067:
068:            /**
069:             * tests to make sure the instanceCounts method throws a not supported
070:             */
071:            public void testGetInstanceCountsUnsupported() {
072:                if (fVM.version().indexOf("1.6") > -1) {
073:                    try {
074:                        fVM.instanceCounts(new ArrayList());
075:                    } catch (UnsupportedOperationException uoe) {
076:                        assertTrue("Threw unsupported exception in 1.6 VM",
077:                                false);
078:                    }
079:                } else {
080:                    try {
081:                        fVM.instanceCounts(new ArrayList());
082:                        assertTrue("No exception for non 1.6 VM", false);
083:                    } catch (UnsupportedOperationException uoe) {
084:                    }
085:                }
086:            }
087:
088:            /**
089:             * test to collect any referring instances can be collected for the specified class.
090:             * test is not applicable to non 1.6 VMs.
091:             */
092:            public void testGetInstanceCounts() {
093:                if (!fVM.canGetInstanceInfo()) {
094:                    return;
095:                }
096:                triggerAndWait(fVM.eventRequestManager()
097:                        .createClassPrepareRequest(), "refclass3load", true);
098:                triggerAndWait(fVM.eventRequestManager()
099:                        .createClassPrepareRequest(), "refclassload", true);
100:                ArrayList list = new ArrayList(2);
101:                fClass = getClass("org.eclipse.debug.jdi.tests.program.RefClass1");
102:                assertNotNull("RefClass should not be null", fClass);
103:                list.add(fClass);
104:                fClass1 = getClass("org.eclipse.debug.jdi.tests.program.RefClass2");
105:                list.add(fClass1);
106:                long[] counts = fVM.instanceCounts(list);
107:                assertNotNull("counts should not be null", counts);
108:                assertTrue("counts should have two entires", counts.length == 2);
109:                assertTrue("count for RefClass1 should be 2", counts[0] == 2);
110:                assertTrue("count for RefClass2 should be 1", counts[1] == 1);
111:            }
112:
113:            /**
114:             * test to make sure instances throws an unsupported exception for non 1.6 VMs
115:             */
116:            public void testGetInstancesUnsupported() {
117:                fClass = getClass("java.io.PrintStream");
118:                assertNotNull("classs should not be null", fClass);
119:                if (fVM.version().indexOf("1.6") > -1) {
120:                    try {
121:                        fClass.instances(20);
122:                    } catch (UnsupportedOperationException uoe) {
123:                        assertTrue("Threw unsupported exception in 1.6 VM",
124:                                false);
125:                    }
126:                } else {
127:                    try {
128:                        fClass.instances(20);
129:                        assertTrue("No exception for non 1.6 VM", false);
130:                    } catch (UnsupportedOperationException uoe) {
131:                    }
132:                }
133:            }
134:
135:            /**
136:             * test to make sure instances throws and IllegalArgument exception for negative long arguments.
137:             * test is not applicable to non 1.6 VMs
138:             */
139:            public void testGetInstancesNegativeMax() {
140:                if (!fVM.canGetInstanceInfo()) {
141:                    return;
142:                }
143:                fClass = getClass("java.io.PrintStream");
144:                assertNotNull("classs should not be null", fClass);
145:                try {
146:                    fClass.instances(-1);
147:                    assertTrue("No excpetion thrown", false);
148:                } catch (IllegalArgumentException iae) {
149:                }
150:            }
151:
152:            /**
153:             * test to collect a list of instances.
154:             * test is not applicable to non 1.6 VMs. 
155:             */
156:            public void testGetInstances() {
157:                if (!fVM.canGetInstanceInfo()) {
158:                    return;
159:                }
160:                triggerAndWait(fVM.eventRequestManager()
161:                        .createClassPrepareRequest(), "refclass3load", true);
162:                triggerAndWait(fVM.eventRequestManager()
163:                        .createClassPrepareRequest(), "refclassload", true);
164:                fClass = getClass("org.eclipse.debug.jdi.tests.program.RefClass3");
165:                assertNotNull("RefClass3 should not be null", fClass);
166:                fClass1 = getClass("org.eclipse.debug.jdi.tests.program.RefClass1");
167:                assertNotNull("RefClass1 should not be null", fClass1);
168:                List list = fClass1.instances(10);
169:                assertNotNull("list should not be null", list);
170:                assertTrue("list should have two enrtries", list.size() == 2);
171:            }
172:
173:            /**
174:             * test to make sure referringObjects throws an unsupported exception for non-1.6 VMs
175:             */
176:            public void testGetReferringObjectsUnsupported() {
177:                fClass = getMainClass();
178:                assertNotNull("main class ref should not be null", fClass);
179:                fObject = getObjectReference();
180:                assertNotNull("String obj ref should not be null", fObject);
181:                if (fVM.version().indexOf("1.6") > -1) {
182:                    try {
183:                        fObject.referringObjects(100);
184:                    } catch (UnsupportedOperationException uoe) {
185:                        assertTrue("Threw unsupported exception in 1.6 VM",
186:                                false);
187:                    }
188:                } else {
189:                    try {
190:                        fObject.referringObjects(10);
191:                        assertTrue("No exception for non 1.6 VM", false);
192:                    } catch (UnsupportedOperationException uoe) {
193:                    }
194:                }
195:            }
196:
197:            /**
198:             * test to make sure referringObjects throws an IllegalArgument exception for bad values of max
199:             */
200:            public void testGetreferringObjectsNegativeMax() {
201:                if (!fVM.canGetInstanceInfo()) {
202:                    return;
203:                }
204:                fClass = getMainClass();
205:                assertNotNull("main class ref should not be null", fClass);
206:                fObject = getStringReference();
207:                assertNotNull("String obj ref should not be null", fObject);
208:                try {
209:                    fObject.referringObjects(-1);
210:                    assertTrue("No excpetion thrown", false);
211:                } catch (IllegalArgumentException iae) {
212:                    assertTrue("Threw exception", true);
213:                }
214:            }
215:
216:            /**
217:             * tests the method referring objects to ensure working to spec.
218:             * test is not applicable to non 1.6 VMs
219:             */
220:            public void testGetReferringObjects() {
221:                if (!fVM.canGetInstanceInfo()) {
222:                    return;
223:                }
224:                fClass = getMainClass();
225:                assertNotNull("main class ref should not be null", fClass);
226:                triggerAndWait(fVM.eventRequestManager()
227:                        .createClassPrepareRequest(), "refclassload", true);
228:                fClass1 = getClass("org.eclipse.debug.jdi.tests.program.RefClass");
229:                assertNotNull("RefClass should not be null", fClass1);
230:                fObject = getObjectReference();
231:                assertNotNull("String obj ref should not be null", fObject);
232:                List list = fObject.referringObjects(100);
233:                assertNotNull("referring objects list should not be null", list);
234:                assertTrue("list size should be 4", list.size() == 4);
235:                assertTrue("list should contain the main class", list
236:                        .contains(fClass.classObject()));
237:                assertTrue("list should contain the main class thread", list
238:                        .contains(getThread()));
239:            }
240:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.