Source Code Cross Referenced for JDelegatingClassTypeTestBase.java in  » Ajax » GWT » com » google » gwt » core » ext » typeinfo » 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 » Ajax » GWT » com.google.gwt.core.ext.typeinfo 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2007 Google Inc.
003:         * 
004:         * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005:         * use this file except in compliance with the License. You may obtain a copy of
006:         * the License at
007:         * 
008:         * http://www.apache.org/licenses/LICENSE-2.0
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012:         * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013:         * License for the specific language governing permissions and limitations under
014:         * the License.
015:         */
016:        package com.google.gwt.core.ext.typeinfo;
017:
018:        import junit.framework.TestCase;
019:
020:        import java.lang.annotation.Annotation;
021:        import java.util.Arrays;
022:
023:        /**
024:         * Base test cases for all {@link JDelegatingClassType}s.
025:         */
026:        public abstract class JDelegatingClassTypeTestBase extends TestCase {
027:
028:            protected static void assertArraysEqual(Object[] expected,
029:                    Object[] actual) {
030:                assertTrue("Expected: \n" + Arrays.toString(expected)
031:                        + ",\n Actual: \n" + Arrays.toString(actual), Arrays
032:                        .equals(expected, actual));
033:            }
034:
035:            protected static void validateAbstractMethodSubstitution(
036:                    JAbstractMethod preSubMethod,
037:                    JAbstractMethod postSubMethod, Substitution substitution) {
038:
039:                assertEquals(preSubMethod.getName(), postSubMethod.getName());
040:
041:                assertEquals(preSubMethod.getModifierBits(), postSubMethod
042:                        .getModifierBits());
043:
044:                validateAnnotations(preSubMethod, postSubMethod);
045:
046:                validateMetaData(preSubMethod, postSubMethod);
047:
048:                JParameter[] preSubParams = preSubMethod.getParameters();
049:                JParameter[] postSubParams = postSubMethod.getParameters();
050:
051:                assertEquals(preSubParams.length, postSubParams.length);
052:
053:                for (int j = 0; j < preSubParams.length; ++j) {
054:                    JParameter preSubParam = preSubParams[j];
055:                    JParameter postSubParam = postSubParams[j];
056:
057:                    validateAnnotations(preSubParam, postSubParam);
058:                    validateMetaData(preSubParam, postSubParam);
059:
060:                    assertEquals(substitution.getSubstitution(preSubParam
061:                            .getType()), postSubParam.getType());
062:                }
063:            }
064:
065:            protected static void validateAnnotations(HasAnnotations ha1,
066:                    HasAnnotations ha2) {
067:                assertArraysEqual(ha1.getAnnotations(), ha2.getAnnotations());
068:            }
069:
070:            protected static void validateConstructorSubstitutions(
071:                    JClassType preSubstitution, JClassType postSubstituion,
072:                    Substitution substitution) {
073:                // Check the constructors
074:                JConstructor[] preSubCtors = preSubstitution.getConstructors();
075:                JConstructor[] postSubCtors = postSubstituion.getConstructors();
076:                assertEquals(preSubCtors.length, postSubCtors.length);
077:                for (int i = 0; i < preSubCtors.length; ++i) {
078:                    validateAbstractMethodSubstitution(preSubCtors[i],
079:                            postSubCtors[i], substitution);
080:                }
081:            }
082:
083:            protected static void validateDeclaredAnnotations(
084:                    HasAnnotations ha1, HasAnnotations ha2) {
085:                assertArraysEqual(ha1.getDeclaredAnnotations(), ha2
086:                        .getDeclaredAnnotations());
087:            }
088:
089:            protected static void validateEquals(TypeOracle oracle,
090:                    JClassType[] expectedTypes, JClassType actualTypes[]) {
091:                oracle.sort(expectedTypes);
092:                oracle.sort(actualTypes);
093:
094:                assertArraysEqual(expectedTypes, actualTypes);
095:            }
096:
097:            protected static void validateFieldSubstitutions(
098:                    JClassType preSubstitution, JClassType postSubstituion,
099:                    Substitution substitution) {
100:                // Check the fields
101:                JField[] preSubfields = preSubstitution.getFields();
102:                JField[] postSubFields = postSubstituion.getFields();
103:                assertEquals(preSubfields.length, postSubFields.length);
104:                for (int i = 0; i < preSubfields.length; ++i) {
105:                    JField postSubField = postSubstituion
106:                            .getField(preSubfields[i].getName());
107:                    assertNotNull(postSubField);
108:                    assertEquals(substitution.getSubstitution(preSubfields[i]
109:                            .getType()), postSubField.getType());
110:                }
111:            }
112:
113:            protected static void validateFindConstructor(
114:                    JClassType preSubstitution, JClassType postSubstitution,
115:                    Substitution substitution) {
116:
117:                JConstructor[] constructors = preSubstitution.getConstructors();
118:                for (JConstructor constructor : constructors) {
119:                    JParameter[] params = constructor.getParameters();
120:                    JType[] paramTypes = new JType[params.length];
121:
122:                    for (int i = 0; i < params.length; ++i) {
123:                        paramTypes[i] = substitution.getSubstitution(params[i]
124:                                .getType());
125:                    }
126:
127:                    assertNotNull(postSubstitution.findConstructor(paramTypes));
128:                }
129:            }
130:
131:            /**
132:             * 
133:             */
134:            protected static void validateFindField(JClassType preSubstitution,
135:                    JClassType postSubstitution) {
136:                JField[] fields = preSubstitution.getFields();
137:                for (JField field : fields) {
138:                    assertNotNull(postSubstitution.findField(field.getName()));
139:                }
140:            }
141:
142:            protected static void validateFindMethod(
143:                    JClassType preSubstitution, JClassType postSubstitution,
144:                    Substitution substitution) {
145:
146:                JMethod[] methods = preSubstitution.getMethods();
147:                for (JMethod method : methods) {
148:                    JParameter[] params = method.getParameters();
149:                    JType[] paramTypes = new JType[params.length];
150:
151:                    for (int i = 0; i < params.length; ++i) {
152:                        paramTypes[i] = substitution.getSubstitution(params[i]
153:                                .getType());
154:                    }
155:
156:                    assertNotNull(postSubstitution.findMethod(method.getName(),
157:                            paramTypes));
158:                }
159:            }
160:
161:            protected static void validateGetConstructor(
162:                    JClassType preSubstitution, JClassType postSubstitution,
163:                    Substitution substitution) throws NotFoundException {
164:
165:                JConstructor[] constructors = preSubstitution.getConstructors();
166:                for (JConstructor constructor : constructors) {
167:                    JParameter[] params = constructor.getParameters();
168:                    JType[] paramTypes = new JType[params.length];
169:
170:                    for (int i = 0; i < params.length; ++i) {
171:                        paramTypes[i] = substitution.getSubstitution(params[i]
172:                                .getType());
173:                    }
174:
175:                    assertNotNull(postSubstitution.getConstructor(paramTypes));
176:                }
177:            }
178:
179:            /**
180:             * 
181:             */
182:            protected static void validateGetField(JClassType preSubstitution,
183:                    JClassType postSubstitution) {
184:                JField[] fields = preSubstitution.getFields();
185:                for (JField field : fields) {
186:                    assertNotNull(postSubstitution.getField(field.getName()));
187:                }
188:            }
189:
190:            protected static void validateGetMethod(JClassType preSubstitution,
191:                    JClassType postSubstitution, Substitution substitution)
192:                    throws NotFoundException {
193:
194:                JMethod[] methods = preSubstitution.getMethods();
195:                for (JMethod method : methods) {
196:                    JParameter[] params = method.getParameters();
197:                    JType[] paramTypes = new JType[params.length];
198:
199:                    for (int i = 0; i < params.length; ++i) {
200:                        paramTypes[i] = substitution.getSubstitution(params[i]
201:                                .getType());
202:                    }
203:
204:                    assertNotNull(postSubstitution.getMethod(method.getName(),
205:                            paramTypes));
206:                }
207:            }
208:
209:            protected static void validateGetOverloads(
210:                    JClassType preSubstitution, JClassType postSubstitution) {
211:                JMethod[] methods = preSubstitution.getMethods();
212:                for (JMethod method : methods) {
213:                    assertEquals(
214:                            preSubstitution.getOverloads(method.getName()).length,
215:                            postSubstitution.getOverloads(method.getName()).length);
216:                }
217:            }
218:
219:            protected static void validateImplementedInterfaceSubstitution(
220:                    JClassType preSubstitution, JClassType postSubstituion,
221:                    Substitution substitution) {
222:                JClassType[] preSubIntfs = preSubstitution
223:                        .getImplementedInterfaces();
224:                JClassType[] postSubIntfs = postSubstituion
225:                        .getImplementedInterfaces();
226:
227:                assertEquals(preSubIntfs.length, postSubIntfs.length);
228:
229:                for (int i = 0; i < preSubIntfs.length; ++i) {
230:                    assertEquals(postSubIntfs[i], substitution
231:                            .getSubstitution(postSubIntfs[i]));
232:                }
233:            }
234:
235:            protected static void validateMetaData(HasMetaData md1,
236:                    HasMetaData md2) {
237:                validateMetaDataTags(md1, md2);
238:
239:                String[] md1TagNames = md1.getMetaDataTags();
240:                String[] md2TagNames = md2.getMetaDataTags();
241:
242:                for (int i = 0; i < md1TagNames.length; ++i) {
243:                    assertEquals(md1TagNames[i], md2TagNames[i]);
244:
245:                    String[][] md1TagValues = md1.getMetaData(md1TagNames[i]);
246:                    String[][] md2TagValues = md2.getMetaData(md2TagNames[i]);
247:
248:                    assertTrue(Arrays.deepEquals(md1TagValues, md2TagValues));
249:                }
250:            }
251:
252:            protected static void validateMetaDataTags(HasMetaData md1,
253:                    HasMetaData md2) {
254:                assertEquals(md1.getMetaDataTags().length, md2
255:                        .getMetaDataTags().length);
256:            }
257:
258:            protected static void validateMethodSubstitution(
259:                    JMethod preSubMethod, JMethod postSubMethod,
260:                    Substitution substitution) {
261:
262:                assertEquals(substitution.getSubstitution(preSubMethod
263:                        .getReturnType()), postSubMethod.getReturnType());
264:
265:                validateAbstractMethodSubstitution(preSubMethod, postSubMethod,
266:                        substitution);
267:            }
268:
269:            protected static void validateMethodSubstitutions(
270:                    JClassType preSubstitution, JClassType postSubstituion,
271:                    Substitution substitution) throws NotFoundException {
272:                // Check the methods
273:                JMethod[] preSubMethods = preSubstitution.getMethods();
274:                JMethod[] postSubMethods = postSubstituion.getMethods();
275:                assertEquals(preSubMethods.length, postSubMethods.length);
276:
277:                for (int i = 0; i < preSubMethods.length; ++i) {
278:                    JMethod preSubMethod = preSubMethods[i];
279:
280:                    JParameter[] preSubParams = preSubMethod.getParameters();
281:                    JType[] postSubParamTypes = new JType[preSubParams.length];
282:                    for (int j = 0; j < preSubParams.length; ++j) {
283:                        postSubParamTypes[j] = substitution
284:                                .getSubstitution(preSubParams[j].getType());
285:                    }
286:                    JMethod postSubMethod = postSubstituion.getMethod(
287:                            preSubMethod.getName(), postSubParamTypes);
288:
289:                    validateMethodSubstitution(preSubMethod, postSubMethod,
290:                            substitution);
291:                }
292:            }
293:
294:            protected static void validateTypeSubstitution(
295:                    JClassType preSubstitution, JClassType postSubstituion,
296:                    Substitution substitution) throws NotFoundException {
297:                if (preSubstitution.isGenericType() == null) {
298:                    return;
299:                }
300:
301:                assertEquals(preSubstitution.getModifierBits(), postSubstituion
302:                        .getModifierBits());
303:
304:                validateAnnotations(preSubstitution, postSubstituion);
305:
306:                validateMetaData(preSubstitution, postSubstituion);
307:
308:                assertEquals(preSubstitution.getName(), postSubstituion
309:                        .getName());
310:                // assertEquals(preSubstitution.getSubstitution(substitution),
311:                // postSubstituion);
312:
313:                // Check superclass
314:                JClassType super Class = preSubstitution.getSuperclass();
315:                if (super Class != null) {
316:                    validateTypeSubstitution(super Class, postSubstituion
317:                            .getSuperclass(), substitution);
318:                }
319:
320:                // Check interfaces
321:                validateImplementedInterfaceSubstitution(preSubstitution,
322:                        postSubstituion, substitution);
323:
324:                validateFieldSubstitutions(preSubstitution, postSubstituion,
325:                        substitution);
326:
327:                validateConstructorSubstitutions(preSubstitution,
328:                        postSubstituion, substitution);
329:
330:                validateMethodSubstitutions(preSubstitution, postSubstituion,
331:                        substitution);
332:            }
333:
334:            /**
335:             * Test method for
336:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#findConstructor(com.google.gwt.core.ext.typeinfo.JType[])}.
337:             */
338:            public void testFindConstructor() throws NotFoundException {
339:                JDelegatingClassType testType = getTestType();
340:                JClassType baseType = testType.getBaseType();
341:
342:                validateFindConstructor(baseType, testType, getSubstitution());
343:            }
344:
345:            /**
346:             * Test method for
347:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#findField(java.lang.String)}.
348:             */
349:            public void testFindField() throws NotFoundException {
350:                JDelegatingClassType testType = getTestType();
351:                JClassType baseType = testType.getBaseType();
352:
353:                validateFindField(baseType, testType);
354:            }
355:
356:            /**
357:             * Test method for
358:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#findMethod(java.lang.String, com.google.gwt.core.ext.typeinfo.JType[])}.
359:             */
360:            public void testFindMethod() throws NotFoundException {
361:                JDelegatingClassType testType = getTestType();
362:                JClassType baseType = testType.getBaseType();
363:
364:                validateFindMethod(baseType, testType, getSubstitution());
365:            }
366:
367:            /**
368:             * Test method for
369:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#findNestedType(java.lang.String)}.
370:             */
371:            public abstract void testFindNestedType() throws NotFoundException;
372:
373:            /**
374:             * Test method for
375:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#getAnnotation(java.lang.Class)}.
376:             */
377:            public void testGetAnnotation() throws NotFoundException {
378:                JDelegatingClassType testType = getTestType();
379:                JClassType baseType = testType.getBaseType();
380:
381:                Annotation[] annotations = baseType.getAnnotations();
382:                for (Annotation annotation : annotations) {
383:                    assertNotNull(testType.getAnnotation(annotation
384:                            .annotationType()));
385:                }
386:            }
387:
388:            /**
389:             * Test method for
390:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#getAnnotations()}.
391:             */
392:            public void testGetAnnotations() throws NotFoundException {
393:                JDelegatingClassType testType = getTestType();
394:                JClassType baseType = testType.getBaseType();
395:
396:                validateAnnotations(baseType, testType);
397:            }
398:
399:            /**
400:             * Test method for
401:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#getBaseType()}.
402:             */
403:            public void testGetBaseType() throws NotFoundException {
404:                JDelegatingClassType testType = getTestType();
405:                assertNotNull(testType.getBaseType());
406:            }
407:
408:            /**
409:             * Test method for
410:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#getCompilationUnit()}.
411:             */
412:            public void testGetCompilationUnit() throws NotFoundException {
413:                JDelegatingClassType testType = getTestType();
414:                JClassType baseType = testType.getBaseType();
415:
416:                assertEquals(testType.getCompilationUnit(), baseType
417:                        .getCompilationUnit());
418:            }
419:
420:            /**
421:             * Test method for
422:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#getConstructor(com.google.gwt.core.ext.typeinfo.JType[])}.
423:             */
424:            public void testGetConstructor() throws NotFoundException {
425:                JDelegatingClassType testType = getTestType();
426:                JClassType baseType = testType.getBaseType();
427:                baseType.getConstructors();
428:            }
429:
430:            /**
431:             * Test method for
432:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#getConstructors()}.
433:             */
434:            public void testGetConstructors() throws NotFoundException {
435:                JDelegatingClassType testType = getTestType();
436:                JClassType baseType = testType.getBaseType();
437:
438:                validateConstructorSubstitutions(baseType, testType,
439:                        getSubstitution());
440:            }
441:
442:            /**
443:             * Test method for
444:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#getDeclaredAnnotations()}.
445:             */
446:            public void testGetDeclaredAnnotations() throws NotFoundException {
447:                JDelegatingClassType testType = getTestType();
448:                JClassType baseType = testType.getBaseType();
449:
450:                validateDeclaredAnnotations(baseType, testType);
451:            }
452:
453:            /**
454:             * Test method for
455:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#getEnclosingType()}.
456:             */
457:            public abstract void testGetEnclosingType()
458:                    throws NotFoundException;
459:
460:            /**
461:             * Test method for
462:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#getErasedType()}.
463:             */
464:            public void testGetErasedType() throws NotFoundException {
465:                JDelegatingClassType testType = getTestType();
466:                JClassType baseType = testType.getBaseType();
467:
468:                assertEquals(baseType.getErasedType(), testType.getErasedType());
469:            }
470:
471:            /**
472:             * Test method for
473:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#getField(java.lang.String)}.
474:             */
475:            public void testGetField() throws NotFoundException {
476:                JDelegatingClassType testType = getTestType();
477:                JClassType baseType = testType.getBaseType();
478:
479:                validateGetField(baseType, testType);
480:            }
481:
482:            /**
483:             * Test method for
484:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#getFields()}.
485:             */
486:            public void testGetFields() throws NotFoundException {
487:                JDelegatingClassType testType = getTestType();
488:                JClassType baseType = testType.getBaseType();
489:
490:                validateFieldSubstitutions(baseType, testType,
491:                        getSubstitution());
492:            }
493:
494:            /**
495:             * Test method for
496:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#getImplementedInterfaces()}.
497:             */
498:            public void testGetImplementedInterfaces() throws NotFoundException {
499:                JDelegatingClassType testType = getTestType();
500:                JClassType baseType = testType.getBaseType();
501:
502:                validateImplementedInterfaceSubstitution(baseType, testType,
503:                        getSubstitution());
504:            }
505:
506:            /**
507:             * Test method for
508:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#getJNISignature()}.
509:             */
510:            public void testGetJNISignature() {
511:            }
512:
513:            /**
514:             * Test method for
515:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#getMetaData(java.lang.String)}.
516:             */
517:            public void testGetMetaData() throws NotFoundException {
518:                JDelegatingClassType testType = getTestType();
519:                JClassType baseType = testType.getBaseType();
520:
521:                validateMetaData(baseType, testType);
522:            }
523:
524:            /**
525:             * Test method for
526:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#getMetaDataTags()}.
527:             */
528:            public void testGetMetaDataTags() throws NotFoundException {
529:                JDelegatingClassType testType = getTestType();
530:                JClassType baseType = testType.getBaseType();
531:
532:                validateMetaDataTags(baseType, testType);
533:            }
534:
535:            /**
536:             * Test method for
537:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#getMethod(java.lang.String, com.google.gwt.core.ext.typeinfo.JType[])}.
538:             */
539:            public void testGetMethod() throws NotFoundException {
540:                JDelegatingClassType testType = getTestType();
541:                JClassType baseType = testType.getBaseType();
542:
543:                validateGetMethod(baseType, testType, getSubstitution());
544:            }
545:
546:            /**
547:             * Test method for
548:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#getMethods()}.
549:             */
550:            public void testGetMethods() throws NotFoundException {
551:                JDelegatingClassType testType = getTestType();
552:                JClassType baseType = testType.getBaseType();
553:
554:                validateMethodSubstitutions(baseType, testType,
555:                        getSubstitution());
556:            }
557:
558:            /**
559:             * Test method for
560:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#getModifierBits()}.
561:             */
562:            public void testGetModifierBits() throws NotFoundException {
563:                JDelegatingClassType testType = getTestType();
564:                JClassType baseType = testType.getBaseType();
565:
566:                assertEquals(baseType.getModifierBits(), testType
567:                        .getModifierBits());
568:            }
569:
570:            /**
571:             * Test method for
572:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#getName()}.
573:             */
574:            public void testGetName() throws NotFoundException {
575:                JDelegatingClassType testType = getTestType();
576:                JClassType baseType = testType.getBaseType();
577:
578:                assertEquals(baseType.getName(), testType.getName());
579:            }
580:
581:            /**
582:             * Test method for
583:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#getNestedType(java.lang.String)}.
584:             */
585:            public abstract void testGetNestedType() throws NotFoundException;
586:
587:            /**
588:             * Test method for
589:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#getNestedTypes()}.
590:             */
591:            public abstract void testGetNestedTypes() throws NotFoundException;
592:
593:            /**
594:             * Test method for
595:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#getOracle()}.
596:             */
597:            public void testGetOracle() throws NotFoundException {
598:                JDelegatingClassType testType = getTestType();
599:                JClassType baseType = testType.getBaseType();
600:
601:                assertEquals(baseType.getOracle(), testType.getOracle());
602:            }
603:
604:            /**
605:             * Test method for
606:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#getOverloads(java.lang.String)}.
607:             */
608:            public void testGetOverloads() throws NotFoundException {
609:                JDelegatingClassType testType = getTestType();
610:                JClassType baseType = testType.getBaseType();
611:
612:                validateGetOverloads(baseType, testType);
613:            }
614:
615:            /**
616:             * Test method for
617:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#getOverridableMethods()}.
618:             */
619:            public abstract void testGetOverridableMethods()
620:                    throws NotFoundException;
621:
622:            /**
623:             * Test method for
624:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#getPackage()}.
625:             */
626:            public void testGetPackage() throws NotFoundException {
627:                JDelegatingClassType testType = getTestType();
628:                JClassType baseType = testType.getBaseType();
629:
630:                assertEquals(baseType.getPackage(), testType.getPackage());
631:            }
632:
633:            /**
634:             * Test method for
635:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#getSubtypes()}.
636:             */
637:            public abstract void testGetSubtypes() throws NotFoundException;
638:
639:            /**
640:             * Test method for
641:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#getSuperclass()}.
642:             */
643:            public void testGetSuperclass() throws NotFoundException {
644:                JDelegatingClassType testType = getTestType();
645:                JClassType baseType = testType.getBaseType();
646:
647:                assertEquals(baseType.getSuperclass() != null, testType
648:                        .getSuperclass() != null);
649:
650:                /*
651:                 * TODO: need to check that the super classes are consistent, if base super
652:                 * is generic then test type super should be parameterized with same super,
653:                 * etc.
654:                 */
655:            }
656:
657:            /**
658:             * Test method for
659:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#isAbstract()}.
660:             */
661:            public void testIsAbstract() throws NotFoundException {
662:                JDelegatingClassType testType = getTestType();
663:                JClassType baseType = testType.getBaseType();
664:
665:                assertEquals(baseType.isAbstract(), testType.isAbstract());
666:            }
667:
668:            /**
669:             * Test method for
670:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#isAnnotationPresent(java.lang.Class)}.
671:             */
672:            public void testIsAnnotationPresent() throws NotFoundException {
673:                JDelegatingClassType testType = getTestType();
674:                JClassType baseType = testType.getBaseType();
675:
676:                Annotation[] annotations = baseType.getAnnotations();
677:                for (Annotation annotation : annotations) {
678:                    assertTrue(testType.isAnnotationPresent(annotation
679:                            .annotationType()));
680:                }
681:            }
682:
683:            /**
684:             * Test method for
685:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#isArray()}.
686:             */
687:            public void testIsArray() throws NotFoundException {
688:                JDelegatingClassType testType = getTestType();
689:                JClassType baseType = testType.getBaseType();
690:
691:                assertEquals(baseType.isArray(), testType.isArray());
692:
693:                // TODO: check parameterized arrays
694:            }
695:
696:            /**
697:             * Test method for
698:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#isAssignableFrom(com.google.gwt.core.ext.typeinfo.JClassType)}.
699:             */
700:            public abstract void testIsAssignableFrom()
701:                    throws NotFoundException;
702:
703:            /**
704:             * Test method for
705:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#isAssignableTo(com.google.gwt.core.ext.typeinfo.JClassType)}.
706:             */
707:            public abstract void testIsAssignableTo() throws NotFoundException;
708:
709:            /**
710:             * Test method for
711:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#isClass()}.
712:             */
713:            public void testIsClass() throws NotFoundException {
714:                JDelegatingClassType testType = getTestType();
715:                JClassType baseType = testType.getBaseType();
716:
717:                assertEquals(baseType.isClass() != null,
718:                        testType.isClass() != null);
719:            }
720:
721:            /**
722:             * Test method for
723:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#isClassOrInterface()}.
724:             */
725:            public void testIsClassOrInterface() throws NotFoundException {
726:                JDelegatingClassType testType = getTestType();
727:                JClassType baseType = testType.getBaseType();
728:
729:                assertEquals(baseType.isClassOrInterface() != null, testType
730:                        .isClassOrInterface() != null);
731:            }
732:
733:            /**
734:             * Test method for
735:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#isDefaultInstantiable()}.
736:             */
737:            public void testIsDefaultInstantiable() throws NotFoundException {
738:                JDelegatingClassType testType = getTestType();
739:                JClassType baseType = testType.getBaseType();
740:
741:                assertEquals(baseType.isDefaultInstantiable(), testType
742:                        .isDefaultInstantiable());
743:            }
744:
745:            /**
746:             * Test method for
747:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#isEnum()}.
748:             */
749:            public void testIsEnum() throws NotFoundException {
750:                JDelegatingClassType testType = getTestType();
751:                JClassType baseType = testType.getBaseType();
752:
753:                assertEquals(baseType.isEnum() != null,
754:                        testType.isEnum() != null);
755:            }
756:
757:            /**
758:             * Test method for
759:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#isInterface()}.
760:             */
761:            public void testIsInterface() throws NotFoundException {
762:                JDelegatingClassType testType = getTestType();
763:                JClassType baseType = testType.getBaseType();
764:
765:                assertEquals(baseType.isInterface() != null, testType
766:                        .isInterface() != null);
767:            }
768:
769:            /**
770:             * Test method for
771:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#isLocalType()}.
772:             */
773:            public void testIsLocalType() throws NotFoundException {
774:                JDelegatingClassType testType = getTestType();
775:                JClassType baseType = testType.getBaseType();
776:
777:                assertEquals(baseType.isLocalType(), testType.isLocalType());
778:            }
779:
780:            /**
781:             * Test method for
782:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#isMemberType()}.
783:             */
784:            public void testIsMemberType() throws NotFoundException {
785:                JDelegatingClassType testType = getTestType();
786:                JClassType baseType = testType.getBaseType();
787:
788:                assertEquals(baseType.isMemberType(), testType.isMemberType());
789:            }
790:
791:            /**
792:             * Test method for
793:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#isPrimitive()}.
794:             */
795:            public void testIsPrimitive() throws NotFoundException {
796:                JDelegatingClassType testType = getTestType();
797:                JClassType baseType = testType.getBaseType();
798:
799:                assertNull(testType.isPrimitive());
800:                assertNull(baseType.isPrimitive());
801:            }
802:
803:            /**
804:             * Test method for
805:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#isPrivate()}.
806:             */
807:            public void testIsPrivate() throws NotFoundException {
808:                JDelegatingClassType testType = getTestType();
809:                JClassType baseType = testType.getBaseType();
810:
811:                assertEquals(baseType.isPrivate(), testType.isPrivate());
812:            }
813:
814:            /**
815:             * Test method for
816:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#isProtected()}.
817:             */
818:            public void testIsProtected() throws NotFoundException {
819:                JDelegatingClassType testType = getTestType();
820:                JClassType baseType = testType.getBaseType();
821:
822:                assertEquals(baseType.isProtected(), testType.isProtected());
823:            }
824:
825:            /**
826:             * Test method for
827:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#isPublic()}.
828:             */
829:            public void testIsPublic() throws NotFoundException {
830:                JDelegatingClassType testType = getTestType();
831:                JClassType baseType = testType.getBaseType();
832:
833:                assertEquals(baseType.isPublic(), testType.isPublic());
834:            }
835:
836:            /**
837:             * Test method for
838:             * {@link com.google.gwt.core.ext.typeinfo.JDelegatingClassType#isStatic()}.
839:             */
840:            public void testIsStatic() throws NotFoundException {
841:                JDelegatingClassType testType = getTestType();
842:                JClassType baseType = testType.getBaseType();
843:
844:                assertEquals(baseType.isStatic(), testType.isStatic());
845:            }
846:
847:            protected abstract Substitution getSubstitution()
848:                    throws NotFoundException;
849:
850:            protected abstract JDelegatingClassType getTestType()
851:                    throws NotFoundException;
852:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.