// so the class name can only be used reflectively
TestUtil.loadTestsReflectively(suite, "Aspectj5rtModuleTests", false);
TestUtil.loadTestsReflectively(suite, "Loadtime5ModuleTests", false);
+ // this next one is built normally, but needs 1.5 rt.jar to pass
+ suite.addTest(BcweaverModuleTests15.suite());
} else {
suite.addTest(TestUtil.skipTest("for 1.5"));
}
// default package
-import org.aspectj.weaver.BoundedReferenceTypeTestCase;
-import org.aspectj.weaver.GenericsWildCardTypeXTestCase;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
import org.aspectj.weaver.LocaleTest;
-import org.aspectj.weaver.ReferenceTypeTestCase;
-import org.aspectj.weaver.TypeVariableReferenceTypeTestCase;
-import org.aspectj.weaver.TypeVariableTestCase;
import org.aspectj.weaver.tools.ToolsTests;
-import junit.framework.*;
-
public class BcweaverModuleTests extends TestCase {
public static Test suite() {
suite.addTest(org.aspectj.weaver.BcweaverTests.suite());
suite.addTest(org.aspectj.weaver.patterns.PatternsTests.suite());
suite.addTestSuite(LocaleTest.class);
- suite.addTestSuite(TypeVariableTestCase.class);
- suite.addTestSuite(ReferenceTypeTestCase.class);
- suite.addTestSuite(BoundedReferenceTypeTestCase.class);
- suite.addTestSuite(TypeVariableReferenceTypeTestCase.class);
- suite.addTestSuite(GenericsWildCardTypeXTestCase.class);
suite.addTest(ToolsTests.suite());
return suite;
}
--- /dev/null
+/* *******************************************************************
+ * 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
+ * ******************************************************************/
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.aspectj.weaver.BoundedReferenceTypeTestCase;
+import org.aspectj.weaver.GenericsWildCardTypeXTestCase;
+import org.aspectj.weaver.MemberTestCase15;
+import org.aspectj.weaver.ReferenceTypeTestCase;
+import org.aspectj.weaver.TypeVariableReferenceTypeTestCase;
+import org.aspectj.weaver.TypeVariableTestCase;
+
+public class BcweaverModuleTests15 extends TestCase {
+ public static Test suite() {
+ TestSuite suite = new TestSuite(BcweaverModuleTests15.class.getName());
+ suite.addTestSuite(TypeVariableTestCase.class);
+ suite.addTestSuite(ReferenceTypeTestCase.class);
+ suite.addTestSuite(BoundedReferenceTypeTestCase.class);
+ suite.addTestSuite(TypeVariableReferenceTypeTestCase.class);
+ suite.addTestSuite(GenericsWildCardTypeXTestCase.class);
+ suite.addTestSuite(MemberTestCase15.class);
+ return suite;
+ }
+
+ public BcweaverModuleTests15(String name) { super(name); }
+}
public void testIdentity() {
TypeX anything = GenericsWildcardTypeX.GENERIC_WILDCARD;
- assertEquals("?",anything.getSignature());
+ assertEquals("Ljava/lang/Object;",anything.getSignature());
}
public void testResolving() {
BoundedReferenceType brt = (BoundedReferenceType)
GenericsWildcardTypeX.GENERIC_WILDCARD.resolve(new BcelWorld());
- assertEquals("?",brt.getSignature());
+ assertEquals("Ljava/lang/Object;",brt.getSignature());
assertTrue(brt.isExtends());
assertEquals("Ljava/lang/Object;",brt.getUpperBound().getSignature());
}
isStaticTest(m, true);
}
- public void testCanBeParameterizedRegularMethod() {
- BcelWorld world = new BcelWorld();
- ResolvedTypeX javaLangClass = world.resolve(TypeX.forName("java/lang/Class"));
- ResolvedMember[] methods = javaLangClass.getDeclaredMethods();
- ResolvedMember getAnnotations = null;
- for (int i = 0; i < methods.length; i++) {
- if (methods[i].getName().equals("getAnnotations")) {
- getAnnotations = methods[i];
- break;
- }
- }
- if (getAnnotations != null) { // so can run on non-Java 5
-// System.out.println("got it");
- assertFalse(getAnnotations.canBeParameterized());
- }
- }
-
- public void testCanBeParameterizedGenericMethod() {
- BcelWorld world = new BcelWorld();
- ResolvedTypeX javaLangClass = world.resolve(TypeX.forName("java/lang/Class"));
- ResolvedMember[] methods = javaLangClass.getDeclaredMethods();
- ResolvedMember asSubclass = null;
- for (int i = 0; i < methods.length; i++) {
- if (methods[i].getName().equals("asSubclass")) {
- asSubclass = methods[i];
- break;
- }
- }
- if (asSubclass != null) { // so can run on non-Java 5
-// System.out.println("got it");
- assertTrue(asSubclass.canBeParameterized());
- }
- }
-
- public void testCanBeParameterizedMethodInGenericType() {
- BcelWorld world = new BcelWorld();
- ResolvedTypeX javaUtilList = world.resolve(TypeX.forName("java/util/List"));
- ResolvedMember[] methods = javaUtilList.getDeclaredMethods();
- ResolvedMember add = null;
- for (int i = 0; i < methods.length; i++) {
- if (methods[i].getName().equals("add")) {
- add = methods[i];
- break;
- }
- }
- if (add != null) { // so can run on non-Java 5
-// System.out.println("got it");
- assertTrue(add.canBeParameterized());
- }
- }
-
private void isStaticTest(Member m, boolean b) {
assertEquals(m + " is static", b, m.isStatic());
}
--- /dev/null
+/* *******************************************************************
+ * 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.weaver;
+
+import org.aspectj.weaver.bcel.BcelWorld;
+
+import junit.framework.TestCase;
+
+/**
+ * @author colyer
+ *
+ */
+public class MemberTestCase15 extends TestCase {
+
+ public void testCanBeParameterizedRegularMethod() {
+ BcelWorld world = new BcelWorld();
+ ResolvedTypeX javaLangClass = world.resolve(TypeX.forName("java/lang/Class"));
+ ResolvedMember[] methods = javaLangClass.getDeclaredMethods();
+ ResolvedMember getAnnotations = null;
+ for (int i = 0; i < methods.length; i++) {
+ if (methods[i].getName().equals("getAnnotations")) {
+ getAnnotations = methods[i];
+ break;
+ }
+ }
+ if (getAnnotations != null) { // so can run on non-Java 5
+// System.out.println("got it");
+ assertFalse(getAnnotations.canBeParameterized());
+ }
+ }
+
+ public void testCanBeParameterizedGenericMethod() {
+ BcelWorld world = new BcelWorld();
+ ResolvedTypeX javaLangClass = world.resolve(TypeX.forName("java/lang/Class"));
+ ResolvedMember[] methods = javaLangClass.getDeclaredMethods();
+ ResolvedMember asSubclass = null;
+ for (int i = 0; i < methods.length; i++) {
+ if (methods[i].getName().equals("asSubclass")) {
+ asSubclass = methods[i];
+ break;
+ }
+ }
+ if (asSubclass != null) { // so can run on non-Java 5
+// System.out.println("got it");
+ assertTrue(asSubclass.canBeParameterized());
+ }
+ }
+
+ public void testCanBeParameterizedMethodInGenericType() {
+ BcelWorld world = new BcelWorld();
+ ResolvedTypeX javaUtilList = world.resolve(TypeX.forName("java/util/List"));
+ ResolvedMember[] methods = javaUtilList.getDeclaredMethods();
+ ResolvedMember add = null;
+ for (int i = 0; i < methods.length; i++) {
+ if (methods[i].getName().equals("add")) {
+ add = methods[i];
+ break;
+ }
+ }
+ if (add != null) { // so can run on non-Java 5
+// System.out.println("got it");
+ assertTrue(add.canBeParameterized());
+ }
+ }
+
+}
--- /dev/null
+/* *******************************************************************
+ * 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.weaver;
+
+import org.aspectj.weaver.bcel.BcelWorld;
+
+import junit.framework.TestCase;
+
+/**
+ * @author colyer
+ * For a parameterized reference type, the methods that return members
+ * - getDeclaredFields
+ * - getDeclaredMethods
+ * - getDeclaredInterfaces
+ * - getDeclaredPointcuts
+ * should have any type variables substituted by the given type parameter before
+ * being returned.
+ */
+public class ParameterizedReferenceTypeTestCase extends TestCase {
+
+ BcelWorld world;
+ ReferenceType listOfString;
+
+ public void testDeclaredMethodWithParameter() {
+ ResolvedMember[] methods = listOfString.getDeclaredMethods();
+ ResolvedMember add = null;
+ for (int i = 0; i < methods.length; i++) {
+ if (methods[i].getName().equals("add")) {
+ if (methods[i].getParameterTypes().length == 1) {
+ add = methods[i];
+ break;
+ }
+ }
+ }
+ TypeX parameterType = add.getParameterTypes()[0];
+ assertEquals("Ljava/lang/String;",parameterType.getSignature());
+
+ ResolvedMember get = null;
+ for (int i = 0; i < methods.length; i++) {
+ if (methods[i].getName().equals("get")) {
+ if (methods[i].getParameterTypes().length == 1) {
+ get = methods[i];
+ break;
+ }
+ }
+ }
+ TypeX returnType = get.getReturnType();
+ assertEquals("Ljava/lang/String;",returnType.getSignature());
+
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ world = new BcelWorld();
+ listOfString = (ReferenceType)
+ world.resolve(TypeX.forParameterizedTypeNames("java/util/List",
+ new String[] {"java/lang/String"}));
+ }
+}
BoundedReferenceType superClass;
BoundedReferenceType extendsWithExtras;
BcelWorld world;
-
- public void testConstructionByNameAndBound() {
- TypeVariableReferenceType tvrt = new TypeVariableReferenceType("T",javaLangClass,true,world);
- assertEquals("T",tvrt.getTypeVariableName());
- assertTrue(tvrt.isExtends);
- assertEquals(javaLangClass,tvrt.getUpperBound());
- }
public void testConstructionByNameAndVariable() {
TypeVariable tv = new TypeVariable("T",javaLangClass);
TypeVariableReferenceType tvrt = new TypeVariableReferenceType(tv,world);
- assertEquals("T",tvrt.getTypeVariableName());
- assertTrue(tvrt.isExtends);
+ assertEquals("T",tvrt.getTypeVariable().getName());
assertEquals(javaLangClass,tvrt.getUpperBound());
}
public void testTypeXForParameterizedTypes() {
TypeX stringType = TypeX.forName("java/lang/String");
- TypeX listOfStringType = TypeX.forParameterizedTypes("java/util/List", new TypeX[] {stringType});
+ TypeX listOfStringType = TypeX.forParameterizedTypes(TypeX.forName("java/util/List"), new TypeX[] {stringType});
assertEquals("1 type param",1,listOfStringType.typeParameters.length);
assertEquals(stringType,listOfStringType.typeParameters[0]);
assertTrue(listOfStringType.isParameterized());