diff options
author | acolyer <acolyer> | 2005-10-04 13:56:38 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-10-04 13:56:38 +0000 |
commit | b305f9ee512015657cad0ea722b8180d884b1f72 (patch) | |
tree | 1b9c2696672575838f39cc58bd86ba61eecaba79 /aspectj5rt/java5-testsrc | |
parent | 32a02ec2a3e15651249d5d7cc5f63fa409468b2a (diff) | |
download | aspectj-b305f9ee512015657cad0ea722b8180d884b1f72.tar.gz aspectj-b305f9ee512015657cad0ea722b8180d884b1f72.zip |
itd support in the MAP
Diffstat (limited to 'aspectj5rt/java5-testsrc')
3 files changed, 91 insertions, 0 deletions
diff --git a/aspectj5rt/java5-testsrc/Aspectj5rt15ModuleTests.java b/aspectj5rt/java5-testsrc/Aspectj5rt15ModuleTests.java index b0ab7d1fe..c1d54dc67 100644 --- a/aspectj5rt/java5-testsrc/Aspectj5rt15ModuleTests.java +++ b/aspectj5rt/java5-testsrc/Aspectj5rt15ModuleTests.java @@ -18,6 +18,7 @@ import junit.framework.TestSuite; import org.aspectj.internal.lang.reflect.AjTypeTests; import org.aspectj.internal.lang.reflect.AjTypeTestsWithAspects; +import org.aspectj.internal.lang.reflect.InterTypeTests; public class Aspectj5rt15ModuleTests extends TestCase { @@ -25,6 +26,7 @@ public class Aspectj5rt15ModuleTests extends TestCase { TestSuite suite = new TestSuite("Aspectj5rt module tests"); suite.addTestSuite(AjTypeTests.class); suite.addTestSuite(AjTypeTestsWithAspects.class); + suite.addTestSuite(InterTypeTests.class); return suite; } diff --git a/aspectj5rt/java5-testsrc/org/aspectj/internal/lang/reflect/AjTypeTestsWithAspects.java b/aspectj5rt/java5-testsrc/org/aspectj/internal/lang/reflect/AjTypeTestsWithAspects.java index 7b15d3e64..d2fad06b0 100644 --- a/aspectj5rt/java5-testsrc/org/aspectj/internal/lang/reflect/AjTypeTestsWithAspects.java +++ b/aspectj5rt/java5-testsrc/org/aspectj/internal/lang/reflect/AjTypeTestsWithAspects.java @@ -17,6 +17,7 @@ import java.lang.reflect.Modifier; import junit.framework.TestCase; import org.aspectj.internal.lang.annotation.ajcDeclareEoW; +import org.aspectj.internal.lang.annotation.ajcITD; import org.aspectj.internal.lang.annotation.ajcPrivileged; import org.aspectj.lang.annotation.AdviceName; import org.aspectj.lang.annotation.After; diff --git a/aspectj5rt/java5-testsrc/org/aspectj/internal/lang/reflect/InterTypeTests.java b/aspectj5rt/java5-testsrc/org/aspectj/internal/lang/reflect/InterTypeTests.java new file mode 100644 index 000000000..ae7939bb6 --- /dev/null +++ b/aspectj5rt/java5-testsrc/org/aspectj/internal/lang/reflect/InterTypeTests.java @@ -0,0 +1,88 @@ +/* ******************************************************************* + * Copyright (c) 2005 Contributors. + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://eclipse.org/legal/epl-v10.html + * + * Contributors: + * Adrian Colyer Initial implementation + * ******************************************************************/ +package org.aspectj.internal.lang.reflect; + +import java.lang.reflect.Method; +import java.lang.reflect.Type; + +import org.aspectj.lang.reflect.AjType; +import org.aspectj.lang.reflect.AjTypeSystem; +import org.aspectj.lang.reflect.InterTypeConstructorDeclaration; +import org.aspectj.lang.reflect.InterTypeDeclaration; +import org.aspectj.lang.reflect.InterTypeFieldDeclaration; +import org.aspectj.lang.reflect.InterTypeMethodDeclaration; + +import junit.framework.TestCase; + +/** + * @author colyer + * + */ +public class InterTypeTests extends TestCase { + + public void testITDImpl() throws ClassNotFoundException { + AjType<InterTypeTests> thisClass = AjTypeSystem.getAjType(InterTypeTests.class); + AjType<Runnable> runnable = AjTypeSystem.getAjType(java.lang.Runnable.class); + InterTypeDeclaration itd = new InterTypeDeclarationImpl(thisClass,"java.lang.Runnable",5); + assertEquals(thisClass,itd.getDeclaringType()); + assertEquals(runnable,itd.getTargetType()); + assertEquals(5, itd.getModifiers()); + } + + public void testITDField() throws ClassNotFoundException { + AjType<InterTypeTests> thisClass = AjTypeSystem.getAjType(InterTypeTests.class); + AjType<Runnable> runnable = AjTypeSystem.getAjType(java.lang.Runnable.class); + InterTypeDeclaration itd = new InterTypeDeclarationImpl(thisClass,"java.lang.Runnable",5); + AjType<String> stringType = AjTypeSystem.getAjType(java.lang.String.class); + Type t = Type.class; + InterTypeFieldDeclaration itdf = new InterTypeFieldDeclarationImpl(thisClass,"java.lang.Runnable",5,"f",stringType,t); + assertEquals("f",itdf.getName()); + assertEquals(stringType,itdf.getType()); + assertEquals(t,itdf.getGenericType()); + } + + public void testITDCons() throws ClassNotFoundException, NoSuchMethodException { + AjType<InterTypeTests> thisClass = AjTypeSystem.getAjType(InterTypeTests.class); + AjType<Runnable> runnable = AjTypeSystem.getAjType(java.lang.Runnable.class); + Method base = InterTypeTests.class.getDeclaredMethod("interCons",InterTypeTests.class,String.class,int.class); + InterTypeConstructorDeclaration itdc = + new InterTypeConstructorDeclarationImpl(thisClass,"java.lang.Runnable",5,base); + assertEquals(2,itdc.getParameterTypes().length); + assertEquals(String.class,itdc.getParameterTypes()[0].getJavaClass()); + assertEquals(int.class,itdc.getParameterTypes()[1].getJavaClass()); + assertEquals(2,itdc.getGenericParameterTypes().length); + assertEquals(base.getGenericParameterTypes()[1],((AjType<?>)itdc.getGenericParameterTypes()[0]).getJavaClass()); + assertEquals(base.getGenericParameterTypes()[2],((AjType<?>)itdc.getGenericParameterTypes()[1]).getJavaClass()); + assertEquals(0,itdc.getExceptionTypes().length); + } + + public void testITDMethod() throws NoSuchMethodException { + AjType<InterTypeTests> thisClass = AjTypeSystem.getAjType(InterTypeTests.class); + AjType<Runnable> runnable = AjTypeSystem.getAjType(java.lang.Runnable.class); + Method base = InterTypeTests.class.getDeclaredMethod("interMethod",InterTypeTests.class,String.class,int.class); + InterTypeMethodDeclaration itdm = new InterTypeMethodDeclarationImpl(thisClass,"java.lang.Runnable",5,"foo",base); + assertEquals("foo",itdm.getName()); + assertEquals(int.class,itdm.getReturnType().getJavaClass()); + assertEquals(int.class,((AjType<?>)itdm.getGenericReturnType()).getJavaClass()); + assertEquals(2,itdm.getParameterTypes().length); + assertEquals(String.class,itdm.getParameterTypes()[0].getJavaClass()); + assertEquals(int.class,itdm.getParameterTypes()[1].getJavaClass()); + assertEquals(2,itdm.getGenericParameterTypes().length); + assertEquals(base.getGenericParameterTypes()[1],((AjType<?>)itdm.getGenericParameterTypes()[0]).getJavaClass()); + assertEquals(base.getGenericParameterTypes()[2],((AjType<?>)itdm.getGenericParameterTypes()[1]).getJavaClass()); + assertEquals(0,itdm.getExceptionTypes().length); + } + + public static void interCons(InterTypeTests itt, String s, int i) { } + + public static int interMethod(InterTypeTests itt, String s, int i) { return 5; } +} |