]> source.dussan.org Git - aspectj.git/commitdiff
Guard test execution on 1.5 vm level
authoraclement <aclement>
Fri, 11 Mar 2005 09:43:11 +0000 (09:43 +0000)
committeraclement <aclement>
Fri, 11 Mar 2005 09:43:11 +0000 (09:43 +0000)
weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java
weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java

index e7fdbdca99a57db287487a9b72d571304b5f0a68..e9173723d722d8ab29f9ed7415383e5b38b56bd1 100644 (file)
@@ -61,6 +61,19 @@ public class AnnotationPatternMatchingTestCase extends TestCase {
        private BcelWorld world;
        private AnnotationTypePattern fooTP,simpleAnnotationTP;
        
+       private static boolean is13VMOrGreater = true;
+       private static boolean is14VMOrGreater = true;
+       private static boolean is15VMOrGreater = false;
+       
+       static {
+               String vm = System.getProperty("java.vm.version");
+               if (vm.startsWith("1.3")) {
+                       is14VMOrGreater = false;
+               } else if (vm.startsWith("1.5")) {
+                       is15VMOrGreater = true;
+               }
+       }
+       
        private ResolvedTypeX loadType(String name) {
                if (world == null) {
                  world = new BcelWorld(BcweaverTests.TESTDATA_PATH + "/testcode.jar");
@@ -80,7 +93,7 @@ public class AnnotationPatternMatchingTestCase extends TestCase {
        
        
        public void testAnnotationPatternMatchingOnTypes() {
-               
+               if (is15VMOrGreater) {
                ResolvedTypeX rtx = loadType("AnnotatedClass");
         initAnnotationTypePatterns();          
                
@@ -89,6 +102,7 @@ public class AnnotationPatternMatchingTestCase extends TestCase {
                                   fooTP.matches(rtx).alwaysFalse());
                assertTrue("@SimpleAnnotation should match on the AnnotatedClass",
                                   simpleAnnotationTP.matches(rtx).alwaysTrue());
+               }
 
        }
        
@@ -155,7 +169,7 @@ public class AnnotationPatternMatchingTestCase extends TestCase {
        }
        
        public void testAnnotationPatternMatchingOnMethods() {
-               
+               if (is15VMOrGreater) {
                ResolvedTypeX rtx = loadType("AnnotatedClass");
                ResolvedMember aMethod = rtx.getDeclaredMethods()[1];
         
@@ -169,11 +183,11 @@ public class AnnotationPatternMatchingTestCase extends TestCase {
                                   fooTP.matches(aMethod).alwaysFalse());
                assertTrue("@SimpleAnnotation should match on the AnnotatedClass.m1() method",
                                   simpleAnnotationTP.matches(aMethod).alwaysTrue());
-
+               }
        }
        
        public void testAnnotationPatternMatchingOnFields() {
-               
+               if (is15VMOrGreater) {
                ResolvedTypeX rtx = loadType("AnnotatedClass");
                ResolvedMember aField = rtx.getDeclaredFields()[0];
 
@@ -187,6 +201,7 @@ public class AnnotationPatternMatchingTestCase extends TestCase {
                                   fooTP.matches(aField).alwaysFalse());
                assertTrue("@SimpleAnnotation should match on the AnnotatedClass.i field",
                                   simpleAnnotationTP.matches(aField).alwaysTrue());
+               }
 
        }
        
index 47b6d46b6c0cbb55ec8f988fe436c1cc84ab28c7..02f0e274ec9683292de76055eeca845f049de11e 100644 (file)
@@ -19,7 +19,20 @@ import org.aspectj.weaver.bcel.BcelWorld;
 import junit.framework.TestCase;
 
 public class AnnotationPatternTestCase extends TestCase {
-
+       
+       private static boolean is13VMOrGreater = true;
+       private static boolean is14VMOrGreater = true;
+       private static boolean is15VMOrGreater = false;
+       
+       static {
+               String vm = System.getProperty("java.vm.version");
+               if (vm.startsWith("1.3")) {
+                       is14VMOrGreater = false;
+               } else if (vm.startsWith("1.5")) {
+                       is15VMOrGreater = true;
+               }
+       }
+       
        public void testParseSimpleAnnotationPattern() {
                PatternParser p = new PatternParser("@Foo");
                AnnotationTypePattern foo = p.maybeParseAnnotationPattern();
@@ -241,6 +254,7 @@ public class AnnotationPatternTestCase extends TestCase {
        }
        
        public void testExactAnnotationPatternMatching() {
+               if (is15VMOrGreater) {
                PatternParser p = new PatternParser("@Foo");
                AnnotationTypePattern ap = p.maybeParseAnnotationPattern();
                ap = ap.resolveBindings(makeSimpleScope(),new Bindings(3),true);
@@ -248,9 +262,11 @@ public class AnnotationPatternTestCase extends TestCase {
                assertTrue("matches element with Foo",ap.matches(ae).alwaysTrue());
                AnnotatedElementImpl ae2 = new AnnotatedElementImpl(new String[]{"Boo"});
                assertTrue("does not match element with Boo",ap.matches(ae2).alwaysFalse());
+               }
        }
        
        public void testBindingAnnotationPatternMatching() {
+               if (is15VMOrGreater) {
                PatternParser p = new PatternParser("foo");
                AnnotationTypePattern ap = p.parseAnnotationNameOrVarTypePattern();
                try {
@@ -263,9 +279,11 @@ public class AnnotationPatternTestCase extends TestCase {
 //             assertTrue("matches element with Foo",ap.matches(ae).alwaysTrue());
 //             AnnotatedElementImpl ae2 = new AnnotatedElementImpl(new String[]{"Boo"});
 //             assertTrue("does not match element with Boo",ap.matches(ae2).alwaysFalse());
+               }
        }
        
        public void testAndAnnotationPatternMatching() {
+               if (is15VMOrGreater) {
                PatternParser p = new PatternParser("@Foo @Boo");
                AnnotationTypePattern ap = p.maybeParseAnnotationPattern();
                ap = ap.resolveBindings(makeSimpleScope(),new Bindings(3),true);
@@ -276,7 +294,8 @@ public class AnnotationPatternTestCase extends TestCase {
                ae = new AnnotatedElementImpl(new String[] {"Boo"});
                assertTrue("does not match boo",ap.matches(ae).alwaysFalse());
                ae = new AnnotatedElementImpl(new String[] {"Goo"});
-               assertTrue("does not match goo",ap.matches(ae).alwaysFalse());          
+               assertTrue("does not match goo",ap.matches(ae).alwaysFalse());
+               }
        }
 //     
 //     public void testOrAnnotationPatternMatching() {
@@ -294,13 +313,15 @@ public class AnnotationPatternTestCase extends TestCase {
 //     }
 //     
        public void testNotAnnotationPatternMatching() {
+               if (is15VMOrGreater) {
                PatternParser p = new PatternParser("!@Foo");
                AnnotationTypePattern ap = p.maybeParseAnnotationPattern();
                ap = ap.resolveBindings(makeSimpleScope(),new Bindings(3),true);
                AnnotatedElementImpl ae = new AnnotatedElementImpl(new String[] {"Foo","Boo"});
                assertTrue("does not match foo and boo",ap.matches(ae).alwaysFalse());          
                ae = new AnnotatedElementImpl(new String[] {"Boo"});
-               assertTrue("matches boo",ap.matches(ae).alwaysTrue());          
+               assertTrue("matches boo",ap.matches(ae).alwaysTrue());
+               }
        }
        
        public void testAnyAnnotationPatternMatching() {