diff options
author | aclement <aclement> | 2005-03-11 09:43:11 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-03-11 09:43:11 +0000 |
commit | 4a2b927f416cc09337aed8d470349c6f43e1ffb5 (patch) | |
tree | 8594eea35454dec892d2117a3d41ca4f7c2319dc /weaver/testsrc/org | |
parent | fa54cd96661ca2b2fa6c0289bd6b90bc38fa5e47 (diff) | |
download | aspectj-4a2b927f416cc09337aed8d470349c6f43e1ffb5.tar.gz aspectj-4a2b927f416cc09337aed8d470349c6f43e1ffb5.zip |
Guard test execution on 1.5 vm level
Diffstat (limited to 'weaver/testsrc/org')
-rw-r--r-- | weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java | 23 | ||||
-rw-r--r-- | weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java | 27 |
2 files changed, 43 insertions, 7 deletions
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java index e7fdbdca9..e9173723d 100644 --- a/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java @@ -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()); + } } diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java index 47b6d46b6..02f0e274e 100644 --- a/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java @@ -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() { |