From 9b730456c99c01c7381317e7c4511ae238cfd027 Mon Sep 17 00:00:00 2001 From: aclement <aclement> Date: Thu, 12 May 2005 10:49:25 +0000 Subject: Reduced duplication of vm checking logic. --- .../AnnotationPatternMatchingTestCase.java | 20 ++++---------------- .../weaver/patterns/AnnotationPatternTestCase.java | 22 ++++++---------------- 2 files changed, 10 insertions(+), 32 deletions(-) (limited to 'weaver/testsrc') diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java index 35c191bbb..37506ad48 100644 --- a/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java @@ -20,6 +20,7 @@ import org.aspectj.bridge.AbortException; import org.aspectj.bridge.IMessage; import org.aspectj.bridge.IMessageHandler; import org.aspectj.bridge.IMessage.Kind; +import org.aspectj.util.LangUtil; import org.aspectj.weaver.BcweaverTests; import org.aspectj.weaver.ResolvedMember; import org.aspectj.weaver.ResolvedTypeX; @@ -61,19 +62,6 @@ 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"); @@ -93,7 +81,7 @@ public class AnnotationPatternMatchingTestCase extends TestCase { public void testAnnotationPatternMatchingOnTypes() { - if (is15VMOrGreater) { + if (LangUtil.is15VMOrGreater()) { ResolvedTypeX rtx = loadType("AnnotatedClass"); initAnnotationTypePatterns(); @@ -170,7 +158,7 @@ public class AnnotationPatternMatchingTestCase extends TestCase { } public void testAnnotationPatternMatchingOnMethods() { - if (is15VMOrGreater) { + if (LangUtil.is15VMOrGreater()) { ResolvedTypeX rtx = loadType("AnnotatedClass"); ResolvedMember aMethod = rtx.getDeclaredMethods()[1]; @@ -188,7 +176,7 @@ public class AnnotationPatternMatchingTestCase extends TestCase { } public void testAnnotationPatternMatchingOnFields() { - if (is15VMOrGreater) { + if (LangUtil.is15VMOrGreater()) { ResolvedTypeX rtx = loadType("AnnotatedClass"); ResolvedMember aField = rtx.getDeclaredFields()[0]; diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java index 02f0e274e..7697b43d7 100644 --- a/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java @@ -10,6 +10,7 @@ package org.aspectj.weaver.patterns; import org.aspectj.bridge.AbortException; +import org.aspectj.util.LangUtil; import org.aspectj.weaver.AnnotatedElement; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.BcweaverTests; @@ -20,18 +21,7 @@ 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"); @@ -254,7 +244,7 @@ public class AnnotationPatternTestCase extends TestCase { } public void testExactAnnotationPatternMatching() { - if (is15VMOrGreater) { + if (LangUtil.is15VMOrGreater()) { PatternParser p = new PatternParser("@Foo"); AnnotationTypePattern ap = p.maybeParseAnnotationPattern(); ap = ap.resolveBindings(makeSimpleScope(),new Bindings(3),true); @@ -266,7 +256,7 @@ public class AnnotationPatternTestCase extends TestCase { } public void testBindingAnnotationPatternMatching() { - if (is15VMOrGreater) { + if (LangUtil.is15VMOrGreater()) { PatternParser p = new PatternParser("foo"); AnnotationTypePattern ap = p.parseAnnotationNameOrVarTypePattern(); try { @@ -283,7 +273,7 @@ public class AnnotationPatternTestCase extends TestCase { } public void testAndAnnotationPatternMatching() { - if (is15VMOrGreater) { + if (LangUtil.is15VMOrGreater()) { PatternParser p = new PatternParser("@Foo @Boo"); AnnotationTypePattern ap = p.maybeParseAnnotationPattern(); ap = ap.resolveBindings(makeSimpleScope(),new Bindings(3),true); @@ -313,7 +303,7 @@ public class AnnotationPatternTestCase extends TestCase { // } // public void testNotAnnotationPatternMatching() { - if (is15VMOrGreater) { + if (LangUtil.is15VMOrGreater()) { PatternParser p = new PatternParser("!@Foo"); AnnotationTypePattern ap = p.maybeParseAnnotationPattern(); ap = ap.resolveBindings(makeSimpleScope(),new Bindings(3),true); -- cgit v1.2.3