]> source.dussan.org Git - aspectj.git/commitdiff
moved some tests with 1.5 dependencies
authoracolyer <acolyer>
Fri, 8 Jul 2005 16:01:02 +0000 (16:01 +0000)
committeracolyer <acolyer>
Fri, 8 Jul 2005 16:01:02 +0000 (16:01 +0000)
run-all-junit-tests/testsrc/AllTests.java
weaver/testsrc/BcweaverModuleTests.java
weaver/testsrc/BcweaverModuleTests15.java [new file with mode: 0644]
weaver/testsrc/org/aspectj/weaver/GenericsWildCardTypeXTestCase.java
weaver/testsrc/org/aspectj/weaver/MemberTestCase.java
weaver/testsrc/org/aspectj/weaver/MemberTestCase15.java [new file with mode: 0644]
weaver/testsrc/org/aspectj/weaver/ParameterizedReferenceTypeTestCase.java [new file with mode: 0644]
weaver/testsrc/org/aspectj/weaver/TypeVariableReferenceTypeTestCase.java
weaver/testsrc/org/aspectj/weaver/TypeXTestCase.java

index 116812b20e56567b84bc13398cb95bfc7c4acee3..051d2deb1b10de3a92b6fe11e25ac42d157a95e2 100644 (file)
@@ -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"));
         } 
index b5ca63a483c8fd074610bd569c5947e0f68810b7..229cb3d1defa1df254577add25563e98fe66b637 100644 (file)
 
 // 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 (file)
index 0000000..c00f055
--- /dev/null
@@ -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); }
+}
index b3d127b1bdb66b57411a995d59115ddd6f6d679c..942812071a770699a0f58b957b85e0cc1ec6f6c5 100644 (file)
@@ -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());
        }
index 117cf6b22bf23baceb2d167cedc0de959b728ddc..f1ac6e997a1837c5099b10ec259daf53665a9461 100644 (file)
@@ -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 (file)
index 0000000..0311116
--- /dev/null
@@ -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 (file)
index 0000000..6a7db20
--- /dev/null
@@ -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"}));
+       }
+}
index de75f49be7702482b328b7fd75d3d63b8276ff74..1ab0c287b979a4b9857b3449d59d22fd7bd2c12b 100644 (file)
@@ -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());
        }
        
index ca6b27329f79f35da7d72209be1c4c8575ecd0f2..6c39a1ef098faba324b22e9b90f418a3895e31dd 100644 (file)
@@ -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());