Source Code Cross Referenced for MethodTest.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, 2005 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.List;
013:
014:        import com.sun.jdi.AbsentInformationException;
015:        import com.sun.jdi.ClassNotLoadedException;
016:        import com.sun.jdi.LocalVariable;
017:        import com.sun.jdi.Location;
018:        import com.sun.jdi.Method;
019:        import com.sun.jdi.NativeMethodException;
020:        import com.sun.jdi.VoidType;
021:
022:        /**
023:         * Tests for JDI com.sun.jdi.Method
024:         * and JDWP Method command set.
025:         */
026:        public class MethodTest extends AbstractJDITest {
027:
028:            private Method fMethod1;
029:
030:            /**
031:             * Creates a new test.
032:             */
033:            public MethodTest() {
034:                super ();
035:            }
036:
037:            /**
038:             * Init the fields that are used by this test only.
039:             */
040:            public void localSetUp() {
041:                // Get method useLocalVars(Thread, MainClass)
042:                fMethod1 = getMethod("useLocalVars",
043:                        "(Ljava/lang/Thread;Lorg/eclipse/debug/jdi/tests/program/MainClass;)V");
044:            }
045:
046:            /**
047:             * Run all tests and output to standard output.
048:             * @param args
049:             */
050:            public static void main(java.lang.String[] args) {
051:                new MethodTest().runSuite(args);
052:            }
053:
054:            /**
055:             * Gets the name of the test case.
056:             * @see junit.framework.TestCase#getName()
057:             */
058:            public String getName() {
059:                return "com.sun.jdi.Method";
060:            }
061:
062:            /**
063:             * Test JDI arguments() and JDWP 'Method - Get variable table'.
064:             */
065:            public void testJDIArguments() {
066:                List arguments = null;
067:                try {
068:                    arguments = fMethod1.arguments();
069:                } catch (AbsentInformationException e) {
070:                    assertTrue("1", false);
071:                }
072:                assertEquals("2", 2, arguments.size());
073:                assertEquals("3", "t", ((LocalVariable) arguments.get(0))
074:                        .name());
075:                assertEquals("4", "o", ((LocalVariable) arguments.get(1))
076:                        .name());
077:            }
078:
079:            /**
080:             * Test JDI argumentTypeNames().
081:             */
082:            public void testJDIArgumentTypeNames() {
083:                List names = fMethod1.argumentTypeNames();
084:                assertEquals("1", 2, names.size());
085:                assertEquals("2", "java.lang.Thread", names.get(0));
086:                assertEquals("3",
087:                        "org.eclipse.debug.jdi.tests.program.MainClass", names
088:                                .get(1));
089:            }
090:
091:            /**
092:             * Test JDI argumentTypes().
093:             */
094:            public void testJDIArgumentTypes() {
095:                List types = null;
096:                try {
097:                    types = fMethod1.argumentTypes();
098:                } catch (ClassNotLoadedException e) {
099:                    assertTrue("1", false);
100:                }
101:                assertEquals("2", 2, types.size());
102:                assertEquals("3", fVM.classesByName("java.lang.Thread").get(0),
103:                        types.get(0));
104:                assertEquals(
105:                        "4",
106:                        fVM
107:                                .classesByName(
108:                                        "org.eclipse.debug.jdi.tests.program.MainClass")
109:                                .get(0), types.get(1));
110:            }
111:
112:            /**
113:             * Test JDI bytecodes().
114:             */
115:            public void testJDIBytecodes() {
116:                if (!fVM.canGetBytecodes())
117:                    return;
118:
119:                byte[] bytecodes = fMethod1.bytecodes();
120:                assertEquals("1", 27, bytecodes.length);
121:            }
122:
123:            /**
124:             * Test JDI equals() and hashCode().
125:             */
126:            public void testJDIEquality() {
127:                assertTrue("1", fMethod1.equals(fMethod1));
128:                Method other = getMethod("run", "()V");
129:                assertTrue("2", !fMethod1.equals(other));
130:                assertTrue("3", !fMethod1.equals(new Object()));
131:                assertTrue("4", !fMethod1.equals(null));
132:                assertTrue("5", fMethod1.hashCode() != other.hashCode());
133:            }
134:
135:            /**
136:             * Test JDI isAbstract().
137:             */
138:            public void testJDIIsAbstract() {
139:                assertTrue("1", !fMethod1.isAbstract());
140:            }
141:
142:            /**
143:             * Test JDI isConstructor().
144:             */
145:            public void testJDIIsConstructor() {
146:                assertTrue("1", !fMethod1.isConstructor());
147:            }
148:
149:            /**
150:             * Test JDI isNative().
151:             */
152:            public void testJDIIsNative() {
153:                assertTrue("1", !fMethod1.isNative());
154:            }
155:
156:            /**
157:             * Test JDI isStaticInitializer().
158:             */
159:            public void testJDIIsStaticInitializer() {
160:                assertTrue("1", !fMethod1.isStaticInitializer());
161:            }
162:
163:            /**
164:             * Test JDI isSynchronized().
165:             */
166:            public void testJDIIsSynchronized() {
167:                assertTrue("1", !fMethod1.isSynchronized());
168:            }
169:
170:            /**
171:             * Test JDI locationOfCodeIndex(long).
172:             */
173:            public void testJDILocationOfCodeIndex() {
174:                Location expected = fMethod1.location();
175:                Location result = fMethod1.locationOfCodeIndex(expected
176:                        .codeIndex());
177:                assertEquals("1", expected, result);
178:            }
179:
180:            /**
181:             * Test JDI locationsOfLine(int) and JDWP 'Method - Get line table'.
182:             */
183:            public void testJDILocationsOfLine() {
184:                int expected = fMethod1.location().lineNumber();
185:                List locations = null;
186:                try {
187:                    locations = fMethod1.locationsOfLine(expected);
188:                } catch (AbsentInformationException e) {
189:                    assertTrue("1", false);
190:                }
191:                assertEquals("2", 1, locations.size());
192:                assertEquals("3", expected, ((Location) locations.get(0))
193:                        .lineNumber());
194:            }
195:
196:            /**
197:             * Test JDI returnType().
198:             */
199:            public void testJDIReturnType() {
200:                try {
201:                    assertTrue("1", fMethod1.returnType() instanceof  VoidType);
202:                } catch (ClassNotLoadedException e) {
203:                    assertTrue("2", false);
204:                }
205:            }
206:
207:            /**
208:             * Test JDI returnTypeName().
209:             */
210:            public void testJDIReturnTypeName() {
211:                assertEquals("1", "void", fMethod1.returnTypeName());
212:            }
213:
214:            /**
215:             * Test JDI variables() and JDWP 'Method - Get variable table'.
216:             */
217:            public void testJDIVariables() {
218:                List variables = null;
219:                try {
220:                    variables = fMethod1.variables();
221:                } catch (AbsentInformationException e) {
222:                    assertTrue("1", false);
223:                }
224:                assertEquals("2", 2, variables.size());
225:                assertEquals("3", "t", ((LocalVariable) variables.get(0))
226:                        .name());
227:                assertEquals("4", "o", ((LocalVariable) variables.get(1))
228:                        .name());
229:            }
230:
231:            /**
232:             * Test JDI variables() and JDWP 'Method - Get variable table'
233:             * for native method.
234:             */
235:            public void testJDINativeMethodVariables() {
236:                Method method = getMethod("java.lang.Thread", "sleep", "(J)V");
237:
238:                try {
239:                    method.variables();
240:                } catch (AbsentInformationException e) {
241:                    // since 1.4, returns an AbsentInformationException for native methods
242:                    assertFalse("1", "1.3".equals(fVM.version()));
243:                    return;
244:                } catch (NativeMethodException nme) {
245:                    assertTrue("1", "1.3".equals(fVM.version()));
246:                    return;
247:                }
248:                assertTrue("Should have thrown native method exception", false);
249:            }
250:
251:            /**
252:             * Test JDI variables() and JDWP 'Method - Get variable table'
253:             * for non-native method with a long argument.
254:             */
255:            public void testJDIMethodVariablesWithLong() {
256:                List variables = null;
257:                Method method = getMethod("variablesTest", "(J)V");
258:
259:                try {
260:                    variables = method.variables();
261:                } catch (AbsentInformationException e) {
262:                    assertTrue("1", false);
263:                }
264:                assertEquals("1", 1, variables.size());
265:            }
266:
267:            /**
268:             * Test JDI variablesByName(String) and JDWP 'Method - Get variable table'.
269:             */
270:            public void testJDIVariablesByName() {
271:                String varName = "t";
272:                List variables = null;
273:                try {
274:                    variables = fMethod1.variablesByName(varName);
275:                } catch (AbsentInformationException e) {
276:                    assertTrue("1", false);
277:                }
278:                assertEquals("2", 1, variables.size());
279:                assertEquals("3", varName, ((LocalVariable) variables.get(0))
280:                        .name());
281:            }
282:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.