From db791ba47d698d829ccac9fdb22b38d82a77492d Mon Sep 17 00:00:00 2001 From: acolyer Date: Fri, 8 Jul 2005 16:01:02 +0000 Subject: [PATCH] moved some tests with 1.5 dependencies --- run-all-junit-tests/testsrc/AllTests.java | 2 + weaver/testsrc/BcweaverModuleTests.java | 16 +--- weaver/testsrc/BcweaverModuleTests15.java | 36 +++++++++ .../weaver/GenericsWildCardTypeXTestCase.java | 4 +- .../org/aspectj/weaver/MemberTestCase.java | 51 ------------- .../org/aspectj/weaver/MemberTestCase15.java | 75 +++++++++++++++++++ .../ParameterizedReferenceTypeTestCase.java | 68 +++++++++++++++++ .../TypeVariableReferenceTypeTestCase.java | 10 +-- .../org/aspectj/weaver/TypeXTestCase.java | 2 +- 9 files changed, 189 insertions(+), 75 deletions(-) create mode 100644 weaver/testsrc/BcweaverModuleTests15.java create mode 100644 weaver/testsrc/org/aspectj/weaver/MemberTestCase15.java create mode 100644 weaver/testsrc/org/aspectj/weaver/ParameterizedReferenceTypeTestCase.java diff --git a/run-all-junit-tests/testsrc/AllTests.java b/run-all-junit-tests/testsrc/AllTests.java index 116812b20..051d2deb1 100644 --- a/run-all-junit-tests/testsrc/AllTests.java +++ b/run-all-junit-tests/testsrc/AllTests.java @@ -47,6 +47,8 @@ public class AllTests extends TestCase { // 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")); } diff --git a/weaver/testsrc/BcweaverModuleTests.java b/weaver/testsrc/BcweaverModuleTests.java index b5ca63a48..229cb3d1d 100644 --- a/weaver/testsrc/BcweaverModuleTests.java +++ b/weaver/testsrc/BcweaverModuleTests.java @@ -12,16 +12,13 @@ // 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() { @@ -30,11 +27,6 @@ public class BcweaverModuleTests extends TestCase { 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; } diff --git a/weaver/testsrc/BcweaverModuleTests15.java b/weaver/testsrc/BcweaverModuleTests15.java new file mode 100644 index 000000000..c00f055f1 --- /dev/null +++ b/weaver/testsrc/BcweaverModuleTests15.java @@ -0,0 +1,36 @@ +/* ******************************************************************* + * 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); } +} diff --git a/weaver/testsrc/org/aspectj/weaver/GenericsWildCardTypeXTestCase.java b/weaver/testsrc/org/aspectj/weaver/GenericsWildCardTypeXTestCase.java index b3d127b1b..942812071 100644 --- a/weaver/testsrc/org/aspectj/weaver/GenericsWildCardTypeXTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/GenericsWildCardTypeXTestCase.java @@ -23,13 +23,13 @@ public class GenericsWildCardTypeXTestCase extends TestCase { 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()); } diff --git a/weaver/testsrc/org/aspectj/weaver/MemberTestCase.java b/weaver/testsrc/org/aspectj/weaver/MemberTestCase.java index 117cf6b22..f1ac6e997 100644 --- a/weaver/testsrc/org/aspectj/weaver/MemberTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/MemberTestCase.java @@ -145,57 +145,6 @@ public class MemberTestCase extends TestCase { 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()); } diff --git a/weaver/testsrc/org/aspectj/weaver/MemberTestCase15.java b/weaver/testsrc/org/aspectj/weaver/MemberTestCase15.java new file mode 100644 index 000000000..03111165e --- /dev/null +++ b/weaver/testsrc/org/aspectj/weaver/MemberTestCase15.java @@ -0,0 +1,75 @@ +/* ******************************************************************* + * 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()); + } + } + +} diff --git a/weaver/testsrc/org/aspectj/weaver/ParameterizedReferenceTypeTestCase.java b/weaver/testsrc/org/aspectj/weaver/ParameterizedReferenceTypeTestCase.java new file mode 100644 index 000000000..6a7db20f6 --- /dev/null +++ b/weaver/testsrc/org/aspectj/weaver/ParameterizedReferenceTypeTestCase.java @@ -0,0 +1,68 @@ +/* ******************************************************************* + * 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"})); + } +} diff --git a/weaver/testsrc/org/aspectj/weaver/TypeVariableReferenceTypeTestCase.java b/weaver/testsrc/org/aspectj/weaver/TypeVariableReferenceTypeTestCase.java index de75f49be..1ab0c287b 100644 --- a/weaver/testsrc/org/aspectj/weaver/TypeVariableReferenceTypeTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/TypeVariableReferenceTypeTestCase.java @@ -27,19 +27,11 @@ public class TypeVariableReferenceTypeTestCase extends TestCase { 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()); } diff --git a/weaver/testsrc/org/aspectj/weaver/TypeXTestCase.java b/weaver/testsrc/org/aspectj/weaver/TypeXTestCase.java index ca6b27329..6c39a1ef0 100644 --- a/weaver/testsrc/org/aspectj/weaver/TypeXTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/TypeXTestCase.java @@ -106,7 +106,7 @@ public class TypeXTestCase extends TestCase { 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()); -- 2.39.5