diff options
author | aclement <aclement> | 2005-11-25 09:39:43 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-11-25 09:39:43 +0000 |
commit | 749461102f3d5b4d89cf0b1ad744be97e161951b (patch) | |
tree | 5b91f41d853445db16480f18ae476826a1a2d0c2 /weaver5/java5-testsrc | |
parent | 9f5c8ea89b848be4f0d8a88bbc595dbd84d0846d (diff) | |
download | aspectj-749461102f3d5b4d89cf0b1ad744be97e161951b.tar.gz aspectj-749461102f3d5b4d89cf0b1ad744be97e161951b.zip |
fixes and improved tests for 117622
Diffstat (limited to 'weaver5/java5-testsrc')
-rw-r--r-- | weaver5/java5-testsrc/org/aspectj/weaver/TestJava5ReflectionBasedReferenceTypeDelegate.java | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/TestJava5ReflectionBasedReferenceTypeDelegate.java b/weaver5/java5-testsrc/org/aspectj/weaver/TestJava5ReflectionBasedReferenceTypeDelegate.java index 450d00c6d..aadfd525b 100644 --- a/weaver5/java5-testsrc/org/aspectj/weaver/TestJava5ReflectionBasedReferenceTypeDelegate.java +++ b/weaver5/java5-testsrc/org/aspectj/weaver/TestJava5ReflectionBasedReferenceTypeDelegate.java @@ -4,22 +4,35 @@ import org.aspectj.weaver.reflect.ReflectionBasedReferenceTypeDelegateTest; public class TestJava5ReflectionBasedReferenceTypeDelegate extends ReflectionBasedReferenceTypeDelegateTest { + /** + * Let's play about with a generic type and ensure we can work with it in a reflective world. + */ public void testResolveGeneric() { - UnresolvedType collectionType = UnresolvedType.forName("java.util.Collection<E>"); -// ResolvedType rt= world.resolve(collectionType); -// ResolvedMember[] methods = world.resolve(collectionType).getDeclaredMethods(); -// assertTrue(findMethod("toArray", methods) != -1); + UnresolvedType collectionType = UnresolvedType.forName("java.util.Collection"); + ResolvedType rt= world.resolve(collectionType).getRawType().resolve(world); + ResolvedMember[] methods = world.resolve(collectionType).getDeclaredMethods(); + int i = findMethod("toArray", methods); + assertTrue("Couldn't find 'toArray' in the set of methods? "+methods,i != -1); + String expectedSignature = "T[] java.util.Collection.toArray(T[])"; + assertTrue("Expected signature of '"+expectedSignature+"' but it was '"+methods[i],methods[i].toString().equals(expectedSignature)); + } + + /** + * Can we resolve the dreaded Enum type... + */ + public void testResolveEnum() { + ResolvedType enumType = world.resolve("java.lang.Enum"); + assertTrue("Should be the raw type but is "+enumType.typeKind,enumType.isRawType()); + ResolvedType theGenericEnumType = enumType.getGenericType(); + assertTrue("Should have a type variable ",theGenericEnumType.getTypeVariables().length>0); + TypeVariable tv = theGenericEnumType.getTypeVariables()[0]; + String expected = "TypeVar E extends java.lang.Enum<E>"; + assertTrue("Type variable should be '"+expected+"' but is '"+tv+"'",tv.toString().equals(expected)); } public void testResolveClass() { - //stack overflow - world.resolve("java.lang.Class"); + world.resolve("java.lang.Class").getGenericType(); } - // just here to override the super one so it doesnt run in this case ;) - public void testGetDeclaredMethods() { - - } - - + } |