aboutsummaryrefslogtreecommitdiffstats
path: root/weaver/testsrc/org
diff options
context:
space:
mode:
authoraclement <aclement>2008-10-28 20:32:52 +0000
committeraclement <aclement>2008-10-28 20:32:52 +0000
commit05e64c98ba6effe6a083dfe7c34e3f7f04fe7fb0 (patch)
tree7645a33ef0adc81abee461643d2e9578d9e600b4 /weaver/testsrc/org
parent0ac2913585d05269ea908c1294bf8d507ea16bb7 (diff)
downloadaspectj-05e64c98ba6effe6a083dfe7c34e3f7f04fe7fb0.tar.gz
aspectj-05e64c98ba6effe6a083dfe7c34e3f7f04fe7fb0.zip
246125: pulled tests from weaver into matcher and created bcel subtypes of matcher tests where appropriate
Diffstat (limited to 'weaver/testsrc/org')
-rw-r--r--weaver/testsrc/org/aspectj/weaver/BcweaverModuleTests.java2
-rw-r--r--weaver/testsrc/org/aspectj/weaver/BcweaverTests.java72
-rw-r--r--weaver/testsrc/org/aspectj/weaver/TestUtils.java304
-rw-r--r--weaver/testsrc/org/aspectj/weaver/bcel/NonstaticWeaveTestCase.java1
-rw-r--r--weaver/testsrc/org/aspectj/weaver/bcel/PointcutResidueTestCase.java1
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/AndOrNotTestCase.java103
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java1
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java1
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/ArgsTestCase.java181
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/BindingTestCase.java132
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/DeclareErrorOrWarningTestCase.java70
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/DumpPointcutVisitor.java525
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/ModifiersPatternTestCase.java139
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/NamePatternParserTestCase.java61
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/NamePatternTestCase.java121
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/ParserTestCase.java790
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/PatternsTests.java48
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/PointcutRewriterTest.java447
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/SignaturePatternTestCase.java176
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/TestScope.java30
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/ThisOrTargetTestCase.java162
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/TypePatternListTestCase.java197
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/TypePatternTestCase.java303
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/VisitorTestCase.java75
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/WithinTestCase.java133
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelAndOrNotTestCase.java24
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelBindingTestCase.java24
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelModifiersPatternTestCase.java24
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelParserTestCase.java25
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelPatternsTests.java46
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelSignaturePatternTestCase.java24
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelTypePatternListTestCase.java23
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelTypePatternTestCase.java24
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelWithinTestCase.java23
34 files changed, 276 insertions, 4036 deletions
diff --git a/weaver/testsrc/org/aspectj/weaver/BcweaverModuleTests.java b/weaver/testsrc/org/aspectj/weaver/BcweaverModuleTests.java
index 2090ed446..1f1997864 100644
--- a/weaver/testsrc/org/aspectj/weaver/BcweaverModuleTests.java
+++ b/weaver/testsrc/org/aspectj/weaver/BcweaverModuleTests.java
@@ -25,7 +25,7 @@ public class BcweaverModuleTests extends TestCase {
TestSuite suite = new TestSuite(BcweaverModuleTests.class.getName());
suite.addTest(org.aspectj.weaver.bcel.BcelTests.suite());
suite.addTest(org.aspectj.weaver.BcweaverTests.suite());
- suite.addTest(org.aspectj.weaver.patterns.PatternsTests.suite());
+ suite.addTest(org.aspectj.weaver.patterns.bcel.BcelPatternsTests.suite());
suite.addTestSuite(LocaleTest.class);
suite.addTestSuite(GenericSignatureParserTest.class);
suite.addTest(ToolsTests.suite());
diff --git a/weaver/testsrc/org/aspectj/weaver/BcweaverTests.java b/weaver/testsrc/org/aspectj/weaver/BcweaverTests.java
index 88a97ce03..c14b59f32 100644
--- a/weaver/testsrc/org/aspectj/weaver/BcweaverTests.java
+++ b/weaver/testsrc/org/aspectj/weaver/BcweaverTests.java
@@ -10,7 +10,6 @@
* PARC initial implementation
* ******************************************************************/
-
package org.aspectj.weaver;
import java.io.File;
@@ -23,42 +22,43 @@ import org.aspectj.util.FileUtil;
public class BcweaverTests extends TestCase {
- public static final String TESTDATA_PATH = "../weaver/testdata";
- public static final String OUTDIR_PATH = "../weaver/out";
-
- /** @return File outDir (writable) or null if unable to write */
- public static File getOutdir() {
- File result = new File(OUTDIR_PATH);
- if (result.mkdirs()
- || (result.canWrite() && result.isDirectory())) {
- return result;
- }
- return null;
- }
-
- /** best efforts to delete the output directory and any contents */
- public static void removeOutDir() {
- File outDir = getOutdir();
- if (null != outDir) {
- FileUtil.deleteContents(outDir);
- outDir.delete();
- }
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(BcweaverTests.class.getName());
- // abstract
- //suite.addTestSuite(AbstractWorldTestCase.class);
- //$JUnit-BEGIN$
- suite.addTestSuite(MemberTestCase.class);
- suite.addTestSuite(TypeXTestCase.class);
+ public static final String TESTDATA_PATH = "../weaver/testdata";
+ public static final String OUTDIR_PATH = "../weaver/out";
+
+ /** @return File outDir (writable) or null if unable to write */
+ public static File getOutdir() {
+ File result = new File(OUTDIR_PATH);
+ if (result.mkdirs() || (result.canWrite() && result.isDirectory())) {
+ return result;
+ }
+ return null;
+ }
+
+ /** best efforts to delete the output directory and any contents */
+ public static void removeOutDir() {
+ File outDir = getOutdir();
+ if (null != outDir) {
+ FileUtil.deleteContents(outDir);
+ outDir.delete();
+ }
+ }
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(BcweaverTests.class.getName());
+ // abstract
+ // suite.addTestSuite(AbstractWorldTestCase.class);
+ // $JUnit-BEGIN$
+ suite.addTestSuite(MemberTestCase.class);
+ suite.addTestSuite(TypeXTestCase.class);
suite.addTestSuite(WeaverMessagesTestCase.class);
suite.addTestSuite(DumpTestCase.class);
- suite.addTest(AllTracingTests.suite());
- //$JUnit-END$
- return suite;
- }
+ suite.addTest(AllTracingTests.suite());
+ // $JUnit-END$
+ return suite;
+ }
- public BcweaverTests(String name) { super(name); }
+ public BcweaverTests(String name) {
+ super(name);
+ }
-}
+}
diff --git a/weaver/testsrc/org/aspectj/weaver/TestUtils.java b/weaver/testsrc/org/aspectj/weaver/TestUtils.java
deleted file mode 100644
index 456cd2bfc..000000000
--- a/weaver/testsrc/org/aspectj/weaver/TestUtils.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2008 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andy Clement initial implementation
- * ******************************************************************/
-package org.aspectj.weaver;
-
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.List;
-
-public class TestUtils {
- private static final String[] ZERO_STRINGS = new String[0];
-
- // For stringifying a delegate - extracted from AbstractReferenceTypeDelegate, not fixed up
- // /**
- // * Create the string representation for a delegate, allowing us to
- // * more easily compare delegate implementations.
- // */
- // public String stringifyDelegate() {
- //
- // StringBuffer result = new StringBuffer();
- // result.append("=== Delegate for "+getResolvedTypeX().getName()+"\n");
- //
- // result.append("isAspect?"+isAspect()+"\n");
- // result.append("isAnnotationStyleAspect?"+isAnnotationStyleAspect()+"\n");
- // result.append("isInterface?"+isInterface()+"\n");
- // result.append("isEnum?"+isEnum()+"\n");
- // result.append("isClass?"+isClass()+"\n");
- // result.append("-\n");
- // result.append("isAnnotation?"+isAnnotation()+"\n");
- // result.append("retentionPolicy="+getRetentionPolicy()+"\n");
- // result.append("canAnnotationTargetType?"+canAnnotationTargetType()+"\n");
- // AnnotationTargetKind[] kinds = getAnnotationTargetKinds();
- // if (kinds!=null && kinds.length>0) {
- // result.append("annotationTargetKinds:[");
- // for (int i = 0; i < kinds.length; i++) {
- // AnnotationTargetKind kind = kinds[i];
- // result.append(kind);
- // if ((i+1)<kinds.length) result.append(" ");
- // }
- // result.append("]\n");
- // }
- // result.append("isAnnotationWithRuntimeRetention?"+isAnnotationWithRuntimeRetention()+"\n");
- // result.append("-\n");
- //
- // result.append("isAnonymous?"+isAnonymous()+"\n");
- // result.append("isNested?"+isNested()+"\n");
- // result.append("-\n");
- //
- // result.append("isGeneric?"+isGeneric()+"\n");
- // result.append("declaredGenericSignature="+getDeclaredGenericSignature()+"\n");
- // result.append("-\n");
- //
- // AnnotationX[] axs = getAnnotations();
- // if (axs!=null && axs.length>0) {
- // result.append("getAnnotations() returns: "+axs.length+" annotations\n");
- // for (int i = 0; i < axs.length; i++) {
- // AnnotationX annotationX = axs[i];
- // result.append(" #"+i+") "+annotationX+"\n");
- // }
- // } else {
- // result.append("getAnnotations() returns nothing\n");
- // }
- // ResolvedType[] axtypes = getAnnotationTypes();
- // if (axtypes!=null && axtypes.length>0) {
- // result.append("getAnnotationTypes() returns: "+axtypes.length+" annotations\n");
- // for (int i = 0; i < axtypes.length; i++) {
- // ResolvedType annotation = axtypes[i];
- // result.append(" #"+i+") "+annotation+":"+annotation.getClass()+"\n");
- // }
- // } else {
- // result.append("getAnnotationTypes() returns nothing\n");
- // }
- //
- // result.append("isExposedToWeaver?"+isExposedToWeaver()+"\n");
- // result.append("getSuperclass?"+getSuperclass()+"\n");
- // result.append("getResolvedTypeX?"+getResolvedTypeX()+"\n");
- // result.append("--\n");
- //
- // ResolvedMember[] fields = getDeclaredFields();
- // if (fields!=null && fields.length>0) {
- // result.append("The fields: "+fields.length+"\n");
- // for (int i = 0; i < fields.length; i++) {
- // ResolvedMember member = fields[i];
- // result.append("f"+i+") "+member.toDebugString()+"\n");
- // }
- // }
- // ResolvedMember[] methods = getDeclaredMethods();
- // if (methods!=null && methods.length>0) {
- // result.append("The methods: "+methods.length+"\n");
- // for (int i = 0; i < methods.length; i++) {
- // ResolvedMember member = methods[i];
- // result.append("m"+i+") "+member.toDebugString()+"\n");
- // }
- // }
- // ResolvedType[] interfaces = getDeclaredInterfaces();
- // if (interfaces!=null && interfaces.length>0) {
- // result.append("The interfaces: "+interfaces.length+"\n");
- // for (int i = 0; i < interfaces.length; i++) {
- // ResolvedType member = interfaces[i];
- // result.append("i"+i+") "+member+"\n");
- // }
- // }
- //
- // result.append("getModifiers?"+getModifiers()+"\n");
- //
- // result.append("perclause="+getPerClause()+"\n");
- //
- // result.append("aj:weaverstate="+getWeaverState()+"\n");
- //
- // ResolvedMember[] pointcuts = getDeclaredPointcuts();
- // if (pointcuts!=null && pointcuts.length>0) {
- // result.append("The pointcuts: "+pointcuts.length+"\n");
- //
- // // Sort the damn things
- // List sortedSetOfPointcuts = new ArrayList();
- // for (int i = 0; i < pointcuts.length; i++) {sortedSetOfPointcuts.add(pointcuts[i]);}
- // Collections.sort(sortedSetOfPointcuts);
- //
- // int i =0;
- // for (Iterator iter = sortedSetOfPointcuts.iterator(); iter.hasNext();) {
- // ResolvedMember member = (ResolvedMember) iter.next();
- // result.append("p"+i+") "+member.toDebugString()+"\n");
- // i++;
- // }
- // }
- //
- // Collection declares = getDeclares();
- // if (declares.size()>0) {
- // result.append("The declares: "+declares.size()+"\n");
- //
- // // // Sort the damn things
- // // List sortedSetOfPointcuts = new ArrayList();
- // // for (int i = 0; i < pointcuts.length; i++) {sortedSetOfPointcuts.add(pointcuts[i]);}
- // // Collections.sort(sortedSetOfPointcuts);
- //
- // int i=0;
- // for (Iterator iter = declares.iterator(); iter.hasNext();) {
- // Declare dec = (Declare) iter.next();
- // result.append("d"+i+") "+dec.toString()+"\n");
- // i++;
- // }
- // }
- //
- // TypeVariable[] tv = getTypeVariables();
- // if (tv!=null && tv.length>0) {
- // result.append("The type variables: "+tv.length+"\n");
- // for (int i = 0; i < tv.length; i++) {
- // result.append("tv"+i+") "+tv[i]+"\n");
- // }
- // }
- //
- // Collection tmungers = getTypeMungers();
- // if (tmungers.size()>0) {
- // List sorted = new ArrayList();
- // sorted.addAll(tmungers);
- // Collections.sort(sorted,new Comparator() {
- // public int compare(Object arg0, Object arg1) {
- // return arg0.toString().compareTo(arg1.toString());
- // }
- // });
- // result.append("The type mungers: "+tmungers.size()+"\n");
- // int i=0;
- // for (Iterator iter = sorted.iterator(); iter.hasNext();) {
- // ConcreteTypeMunger mun = (ConcreteTypeMunger) iter.next();
- // result.append("tm"+i+") "+mun.toString()+"\n");
- // i++;
- // }
- // }
- //
- // result.append("doesNotExposeShadowMungers?"+doesNotExposeShadowMungers()+"\n");
- //
- // Collection pas = getPrivilegedAccesses();
- // if (pas!=null && pas.size()>0) {
- // // List sorted = new ArrayList();
- // // sorted.addAll(tmungers);
- // // Collections.sort(sorted,new Comparator() {
- // // public int compare(Object arg0, Object arg1) {
- // // return arg0.toString().compareTo(arg1.toString());
- // // }
- // // });
- // result.append("The privileged accesses: "+pas.size()+"\n");
- // int i=0;
- // for (Iterator iter = pas.iterator(); iter.hasNext();) {
- // ResolvedMember mun = (ResolvedMember) iter.next();
- // result.append("tm"+i+") "+mun.toDebugString()+"\n");
- // i++;
- // }
- // }
- //
- // // public Collection getPrivilegedAccesses();
- // // public boolean hasAnnotation(UnresolvedType ofType);
- // result.append("===");
- // return result.toString();
- // }
-
- /**
- * Build a member from a string representation: <blockquote>
- *
- * <pre>
- * static? TypeName TypeName.Id
- * </pre>
- *
- * </blockquote>
- */
- public static MemberImpl fieldFromString(String str) {
- str = str.trim();
- final int len = str.length();
- int i = 0;
- int mods = 0;
- if (str.startsWith("static", i)) {
- mods = Modifier.STATIC;
- i += 6;
- while (Character.isWhitespace(str.charAt(i)))
- i++;
- }
- int start = i;
- while (!Character.isWhitespace(str.charAt(i)))
- i++;
- UnresolvedType retTy = UnresolvedType.forName(str.substring(start, i));
-
- start = i;
- i = str.lastIndexOf('.');
- UnresolvedType declaringTy = UnresolvedType.forName(str.substring(start, i).trim());
- start = ++i;
- String name = str.substring(start, len).trim();
- return new MemberImpl(Member.FIELD, declaringTy, mods, retTy, name, UnresolvedType.NONE);
- }
-
- /**
- * Build a member from a string representation: <blockquote>
- *
- * <pre>
- * (static|interface|private)? TypeName TypeName . Id ( TypeName , ...)
- * </pre>
- *
- * </blockquote>
- */
-
- public static Member methodFromString(String str) {
- str = str.trim();
- // final int len = str.length();
- int i = 0;
-
- int mods = 0;
- if (str.startsWith("static", i)) {
- mods = Modifier.STATIC;
- i += 6;
- } else if (str.startsWith("interface", i)) {
- mods = Modifier.INTERFACE;
- i += 9;
- } else if (str.startsWith("private", i)) {
- mods = Modifier.PRIVATE;
- i += 7;
- }
- while (Character.isWhitespace(str.charAt(i)))
- i++;
-
- int start = i;
- while (!Character.isWhitespace(str.charAt(i)))
- i++;
- UnresolvedType returnTy = UnresolvedType.forName(str.substring(start, i));
-
- start = i;
- i = str.indexOf('(', i);
- i = str.lastIndexOf('.', i);
- UnresolvedType declaringTy = UnresolvedType.forName(str.substring(start, i).trim());
-
- start = ++i;
- i = str.indexOf('(', i);
- String name = str.substring(start, i).trim();
- start = ++i;
- i = str.indexOf(')', i);
-
- String[] paramTypeNames = parseIds(str.substring(start, i).trim());
-
- return MemberImpl.method(declaringTy, mods, returnTy, name, UnresolvedType.forNames(paramTypeNames));
- }
-
- public static String[] parseIds(String str) {
- if (str.length() == 0)
- return ZERO_STRINGS;
- List l = new ArrayList();
- int start = 0;
- while (true) {
- int i = str.indexOf(',', start);
- if (i == -1) {
- l.add(str.substring(start).trim());
- break;
- }
- l.add(str.substring(start, i).trim());
- start = i + 1;
- }
- return (String[]) l.toArray(new String[l.size()]);
- }
-
-}
diff --git a/weaver/testsrc/org/aspectj/weaver/bcel/NonstaticWeaveTestCase.java b/weaver/testsrc/org/aspectj/weaver/bcel/NonstaticWeaveTestCase.java
index ecf7b6526..1f67a6249 100644
--- a/weaver/testsrc/org/aspectj/weaver/bcel/NonstaticWeaveTestCase.java
+++ b/weaver/testsrc/org/aspectj/weaver/bcel/NonstaticWeaveTestCase.java
@@ -16,7 +16,6 @@ package org.aspectj.weaver.bcel;
import java.io.IOException;
import org.aspectj.weaver.*;
-import org.aspectj.weaver.ShadowMunger;
import org.aspectj.weaver.patterns.*;
public class NonstaticWeaveTestCase extends WeaveTestCase {
diff --git a/weaver/testsrc/org/aspectj/weaver/bcel/PointcutResidueTestCase.java b/weaver/testsrc/org/aspectj/weaver/bcel/PointcutResidueTestCase.java
index 65238450b..14b5240e3 100644
--- a/weaver/testsrc/org/aspectj/weaver/bcel/PointcutResidueTestCase.java
+++ b/weaver/testsrc/org/aspectj/weaver/bcel/PointcutResidueTestCase.java
@@ -19,7 +19,6 @@ import java.util.*;
import org.aspectj.weaver.*;
import org.aspectj.weaver.patterns.*;
-import org.aspectj.weaver.patterns.SimpleScope;
public class PointcutResidueTestCase extends WeaveTestCase {
{
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/AndOrNotTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/AndOrNotTestCase.java
deleted file mode 100644
index 481f3a0c1..000000000
--- a/weaver/testsrc/org/aspectj/weaver/patterns/AndOrNotTestCase.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.weaver.patterns;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-import org.aspectj.weaver.VersionedDataInputStream;
-import org.aspectj.weaver.World;
-import org.aspectj.weaver.bcel.BcelWorld;
-
-/**
- * @author hugunin
- *
- */
-public class AndOrNotTestCase extends TestCase {
- /**
- * Constructor for PatternTestCase.
- * @param name
- */
- public AndOrNotTestCase(String name) {
- super(name);
- }
-
- static {
- new Foo();new Bar();new C(); // just to touch them and so eclipse thinks they are used
- }
- World world;
-
-
- public void testMatch() throws IOException {
- world = new BcelWorld();
-
- Pointcut foo = makePointcut("this(Foo)");
- Pointcut bar = makePointcut("this(Bar)");
- Pointcut c = makePointcut("this(C)");
-
- checkEquals("this(Foo) && this(Bar)", new AndPointcut(foo, bar));
- checkEquals("this(Foo) && this(Bar) && this(C)", new AndPointcut(foo, new AndPointcut(bar, c)));
-
-
- checkEquals("this(Foo) || this(Bar)", new OrPointcut(foo, bar));
- checkEquals("this(Foo) || this(Bar) || this(C)", new OrPointcut(foo, new OrPointcut(bar, c)));
-
- checkEquals("this(Foo) && this(Bar) || this(C)", new OrPointcut(new AndPointcut(foo, bar), c));
- checkEquals("this(Foo) || this(Bar) && this(C)", new OrPointcut(foo, new AndPointcut(bar, c)));
- checkEquals("(this(Foo) || this(Bar)) && this(C)", new AndPointcut(new OrPointcut(foo, bar), c));
- checkEquals("this(Foo) || (this(Bar) && this(C))", new OrPointcut(foo, new AndPointcut(bar, c)));
-
- checkEquals("!this(Foo)", new NotPointcut(foo));
- checkEquals("!this(Foo) && this(Bar)", new AndPointcut(new NotPointcut(foo), bar));
- checkEquals("!(this(Foo) && this(Bar)) || this(C)", new OrPointcut(new NotPointcut(new AndPointcut(foo, bar)), c));
- checkEquals("!!this(Foo)", new NotPointcut(new NotPointcut(foo)));
-
- }
-
- private Pointcut makePointcut(String pattern) {
- return new PatternParser(pattern).parsePointcut();
- }
-
- private void checkEquals(String pattern, Pointcut p) throws IOException {
- assertEquals(pattern, p, makePointcut(pattern));
- checkSerialization(pattern);
- }
-
- /**
- * Method checkSerialization.
- * @param string
- */
- private void checkSerialization(String string) throws IOException {
- Pointcut p = makePointcut(string);
- ByteArrayOutputStream bo = new ByteArrayOutputStream();
- DataOutputStream out = new DataOutputStream(bo);
- p.write(out);
- out.close();
-
- ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray());
- VersionedDataInputStream in = new VersionedDataInputStream(bi);
- Pointcut newP = Pointcut.read(in, null);
-
- assertEquals("write/read", p, newP);
- }
-
- private static class Foo{}
- private static class Bar{}
- private static class C{}
-
-}
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java
index 5e6ad5e59..9efe6bc20 100644
--- a/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java
+++ b/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java
@@ -25,6 +25,7 @@ import org.aspectj.weaver.BcweaverTests;
import org.aspectj.weaver.ResolvedMember;
import org.aspectj.weaver.ResolvedType;
import org.aspectj.weaver.bcel.BcelWorld;
+import org.aspectj.weaver.patterns.TestScope;
/*
* Sample types that this program uses are:
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java
index 45f922707..2e767b636 100644
--- a/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java
+++ b/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java
@@ -19,6 +19,7 @@ import org.aspectj.weaver.BcweaverTests;
import org.aspectj.weaver.ResolvedType;
import org.aspectj.weaver.UnresolvedType;
import org.aspectj.weaver.bcel.BcelWorld;
+import org.aspectj.weaver.patterns.TestScope;
public class AnnotationPatternTestCase extends TestCase {
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/ArgsTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/ArgsTestCase.java
deleted file mode 100644
index 4d157628c..000000000
--- a/weaver/testsrc/org/aspectj/weaver/patterns/ArgsTestCase.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.aspectj.weaver.patterns;
-
-import java.lang.reflect.Method;
-
-import junit.framework.TestCase;
-
-import org.aspectj.util.LangUtil;
-import org.aspectj.weaver.tools.JoinPointMatch;
-import org.aspectj.weaver.tools.PointcutExpression;
-import org.aspectj.weaver.tools.PointcutParameter;
-import org.aspectj.weaver.tools.PointcutParser;
-import org.aspectj.weaver.tools.ShadowMatch;
-
-/**
- * @author colyer
- *
- */
-public class ArgsTestCase extends TestCase {
-
- PointcutExpression wildcardArgs;
- PointcutExpression oneA;
- PointcutExpression oneAandaC;
- PointcutExpression BthenAnything;
- PointcutExpression singleArg;
-
- public void testMatchJP() throws Exception {
- if (needToSkip) return;
-
- Method oneAArg = B.class.getMethod("x", new Class[] {A.class});
- Method oneBArg = B.class.getMethod("y",new Class[] {B.class});
- Method acArgs = C.class.getMethod("z",new Class[] {A.class,C.class});
- Method baArgs = C.class.getMethod("t",new Class[] {B.class, A.class});
-
- checkMatches(wildcardArgs.matchesMethodExecution(oneAArg),new B(), new B(), new Object[] {new A()} );
- checkMatches(wildcardArgs.matchesMethodExecution(oneBArg),new B(), new B(), new Object[] {new B()} );
- checkMatches(wildcardArgs.matchesMethodExecution(acArgs),new C(), new C(), new Object[] {new B(), new C()} );
- checkMatches(wildcardArgs.matchesMethodExecution(baArgs),new C(), new C(), new Object[] {new B(), new B()} );
-
- checkMatches(oneA.matchesMethodExecution(oneAArg),new B(), new B(), new Object[] {new A()} );
- checkMatches(oneA.matchesMethodExecution(oneBArg),new B(), new B(), new Object[] {new B()} );
- checkNoMatch(oneA.matchesMethodExecution(acArgs),new C(), new C(), new Object[] {new B(), new C()});
- checkNoMatch(oneA.matchesMethodExecution(baArgs),new C(), new C(), new Object[] {new B(), new B()});
-
- checkNoMatch(oneAandaC.matchesMethodExecution(oneAArg),new B(), new B(), new Object[] {new A()} );
- checkNoMatch(oneAandaC.matchesMethodExecution(oneBArg),new B(), new B(), new Object[] {new B()} );
- checkMatches(oneAandaC.matchesMethodExecution(acArgs),new C(), new C(), new Object[] {new B(), new C()});
- checkNoMatch(oneAandaC.matchesMethodExecution(baArgs),new C(), new C(), new Object[] {new B(), new B()});
-
- checkNoMatch(BthenAnything.matchesMethodExecution(oneAArg),new B(), new B(), new Object[] {new A()} );
- checkMatches(BthenAnything.matchesMethodExecution(oneBArg),new B(), new B(), new Object[] {new B()} );
- checkNoMatch(BthenAnything.matchesMethodExecution(acArgs),new C(), new C(), new Object[] {new A(), new C()});
- checkMatches(BthenAnything.matchesMethodExecution(baArgs),new C(), new C(), new Object[] {new B(), new B()});
-
- checkMatches(singleArg.matchesMethodExecution(oneAArg),new B(), new B(), new Object[] {new A()} );
- checkMatches(singleArg.matchesMethodExecution(oneBArg),new B(), new B(), new Object[] {new B()} );
- checkNoMatch(singleArg.matchesMethodExecution(acArgs),new C(), new C(), new Object[] {new B(), new C()});
- checkNoMatch(singleArg.matchesMethodExecution(baArgs),new C(), new C(), new Object[] {new B(), new B()});
-
- }
-
- public void testBinding() throws Exception {
- if (needToSkip) return;
-
- PointcutParser parser = PointcutParser.getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(A.class.getClassLoader());
- PointcutParameter a = parser.createPointcutParameter("a",A.class);
- A theParameter = new A();
- PointcutExpression bindA = parser.parsePointcutExpression("args(a,*)",A.class,new PointcutParameter[] {a});
-
- Method acArgs = C.class.getMethod("z",new Class[] {A.class,C.class});
- ShadowMatch sMatch = bindA.matchesMethodExecution(acArgs);
- JoinPointMatch jpMatch = sMatch.matchesJoinPoint(new A(),new A(), new Object[] {theParameter});
- assertTrue("should match", jpMatch.matches());
- PointcutParameter[] bindings = jpMatch.getParameterBindings();
- assertTrue("one parameter",bindings.length == 1);
- assertEquals("should be bound to the arg value",theParameter, bindings[0].getBinding());
-
- PointcutParameter c = parser.createPointcutParameter("c", C.class);
- C cParameter = new C();
- PointcutExpression bindAandC = parser.parsePointcutExpression("args(a,c)",A.class,new PointcutParameter[] {a,c});
- sMatch = bindAandC.matchesMethodExecution(acArgs);
- jpMatch = sMatch.matchesJoinPoint(new A(),new A(), new Object[] {theParameter,cParameter});
- assertTrue("should match", jpMatch.matches());
- bindings = jpMatch.getParameterBindings();
- assertTrue("two parameters",bindings.length == 2);
- assertEquals("should be bound to the a arg value",theParameter, bindings[0].getBinding());
- assertEquals("should be bound to the c arg value",cParameter, bindings[1].getBinding());
- assertEquals("a",bindings[0].getName());
- assertEquals("c",bindings[1].getName());
- }
-
- public void testMatchJPWithPrimitiveTypes() throws Exception {
- if (needToSkip) return;
-
- try {
-
- PointcutParser parser = PointcutParser.getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(A.class.getClassLoader());
- PointcutExpression oneInt = parser.parsePointcutExpression("args(int)");
- PointcutExpression oneInteger = parser.parsePointcutExpression("args(Integer)");
-
- Method oneIntM = A.class.getMethod("anInt",new Class[] {int.class});
- Method oneIntegerM = A.class.getMethod("anInteger",new Class[] {Integer.class});
-
- if (LangUtil.is15VMOrGreater()) {
- checkMatches(oneInt.matchesMethodExecution(oneIntM),new A(), new A(), new Object[] {new Integer(5)});
- checkMatches(oneInt.matchesMethodExecution(oneIntegerM),new A(), new A(), new Object[] {new Integer(5)});
- checkMatches(oneInteger.matchesMethodExecution(oneIntM),new A(), new A(), new Object[] {new Integer(5)});
- checkMatches(oneInteger.matchesMethodExecution(oneIntegerM),new A(), new A(), new Object[] {new Integer(5)});
- } else {
- checkMatches(oneInt.matchesMethodExecution(oneIntM),new A(), new A(), new Object[] {new Integer(5)});
- checkNoMatch(oneInt.matchesMethodExecution(oneIntegerM),new A(), new A(), new Object[] {new Integer(5)});
- checkNoMatch(oneInteger.matchesMethodExecution(oneIntM),new A(), new A(), new Object[] {new Integer(5)});
- checkMatches(oneInteger.matchesMethodExecution(oneIntegerM),new A(), new A(), new Object[] {new Integer(5)});
- }
-
- } catch( Exception ex) {
- fail("Unexpected exception " + ex);
- }
-
- }
-
- private void checkMatches(ShadowMatch sMatch,Object thisOjb, Object targetObj, Object[] args) {
- assertTrue("match expected",sMatch.matchesJoinPoint(thisOjb, targetObj, args).matches());
- }
-
- private void checkNoMatch(ShadowMatch sMatch,Object thisOjb, Object targetObj, Object[] args) {
- assertFalse("no match expected",sMatch.matchesJoinPoint(thisOjb, targetObj, args).matches());
- }
-
- private static class A {
- public void anInt(int i) {}
- public void anInteger(Integer i) {}
-
- }
- private static class B extends A {
- public void x(A a) {}
- public void y(B b) {}
- }
- private static class C {
- public void z(A a, C c) {}
- public void t(B b, A a) {}
- }
-
-
- private boolean needToSkip = false;
-
- /** this condition can occur on the build machine only, and is way too complex to fix right now... */
- private boolean needToSkipPointcutParserTests() {
- if (!LangUtil.is15VMOrGreater()) return false;
- try {
- Class.forName("org.aspectj.weaver.reflect.Java15ReflectionBasedReferenceTypeDelegate",false,this.getClass().getClassLoader());//ReflectionBasedReferenceTypeDelegate.class.getClassLoader());
- } catch (ClassNotFoundException cnfEx) {
- return true;
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- needToSkip = needToSkipPointcutParserTests();
- if (needToSkip) return;
- PointcutParser parser = PointcutParser.getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(A.class.getClassLoader());
- wildcardArgs = parser.parsePointcutExpression("args(..)");
- oneA = parser.parsePointcutExpression("args(org.aspectj.weaver.patterns.ArgsTestCase.A)");
- oneAandaC = parser.parsePointcutExpression("args(org.aspectj.weaver.patterns.ArgsTestCase.A,org.aspectj.weaver.patterns.ArgsTestCase.C)");
- BthenAnything = parser.parsePointcutExpression("args(org.aspectj.weaver.patterns.ArgsTestCase.B,..)");
- singleArg = parser.parsePointcutExpression("args(*)");
- }
-}
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/BindingTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/BindingTestCase.java
deleted file mode 100644
index 7901a5574..000000000
--- a/weaver/testsrc/org/aspectj/weaver/patterns/BindingTestCase.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.weaver.patterns;
-
-import org.aspectj.weaver.bcel.*;
-
-import junit.framework.TestCase;
-
-import org.aspectj.bridge.AbortException;
-import org.aspectj.weaver.*;
-
-public class BindingTestCase extends TestCase {
-
-
- public BindingTestCase(String arg0) {
- super(arg0);
- }
-
- World world = new BcelWorld();
-
-
- public void testResolveBindings() {
- BindingTypePattern at = new BindingTypePattern(world.resolve("java.lang.Object"), 0, false);
- BindingTypePattern bt = new BindingTypePattern(world.resolve("java.lang.Object"), 1, false);
-
- BindingTypePattern[] all = new BindingTypePattern[] {at, bt};
- BindingTypePattern[] none = new BindingTypePattern[] {null, null};
- BindingTypePattern[] a = new BindingTypePattern[] {at, null};
- BindingTypePattern[] b = new BindingTypePattern[] {null, bt};
-
- checkBindings("this(b)",b);
- checkBindings("this(java.lang.String)", none);
- checkBindings("this(*)", none);
- checkBindings("this(a)", a);
-
- try {checkBindings("args(.., a,..,b)", all);
- //checkBindings("args(a,..,b, ..)", all);
- fail("shouldn't be implemented yet");
- } catch (AbortException ae) {
- // not implemented yet
- }
-
- checkBindings("args(a,..,b)", all);
- checkBindings("args(b)", b);
-
- checkBindings("args()", none);
-
- checkBindings("this(a) && this(b)", all);
-
- checkBindingFailure("this(a) && this(a)", "multiple");
- //checkBindingFailure("this(a) && this(b)");
-
- checkBindingFailure("this(a) || this(b)", "inconsistent");
- checkBindingFailure("this(java.lang.String) || this(b)", "inconsistent");
- checkBindingFailure("this(a) || this(java.lang.String)", "inconsistent");
- checkBindings("this(a) || this(a)", a);
-
- checkBindings("!this(java.lang.String)", none);
- checkBindings("!this(java.lang.String) && this(a)", a);
- checkBindingFailure("!this(a)", "negation");
- //checkBindingFailure("this(a)");
-
-
- checkBindings("cflow(this(a))", a);
- checkBindings("cflow(this(a)) && this(b)", all);
-
- checkBindingFailure("cflow(this(a)) || this(b)", "inconsistent");
- checkBindingFailure("cflow(this(a)) && this(a)", "multiple");
-
- checkBindingFailure("!cflow(this(a))", "negation");
-
- // todo
- // this should fail since a isn't visible to if
- //checkBindingFailure("cflow(if(a != null)) && this(a)");
- //checkBinding("cflow(if(a != null) && this(a))", a);
-
- }
-
-
- /**
- * Method checkBindingFailure. (assumes an env where "a" and "b" are formals).
- * @param string
- */
- private void checkBindingFailure(String pattern, String prefix) {
- PatternParser parser = new PatternParser(pattern);
- Pointcut p = parser.parsePointcut();
- Bindings actualBindings = new Bindings(2);
- try {
- p.resolveBindings(makeSimpleScope(), actualBindings);
- } catch (AbortException re) {
- assertEquals(prefix, re.getIMessage().getMessage().substring(0, prefix.length()));
- //System.out.println("expected exception: " + re);
- return;
- }
- assertTrue("should have failed", false);
- }
-
-
- /**
- * Method checkBindings.
- * @param string
- * @param i
- */
- private void checkBindings(String pattern, BindingTypePattern[] expectedBindings) {
- PatternParser parser = new PatternParser(pattern);
- Pointcut p = parser.parsePointcut();
- Bindings actualBindings = new Bindings(expectedBindings.length);
-
- TestScope simpleScope = makeSimpleScope();
- p.resolveBindings(simpleScope, actualBindings);
- //System.out.println(actualBindings);
-
- new Bindings(expectedBindings).checkEquals(actualBindings, simpleScope);
- }
-
-
- public TestScope makeSimpleScope() {
- return new TestScope(new String[] {"int", "java.lang.String"}, new String[] {"a", "b"}, world);
- }
-}
-
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/DeclareErrorOrWarningTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/DeclareErrorOrWarningTestCase.java
deleted file mode 100644
index c72db9b2a..000000000
--- a/weaver/testsrc/org/aspectj/weaver/patterns/DeclareErrorOrWarningTestCase.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.weaver.patterns;
-
-import java.io.*;
-
-import org.aspectj.weaver.VersionedDataInputStream;
-
-import junit.framework.TestCase;
-
-public class DeclareErrorOrWarningTestCase extends TestCase {
-
- public DeclareErrorOrWarningTestCase(String name) {
- super(name);
- }
-
-
- public void testParse() throws IOException {
- DeclareErrorOrWarning d =
- parse("declare error: call(void foo()): \"that is bad\";");
- assertTrue(d.isError());
- assertEquals(d.getPointcut(),
- new PatternParser("call(void foo())").parsePointcut());
- assertEquals("that is bad", d.getMessage());
- checkSerialization(d);
-
- d = parse("declare warning: bar() && baz(): \"boo!\";");
- assertTrue(!d.isError());
- assertEquals(d.getPointcut(),
- new PatternParser("bar() && baz()").parsePointcut());
- assertEquals("boo!", d.getMessage());
- checkSerialization(d);
-
- }
-
- public void testStartAndEndPositionSet() throws IOException {
- DeclareErrorOrWarning d =
- parse("declare error: call(void foo()): \"that is bad\";");
- assertEquals("start position should be 0", 0, d.getStart());
- assertEquals("end position should be 46", 46, d.getEnd());
- }
-
- private DeclareErrorOrWarning parse(String string) {
- return (DeclareErrorOrWarning)new PatternParser(string).parseDeclare();
- }
-
- private void checkSerialization(Declare declare) throws IOException {
- ByteArrayOutputStream bo = new ByteArrayOutputStream();
- DataOutputStream out = new DataOutputStream(bo);
- declare.write(out);
- out.close();
-
- ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray());
- VersionedDataInputStream in = new VersionedDataInputStream(bi);
- Declare newDeclare = Declare.read(in, null);
-
- assertEquals("write/read", declare, newDeclare);
- }
-}
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/DumpPointcutVisitor.java b/weaver/testsrc/org/aspectj/weaver/patterns/DumpPointcutVisitor.java
deleted file mode 100644
index 3c47c2005..000000000
--- a/weaver/testsrc/org/aspectj/weaver/patterns/DumpPointcutVisitor.java
+++ /dev/null
@@ -1,525 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2007-2008 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Alexandre Vasseur
- * ******************************************************************/
-package org.aspectj.weaver.patterns;
-
-import org.aspectj.weaver.Member;
-
-/**
- * A sample toString like visitor that helps understanding the AST tree structure organization
- *
- * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
- */
-public class DumpPointcutVisitor implements PatternNodeVisitor {
-
- private StringBuffer sb = new StringBuffer();
- public String get() {
- return sb.toString();
- }
-
- private void append(Object o) {
- sb.append(o.toString());
- }
-
- private void append(char c) {
- sb.append(c);
- }
-
- /**
- * This method helps maintaining the API and raises warning when PatternNode subclasses do not
- * implement the visitor pattern
- *
- * @param node
- * @param data
- * @return
- */
- public Object visit(PatternNode node, Object data) {
- System.err.println("Should implement: " + node.getClass());
- return null;
- }
-
- public Object visit(AnyTypePattern node, Object data) {
- append('*');
- return null;
- }
-
- public Object visit(NoTypePattern node, Object data) {
- append(node.toString());//TODO no idea when this one is used
- return null;
- }
-
- public Object visit(EllipsisTypePattern node, Object data) {
- append(node.toString());
- return null;
- }
-
- public Object visit(AnyWithAnnotationTypePattern node, Object data) {
- node.annotationPattern.accept(this, data);
- append(" *");
- return null;
- }
-
- public Object visit(AnyAnnotationTypePattern node, Object data) {
- //@ANY : ignore
- append('*');
- return null;
- }
-
- public Object visit(EllipsisAnnotationTypePattern node, Object data) {
- append("..");
- return null;
- }
-
- public Object visit(AndAnnotationTypePattern node, Object data) {
- node.getLeft().accept(this, data);
- append(' ');
- node.getRight().accept(this, data);
- return null;
- }
-
- public Object visit(AndPointcut node, Object data) {
- append('(');
- node.getLeft().accept(this, data);
- append(" && ");
- node.getRight().accept(this, data);
- append(')');
- return null;
- }
-
- public Object visit(AndTypePattern node, Object data) {
- append('(');
- node.getLeft().accept(this, data);
- append(" && ");
- node.getRight().accept(this, data);
- append(')');
- return null;
- }
-
- public Object visit(AnnotationPatternList node, Object data) {
- AnnotationTypePattern[] annotations = node.getAnnotationPatterns();
- for (int i = 0; i < annotations.length; i++) {
- if (i>0) append(", ");//Note: list is ",", and is " " separated for annotations
- annotations[i].accept(this, data);
- }
- return null;
- }
-
- public Object visit(AnnotationPointcut node, Object data) {
- append("@annotation(");
- node.getAnnotationTypePattern().accept(this, data);
- append(')');
- return null;
- }
-
- public Object visit(ArgsAnnotationPointcut node, Object data) {
- append("@args(");
- node.getArguments().accept(this, data);
- append(')');
- return null;
- }
-
- public Object visit(ArgsPointcut node, Object data) {
- append("args(");
- node.getArguments().accept(this, data);
- append(')');
- return null;
- }
-
- public Object visit(BindingAnnotationTypePattern node, Object data) {
- append(node);
- return null;
- }
-
- public Object visit(BindingTypePattern node, Object data) {
- append(node);
- return null;
- }
-
- public Object visit(CflowPointcut node, Object data) {
- append(node.isCflowBelow()?"cflowbelow(":"cflow(");
- node.getEntry().accept(this, data);
- append(')');
- return null;
- }
-
- public Object visit(ExactAnnotationTypePattern node, Object data) {
- //append('@'); // since @annotation(@someAnno) cannot be parsed anymore
- append(node.getAnnotationType().getName());
- return null;
- }
-
- public Object visit(ExactTypePattern node, Object data) {
- if (node.getAnnotationPattern() != AnnotationTypePattern.ANY) {
- append('(');
- node.getAnnotationPattern().accept(this, data);
- append(' ');
- }
-
- String typeString = node.getType().toString();
- if (node.isVarArgs()) typeString = typeString.substring(0, typeString.lastIndexOf('['));//TODO AV - ugly
- append(typeString);
- if (node.isIncludeSubtypes()) append('+');
- if (node.isVarArgs()) append("...");
- if (node.getAnnotationPattern() != AnnotationTypePattern.ANY) {
- append(')');
- }
- return null;
- }
-
- public Object visit(KindedPointcut node, Object data) {
- append(node.getKind().getSimpleName());
- append('(');
- node.getSignature().accept(this, data);
- append(')');
- return null;
- }
-
- public Object visit(ModifiersPattern node, Object data) {
- append(node.toString());//note: node takes care of forbidden mods
- return null;
- }
-
- public Object visit(NamePattern node, Object data) {
- append(node.toString());
- return null;
- }
-
- public Object visit(NotAnnotationTypePattern node, Object data) {
- append("!");
- node.getNegatedPattern().accept(this, data);
- return null;
- }
-
- public Object visit(NotPointcut node, Object data) {
- append("!(");
- node.getNegatedPointcut().accept(this, data);
- append(')');
- return null;
- }
-
- public Object visit(NotTypePattern node, Object data) {
- append("!(");
- node.getNegatedPattern().accept(this, data);
- append(')');
- return null;
- }
-
- public Object visit(OrAnnotationTypePattern node, Object data) {
- append('(');
- node.getLeft().accept(this, data);
- append(" || ");
- node.getRight().accept(this, data);
- append(')');
- return null;
- }
-
- public Object visit(OrPointcut node, Object data) {
- append('(');
- node.getLeft().accept(this, data);
- append(" || ");
- node.getRight().accept(this, data);
- append(')');
- return null;
- }
-
- public Object visit(OrTypePattern node, Object data) {
- append('(');
- node.getLeft().accept(this, data);
- append(" || ");
- node.getRight().accept(this, data);
- append(')');
- return null;
- }
-
- public Object visit(ReferencePointcut node, Object data) {
- append(node.toString());
- return null;
- }
-
- public Object visit(SignaturePattern node, Object data) {
- if (node.getAnnotationPattern() != AnnotationTypePattern.ANY) {
- node.getAnnotationPattern().accept(this, data);
- append(' ');
- }
-
- if (node.getModifiers() != ModifiersPattern.ANY) {
- node.getModifiers().accept(this, data);
- append(' ');
- }
-
- if (node.getKind() == Member.STATIC_INITIALIZATION) {
- node.getDeclaringType().accept(this, data);
- } else if (node.getKind() == Member.HANDLER) {
- append("handler(");
- node.getParameterTypes().get(0).accept(this, data);//Note: we know we have 1 child
- append(')');
- } else {
- if (!(node.getKind() == Member.CONSTRUCTOR)) {
- node.getReturnType().accept(this, data);
- append(' ');
- }
- if (node.getDeclaringType() != TypePattern.ANY) {
- node.getDeclaringType().accept(this, data);
- append('.');
- }
- if (node.getKind() == Member.CONSTRUCTOR) {
- append("new");
- } else {
- node.getName().accept(this, data);
- }
- if (node.getKind() == Member.METHOD || node.getKind() == Member.CONSTRUCTOR) {
- append('(');
- node.getParameterTypes().accept(this, data);
- append(')');
- }
- if (node.getThrowsPattern() != null) {
- append(' ');
- node.getThrowsPattern().accept(this, data);
- }
- }
- return null;
- }
-
- public Object visit(ThisOrTargetAnnotationPointcut node, Object data) {
- append(node.isThis() ? "@this(" : "@target(");
- node.getAnnotationTypePattern().accept(this, data);
- append(')');
- return null;
- }
-
- public Object visit(ThisOrTargetPointcut node, Object data) {
- append(node.isThis() ? "this(" : "target(");
- node.getType().accept(this, data);
- append(')');
- return null;
- }
-
- // Note: a visitor instance is not thread safe so should not be shared
- private boolean inThrowsForbidden = false;
-
- public Object visit(ThrowsPattern node, Object data) {
- if (node == ThrowsPattern.ANY) return null;
-
- append("throws ");
- node.getRequired().accept(this, data);
- if (node.getForbidden().size() > 0) {
- // a hack since throws !(A, B) cannot be parsed
- try {
- inThrowsForbidden = true;
- node.getForbidden().accept(this, data);
- } finally {
- inThrowsForbidden = false;
- }
- }
- return null;
- }
-
- public Object visit(TypePatternList node, Object data) {
- if (node.getTypePatterns().length == 0) return null;
-
- TypePattern[] typePatterns = node.getTypePatterns();
- for (int i = 0; i < typePatterns.length; i++) {
- TypePattern typePattern = typePatterns[i];
- if (i > 0) append(", ");
- if (inThrowsForbidden) append('!');
- typePattern.accept(this, data);
- }
- return null;
- }
-
- public Object visit(WildAnnotationTypePattern node, Object data) {
- append("@(");
- node.getTypePattern().accept(this, data);
- append(')');
- return null;
- }
-
- public Object visit(WildTypePattern node, Object data) {
- if (node.getAnnotationPattern() != AnnotationTypePattern.ANY) {
- append('(');
- node.getAnnotationPattern().accept(this, data);
- append(' ');
- }
- NamePattern[] namePatterns = node.getNamePatterns();
- for (int i=0; i < namePatterns.length; i++) {
- if (namePatterns[i] == null) {
- append('.');//FIXME mh, error prone, can't we have a nullNamePattern ?
- } else {
- if (i > 0) append('.');
- namePatterns[i].accept(this, data);
- }
- }
- if (node.isIncludeSubtypes()) append('+');
- if (node.isVarArgs()) append("...");
- if (node.getAnnotationPattern() != AnnotationTypePattern.ANY) {
- append(')');
- }
- return null;
- }
-
- public Object visit(WithinAnnotationPointcut node, Object data) {
- append("@within(");
- node.getAnnotationTypePattern().accept(this, data);
- append(')');
- return null;
- }
-
- public Object visit(WithinCodeAnnotationPointcut node, Object data) {
- append("@withincode(");
- node.getAnnotationTypePattern().accept(this, data);
- append(')');
- return null;
- }
-
- public Object visit(WithinPointcut node, Object data) {
- append("within(");
- node.getTypePattern().accept(this, data);
- append(')');
- return null;
- }
-
- public Object visit(WithincodePointcut node, Object data) {
- append("withincode(");
- node.getSignature().accept(this, data);
- append(')');
- return null;
- }
-
- public Object visit(Pointcut.MatchesNothingPointcut node, Object data) {
- append("");//TODO shouldn't that be a "false" ?
- return null;
- }
-
-
- //-------------- perX
-
- public Object visit(PerCflow node, Object data) {
- append(node);
- return null;
- }
-
- public Object visit(PerFromSuper node, Object data) {
- append(node);
- return null;
- }
-
- public Object visit(PerObject node, Object data) {
- append(node);
- return null;
- }
-
- public Object visit(PerSingleton node, Object data) {
- append(node);
- return null;
- }
-
- public Object visit(PerTypeWithin node, Object data) {
- append(node);
- return null;
- }
-
- // ------------- declare X
-
- public Object visit(DeclareAnnotation node, Object data) {
- append(node);
- return null;
- }
-
- public Object visit(DeclareErrorOrWarning node, Object data) {
- append(node);
- return null;
- }
-
- public Object visit(DeclareParents node, Object data) {
- append(node);
- return null;
- }
-
- public Object visit(DeclarePrecedence node, Object data) {
- append(node);
- return null;
- }
-
- public Object visit(DeclareSoft node, Object data) {
- append(node);
- return null;
- }
-
- // ----------- misc
-
- public Object visit(ConcreteCflowPointcut node, Object data) {
- append(node);
- return null;
- }
-
- public Object visit(HandlerPointcut node, Object data) {
- append(node);
- return null;
- }
-
- public Object visit(IfPointcut node, Object data) {
- append(node);
- return null;
- }
-
- public Object visit(TypeVariablePattern node, Object data) {
- append(node);
- return null;
- }
-
- public Object visit(TypeVariablePatternList node, Object data) {
- append(node);
- return null;
- }
-
- public Object visit(HasMemberTypePattern node, Object data) {
- append(node);
- return null;
- }
-
- public static void check(String s) {
- check(Pointcut.fromString(s), false);
- }
-
- public static void check(PatternNode pc, boolean isTypePattern) {
- DumpPointcutVisitor v1 = new DumpPointcutVisitor();
- pc.accept(v1, null);
-
- DumpPointcutVisitor v2 = new DumpPointcutVisitor();
- final PatternNode pc2;
- if (isTypePattern) {
- pc2 = new PatternParser(v1.get()).parseTypePattern();
- } else {
- pc2 = Pointcut.fromString(v1.get());
- }
- pc2.accept(v2, null);
-
- // at second parsing, the String form stay stable when parsed and parsed again
- if (! v1.get().equals(v2.get())) {
- throw new ParserException("Unstable back parsing for '"+pc+"', got '" + v1.get() + "' and '" + v2.get() + "'", null);
- }
- }
-
- public static void main(String args[]) throws Throwable {
- String[] s = new String[]{
- //"@args(Foo, Goo, *, .., Moo)",
- //"execution(* *())",
- //"call(* *(int, Integer...))",
- //"staticinitialization(@(Foo) @(Boo) @(Goo) Moo)",
- "(if(true) && set(int BaseApp.i))"
-
- };
- for (int i = 0; i < s.length; i++) {
- check(s[i]);
- }
- }
-
-} \ No newline at end of file
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/ModifiersPatternTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/ModifiersPatternTestCase.java
deleted file mode 100644
index 91e183092..000000000
--- a/weaver/testsrc/org/aspectj/weaver/patterns/ModifiersPatternTestCase.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.weaver.patterns;
-
-import java.io.*;
-import java.lang.reflect.*;
-
-import org.aspectj.weaver.bcel.*;
-
-import junit.framework.TestCase;
-import org.aspectj.weaver.*;
-
-public class ModifiersPatternTestCase extends TestCase {
- /**
- * Constructor for PatternTestCase.
- * @param name
- */
- public ModifiersPatternTestCase(String name) {
- super(name);
- }
-
- World world;
-
- public void testMatch() {
- world = new BcelWorld();
-
- int[] publicMatches = new int[] {
- Modifier.PUBLIC,
- Modifier.PUBLIC | Modifier.STATIC,
- Modifier.PUBLIC | Modifier.STATIC | Modifier.STRICT | Modifier.FINAL,
- };
-
- int[] publicFailures = new int[] {
- Modifier.PRIVATE,
- 0,
- Modifier.STATIC | Modifier.STRICT | Modifier.FINAL,
- };
-
- int[] publicStaticMatches = new int[] {
- Modifier.PUBLIC | Modifier.STATIC,
- Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL | Modifier.STRICT,
- };
-
- int[] publicStaticFailures = new int[] {
- 0,
- Modifier.PUBLIC,
- Modifier.STATIC,
- };
-
- int[] trickMatches = new int[] {
- Modifier.PRIVATE,
- Modifier.PRIVATE | Modifier.ABSTRACT,
- Modifier.PRIVATE | Modifier.FINAL,
- };
-
- int[] trickFailures = new int[] {
- Modifier.PUBLIC,
- Modifier.PRIVATE | Modifier.STATIC,
- Modifier.PRIVATE | Modifier.STRICT,
- };
-
-
- int[] none = new int[0];
-
- checkMatch("", publicMatches, none);
- checkMatch("", publicFailures, none);
- checkMatch("!public", publicFailures, publicMatches);
- checkMatch("public", publicMatches, publicFailures);
- checkMatch("public static", none, publicFailures);
- checkMatch("public static", publicStaticMatches, publicStaticFailures);
-
- checkMatch("private !static !strictfp", trickMatches, trickFailures);
- checkMatch("private !static !strictfp", none, publicMatches);
- checkMatch("private !static !strictfp", none, publicStaticMatches);
- }
-
- private ModifiersPattern makeModifiersPattern(String pattern) {
- return new PatternParser(pattern).parseModifiersPattern();
- }
-
- private void checkMatch(String pattern, int[] shouldMatch, int[] shouldFail) {
- ModifiersPattern p = makeModifiersPattern(pattern);
- checkMatch(p, shouldMatch, true);
- checkMatch(p, shouldFail, false);
- }
-
- private void checkMatch(ModifiersPattern p, int[] matches, boolean shouldMatch) {
- for (int i=0; i<matches.length; i++) {
- boolean result = p.matches(matches[i]);
- String msg = "matches " + p + " to " + Modifier.toString(matches[i]) + " expected ";
- if (shouldMatch) {
- assertTrue(msg + shouldMatch, result);
- } else {
- assertTrue(msg + shouldMatch, !result);
- }
- }
- }
-
- public void testSerialization() throws IOException {
- String[] patterns = new String[] {
- "", "!public", "public", "public static",
- "private !static !strictfp",
- };
-
- for (int i=0, len=patterns.length; i < len; i++) {
- checkSerialization(patterns[i]);
- }
- }
-
- /**
- * Method checkSerialization.
- * @param string
- */
- private void checkSerialization(String string) throws IOException {
- ModifiersPattern p = makeModifiersPattern(string);
- ByteArrayOutputStream bo = new ByteArrayOutputStream();
- DataOutputStream out = new DataOutputStream(bo);
- p.write(out);
- out.close();
-
- ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray());
- VersionedDataInputStream in = new VersionedDataInputStream(bi);
- ModifiersPattern newP = ModifiersPattern.read(in);
-
- assertEquals("write/read", p, newP);
- }
-
-}
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/NamePatternParserTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/NamePatternParserTestCase.java
deleted file mode 100644
index dd4212b29..000000000
--- a/weaver/testsrc/org/aspectj/weaver/patterns/NamePatternParserTestCase.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.weaver.patterns;
-
-import junit.framework.TestCase;
-
-/**
- * @author hugunin
- *
- * To change this generated comment edit the template variable "typecomment":
- * Window>Preferences>Java>Templates.
- * To enable and disable the creation of type comments go to
- * Window>Preferences>Java>Code Generation.
- */
-public class NamePatternParserTestCase extends TestCase {
- /**
- * Constructor for PatternTestCase.
- * @param name
- */
- public NamePatternParserTestCase(String name) {
- super(name);
- }
-
- public void testMatch() {
- checkMatch(NamePatternTestCase.matchAll);
- checkMatch(NamePatternTestCase.match1);
- checkMatch(NamePatternTestCase.match2);
-
-
- NamePattern p = new PatternParser("abc *").parseNamePattern();
- assertEquals(new NamePattern("abc"), p);
- }
-
- /**
- * Method checkMatch.
- * @param string
- * @param matchAll
- * @param b
- */
- private void checkMatch(String[] patterns) {
- for (int i=0, len=patterns.length; i < len; i++) {
- String pattern = patterns[i];
- ITokenSource tokenSource = BasicTokenSource.makeTokenSource(pattern,null);
- NamePattern p1 = new PatternParser(tokenSource).parseNamePattern();
- NamePattern p2 = new NamePattern(pattern);
- assertEquals("pattern: " + pattern, p2, p1);
- assertEquals("eof", IToken.EOF, tokenSource.next());
- }
- }
-}
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/NamePatternTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/NamePatternTestCase.java
deleted file mode 100644
index ada1545ed..000000000
--- a/weaver/testsrc/org/aspectj/weaver/patterns/NamePatternTestCase.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.weaver.patterns;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-import org.aspectj.weaver.VersionedDataInputStream;
-
-import junit.framework.TestCase;
-
-/**
- * @author hugunin
- *
- * To change this generated comment edit the template variable "typecomment":
- * Window>Preferences>Java>Templates.
- * To enable and disable the creation of type comments go to
- * Window>Preferences>Java>Code Generation.
- */
-public class NamePatternTestCase extends TestCase {
- static String[] matchAll = new String[] {
- "*****",
- "*"
- };
-
-
- static String[] match1 = new String[] {
- "abcde", "abc*", "abcd*", "abcde*",
- "*e", "*cde", "*abcde",
- "a*e", "ab*e", "abc*de",
- "*a*b*c*d*e*", "a*c*e", "a***bcde",
- "*d*",
- };
-
- static String[] match2 = new String[] {
- "abababab",
- "aba*", "abab*", "abababab*",
- "*b", "*ab", "*ababab", "*abababab",
- "a*b", "ab*b", "abab*abab",
- "*a*b*a*b*a*b*a*b*", "a*****b", "a**b", "ab*b*b",
- };
-
- /**
- * Constructor for PatternTestCase.
- * @param name
- */
- public NamePatternTestCase(String name) {
- super(name);
- }
-
- public void testMatch() {
- checkMatch("abcde", matchAll, true);
- checkMatch("abcde", match1, true);
- checkMatch("abcde", match2, false);
-
- checkMatch("abababab", matchAll, true);
- checkMatch("abababab", match1, false);
- checkMatch("abababab", match2, true);
-
- }
-
- /**
- * Method checkMatch.
- * @param string
- * @param matchAll
- * @param b
- */
- private void checkMatch(String string, String[] patterns, boolean shouldMatch) {
- for (int i=0, len=patterns.length; i < len; i++) {
- NamePattern p = new NamePattern(patterns[i]);
- checkMatch(string, p, shouldMatch);
- }
- }
-
- private void checkMatch(String string, NamePattern p, boolean shouldMatch) {
- String msg = "matching " + string + " to " + p;
- assertEquals(msg, shouldMatch, p.matches(string));
- }
-
-
- public void testSerialization() throws IOException {
- checkSerialization(matchAll);
- checkSerialization(match1);
- checkSerialization(match2);
- }
-
- private void checkSerialization(String[] patterns) throws IOException {
- for (int i=0, len=patterns.length; i < len; i++) {
- NamePattern p = new NamePattern(patterns[i]);
- checkSerialization(p);
- }
- }
-
-
- private void checkSerialization(NamePattern p) throws IOException {
- ByteArrayOutputStream bo = new ByteArrayOutputStream();
- DataOutputStream out = new DataOutputStream(bo);
- p.write(out);
- out.close();
-
- ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray());
- VersionedDataInputStream in = new VersionedDataInputStream(bi);
- NamePattern newP = NamePattern.read(in);
-
- assertEquals("write/read", p, newP);
- }
-
-}
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/ParserTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/ParserTestCase.java
deleted file mode 100644
index 917fe816b..000000000
--- a/weaver/testsrc/org/aspectj/weaver/patterns/ParserTestCase.java
+++ /dev/null
@@ -1,790 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * PARC initial implementation
- * ******************************************************************/
-
-package org.aspectj.weaver.patterns;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.aspectj.weaver.BcweaverTests;
-import org.aspectj.weaver.Shadow;
-import org.aspectj.weaver.UnresolvedType;
-import org.aspectj.weaver.World;
-import org.aspectj.weaver.bcel.BcelWorld;
-
-/**
- * @author hugunin
- *
- * To change this generated comment edit the template variable "typecomment": Window>Preferences>Java>Templates. To enable
- * and disable the creation of type comments go to Window>Preferences>Java>Code Generation.
- */
-public class ParserTestCase extends TestCase {
-
- public ParserTestCase(String arg0) {
- super(arg0);
- }
-
- World world = new BcelWorld(BcweaverTests.TESTDATA_PATH + "/testcode.jar");
-
- public void testNamePatterns() {
-
- // checkNoMatch("abc *", "abcd");
- // checkNoMatch("* d", "abcd");
- }
-
- public void testParse() {
- PatternParser parser = new PatternParser("execution(void Hello.*(..))");
- KindedPointcut p = (KindedPointcut) parser.parsePointcut();
- // System.out.println(p);
- assertEquals(p.kind, Shadow.MethodExecution);
- assertTrue(p.getSignature().getName().matches("foobar"));
-
- try {
- new PatternParser("initialization(void foo())").parsePointcut();
- fail("should have been a parse error");
- } catch (ParserException pe) {
- // good
- }
- }
-
- public void testParseExecutionWithAnnotation() {
- PatternParser parser = new PatternParser("execution(@SimpleAnnotation void Hello.*(..))");
- KindedPointcut p = (KindedPointcut) parser.parsePointcut();
- // XXX - needs finishing...
- p.resolveBindings(makeSimpleScope(), new Bindings(3));
- assertEquals("execution(@p.SimpleAnnotation void Hello.*(..))", p.toString());
- assertEquals(p.kind, Shadow.MethodExecution);
- assertTrue(p.getSignature().getName().matches("foobar"));
- }
-
- // note... toString on a pointcut is a very quick and easy way to test a successful parse
- public void testParseExecutionWithMultipleAnnotations() {
- PatternParser parser = new PatternParser("execution(@SimpleAnnotation (@Foo Integer) (@Goo Hello).*(..))");
- KindedPointcut p = (KindedPointcut) parser.parsePointcut();
- assertEquals("execution(@(SimpleAnnotation) (@(Foo) Integer) (@(Goo) Hello).*(..))", p.toString());
- }
-
- public void testParseCallWithMultipleAnnotations() {
- PatternParser parser = new PatternParser("call(@SimpleAnnotation (@Foo Integer) (@Goo Hello).*(..))");
- KindedPointcut p = (KindedPointcut) parser.parsePointcut();
- assertEquals("call(@(SimpleAnnotation) (@(Foo) Integer) (@(Goo) Hello).*(..))", p.toString());
- }
-
- public void testParseGetWithAnnotations() {
- PatternParser parser = new PatternParser("get(@Foo (@SimpleAnnotation ReturnType) (@Foo @Goo Hello).*)");
- KindedPointcut p = (KindedPointcut) parser.parsePointcut();
- assertEquals("get(@(Foo) (@(SimpleAnnotation) ReturnType) (@(Foo) @(Goo) Hello).*)", p.toString());
- }
-
- public void testParseBadGetWithAnnotations() {
- PatternParser parser = new PatternParser("get(@Foo (@Foo @Goo Hello).*)");
- try {
- // KindedPointcut p = (KindedPointcut)
- parser.parsePointcut();
- fail("Expected parser exception");
- } catch (ParserException pEx) {
- assertEquals("name pattern", pEx.getMessage());
- }
- }
-
- public void testParseGetWithAndAggregationAnnotations() {
- PatternParser parser = new PatternParser("get(@Foo @SimpleAnnotation ReturnType (@Foo @Goo Hello).*)");
- KindedPointcut p = (KindedPointcut) parser.parsePointcut();
- assertEquals("get(@(Foo) @(SimpleAnnotation) ReturnType (@(Foo) @(Goo) Hello).*)", p.toString());
- }
-
- public void testParseSetWithAnnotations() {
- PatternParser parser = new PatternParser("set(@Foo (@SimpleAnnotation ReturnType) (@Foo @Goo Hello).*)");
- KindedPointcut p = (KindedPointcut) parser.parsePointcut();
- assertEquals("set(@(Foo) (@(SimpleAnnotation) ReturnType) (@(Foo) @(Goo) Hello).*)", p.toString());
- }
-
- public void testParseHandlerWithAnnotations() {
- PatternParser parser = new PatternParser("handler(@Critical Exception+)");
- Pointcut p = parser.parsePointcut();
- assertEquals("handler((@(Critical) Exception+))", p.toString());
- }
-
- public void testParseInitializationWithAnnotations() {
- PatternParser parser = new PatternParser("initialization(@Foo (@Goo Hello).new(@Foo Integer))");
- Pointcut p = parser.parsePointcut();
- assertEquals("initialization(@(Foo) (@(Goo) Hello).new((@(Foo) Integer)))", p.toString());
-
- }
-
- public void testParsePreInitializationWithAnnotations() {
- PatternParser parser = new PatternParser("preinitialization(@Foo (@Goo Hello).new(@Foo Integer))");
- Pointcut p = parser.parsePointcut();
- assertEquals("preinitialization(@(Foo) (@(Goo) Hello).new((@(Foo) Integer)))", p.toString());
- }
-
- public void testStaticInitializationWithAnnotations() {
- PatternParser parser = new PatternParser("staticinitialization(@Foo @Boo @Goo Moo)");
- Pointcut p = parser.parsePointcut();
- assertEquals("staticinitialization((@(Foo) @(Boo) @(Goo) Moo).<clinit>())", p.toString());
- }
-
- public void testWithinWithAnnotations() {
- PatternParser parser = new PatternParser("within(@Foo *)");
- Pointcut p = parser.parsePointcut();
- assertEquals("within((@(Foo) *))", p.toString());
- }
-
- public void testWithinCodeWithAnnotations() {
- PatternParser parser = new PatternParser("withincode(@Foo * *.*(..))");
- Pointcut p = parser.parsePointcut();
- assertEquals("withincode(@(Foo) * *.*(..))", p.toString());
- }
-
- public void testAtAnnotation() {
- PatternParser parser = new PatternParser("@annotation(Foo)");
- AnnotationPointcut p = (AnnotationPointcut) parser.parsePointcut();
- assertEquals("@annotation(Foo)", p.toString());
- }
-
- public void testBadAtAnnotation() {
- PatternParser parser = new PatternParser("@annotation(!Foo)");
- try {
- // Pointcut p =
- parser.parsePointcut();
- fail("Expected parser exception");
- } catch (ParserException pEx) {
- assertEquals("identifier", pEx.getMessage());
- }
- }
-
- public void testAtAnnotationWithBinding() {
- PatternParser parser = new PatternParser("@annotation(foo)");
- AnnotationPointcut p = (AnnotationPointcut) parser.parsePointcut();
- assertEquals("@annotation(foo)", p.toString());
- }
-
- public void testDoubleAtAnnotation() {
- PatternParser parser = new PatternParser("@annotation(Foo Goo)");
- try {
- // Pointcut p =
- parser.parsePointcut();
- fail("Expected parser exception");
- } catch (ParserException pEx) {
- assertEquals(")", pEx.getMessage());
- }
- }
-
- public void testAtWithin() {
- PatternParser parser = new PatternParser("@within(foo)");
- WithinAnnotationPointcut p = (WithinAnnotationPointcut) parser.parsePointcut();
- assertEquals("@within(foo)", p.toString());
- parser = new PatternParser("@within(Foo))");
- p = (WithinAnnotationPointcut) parser.parsePointcut();
- assertEquals("@within(Foo)", p.toString());
- }
-
- public void testAtWithinCode() {
- PatternParser parser = new PatternParser("@withincode(foo)");
- WithinCodeAnnotationPointcut p = (WithinCodeAnnotationPointcut) parser.parsePointcut();
- assertEquals("@withincode(foo)", p.toString());
- parser = new PatternParser("@withincode(Foo))");
- p = (WithinCodeAnnotationPointcut) parser.parsePointcut();
- assertEquals("@withincode(Foo)", p.toString());
- }
-
- public void testAtThis() {
- PatternParser parser = new PatternParser("@this(foo)");
- ThisOrTargetAnnotationPointcut p = (ThisOrTargetAnnotationPointcut) parser.parsePointcut();
- assertEquals("@this(foo)", p.toString());
- assertTrue("isThis", p.isThis());
- parser = new PatternParser("@this(Foo))");
- p = (ThisOrTargetAnnotationPointcut) parser.parsePointcut();
- assertTrue("isThis", p.isThis());
- assertEquals("@this(Foo)", p.toString());
- }
-
- public void testAtTarget() {
- PatternParser parser = new PatternParser("@target(foo)");
- ThisOrTargetAnnotationPointcut p = (ThisOrTargetAnnotationPointcut) parser.parsePointcut();
- assertEquals("@target(foo)", p.toString());
- assertTrue("isTarget", !p.isThis());
- parser = new PatternParser("@target(Foo))");
- p = (ThisOrTargetAnnotationPointcut) parser.parsePointcut();
- assertTrue("isTarget", !p.isThis());
- assertEquals("@target(Foo)", p.toString());
- }
-
- public void testAtArgs() {
- PatternParser parser = new PatternParser("@args(Foo,Goo,*,..,Moo)");
- Pointcut p = parser.parsePointcut();
- assertEquals("@args(Foo, Goo, ANY, .., Moo)", p.toString());
- }
-
- public void testParseSimpleTypeVariable() {
- PatternParser parser = new PatternParser("T");
- TypeVariablePattern tv = parser.parseTypeVariable();
- TypeVariablePattern expected = new TypeVariablePattern("T");
- assertEquals("Expected simple type variable T", expected, tv);
- }
-
- public void testParseExtendingTypeVariable() {
- PatternParser parser = new PatternParser("T extends Number");
- TypeVariablePattern tv = parser.parseTypeVariable();
- TypeVariablePattern expected = new TypeVariablePattern("T", new PatternParser("Number").parseTypePattern());
- assertEquals("Expected type variable T extends Number", expected, tv);
- }
-
- public void testParseExtendingTypeVariableWithPattern() {
- PatternParser parser = new PatternParser("T extends Number+");
- TypeVariablePattern tv = parser.parseTypeVariable();
- TypeVariablePattern expected = new TypeVariablePattern("T", new PatternParser("Number+").parseTypePattern());
- assertEquals("Expected type variable T extends Number+", expected, tv);
- }
-
- public void testParseExtendingTypeVariableWithInterface() {
- PatternParser parser = new PatternParser("T extends Number & Comparable");
- TypeVariablePattern tv = parser.parseTypeVariable();
- TypeVariablePattern expected = new TypeVariablePattern("T", new PatternParser("Number").parseTypePattern(),
- new TypePattern[] { new PatternParser("Comparable").parseTypePattern() }, null);
- assertEquals("Expected type variable T extends Number", expected, tv);
- }
-
- public void testParseExtendingTypeVariableWithInterfaceList() {
- PatternParser parser = new PatternParser("T extends Number & Comparable & Cloneable");
- TypeVariablePattern tv = parser.parseTypeVariable();
- TypeVariablePattern expected = new TypeVariablePattern("T", new PatternParser("Number").parseTypePattern(),
- new TypePattern[] { new PatternParser("Comparable").parseTypePattern(),
- new PatternParser("Cloneable").parseTypePattern() }, null);
- assertEquals("Expected type variable T extends Number", expected, tv);
- }
-
- public void testParseTypeParameterList() {
- PatternParser parser = new PatternParser("<T>");
- TypeVariablePatternList list = parser.maybeParseTypeVariableList();
- TypeVariablePattern[] patterns = list.getTypeVariablePatterns();
- TypeVariablePattern expected = new TypeVariablePattern("T");
- assertEquals("Expected simple type variable T", expected, patterns[0]);
- assertEquals("One pattern in list", 1, patterns.length);
- }
-
- public void testParseTypeParameterListWithSeveralTypeParameters() {
- PatternParser parser = new PatternParser("<T,S extends Number, R>");
- TypeVariablePatternList list = parser.maybeParseTypeVariableList();
- TypeVariablePattern[] patterns = list.getTypeVariablePatterns();
- TypeVariablePattern expected0 = new TypeVariablePattern("T");
- assertEquals("Expected simple type variable T", expected0, patterns[0]);
- TypeVariablePattern expected1 = new TypeVariablePattern("S", new PatternParser("Number").parseTypePattern());
- assertEquals("Expected type variable S extends Number", expected1, patterns[1]);
- TypeVariablePattern expected2 = new TypeVariablePattern("R");
- assertEquals("Expected simple type variable R", expected2, patterns[2]);
-
- assertEquals("3 patterns in list", 3, patterns.length);
- }
-
- public void testParseAllowedSuperInTypeVariable() {
- PatternParser parser = new PatternParser("T super Number+");
- TypeVariablePattern tv = parser.parseTypeVariable();
- TypeVariablePattern expected = new TypeVariablePattern("T", new ExactTypePattern(UnresolvedType.OBJECT, false, false),
- null, new PatternParser("Number+").parseTypePattern());
- assertEquals("Expected type variable T super Number+", expected, tv);
- }
-
- public void testParseAnythingTypeVariable() {
- PatternParser parser = new PatternParser("?");
- WildTypePattern tp = (WildTypePattern) parser.parseTypePattern(true, false);
- assertEquals("Expected type variable ?", "?", tp.maybeGetSimpleName());
- }
-
- public void testParseAnythingExtendsTypeVariable() {
- PatternParser parser = new PatternParser("? extends Number");
- WildTypePattern tp = (WildTypePattern) parser.parseTypePattern(true, false);
- assertEquals("Expected type variable ?", "?", tp.maybeGetSimpleName());
- assertEquals("upper Bound of Number", new PatternParser("Number").parseTypePattern(), tp.getUpperBound());
- }
-
- public void testParseAnythingSuperTypeVariable() {
- PatternParser parser = new PatternParser("? super Number+");
- WildTypePattern tp = (WildTypePattern) parser.parseTypePattern(true, false);
- assertEquals("Expected type variable ?", "?", tp.maybeGetSimpleName());
- assertEquals("lower Bound of Number+", new PatternParser("Number+").parseTypePattern(), tp.getLowerBound());
- }
-
- public void testParseDeclareParentsWithTypeParameterList() {
- try {
- PatternParser parser = new PatternParser("declare parents<T> : Foo<T> implements IveGoneMad");
- // DeclareParents decp = (DeclareParents)
- parser.parseDeclare();
- // String[] tvp = decp.getTypeParameterNames();
- // assertEquals("one type parameter",1,tvp.length);
- // assertEquals("expecting T","T",tvp[0]);
- fail("Expecting parse exception");
- } catch (ParserException pEx) {
- assertEquals(":", pEx.getMessage());
- }
- }
-
- public void testParameterizedTypePatternsAny() {
- try {
- PatternParser parser = new PatternParser("*<T,S extends Number>");
- // WildTypePattern wtp = (WildTypePattern)
- parser.parseTypePattern(false, false);
- // TypePatternList tvs = wtp.getTypeParameters();
- // assertEquals("2 type parameters",2,tvs.getTypePatterns().length);
- // assertEquals("T",new PatternParser("T").parseTypePattern(),tvs.getTypePatterns()[0]);
- // assertEquals("S extends Number",new
- // PatternParser("S extends Number").parseTypePattern(false),tvs.getTypePatterns()[1]);
- fail("Expecting parse exception");
- } catch (ParserException pEx) {
- assertEquals(">", pEx.getMessage());
- }
- }
-
- public void testParameterizedTypePatternsSimple() {
- PatternParser parser = new PatternParser("List<String>");
- WildTypePattern wtp = (WildTypePattern) parser.parseTypePattern();
- TypePatternList tvs = wtp.getTypeParameters();
- assertEquals("1 type parameter", 1, tvs.getTypePatterns().length);
- assertEquals("String", new PatternParser("String").parseTypePattern(), tvs.getTypePatterns()[0]);
- assertEquals("List", wtp.getNamePatterns()[0].toString());
- }
-
- public void testNestedParameterizedTypePatterns() {
- PatternParser parser = new PatternParser("List<List<List<String>>>");
- WildTypePattern wtp = (WildTypePattern) parser.parseTypePattern();
- TypePatternList typeParameters = wtp.getTypeParameters();
- WildTypePattern expected = (WildTypePattern) typeParameters.getTypePatterns()[0];
- assertEquals("expecting a List", "List", expected.maybeGetSimpleName());
- typeParameters = expected.getTypeParameters();
- expected = (WildTypePattern) typeParameters.getTypePatterns()[0];
- assertEquals("expecting a List", "List", expected.maybeGetSimpleName());
- typeParameters = expected.getTypeParameters();
- expected = (WildTypePattern) typeParameters.getTypePatterns()[0];
- assertEquals("expecting a String", "String", expected.maybeGetSimpleName());
- }
-
- public void testSimpleTypeVariableList() {
- PatternParser parser = new PatternParser("<T,S,V>");
- String[] tl = parser.maybeParseSimpleTypeVariableList();
- assertEquals("3 patterns", 3, tl.length);
- assertEquals("T", tl[0]);
- assertEquals("S", tl[1]);
- assertEquals("V", tl[2]);
- }
-
- public void testSimpleTypeVariableListError() {
- PatternParser parser = new PatternParser("<T extends Number>");
- try {
- // String[] tl =
- parser.maybeParseSimpleTypeVariableList();
- fail();
- } catch (ParserException ex) {
- assertEquals("Expecting ',' or '>'", "',' or '>'", ex.getMessage());
- }
- }
-
- // test cases for pointcuts involving type variable specification.
- public void testParseCallPCDWithTypeVariables() {
- PatternParser parser = new PatternParser("call<T>(* Foo<T>.*(T))");
- try {
- parser.parsePointcut();
- // String[] tvps = pc.getTypeVariablesInScope();
- // assertEquals("1 type variable",1,tvps.length);
- // assertEquals("T",tvps[0]);
- fail("should have been a parse error");
- } catch (ParserException pEx) {
- assertEquals("(", pEx.getMessage());
- }
- }
-
- public void testParseCallPCDWithIllegalBounds() {
- PatternParser parser = new PatternParser("call<T extends Number>(* Foo<T>.*(T))");
- try {
- parser.parsePointcut();
- fail("Expecting parse exception");
- } catch (ParserException pEx) {
- assertEquals("(", pEx.getMessage());
- }
- }
-
- public void testNoTypeVarsForHandler() {
- PatternParser parser = new PatternParser("handler<T>(Exception<T>)");
- try {
- parser.parsePointcut();
- fail("Expecting parse exception");
- } catch (ParserException pEx) {
- assertEquals("(", pEx.getMessage());
- }
- }
-
- public void testNoTypeVarsForThis() {
- PatternParser parser = new PatternParser("this<T>(Exception<T>)");
- try {
- parser.parsePointcut();
- fail("Expecting parse exception");
- } catch (ParserException pEx) {
- assertEquals("(", pEx.getMessage());
- }
- }
-
- public void testNoTypeVarsForTarget() {
- PatternParser parser = new PatternParser("target<T>(Exception<T>)");
- try {
- parser.parsePointcut();
- fail("Expecting parse exception");
- } catch (ParserException pEx) {
- assertEquals("(", pEx.getMessage());
- }
- }
-
- public void testNoTypeVarsForArgs() {
- PatternParser parser = new PatternParser("args<T>(Exception<T>)");
- try {
- parser.parsePointcut();
- fail("Expecting parse exception");
- } catch (ParserException pEx) {
- assertEquals("(", pEx.getMessage());
- }
- }
-
- public void testNoTypeVarsForIf() {
- PatternParser parser = new PatternParser("if<T>(true)");
- try {
- parser.parsePointcut();
- fail("Expecting parse exception");
- } catch (ParserException pEx) {
- assertEquals("(", pEx.getMessage());
- }
- }
-
- public void testNoTypeVarsForCflow() {
- PatternParser parser = new PatternParser("cflow<T>(call(* *(..)))");
- try {
- parser.parsePointcut();
- fail("Expecting parse exception");
- } catch (ParserException pEx) {
- assertEquals("(", pEx.getMessage());
- }
- }
-
- public void testNoTypeVarsForCflowbelow() {
- PatternParser parser = new PatternParser("cflowbelow<T>(call(* *(..)))");
- try {
- parser.parsePointcut();
- fail("Expecting parse exception");
- } catch (ParserException pEx) {
- assertEquals("(", pEx.getMessage());
- }
- }
-
- public void testNoTypeVarsForAtWithin() {
- PatternParser parser = new PatternParser("@within<T>(Foo<T>)");
- try {
- parser.parsePointcut();
- fail("Expecting parse exception");
- } catch (ParserException pEx) {
- assertEquals("(", pEx.getMessage());
- }
- }
-
- public void testNoTypeVarsForAtAnnotation() {
- PatternParser parser = new PatternParser("@annotation<T>(Foo<T>)");
- try {
- parser.parsePointcut();
- fail("Expecting parse exception");
- } catch (ParserException pEx) {
- assertEquals("(", pEx.getMessage());
- }
- }
-
- public void testNoTypeVarsForAtWithinCode() {
- PatternParser parser = new PatternParser("@withincode<T>(* Foo<T>.*(..))");
- try {
- parser.parsePointcut();
- fail("Expecting parse exception");
- } catch (ParserException pEx) {
- assertEquals("(", pEx.getMessage());
- }
- }
-
- public void testNoTypeVarsForAtThis() {
- PatternParser parser = new PatternParser("@this<T>(Exception<T>)");
- try {
- parser.parsePointcut();
- fail("Expecting parse exception");
- } catch (ParserException pEx) {
- assertEquals("(", pEx.getMessage());
- }
- }
-
- public void testNoTypeVarsForAtTarget() {
- PatternParser parser = new PatternParser("@target<T>(Exception<T>)");
- try {
- parser.parsePointcut();
- fail("Expecting parse exception");
- } catch (ParserException pEx) {
- assertEquals("(", pEx.getMessage());
- }
- }
-
- public void testNoTypeVarsForAtArgs() {
- PatternParser parser = new PatternParser("@args<T>(Exception<T>)");
- try {
- parser.parsePointcut();
- fail("Expecting parse exception");
- } catch (ParserException pEx) {
- assertEquals("(", pEx.getMessage());
- }
- }
-
- public void testExecutionWithTypeVariables() {
- PatternParser parser = new PatternParser("execution<T>(T Bar<T>.doSomething())");
- try {
- // Pointcut pc =
- parser.parsePointcut();
- // String[] tvs = pc.getTypeVariablesInScope();
- // assertEquals("1 type pattern",1,tvs.length);
- // assertEquals("T",tvs[0]);
- fail("should have been a parse error");
- } catch (ParserException pEx) {
- assertEquals("(", pEx.getMessage());
- }
- }
-
- public void testInitializationWithTypeVariables() {
- PatternParser parser = new PatternParser("initialization<T>(Bar<T>.new())");
- try {
- // Pointcut pc =
- parser.parsePointcut();
- // String[] tvs = pc.getTypeVariablesInScope();
- // assertEquals("1 type pattern",1,tvs.length);
- // assertEquals("T",tvs[0]);
- fail("should have been a parse error");
- } catch (ParserException pEx) {
- assertEquals("(", pEx.getMessage());
- }
- }
-
- public void testPreInitializationWithTypeVariables() {
- PatternParser parser = new PatternParser("preinitialization<T>(Bar<T>.new())");
- try {
- // Pointcut pc =
- parser.parsePointcut();
- // String[] tvs = pc.getTypeVariablesInScope();
- // assertEquals("1 type pattern",1,tvs.length);
- // assertEquals("T",tvs[0]);
- fail("should have been a parse error");
- } catch (ParserException pEx) {
- assertEquals("(", pEx.getMessage());
- }
- }
-
- public void testStaticInitializationWithTypeVariables() {
- PatternParser parser = new PatternParser("staticinitialization<T>(Bar<T>)");
- try {
- parser.parsePointcut();
- // String[] tvs = pc.getTypeVariablesInScope();
- // assertEquals("1 type pattern",1,tvs.length);
- // assertEquals("T",tvs[0]);
- fail("should have been a parse error");
- } catch (ParserException pEx) {
- assertEquals("(", pEx.getMessage());
- }
- }
-
- public void testWithinWithTypeVariables() {
- PatternParser parser = new PatternParser("within<T>(Bar<T>)");
- try {
- parser.parsePointcut();
- // String[] tvs = pc.getTypeVariablesInScope();
- // assertEquals("1 type pattern",1,tvs.length);
- // assertEquals("T",tvs[0]);
- fail("should have been a parse error");
- } catch (ParserException pEx) {
- assertEquals("(", pEx.getMessage());
- }
- }
-
- public void testTypeParamList() {
- PatternParser parser = new PatternParser("Bar<T,S extends T, R extends S>");
- try {
- parser.parseTypePattern(false, false);
- // TypePattern[] tps = tp.getTypeParameters().getTypePatterns();
- // assertEquals("3 type patterns",3,tps.length);
- // assertEquals("T",tps[0].toString());
- // assertEquals("S",tps[1].toString());
- // assertEquals("R",tps[2].toString());
- fail("should have been a parse error");
- } catch (ParserException pEx) {
- assertEquals(">", pEx.getMessage());
- }
- }
-
- public void testWithinCodeWithTypeVariables() {
- PatternParser parser = new PatternParser("withincode<T,S,R>(Bar<T,S extends T, R extends S>.new())");
- try {
- parser.parsePointcut();
- // String[] tvs = pc.getTypeVariablesInScope();
- // assertEquals("3 type patterns",3,tvs.length);
- // assertEquals("T",tvs[0]);
- // assertEquals("S",tvs[1]);
- // assertEquals("R",tvs[2]);
- fail("should have been a parse error");
- } catch (ParserException pEx) {
- assertEquals("(", pEx.getMessage());
- }
- }
-
- public void testCallWithTypeVariables() {
- PatternParser parser = new PatternParser("call<T>(* Bar<T>.*(..))");
- try {
- // Pointcut pc =
- parser.parsePointcut();
- // String[] tvs = pc.getTypeVariablesInScope();
- // assertEquals("1 type pattern",1,tvs.length);
- // assertEquals("T",tvs[0]);
- fail("should have been a parse error");
- } catch (ParserException pEx) {
- assertEquals("(", pEx.getMessage());
- }
- }
-
- public void testGetWithTypeVariables() {
- PatternParser parser = new PatternParser("get<T>(* Bar<T>.*)");
- try {
- // Pointcut pc =
- parser.parsePointcut();
- // String[] tvs = pc.getTypeVariablesInScope();
- // assertEquals("1 type pattern",1,tvs.length);
- // assertEquals("T",tvs[0]);
- fail("should have been a parse error");
- } catch (ParserException pEx) {
- assertEquals("(", pEx.getMessage());
- }
- }
-
- public void testSetWithTypeVariables() {
- PatternParser parser = new PatternParser("set<T>(* Bar<T>.*)");
- try {
- // Pointcut pc =
- parser.parsePointcut();
- // String[] tvs = pc.getTypeVariablesInScope();
- // assertEquals("1 type pattern",1,tvs.length);
- // assertEquals("T",tvs[0]);
- fail("should have been a parse error");
- } catch (ParserException pEx) {
- assertEquals("(", pEx.getMessage());
- }
- }
-
- public void testIntAnnotationVal() {
- PatternParser parser = new PatternParser("execution(@ComplexAnnotation(ival=5) * *(..))");
- Pointcut pc = parser.parsePointcut();
- assertEquals("Expected annotation value not found", "ival=5", getValueString(pc));
- }
-
- private String getValueString(Pointcut pc) {
- if (!(pc instanceof KindedPointcut))
- fail("Expected KindedPointcut but was " + pc.getClass());
- KindedPointcut kpc = (KindedPointcut) pc;
- AnnotationTypePattern atp = kpc.getSignature().getAnnotationPattern();
- if (!(atp instanceof WildAnnotationTypePattern))
- fail("Expected WildAnnotationTypePattern but was " + atp.getClass());
- WildAnnotationTypePattern watp = (WildAnnotationTypePattern) atp;
- Map m = watp.annotationValues;
- Set keys = m.keySet();
- List orderedKeys = new ArrayList();
- orderedKeys.addAll(keys);
- Collections.sort(orderedKeys);
- StringBuffer sb = new StringBuffer();
- for (Iterator iterator = orderedKeys.iterator(); iterator.hasNext();) {
- String object = (String) iterator.next();
- sb.append(object).append("=").append(m.get(object));
- if (iterator.hasNext())
- sb.append(",");
- }
- return sb.toString();
- }
-
- public void testByteAnnotationVal() {
- PatternParser parser = new PatternParser("execution(@ComplexAnnotation(bval=5) * *(..))");
- Pointcut pc = parser.parsePointcut();
- assertEquals("Expected annotation value not found", "bval=5", getValueString(pc));
- }
-
- public void testCharAnnotationVal() {
- PatternParser parser = new PatternParser("execution(@ComplexAnnotation(cval='5') * *(..))");
- Pointcut pc = parser.parsePointcut();
- assertEquals("Expected annotation value not found", "cval='5'", getValueString(pc));
- }
-
- public void testLongAnnotationVal() {
- PatternParser parser = new PatternParser("execution(@ComplexAnnotation(jval=123123) * *(..))");
- Pointcut pc = parser.parsePointcut();
- assertEquals("Expected annotation value not found", "jval=123123", getValueString(pc));
- }
-
- public void testDoubleAnnotationVal() {
- PatternParser parser = new PatternParser("execution(@ComplexAnnotation(dval=123.3) * *(..))");
- Pointcut pc = parser.parsePointcut();
- assertEquals("Expected annotation value not found", "dval=123.3", getValueString(pc));
- }
-
- public void testBooleanAnnotationVal() {
- PatternParser parser = new PatternParser("execution(@ComplexAnnotation(zval=true) * *(..))");
- Pointcut pc = parser.parsePointcut();
- assertEquals("Expected annotation value not found", "zval=true", getValueString(pc));
- }
-
- public void testShortAnnotationVal() {
- PatternParser parser = new PatternParser("execution(@ComplexAnnotation(sval=43) * *(..))");
- Pointcut pc = parser.parsePointcut();
- assertEquals("Expected annotation value not found", "sval=43", getValueString(pc));
- }
-
- public void testEnumAnnotationVal() {
- PatternParser parser = new PatternParser("execution(@ComplexAnnotation(enumval=Color.GREEN) * *(..))");
- Pointcut pc = parser.parsePointcut();
- assertEquals("Expected annotation value not found", "enumval=Color.GREEN", getValueString(pc));
- }
-
- public void testStringAnnotationVal() {
- PatternParser parser = new PatternParser("execution(@ComplexAnnotation(strval=\"abc\") * *(..))");
- Pointcut pc = parser.parsePointcut();
- // notice quotes stripped...
- assertEquals("Expected annotation value not found", "strval=abc", getValueString(pc));
- }
-
- public void testClassAnnotationVal() {
- PatternParser parser = new PatternParser("execution(@ComplexAnnotation(classval=String.class) * *(..))");
- Pointcut pc = parser.parsePointcut();
- assertEquals("Expected annotation value not found", "classval=String.class", getValueString(pc));
- }
-
- // failing as {1 is treated as a single token and so we don't realise the , is within the curlies
- // public void testArrayAnnotationVal() {
- // PatternParser parser = new PatternParser("execution(@ComplexAnnotation(arrayval={1,2,3}) * *(..))");
- // Pointcut pc = parser.parsePointcut();
- // assertEquals("Expected annotation value not found","arrayval={1,2,3}",getValueString(pc));
- // }
-
- // ---
-
- public TestScope makeSimpleScope() {
- world.setBehaveInJava5Way(true);
- TestScope s = new TestScope(new String[] { "int", "java.lang.String" }, new String[] { "a", "b" }, world);
- s.setImportedPrefixes(new String[] { "p." });
- return s;
- }
-
-}
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/PatternsTests.java b/weaver/testsrc/org/aspectj/weaver/patterns/PatternsTests.java
deleted file mode 100644
index e304a2ea0..000000000
--- a/weaver/testsrc/org/aspectj/weaver/patterns/PatternsTests.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.weaver.patterns;
-
-import junit.framework.*;
-
-public class PatternsTests extends TestCase {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(PatternsTests.class.getName());
- //$JUnit-BEGIN$
- suite.addTestSuite(AndOrNotTestCase.class);
- suite.addTestSuite(BindingTestCase.class);
- suite.addTestSuite(DeclareErrorOrWarningTestCase.class);
- suite.addTestSuite(ModifiersPatternTestCase.class);
- suite.addTestSuite(NamePatternParserTestCase.class);
- suite.addTestSuite(NamePatternTestCase.class);
- suite.addTestSuite(ParserTestCase.class);
- suite.addTestSuite(SignaturePatternTestCase.class);
- suite.addTestSuite(ThisOrTargetTestCase.class);
- suite.addTestSuite(TypePatternListTestCase.class);
- suite.addTestSuite(TypePatternTestCase.class);
- suite.addTestSuite(WithinTestCase.class);
- suite.addTestSuite(ArgsTestCase.class);
- suite.addTestSuite(AnnotationPatternTestCase.class);
- suite.addTestSuite(AnnotationPatternMatchingTestCase.class);
- suite.addTestSuite(PointcutRewriterTest.class);
-
- suite.addTestSuite(VisitorTestCase.class);
- //$JUnit-END$
- return suite;
- }
-
- public PatternsTests(String name) { super(name); }
-
-
-}
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/PointcutRewriterTest.java b/weaver/testsrc/org/aspectj/weaver/patterns/PointcutRewriterTest.java
deleted file mode 100644
index f6b96ef2c..000000000
--- a/weaver/testsrc/org/aspectj/weaver/patterns/PointcutRewriterTest.java
+++ /dev/null
@@ -1,447 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2004 IBM Corporation.
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * ******************************************************************/
-package org.aspectj.weaver.patterns;
-
-import java.util.Iterator;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import org.aspectj.weaver.Shadow;
-
-import junit.framework.TestCase;
-
-/**
- * @author colyer
- *
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-public class PointcutRewriterTest extends TestCase {
-
- private PointcutRewriter prw;
-
- public void testDistributeNot() {
- Pointcut plain = getPointcut("this(Foo)");
- assertEquals("Unchanged",plain,prw.rewrite(plain));
- Pointcut not = getPointcut("!this(Foo)");
- assertEquals("Unchanged",not,prw.rewrite(not));
- Pointcut notNot = getPointcut("!!this(Foo)");
- assertEquals("this(Foo)",prw.rewrite(notNot).toString());
- Pointcut notNotNOT = getPointcut("!!!this(Foo)");
- assertEquals("!this(Foo)",prw.rewrite(notNotNOT).toString());
- Pointcut and = getPointcut("!(this(Foo) && this(Goo))");
- assertEquals("(!this(Foo) || !this(Goo))",prw.rewrite(and,true).toString());
- Pointcut or = getPointcut("!(this(Foo) || this(Goo))");
- assertEquals("(!this(Foo) && !this(Goo))",prw.rewrite(or,true).toString());
- Pointcut nestedNot = getPointcut("!(this(Foo) && !this(Goo))");
- assertEquals("(!this(Foo) || this(Goo))",prw.rewrite(nestedNot,true).toString());
- }
-
- public void testPullUpDisjunctions() {
- Pointcut aAndb = getPointcut("this(Foo) && this(Goo)");
- assertEquals("Unchanged",aAndb,prw.rewrite(aAndb));
- Pointcut aOrb = getPointcut("this(Foo) || this(Moo)");
- assertEquals("Unchanged",aOrb,prw.rewrite(aOrb));
-
- Pointcut leftOr = getPointcut("this(Foo) || (this(Goo) && this(Boo))");
- assertEquals("or%anyorder%this(Foo)%and%anyorder%this(Boo)%this(Goo)",prw.rewrite(leftOr));
- //assertEquals("(this(Foo) || (this(Boo) && this(Goo)))",prw.rewrite(leftOr).toString());
-
- Pointcut rightOr = getPointcut("(this(Goo) && this(Boo)) || this(Foo)");
-// assertEquals("(this(Foo) || (this(Boo) && this(Goo)))",prw.rewrite(rightOr).toString());
- assertEquals("or%anyorder%this(Foo)%and%anyorder%this(Goo)%this(Boo)",prw.rewrite(rightOr));
-
- Pointcut leftAnd = getPointcut("this(Foo) && (this(Goo) || this(Boo))");
-// assertEquals("((this(Boo) && this(Foo)) || (this(Foo) && this(Goo)))",prw.rewrite(leftAnd).toString());
- assertEquals("or%anyorder%and%anyorder%this(Boo)%this(Foo)%and%anyorder%this(Foo)%this(Goo)",prw.rewrite(leftAnd));
-
- Pointcut rightAnd = getPointcut("(this(Goo) || this(Boo)) && this(Foo)");
-// assertEquals("((this(Boo) && this(Foo)) || (this(Foo) && this(Goo)))",prw.rewrite(rightAnd).toString());
- assertEquals("or%anyorder%and%anyorder%this(Boo)%this(Foo)%and%anyorder%this(Foo)%this(Goo)",prw.rewrite(rightAnd));
-
- Pointcut nestedOrs = getPointcut("this(Foo) || this(Goo) || this(Boo)");
-// assertEquals("((this(Boo) || this(Foo)) || this(Goo))",prw.rewrite(nestedOrs).toString());
- assertEquals("or%anyorder%this(Goo)%or%anyorder%this(Boo)%this(Foo)",prw.rewrite(nestedOrs));
-
- Pointcut nestedAnds = getPointcut("(this(Foo) && (this(Boo) && (this(Goo) || this(Moo))))");
- // t(F) && (t(B) && (t(G) || t(M)))
- // ==> t(F) && ((t(B) && t(G)) || (t(B) && t(M)))
- // ==> (t(F) && (t(B) && t(G))) || (t(F) && (t(B) && t(M)))
-// assertEquals("(((this(Boo) && this(Foo)) && this(Goo)) || ((this(Boo) && this(Foo)) && this(Moo)))",
-// prw.rewrite(nestedAnds).toString());
- assertEquals("or%anyorder%and%anyorder%and%anyorder%this(Boo)%this(Foo)%this(Goo)%and%anyorder%and%anyorder%this(Boo)%this(Foo)%this(Moo)",prw.rewrite(nestedAnds));
- }
-
- /**
- * spec is reverse polish notation with operators and, or , not, anyorder,
- * delimiter is "%" (not whitespace).
- * @param spec
- * @param pc
- */
- private void assertEquals(String spec, Pointcut pc) {
- StringTokenizer strTok = new StringTokenizer(spec,"%");
- String[] tokens = new String[strTok.countTokens()];
- for (int i = 0; i < tokens.length; i++) {
- tokens[i] = strTok.nextToken();
- }
- tokenIndex = 0;
- assertTrue(spec,equals(pc,tokens));
- }
-
- private int tokenIndex = 0;
- private boolean equals(Pointcut pc, String[] tokens) {
- if (tokens[tokenIndex].equals("and")) {
- tokenIndex++;
- if (!(pc instanceof AndPointcut)) return false;
- AndPointcut apc = (AndPointcut) pc;
- Pointcut left = apc.getLeft();
- Pointcut right = apc.getRight();
- if (tokens[tokenIndex].equals("anyorder")) {
- tokenIndex++;
- int restorePoint = tokenIndex;
- boolean leftMatchFirst = equals(left,tokens) &&
- equals(right,tokens);
- if (leftMatchFirst) return true;
- tokenIndex = restorePoint;
- boolean rightMatchFirst = equals(right,tokens) &&
- equals(left,tokens);
- return rightMatchFirst;
- } else {
- return equals(left,tokens) &&
- equals(right,tokens);
- }
- } else if (tokens[tokenIndex].equals("or")) {
- tokenIndex++;
- if (!(pc instanceof OrPointcut)) return false;
- OrPointcut opc = (OrPointcut) pc;
- Pointcut left = opc.getLeft();
- Pointcut right = opc.getRight();
- if (tokens[tokenIndex].equals("anyorder")) {
- tokenIndex++;
- int restorePoint = tokenIndex;
- boolean leftMatchFirst = equals(left,tokens) &&
- equals(right,tokens);
- if (leftMatchFirst) return true;
- tokenIndex = restorePoint;
- boolean rightMatchFirst = equals(right,tokens) &&
- equals(left,tokens);
- return rightMatchFirst;
- } else {
- return equals(left,tokens) &&
- equals(right,tokens);
- }
-
- } else if (tokens[tokenIndex].equals("not")) {
- if (!(pc instanceof NotPointcut)) return false;
- tokenIndex++;
- NotPointcut np = (NotPointcut) pc;
- return equals(np.getNegatedPointcut(),tokens);
- } else {
- return tokens[tokenIndex++].equals(pc.toString());
- }
- }
-
-// public void testSplitOutWithins() {
-// Pointcut simpleExecution = getPointcut("execution(* *.*(..))");
-// assertEquals("Unchanged",simpleExecution,prw.rewrite(simpleExecution));
-// Pointcut simpleWithinCode = getPointcut("withincode(* *.*(..))");
-// assertEquals("Unchanged",simpleWithinCode,prw.rewrite(simpleWithinCode));
-// Pointcut execution = getPointcut("execution(@Foo Foo (@Goo org.xyz..*).m*(Foo,Boo))");
-// assertEquals("(within((@(Goo) org.xyz..*)) && execution(@(Foo) Foo m*(Foo, Boo)))",
-// prw.rewrite(execution).toString());
-// Pointcut withincode = getPointcut("withincode(@Foo Foo (@Goo org.xyz..*).m*(Foo,Boo))");
-// assertEquals("(within((@(Goo) org.xyz..*)) && withincode(@(Foo) Foo m*(Foo, Boo)))",
-// prw.rewrite(withincode).toString());
-// Pointcut notExecution = getPointcut("!execution(Foo BankAccount+.*(..))");
-// assertEquals("(!within(BankAccount+) || !execution(Foo *(..)))",
-// prw.rewrite(notExecution).toString());
-// Pointcut andWithincode = getPointcut("withincode(Foo.new(..)) && this(Foo)");
-// assertEquals("((within(Foo) && withincode(new(..))) && this(Foo))",
-// prw.rewrite(andWithincode).toString());
-// Pointcut orExecution = getPointcut("this(Foo) || execution(Goo Foo.moo(Baa))");
-// assertEquals("((within(Foo) && execution(Goo moo(Baa))) || this(Foo))",
-// prw.rewrite(orExecution).toString());
-// }
-
-
- public void testRemoveDuplicatesInAnd() {
- Pointcut dupAnd = getPointcut("this(Foo) && this(Foo)");
- assertEquals("this(Foo)",prw.rewrite(dupAnd).toString());
- Pointcut splitdupAnd = getPointcut("(this(Foo) && target(Boo)) && this(Foo)");
- assertEquals("(target(Boo) && this(Foo))",prw.rewrite(splitdupAnd).toString());
- }
-
- public void testNotRemoveNearlyDuplicatesInAnd() {
- Pointcut toAndto = getPointcut("this(Object+) && this(Object)");
-// Pointcut rewritten =
- prw.rewrite(toAndto);
- }
-
- public void testAAndNotAinAnd() {
- Pointcut aAndNota = getPointcut("this(Foo)&& !this(Foo)");
- assertEquals("Matches nothing","",prw.rewrite(aAndNota).toString());
- Pointcut aAndBAndNota = getPointcut("this(Foo) && execution(* *.*(..)) && !this(Foo)");
- assertEquals("Matches nothing","",prw.rewrite(aAndBAndNota).toString());
- }
-
- public void testIfFalseInAnd() {
- Pointcut ifFalse = IfPointcut.makeIfFalsePointcut(Pointcut.CONCRETE);
- Pointcut p = getPointcut("this(A)");
- assertEquals("Matches nothing","",prw.rewrite(new AndPointcut(ifFalse,p)).toString());
- }
-
- public void testMatchesNothinginAnd() {
- Pointcut nothing = Pointcut.makeMatchesNothing(Pointcut.CONCRETE);
- Pointcut p = getPointcut("this(A)");
- assertEquals("Matches nothing","",prw.rewrite(new AndPointcut(nothing,p)).toString());
- }
-
- public void testMixedKindsInAnd() {
- Pointcut mixedKinds = getPointcut("call(* *(..)) && execution(* *(..))");
- assertEquals("Matches nothing","",prw.rewrite(mixedKinds).toString());
- Pointcut ok = getPointcut("call(* *(..)) && this(Foo)");
- assertEquals(ok,prw.rewrite(ok));
- }
-
- public void testDetermineKindSetOfAnd() {
- Pointcut oneKind = getPointcut("execution(* foo(..)) && this(Boo)");
- AndPointcut rewritten = (AndPointcut) prw.rewrite(oneKind);
- assertEquals("Only one kind",1,Shadow.howMany(rewritten.couldMatchKinds()));
- assertTrue("It's Shadow.MethodExecution",Shadow.MethodExecution.isSet(rewritten.couldMatchKinds()));
- }
-
- public void testKindSetOfExecution() {
- Pointcut p = getPointcut("execution(* foo(..))");
- assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
- assertTrue("It's Shadow.MethodExecution",Shadow.MethodExecution.isSet(p.couldMatchKinds()));
- p = getPointcut("execution(new(..))");
- assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
- assertTrue("It's Shadow.ConstructorExecution",Shadow.ConstructorExecution.isSet(p.couldMatchKinds()));
- }
-
- public void testKindSetOfCall() {
- Pointcut p = getPointcut("call(* foo(..))");
- assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
- assertTrue("It's Shadow.MethodCall",Shadow.MethodCall.isSet(p.couldMatchKinds()));
- p = getPointcut("call(new(..))");
- assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
- assertTrue("It's Shadow.ConstructorCall",Shadow.ConstructorCall.isSet(p.couldMatchKinds()));
- }
-
- public void testKindSetOfAdviceExecution() {
- Pointcut p = getPointcut("adviceexecution()");
- assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
- assertTrue("It's Shadow.AdviceExecution",Shadow.AdviceExecution.isSet(p.couldMatchKinds()));
- }
-
- public void testKindSetOfGet() {
- Pointcut p = getPointcut("get(* *)");
- assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
- assertTrue("It's Shadow.FieldGet",Shadow.FieldGet.isSet(p.couldMatchKinds()));
- }
-
- public void testKindSetOfSet() {
- Pointcut p = getPointcut("set(* *)");
- assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
- assertTrue("It's Shadow.FieldSet",Shadow.FieldSet.isSet(p.couldMatchKinds()));
- }
-
- public void testKindSetOfHandler() {
- Pointcut p = getPointcut("handler(*)");
- assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
- assertTrue("It's Shadow.ExceptionHandler",Shadow.ExceptionHandler.isSet(p.couldMatchKinds()));
- }
-
- public void testKindSetOfInitialization() {
- Pointcut p = getPointcut("initialization(new (..))");
- assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
- assertTrue("It's Shadow.Initialization",Shadow.Initialization.isSet(p.couldMatchKinds()));
- }
-
- public void testKindSetOfPreInitialization() {
- Pointcut p = getPointcut("preinitialization(new (..))");
- assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
- assertTrue("It's Shadow.PreInitialization",Shadow.PreInitialization.isSet(p.couldMatchKinds()));
- }
-
- public void testKindSetOfStaticInitialization() {
- Pointcut p = getPointcut("staticinitialization(*)");
- assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
- assertTrue("It's Shadow.StaticInitialization",Shadow.StaticInitialization.isSet(p.couldMatchKinds()));
- }
-
- public void testKindSetOfThis() {
- Pointcut p = getPointcut("this(Foo)");
- Set matches = Shadow.toSet(p.couldMatchKinds());
- for (Iterator iter = matches.iterator(); iter.hasNext();) {
- Shadow.Kind kind = (Shadow.Kind) iter.next();
- assertFalse("No kinds that don't have a this",kind.neverHasThis());
- }
- for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) {
- if (!Shadow.SHADOW_KINDS[i].neverHasThis()) {
- assertTrue("All kinds that do have this",matches.contains(Shadow.SHADOW_KINDS[i]));
- }
- }
- // + @
- p = getPointcut("@this(Foo)");
- matches = Shadow.toSet(p.couldMatchKinds());
- for (Iterator iter = matches.iterator(); iter.hasNext();) {
- Shadow.Kind kind = (Shadow.Kind) iter.next();
- assertFalse("No kinds that don't have a this",kind.neverHasThis());
- }
- for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) {
- if (!Shadow.SHADOW_KINDS[i].neverHasThis()) {
- assertTrue("All kinds that do have this",matches.contains(Shadow.SHADOW_KINDS[i]));
- }
- }
- }
-
- public void testKindSetOfTarget() {
- Pointcut p = getPointcut("target(Foo)");
- Set matches = Shadow.toSet(p.couldMatchKinds());
- for (Iterator iter = matches.iterator(); iter.hasNext();) {
- Shadow.Kind kind = (Shadow.Kind) iter.next();
- assertFalse("No kinds that don't have a target",kind.neverHasTarget());
- }
- for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) {
- if (!Shadow.SHADOW_KINDS[i].neverHasTarget()) {
- assertTrue("All kinds that do have target",matches.contains(Shadow.SHADOW_KINDS[i]));
- }
- }
- // + @
- p = getPointcut("@target(Foo)");
- matches = Shadow.toSet(p.couldMatchKinds());
- for (Iterator iter = matches.iterator(); iter.hasNext();) {
- Shadow.Kind kind = (Shadow.Kind) iter.next();
- assertFalse("No kinds that don't have a target",kind.neverHasTarget());
- }
- for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) {
- if (!Shadow.SHADOW_KINDS[i].neverHasTarget()) {
- assertTrue("All kinds that do have target",matches.contains(Shadow.SHADOW_KINDS[i]));
- }
- }
- }
-
- public void testKindSetOfArgs() {
- Pointcut p = getPointcut("args(..)");
- assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
- // + @
- p = getPointcut("@args(..)");
- assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
- }
-
- public void testKindSetOfAnnotation() {
- Pointcut p = getPointcut("@annotation(Foo)");
- assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
- }
-
- public void testKindSetOfWithin() {
- Pointcut p = getPointcut("within(*)");
- assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
- // + @
- p = getPointcut("@within(Foo)");
- assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
- }
-
- public void testKindSetOfWithinCode() {
- Pointcut p = getPointcut("withincode(* foo(..))");
- Set matches = Shadow.toSet(p.couldMatchKinds());
- for (Iterator iter = matches.iterator(); iter.hasNext();) {
- Shadow.Kind kind = (Shadow.Kind) iter.next();
- assertFalse("No kinds that are themselves enclosing",
- (kind.isEnclosingKind() && kind != Shadow.ConstructorExecution && kind != Shadow.Initialization));
- }
- for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) {
- if (!Shadow.SHADOW_KINDS[i].isEnclosingKind()) {
- assertTrue("All kinds that are not enclosing",matches.contains(Shadow.SHADOW_KINDS[i]));
- }
- }
- assertTrue("Need cons-exe for inlined field inits",matches.contains(Shadow.ConstructorExecution));
- assertTrue("Need init for inlined field inits",matches.contains(Shadow.Initialization));
- // + @
- p = getPointcut("@withincode(Foo)");
- matches = Shadow.toSet(p.couldMatchKinds());
- for (Iterator iter = matches.iterator(); iter.hasNext();) {
- Shadow.Kind kind = (Shadow.Kind) iter.next();
- assertFalse("No kinds that are themselves enclosing",kind.isEnclosingKind());
- }
- for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) {
- if (!Shadow.SHADOW_KINDS[i].isEnclosingKind()) {
- assertTrue("All kinds that are not enclosing",matches.contains(Shadow.SHADOW_KINDS[i]));
- }
- }
- }
-
- public void testKindSetOfIf() {
- Pointcut p = new IfPointcut(null,0);
- assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
- p = IfPointcut.makeIfTruePointcut(Pointcut.CONCRETE);
- assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
- p = IfPointcut.makeIfFalsePointcut(Pointcut.CONCRETE);
- assertTrue("Nothing",p.couldMatchKinds()==Shadow.NO_SHADOW_KINDS_BITS);
- }
-
- public void testKindSetOfCflow() {
- Pointcut p = getPointcut("cflow(this(Foo))");
- assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
- // [below]
- p = getPointcut("cflowbelow(this(Foo))");
- assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
- }
-
- public void testKindSetInNegation() {
- Pointcut p = getPointcut("!execution(new(..))");
- assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
- }
-
- public void testKindSetOfOr() {
- Pointcut p = getPointcut("execution(new(..)) || get(* *)");
- Set matches = Shadow.toSet(p.couldMatchKinds());
- assertEquals("2 kinds",2,matches.size());
- assertTrue("ConstructorExecution",matches.contains(Shadow.ConstructorExecution));
- assertTrue("FieldGet",matches.contains(Shadow.FieldGet));
- }
-
- public void testOrderingInAnd() {
- Pointcut bigLongPC = getPointcut("cflow(this(Foo)) && @args(X) && args(X) && @this(Foo) && @target(Boo) && this(Moo) && target(Boo) && @annotation(Moo) && @withincode(Boo) && withincode(new(..)) && set(* *)&& @within(Foo) && within(Foo)");
- Pointcut rewritten = prw.rewrite(bigLongPC);
- assertEquals("((((((((((((within(Foo) && @within(Foo)) && set(* *)) && withincode(new(..))) && @withincode(Boo)) && @annotation(Moo)) && target(Boo)) && this(Moo)) && @target(Boo)) && @this(Foo)) && args(X)) && @args(X)) && cflow(this(Foo)))",rewritten.toString());
- }
-
- public void testOrderingInSimpleOr() {
- OrPointcut opc = (OrPointcut) getPointcut("execution(new(..)) || get(* *)");
- assertEquals("reordered","(get(* *) || execution(new(..)))",prw.rewrite(opc).toString());
- }
-
- public void testOrderingInNestedOrs() {
- OrPointcut opc = (OrPointcut) getPointcut("(execution(new(..)) || get(* *)) || within(abc)");
- assertEquals("reordered","((within(abc) || get(* *)) || execution(new(..)))",
- prw.rewrite(opc).toString());
- }
-
- public void testOrderingInOrsWithNestedAnds() {
- OrPointcut opc = (OrPointcut) getPointcut("get(* *) || (execution(new(..)) && within(abc))");
- assertEquals("reordered","((within(abc) && execution(new(..))) || get(* *))",
- prw.rewrite(opc).toString());
- }
-
- private Pointcut getPointcut(String s) {
- return new PatternParser(s).parsePointcut();
- }
-
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- prw = new PointcutRewriter();
- }
-
-}
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/SignaturePatternTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/SignaturePatternTestCase.java
deleted file mode 100644
index b355cdc2c..000000000
--- a/weaver/testsrc/org/aspectj/weaver/patterns/SignaturePatternTestCase.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.weaver.patterns;
-
-import java.io.*;
-
-import junit.framework.*;
-
-import org.aspectj.weaver.*;
-import org.aspectj.weaver.bcel.*;
-
-public class SignaturePatternTestCase extends TestCase {
- /**
- * Constructor for PatternTestCase.
- * @param name
- */
- public SignaturePatternTestCase(String name) {
- super(name);
- }
-
- BcelWorld world = new BcelWorld();
-
- public void testThrowsMatch() throws IOException {
- Member onlyDerivedOnDerived = TestUtils.methodFromString("static void fluffy.Derived.onlyDerived()");
- Member mOnBase = TestUtils.methodFromString("void fluffy.Base.m()");
- Member mOnDerived = TestUtils.methodFromString("void fluffy.Derived.m()");
-
- checkMatch(makeMethodPat("* fluffy.Base.*(..) throws java.lang.CloneNotSupportedException"),
- new Member[] { mOnBase },
- new Member[] { mOnDerived });
-
- checkMatch(makeMethodPat("* fluffy.Derived.*(..) throws java.lang.CloneNotSupportedException"),
- new Member[] { },
- new Member[] { mOnBase, mOnDerived });
-
- //XXX need pattern checks
- Member[] NONE = new Member[] {};
- Member[] M = new Member[] { onlyDerivedOnDerived };
- Member[] NO_EXCEPTIONS = new Member[] { mOnDerived };
- Member[] BOTH = new Member[] {mOnDerived, onlyDerivedOnDerived};
-
- checkMatch(makeMethodPat("* *(..)"), M, NONE);
- checkMatch(makeMethodPat("* *(..) throws !*"), NO_EXCEPTIONS, M);
- checkMatch(makeMethodPat("* *(..) throws *"), M, NO_EXCEPTIONS);
- checkMatch(makeMethodPat("* *(..) throws *, !*"), NONE, BOTH);
-
- checkMatch(makeMethodPat("* *(..) throws (!*)"), NONE, BOTH);
- checkMatch(makeMethodPat("* *(..) throws !(!*)"), BOTH, NONE);
-
- checkMatch(makeMethodPat("* *(..) throws *..IOException"), M, NO_EXCEPTIONS);
- checkMatch(makeMethodPat("* *(..) throws *..IOException, *..Clone*"), M, NO_EXCEPTIONS);
- checkMatch(makeMethodPat("* *(..) throws *..IOException, !*..Clone*"), NONE, BOTH);
- checkMatch(makeMethodPat("* *(..) throws !*..IOException"), NO_EXCEPTIONS, M);
- }
-
- public void testInstanceMethodMatch() throws IOException {
- Member objectToString = TestUtils.methodFromString("java.lang.String java.lang.Object.toString()");
- Member integerToString = TestUtils.methodFromString("java.lang.String java.lang.Integer.toString()");
- Member integerIntValue = TestUtils.methodFromString("int java.lang.Integer.intValue()");
- //Member objectToString = Member.methodFromString("java.lang.String java.lang.Object.toString()");
-
- checkMatch(makeMethodPat("* java.lang.Object.*(..)"),
- new Member[] { objectToString, integerToString },
- new Member[] { integerIntValue });
-
- checkMatch(makeMethodPat("* java.lang.Integer.*(..)"),
- new Member[] { integerIntValue, integerToString },
- new Member[] { objectToString });
- }
-
-
- public void testStaticMethodMatch() throws IOException {
- Member onlyBaseOnBase = TestUtils.methodFromString("static void fluffy.Base.onlyBase()");
- Member onlyBaseOnDerived = TestUtils.methodFromString("static void fluffy.Derived.onlyBase()");
- Member onlyDerivedOnDerived = TestUtils.methodFromString("static void fluffy.Derived.onlyDerived()");
- Member bothOnBase = TestUtils.methodFromString("static void fluffy.Base.both()");
- Member bothOnDerived = TestUtils.methodFromString("static void fluffy.Derived.both()");
-
- checkMatch(makeMethodPat("* fluffy.Base.*(..)"),
- new Member[] { onlyBaseOnBase, onlyBaseOnDerived, bothOnBase },
- new Member[] { onlyDerivedOnDerived, bothOnDerived });
-
- checkMatch(makeMethodPat("* fluffy.Derived.*(..)"),
- new Member[] { onlyBaseOnDerived, bothOnDerived, onlyDerivedOnDerived },
- new Member[] { onlyBaseOnBase, bothOnBase });
- }
-
- public void testFieldMatch() throws IOException {
- Member onlyBaseOnBase = TestUtils.fieldFromString("int fluffy.Base.onlyBase");
- Member onlyBaseOnDerived = TestUtils.fieldFromString("int fluffy.Derived.onlyBase");
- Member onlyDerivedOnDerived = TestUtils.fieldFromString("int fluffy.Derived.onlyDerived");
- Member bothOnBase = TestUtils.fieldFromString("int fluffy.Base.both");
- Member bothOnDerived = TestUtils.fieldFromString("int fluffy.Derived.both");
-
- checkMatch(makeFieldPat("* fluffy.Base.*"),
- new Member[] { onlyBaseOnBase, onlyBaseOnDerived, bothOnBase },
- new Member[] { onlyDerivedOnDerived, bothOnDerived });
-
- checkMatch(makeFieldPat("* fluffy.Derived.*"),
- new Member[] { onlyBaseOnDerived, bothOnDerived, onlyDerivedOnDerived },
- new Member[] { onlyBaseOnBase, bothOnBase });
- }
-
- public void testConstructorMatch() throws IOException {
- Member onBase = TestUtils.methodFromString("void fluffy.Base.<init>()");
- Member onDerived = TestUtils.methodFromString("void fluffy.Derived.<init>()");
- Member onBaseWithInt = TestUtils.methodFromString("void fluffy.Base.<init>(int)");
-
-
- checkMatch(makeMethodPat("fluffy.Base.new(..)"),
- new Member[] { onBase, onBaseWithInt },
- new Member[] { onDerived });
-
- checkMatch(makeMethodPat("fluffy.Derived.new(..)"),
- new Member[] { onDerived},
- new Member[] { onBase, onBaseWithInt });
- }
-
-
-
-
-
- public void checkMatch(SignaturePattern p, Member[] yes, Member[] no) throws IOException {
- p = p.resolveBindings(new TestScope(world, new FormalBinding[0]), new Bindings(0));
-
- for (int i=0; i < yes.length; i++) {
- checkMatch(p, yes[i], true);
- }
-
- for (int i=0; i < no.length; i++) {
- checkMatch(p, no[i], false);
- }
-
- checkSerialization(p);
- }
-
- private void checkMatch(SignaturePattern p, Member member, boolean b) {
- boolean matches = p.matches(member, world,false);
- assertEquals(p.toString() + " matches " + member.toString(), b, matches);
- }
-
-
- private SignaturePattern makeMethodPat(String pattern) {
- return new PatternParser(pattern).parseMethodOrConstructorSignaturePattern();
- }
-
- private SignaturePattern makeFieldPat(String pattern) {
- return new PatternParser(pattern).parseFieldSignaturePattern();
- }
-
- private void checkSerialization(SignaturePattern p) throws IOException {
- ByteArrayOutputStream bo = new ByteArrayOutputStream();
- DataOutputStream out = new DataOutputStream(bo);
- p.write(out);
- out.close();
-
- ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray());
- VersionedDataInputStream in = new VersionedDataInputStream(bi);
- SignaturePattern newP = SignaturePattern.read(in, null);
-
- assertEquals("write/read", p, newP);
- }
-
-}
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/TestScope.java b/weaver/testsrc/org/aspectj/weaver/patterns/TestScope.java
deleted file mode 100644
index 89f8f7129..000000000
--- a/weaver/testsrc/org/aspectj/weaver/patterns/TestScope.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.weaver.patterns;
-
-import org.aspectj.weaver.*;
-
-public class TestScope extends SimpleScope {
-
- public TestScope(
- World world,
- FormalBinding[] bindings)
- {
- super(world, bindings);
- }
-
- public TestScope(String[] formalTypes, String[] formalNames, World world) {
- super(world, SimpleScope.makeFormalBindings(UnresolvedType.forNames(formalTypes), formalNames));
- }
-}
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/ThisOrTargetTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/ThisOrTargetTestCase.java
deleted file mode 100644
index 618949689..000000000
--- a/weaver/testsrc/org/aspectj/weaver/patterns/ThisOrTargetTestCase.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * PARC initial implementation
- * Adrian Colyer, runtime reflection extensions
- * ******************************************************************/
-
-
-package org.aspectj.weaver.patterns;
-
-import java.io.IOException;
-import java.lang.reflect.Method;
-
-import junit.framework.TestCase;
-
-import org.aspectj.util.LangUtil;
-import org.aspectj.weaver.World;
-import org.aspectj.weaver.bcel.BcelWorld;
-import org.aspectj.weaver.tools.JoinPointMatch;
-import org.aspectj.weaver.tools.PointcutExpression;
-import org.aspectj.weaver.tools.PointcutParameter;
-import org.aspectj.weaver.tools.PointcutParser;
-import org.aspectj.weaver.tools.ShadowMatch;
-
-/**
- * @author hugunin
- *
- * To change this generated comment edit the template variable "typecomment":
- * Window>Preferences>Java>Templates.
- * To enable and disable the creation of type comments go to
- * Window>Preferences>Java>Code Generation.
- */
-public class ThisOrTargetTestCase extends TestCase {
-
- private boolean needToSkip = false;
-
- /** this condition can occur on the build machine only, and is way too complex to fix right now... */
- private boolean needToSkipPointcutParserTests() {
- if (!LangUtil.is15VMOrGreater()) return false;
- try {
- Class.forName("org.aspectj.weaver.reflect.Java15ReflectionBasedReferenceTypeDelegate",false,this.getClass().getClassLoader());//ReflectionBasedReferenceTypeDelegate.class.getClassLoader());
- } catch (ClassNotFoundException cnfEx) {
- return true;
- }
- return false;
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- needToSkip = needToSkipPointcutParserTests();
- }
-
- /**
- * Constructor for PatternTestCase.
- * @param name
- */
- public ThisOrTargetTestCase(String name) {
- super(name);
- }
-
- World world;
-
-
- public void testMatch() throws IOException {
- world = new BcelWorld();
- }
-
- public void testMatchJP() throws Exception {
- if (needToSkip) return;
-
- PointcutParser parser = PointcutParser.getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(this.getClass().getClassLoader());
- PointcutExpression thisEx = parser.parsePointcutExpression("this(Exception)");
- PointcutExpression thisIOEx = parser.parsePointcutExpression("this(java.io.IOException)");
-
- PointcutExpression targetEx = parser.parsePointcutExpression("target(Exception)");
- PointcutExpression targetIOEx = parser.parsePointcutExpression("target(java.io.IOException)");
-
- Method toString = Object.class.getMethod("toString",new Class[0]);
-
- checkMatches(thisEx.matchesMethodCall(toString, toString),new Exception(),null,null);
- checkNoMatch(thisIOEx.matchesMethodCall(toString, toString),new Exception(),null,null);
- checkNoMatch(targetEx.matchesMethodCall(toString, toString),new Exception(),new Object(),null);
- checkNoMatch(targetIOEx.matchesMethodCall(toString, toString),new Exception(),new Exception(),null);
-
- checkMatches(thisEx.matchesMethodCall(toString, toString),new IOException(),null,null);
- checkMatches(thisIOEx.matchesMethodCall(toString, toString),new IOException(),null,null);
-
- checkNoMatch(thisEx.matchesMethodCall(toString, toString),new Object(),null,null);
- checkNoMatch(thisIOEx.matchesMethodCall(toString, toString),new Exception(),null,null);
- checkMatches(targetEx.matchesMethodCall(toString, toString),new Exception(),new Exception(),null);
- checkNoMatch(targetIOEx.matchesMethodCall(toString, toString),new Exception(),new Exception(),null);
-
- checkMatches(targetIOEx.matchesMethodCall(toString, toString),new Exception(),new IOException(),null);
- }
-
- public void testBinding() throws Exception {
- if (needToSkip) return;
- PointcutParser parser = PointcutParser.getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(this.getClass().getClassLoader());
- PointcutParameter ex = parser.createPointcutParameter("ex", Exception.class);
- PointcutParameter ioEx = parser.createPointcutParameter("ioEx", IOException.class);
-
- PointcutExpression thisEx = parser.parsePointcutExpression("this(ex)",Exception.class,new PointcutParameter[] {ex});
-
- PointcutExpression targetIOEx = parser.parsePointcutExpression("target(ioEx)",Exception.class,new PointcutParameter[] {ioEx});
-
- Method toString = Object.class.getMethod("toString",new Class[0]);
-
- ShadowMatch sMatch = thisEx.matchesMethodCall(toString, toString);
- Exception exceptionParameter = new Exception();
- IOException ioExceptionParameter = new IOException();
- JoinPointMatch jpMatch = sMatch.matchesJoinPoint(exceptionParameter, null, null);
- assertTrue("should match",jpMatch.matches());
- PointcutParameter[] bindings = jpMatch.getParameterBindings();
- assertEquals("one binding",1,bindings.length);
- assertEquals("should be exceptionParameter",exceptionParameter,bindings[0].getBinding());
- assertEquals("ex",bindings[0].getName());
-
- sMatch = targetIOEx.matchesMethodCall(toString,toString);
- jpMatch = sMatch.matchesJoinPoint(exceptionParameter, ioExceptionParameter, null);
- assertTrue("should match",jpMatch.matches());
- bindings = jpMatch.getParameterBindings();
- assertEquals("one binding",1,bindings.length);
- assertEquals("should be ioExceptionParameter",ioExceptionParameter,bindings[0].getBinding());
- assertEquals("ioEx",bindings[0].getName());
-
-
- }
-
- private void checkMatches(ShadowMatch sMatch, Object thisObj, Object targetObj, Object[] args) {
- assertTrue("match expected",sMatch.matchesJoinPoint(thisObj, targetObj, args).matches());
- }
-
- private void checkNoMatch(ShadowMatch sMatch, Object thisObj, Object targetObj, Object[] args) {
- assertFalse("no match expected",sMatch.matchesJoinPoint(thisObj, targetObj, args).matches());
- }
-
- /**
- * Method checkSerialization.
- * @param string
- */
-// private void checkSerialization(String string) throws IOException {
-// Pointcut p = makePointcut(string);
-// ByteArrayOutputStream bo = new ByteArrayOutputStream();
-// DataOutputStream out = new DataOutputStream(bo);
-// p.write(out);
-// out.close();
-//
-// ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray());
-// DataInputStream in = new DataInputStream(bi);
-// Pointcut newP = Pointcut.read(in, null);
-//
-// assertEquals("write/read", p, newP);
-// }
-
-}
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/TypePatternListTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/TypePatternListTestCase.java
deleted file mode 100644
index 3aa164738..000000000
--- a/weaver/testsrc/org/aspectj/weaver/patterns/TypePatternListTestCase.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.weaver.patterns;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-import org.aspectj.util.FuzzyBoolean;
-import org.aspectj.weaver.ResolvedType;
-import org.aspectj.weaver.VersionedDataInputStream;
-import org.aspectj.weaver.World;
-import org.aspectj.weaver.bcel.BcelWorld;
-
-/**
- * @author hugunin
- *
- * To change this generated comment edit the template variable "typecomment":
- * Window>Preferences>Java>Templates.
- * To enable and disable the creation of type comments go to
- * Window>Preferences>Java>Code Generation.
- */
-public class TypePatternListTestCase extends TestCase {
- /**
- * Constructor for PatternTestCase.
- * @param name
- */
- public TypePatternListTestCase(String name) {
- super(name);
- }
-
- World world;
-
- //XXX when instanceof matching works add tests for that here
-
-
- public void testMatch() {
- world = new BcelWorld();
-
- checkStaticMatch("()", new String[] {}, FuzzyBoolean.YES);
- checkStaticMatch("()", new String[] {"java.lang.Object"}, FuzzyBoolean.NO);
-
- checkStaticMatch("(java.lang.Object)", new String[] {"java.lang.Object"}, FuzzyBoolean.YES);
-
- checkStaticMatch("(java.lang.String)", new String[] {"java.lang.Object"}, FuzzyBoolean.NO);
-
- checkStaticMatch("(java.lang.Object)", new String[] {"java.lang.String"}, FuzzyBoolean.NO);
-
- checkStaticMatch("()", new String[] {"java.lang.Object"}, FuzzyBoolean.NO);
-
- checkStaticMatch("(..)", new String[] {}, FuzzyBoolean.YES);
- checkStaticMatch("(..)", new String[] {"int", "char"}, FuzzyBoolean.YES);
-
-
- checkStaticMatch("(int,..,int)", new String[] {"int", "int"}, FuzzyBoolean.YES);
-
- checkStaticMatch("(int,..)", new String[] {}, FuzzyBoolean.NO);
- checkStaticMatch("(int,..)", new String[] {"int"}, FuzzyBoolean.YES);
-
- checkStaticMatch("(..,int,..)", new String[] {"int"}, FuzzyBoolean.YES);
-
- // these checks are taken from new/ExpandedDotPattern.java
- stupidCheck("( .., .., ..)", new boolean[] { true, true, true, true, true });
- stupidCheck("( .., .., int)", new boolean[] { false, true, true, true, true });
- stupidCheck("( .., int, ..)", new boolean[] { false, true, true, true, true });
- stupidCheck("( .., int, int)", new boolean[] { false, false, true, true, true });
- stupidCheck("(int, .., ..)", new boolean[] { false, true, true, true, true });
- stupidCheck("(int, .., int)", new boolean[] { false, false, true, true, true });
- stupidCheck("(int, int, ..)", new boolean[] { false, false, true, true, true });
- stupidCheck("(int, int, int)", new boolean[] { false, false, false, true, false });
-
- stupidCheck("( .., .., .., ..)", new boolean[] { true, true, true, true, true });
- stupidCheck("( .., .., .., int)", new boolean[] { false, true, true, true, true });
- stupidCheck("( .., .., int, ..)", new boolean[] { false, true, true, true, true });
- stupidCheck("( .., .., int, int)", new boolean[] { false, false, true, true, true });
- stupidCheck("( .., int, .., ..)", new boolean[] { false, true, true, true, true });
- stupidCheck("( .., int, .., int)", new boolean[] { false, false, true, true, true });
- stupidCheck("( .., int, int, ..)", new boolean[] { false, false, true, true, true });
- stupidCheck("( .., int, int, int)", new boolean[] { false, false, false, true, true });
-
- stupidCheck("(int, .., .., ..)", new boolean[] { false, true, true, true, true });
- stupidCheck("(int, .., .., int)", new boolean[] { false, false, true, true, true });
- stupidCheck("(int, .., int, ..)", new boolean[] { false, false, true, true, true });
- stupidCheck("(int, .., int, int)", new boolean[] { false, false, false, true, true });
- stupidCheck("(int, int, .., ..)", new boolean[] { false, false, true, true, true });
- stupidCheck("(int, int, .., int)", new boolean[] { false, false, false, true, true });
- stupidCheck("(int, int, int, ..)", new boolean[] { false, false, false, true, true });
- stupidCheck("(int, int, int, int)", new boolean[] { false, false, false, false, true });
- }
-
- private TypePatternList makeArgumentsPattern(String pattern) {
- return new PatternParser(pattern).parseArgumentsPattern(false);
- }
-
- private void checkStaticMatch(String pattern, String[] names,
- FuzzyBoolean shouldMatchStatically) {
- // We're only doing TypePattern.STATIC matching here because my intent was
- // to test the wildcarding, and we don't do DYNAMIC matching on wildcarded things.
-
- TypePatternList p = makeArgumentsPattern(pattern);
- ResolvedType[] types = new ResolvedType[names.length];
- for (int i = 0; i < names.length; i++) {
- types[i] = world.resolve(names[i]);
- }
-
- p.resolveBindings(makeTestScope(), Bindings.NONE, false, false);
- //System.out.println("type: " + type);
- FuzzyBoolean result = p.matches(types, TypePattern.STATIC);
- String msg = "matches statically " + pattern + " to " + Arrays.asList(types);
- assertEquals(msg, shouldMatchStatically, result);
- }
-
- public static final String[] NO_STRINGS = new String[0];
-
- private TestScope makeTestScope() {
- TestScope scope = new TestScope(NO_STRINGS, NO_STRINGS, world);
- return scope;
- }
-
- public void stupidCheck(String pattern, boolean[] matches) {
- TypePatternList p = makeArgumentsPattern(pattern);
- p.resolveBindings(makeTestScope(), Bindings.NONE, false, false);
-
- int len = matches.length;
-
- for (int j = 0; j < len; j++) {
-
- ResolvedType[] types = new ResolvedType[j];
- for (int i = 0; i < j; i++) {
- types[i] = world.resolve("int");
- }
-
- FuzzyBoolean result = p.matches(types, TypePattern.STATIC);
- String msg = "matches statically " + pattern + " to " + Arrays.asList(types);
- assertEquals(msg, FuzzyBoolean.fromBoolean(matches[j]), result);
- }
- }
-
- public void testSerialization() throws IOException {
- String[] patterns = new String[] {
- "( .., .., .., int)",
- "( .., .., int, ..)",
- "( .., .., int, int)",
- "( .., int, .., ..)",
- "( .., int, .., int)",
- "( .., int, int, ..)",
- "( .., int, int, int)",
-
- "(int, .., .., ..)",
- "(int, .., .., int)",
- "(int, .., int, ..)",
- "(int, .., int, int)",
- "(int, int, .., ..)",
- "(int, int, .., int)",
- "(int, int, int, ..)",
- "(int, int, int, int)"
- };
-
- for (int i=0, len=patterns.length; i < len; i++) {
- checkSerialization(patterns[i]);
- }
- }
-
- /**
- * Method checkSerialization.
- * @param string
- */
- private void checkSerialization(String string) throws IOException {
- TypePatternList p = makeArgumentsPattern(string);
- ByteArrayOutputStream bo = new ByteArrayOutputStream();
- DataOutputStream out = new DataOutputStream(bo);
- p.write(out);
- out.close();
-
- ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray());
- VersionedDataInputStream in = new VersionedDataInputStream(bi);
- TypePatternList newP = TypePatternList.read(in, null);
-
- assertEquals("write/read", p, newP);
- }
-
-}
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/TypePatternTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/TypePatternTestCase.java
deleted file mode 100644
index 1d0c9262a..000000000
--- a/weaver/testsrc/org/aspectj/weaver/patterns/TypePatternTestCase.java
+++ /dev/null
@@ -1,303 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.weaver.patterns;
-
-import java.io.*;
-
-import org.aspectj.weaver.bcel.*;
-import org.aspectj.bridge.AbortException;
-import org.aspectj.util.FuzzyBoolean;
-
-import junit.framework.TestCase;
-import org.aspectj.weaver.*;
-
-public class TypePatternTestCase extends TestCase {
- /**
- * Constructor for PatternTestCase.
- * @param name
- */
- public TypePatternTestCase(String name) {
- super(name);
- }
-
- World world;
-
- public void testStaticMatch() {
- world = new BcelWorld();
-
- checkMatch("java.lang.Object", "java.lang.Object", true);
- checkMatch("java.lang.Object+", "java.lang.Object", true);
- checkMatch("java.lang.Object+", "java.lang.String", true);
- checkMatch("java.lang.String+", "java.lang.Object", false);
- checkMatch("java.lang.Integer", "java.lang.String", false);
-
- checkMatch("java.lang.Integer", "int", false);
-
- checkMatch("java.lang.Number+", "java.lang.Integer", true);
-
-
- checkMatch("java..*", "java.lang.Integer", true);
- checkMatch("java..*", "java.lang.reflect.Modifier", true);
- checkMatch("java..*", "int", false);
- checkMatch("java..*", "javax.swing.Action", false);
- checkMatch("java..*+", "javax.swing.Action", true);
-
- checkMatch("*.*.Object", "java.lang.Object", true);
- checkMatch("*.Object", "java.lang.Object", false);
- checkMatch("*..*", "java.lang.Object", true);
- checkMatch("*..*", "int", false);
- checkMatch("java..Modifier", "java.lang.reflect.Modifier", true);
- checkMatch("java.lang.reflect.Mod..ifier", "java.lang.reflect.Modifier", false);
-
- checkMatch("java..reflect..Modifier", "java.lang.reflect.Modifier", true);
- checkMatch("java..lang..Modifier", "java.lang.reflect.Modifier", true);
- checkMatch("java..*..Modifier", "java.lang.reflect.Modifier", true);
- checkMatch("java..*..*..Modifier", "java.lang.reflect.Modifier", true);
- checkMatch("java..*..*..*..Modifier", "java.lang.reflect.Modifier", false);
- //checkMatch("java..reflect..Modifier", "java.lang.reflect.Modxifier", false);
- checkMatch("ja*va..Modifier", "java.lang.reflect.Modifier", true);
- checkMatch("java..*..Mod*ifier", "java.lang.reflect.Modifier", true);
-
- }
-
-
- // three levels:
- // 0. defined in current compilation unit, or imported by name
- // 1. defined in current package/type/whatever
- // 2. defined in package imported by *
- /**
- * We've decided not to test this here, but rather in any compilers
- */
- public void testImportResolve() {
- world = new BcelWorld();
-// checkIllegalImportResolution("List", new String[] { "java.util", "java.awt", },
-// ZERO_STRINGS);
-
-
- }
-
-
- // Assumption for bcweaver: Already resolved type patterns with no *s or ..'s into exact type
- // patterns. Exact type patterns don't have import lists. non-exact-type pattens don't
- // care about precedence, so the current package can be included with all the other packages,
- // and we don't care about compilation units, and we don't care about ordering.
-
- // only giving this wild-type patterns
- public void testImportMatch() {
- world = new BcelWorld();
-
- checkImportMatch("*List", new String[] { "java.awt.", }, ZERO_STRINGS, "java.awt.List", true);
- checkImportMatch("*List", new String[] { "java.awt.", }, ZERO_STRINGS, "java.awt.List", true);
- checkImportMatch("*List", new String[] { "java.awt.", }, ZERO_STRINGS, "java.util.List", false);
- checkImportMatch("*List", new String[] { "java.util.", }, ZERO_STRINGS, "java.awt.List", false);
- checkImportMatch("*List", new String[] { "java.util.", }, ZERO_STRINGS, "java.util.List", true);
-
- checkImportMatch("*List", ZERO_STRINGS, new String[] { "java.awt.List", }, "java.awt.List", true);
-
- checkImportMatch("awt.*List", ZERO_STRINGS, new String[] { "java.awt.List", }, "java.awt.List", false);
- checkImportMatch("*Foo", ZERO_STRINGS, new String[] { "java.awt.List", }, "java.awt.List", false);
-
- checkImportMatch("*List", new String[] { "java.util.", "java.awt.", },
- ZERO_STRINGS, "java.util.List", true);
- checkImportMatch("*List", new String[] { "java.util.", "java.awt.", },
- ZERO_STRINGS, "java.awt.List", true);
-
- checkImportMatch("*..List", new String[] { "java.util." }, ZERO_STRINGS, "java.util.List", true);
- checkImportMatch("*..List", new String[] { "java.util." }, ZERO_STRINGS, "java.awt.List", true);
-
- }
-
- public void testImportMatchWithInners() {
- world = new BcelWorld();
- checkImportMatch("*Entry", new String[] { "java.util.", "java.util.Map$"}, ZERO_STRINGS,
- "java.util.Map$Entry", true);
-
- checkImportMatch("java.util.Map.*Entry", ZERO_STRINGS, ZERO_STRINGS,
- "java.util.Map$Entry", true);
-
- checkImportMatch("*Entry", new String[] { "java.util.", }, ZERO_STRINGS,
- "java.util.Map$Entry", false);
-
- checkImportMatch("*.Entry", new String[] { "java.util.", }, ZERO_STRINGS,
- "java.util.Map$Entry", true);
-
- checkImportMatch("Map.*", new String[] { "java.util.", }, ZERO_STRINGS,
- "java.util.Map$Entry", true);
-
- checkImportMatch("Map.*", ZERO_STRINGS, new String[] { "java.util.Map" },
- "java.util.Map$Entry", true);
- }
-
- private void checkImportMatch(
- String wildPattern,
- String[] importedPackages,
- String[] importedNames,
- String matchName,
- boolean shouldMatch)
- {
- WildTypePattern p = makeResolvedWildTypePattern(wildPattern, importedPackages, importedNames);
- checkPatternMatch(p, matchName, shouldMatch);
- }
-
-
- private WildTypePattern makeResolvedWildTypePattern(
- String wildPattern,
- String[] importedPackages,
- String[] importedNames)
- {
- WildTypePattern unresolved = (WildTypePattern) new PatternParser(wildPattern).parseTypePattern();
-
- WildTypePattern resolved = resolve(unresolved, importedPackages, importedNames);
- return resolved;
-
- }
-
- private WildTypePattern resolve(
- WildTypePattern unresolved,
- String[] importedPrefixes,
- String[] importedNames)
- {
-
- TestScope scope = makeTestScope();
- scope.setImportedPrefixes(importedPrefixes);
- scope.setImportedNames(importedNames);
- return (WildTypePattern) unresolved.resolveBindings(scope, Bindings.NONE, false, false);
- }
-
-
-
- public static final String[] ZERO_STRINGS = new String[0];
-
- public void testInstanceofMatch() {
- world = new BcelWorld();
-
- checkInstanceofMatch("java.lang.Object", "java.lang.Object", FuzzyBoolean.YES);
-
- checkIllegalInstanceofMatch("java.lang.Object+", "java.lang.Object");
- checkIllegalInstanceofMatch("java.lang.Object+", "java.lang.String");
- checkIllegalInstanceofMatch("java.lang.String+", "java.lang.Object");
- checkIllegalInstanceofMatch("java.lang.*", "java.lang.Object");
- checkInstanceofMatch("java.lang.Integer", "java.lang.String", FuzzyBoolean.NO);
-
- checkInstanceofMatch("java.lang.Number", "java.lang.Integer", FuzzyBoolean.YES);
- checkInstanceofMatch("java.lang.Integer", "java.lang.Number", FuzzyBoolean.MAYBE);
-
-
- checkIllegalInstanceofMatch("java..Integer", "java.lang.Integer");
-
-
- checkInstanceofMatch("*", "java.lang.Integer", FuzzyBoolean.YES);
-
-
- }
-
- public void testArrayMatch() {
- world = new BcelWorld();
- checkMatch("*[][]","java.lang.Object",false);
- checkMatch("*[]","java.lang.Object[]",true);
- checkMatch("*[][]","java.lang.Object[][]",true);
- checkMatch("java.lang.Object[]","java.lang.Object",false);
- checkMatch("java.lang.Object[]","java.lang.Object[]",true);
- checkMatch("java.lang.Object[][]","java.lang.Object[][]",true);
- checkMatch("java.lang.String[]","java.lang.Object",false);
- checkMatch("java.lang.String[]","java.lang.Object[]",false);
- checkMatch("java.lang.String[][]","java.lang.Object[][]",false);
- checkMatch("java.lang.Object+[]","java.lang.String[]",true);
- }
-
- private void checkIllegalInstanceofMatch(String pattern, String name) {
- try {
- TypePattern p = makeTypePattern(pattern);
- ResolvedType type = world.resolve(name);
- /*FuzzyBoolean result = */p.matchesInstanceof(type);
- } catch (AbortException e) {
- return;
- }
- assertTrue("matching " + pattern + " with " + name + " should fail", false);
- }
-
- private void checkInstanceofMatch(String pattern, String name, FuzzyBoolean shouldMatch) {
- TypePattern p = makeTypePattern(pattern);
- ResolvedType type = world.resolve(name);
-
- p = p.resolveBindings(makeTestScope(), null, false, false);
-
-
- //System.out.println("type: " + p);
- FuzzyBoolean result = p.matchesInstanceof(type);
- String msg = "matches " + pattern + " to " + type;
- assertEquals(msg, shouldMatch, result);
- }
-
- private TestScope makeTestScope() {
- TestScope scope = new TestScope(ZERO_STRINGS, ZERO_STRINGS, world);
- return scope;
- }
-
- private TypePattern makeTypePattern(String pattern) {
- return new PatternParser(pattern).parseSingleTypePattern();
- }
-
- private void checkMatch(String pattern, String name, boolean shouldMatch) {
- TypePattern p = makeTypePattern(pattern);
- p = p.resolveBindings(makeTestScope(), null, false, false);
- checkPatternMatch(p, name, shouldMatch);
- }
-
- private void checkPatternMatch(
- TypePattern p,
- String name,
- boolean shouldMatch)
- {
- ResolvedType type = world.resolve(name);
- //System.out.println("type: " + type);
- boolean result = p.matchesStatically(type);
- String msg = "matches " + p + " to " + type + " expected ";
- if (shouldMatch) {
- assertTrue(msg + shouldMatch, result);
- } else {
- assertTrue(msg + shouldMatch, !result);
- }
- }
-
- public void testSerialization() throws IOException {
- String[] patterns = new String[] {
- "java.lang.Object", "java.lang.Object+", "java.lang.Integer",
- "int", "java..*", "java..util..*", "*.*.Object", "*",
- };
-
- for (int i=0, len=patterns.length; i < len; i++) {
- checkSerialization(patterns[i]);
- }
- }
-
- /**
- * Method checkSerialization.
- * @param string
- */
- private void checkSerialization(String string) throws IOException {
- TypePattern p = makeTypePattern(string);
- ByteArrayOutputStream bo = new ByteArrayOutputStream();
- DataOutputStream out = new DataOutputStream(bo);
- p.write(out);
- out.close();
-
- ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray());
- VersionedDataInputStream in = new VersionedDataInputStream(bi);
- TypePattern newP = TypePattern.read(in, null);
-
- assertEquals("write/read", p, newP);
- }
-
-}
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/VisitorTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/VisitorTestCase.java
deleted file mode 100644
index 16ee14054..000000000
--- a/weaver/testsrc/org/aspectj/weaver/patterns/VisitorTestCase.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * 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:
- * Alexandre Vasseur initial implementation
- *******************************************************************************/
-package org.aspectj.weaver.patterns;
-
-import junit.framework.TestCase;
-
-import java.util.HashSet;
-import java.util.Set;
-import java.util.Iterator;
-import java.io.LineNumberReader;
-import java.io.FileReader;
-
-/**
- * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
- */
-public class VisitorTestCase extends TestCase {
-
- private Set pointcuts = new HashSet();
- private Set typePatterns = new HashSet();
-
- protected void setUp() throws Exception {
- super.setUp();
- LineNumberReader rp = new LineNumberReader(new FileReader("../weaver/testdata/visitor.pointcuts.txt"));
- feed(rp, pointcuts);
- rp.close();
- LineNumberReader rt = new LineNumberReader(new FileReader("../weaver/testdata/visitor.typepatterns.txt"));
- feed(rt, typePatterns);
- rt.close();
- }
-
- private void feed(LineNumberReader r, Set set) throws Exception {
- for (String line = r.readLine(); line != null; line = r.readLine()) {
- set.add(line);
- }
- }
-
- public void testPointcuts() {
- if (pointcuts.isEmpty()) {
- fail("Empty pointcuts file!");
- }
- for (Iterator iterator = pointcuts.iterator(); iterator.hasNext();) {
- String pointcut = (String) iterator.next();
- try {
- DumpPointcutVisitor.check(pointcut);
- } catch (Throwable t) {
- t.printStackTrace();
- fail("Failed on '"+pointcut+"': " +t.toString());
- }
- }
- }
-
- public void testTypePatterns() {
- if (typePatterns.isEmpty()) {
- fail("Empty typePatterns file!");
- }
- for (Iterator iterator = typePatterns.iterator(); iterator.hasNext();) {
- String tp = (String) iterator.next();
- try {
- TypePattern p = new PatternParser(tp).parseTypePattern();
- DumpPointcutVisitor.check(p, true);
- } catch (Throwable t) {
- fail("Failed on '"+tp+"': " +t.toString());
- }
- }
- }
-}
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/WithinTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/WithinTestCase.java
deleted file mode 100644
index 882db526a..000000000
--- a/weaver/testsrc/org/aspectj/weaver/patterns/WithinTestCase.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.weaver.patterns;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-import org.aspectj.util.FuzzyBoolean;
-import org.aspectj.weaver.IntMap;
-import org.aspectj.weaver.Shadow;
-import org.aspectj.weaver.TestShadow;
-import org.aspectj.weaver.TestUtils;
-import org.aspectj.weaver.UnresolvedType;
-import org.aspectj.weaver.VersionedDataInputStream;
-import org.aspectj.weaver.World;
-import org.aspectj.weaver.bcel.BcelWorld;
-
-public class WithinTestCase extends TestCase {
-
- World world = new BcelWorld();
-
- public WithinTestCase(String name) {
- super(name);
- }
-
- public void testMatch() throws IOException {
- Shadow getOutFromArrayList = new TestShadow(
- Shadow.FieldGet,
- TestUtils.fieldFromString("java.io.PrintStream java.lang.System.out"),
- UnresolvedType.forName("java.util.ArrayList"),
- world);
-
- checkMatch(makePointcut("within(*)"), getOutFromArrayList, FuzzyBoolean.YES);
- checkMatch(makePointcut("within(java.util.*)"), getOutFromArrayList, FuzzyBoolean.YES);
- checkMatch(makePointcut("within(java.lang.*)"), getOutFromArrayList, FuzzyBoolean.NO);
- checkMatch(makePointcut("within(java.util.List+)"), getOutFromArrayList, FuzzyBoolean.YES);
- checkMatch(makePointcut("within(java.uti*.List+)"), getOutFromArrayList, FuzzyBoolean.YES);
- checkMatch(makePointcut("within(java.uti*..*)"), getOutFromArrayList, FuzzyBoolean.YES);
- checkMatch(makePointcut("within(java.util.*List)"), getOutFromArrayList, FuzzyBoolean.YES);
- checkMatch(makePointcut("within(java.util.List*)"), getOutFromArrayList, FuzzyBoolean.NO);
-
-
- Shadow getOutFromEntry = new TestShadow(
- Shadow.FieldGet,
- TestUtils.fieldFromString("java.io.PrintStream java.lang.System.out"),
- UnresolvedType.forName("java.util.Map$Entry"),
- world);
-
- checkMatch(makePointcut("within(*)"), getOutFromEntry, FuzzyBoolean.YES);
- checkMatch(makePointcut("within(java.util.*)"), getOutFromEntry, FuzzyBoolean.YES);
- checkMatch(makePointcut("within(java.util.Map.*)"), getOutFromEntry, FuzzyBoolean.YES);
- checkMatch(makePointcut("within(java.util..*)"), getOutFromEntry, FuzzyBoolean.YES);
- checkMatch(makePointcut("within(java.util.Map..*)"), getOutFromEntry, FuzzyBoolean.YES);
- checkMatch(makePointcut("within(java.lang.*)"), getOutFromEntry, FuzzyBoolean.NO);
- checkMatch(makePointcut("within(java.util.List+)"), getOutFromEntry, FuzzyBoolean.NO);
- checkMatch(makePointcut("within(java.util.Map+)"), getOutFromEntry, FuzzyBoolean.YES);
- checkMatch(makePointcut("within(java.lang.Object+)"), getOutFromEntry, FuzzyBoolean.YES);
-
- //this is something we should in type patterns tests
- //checkMatch(makePointcut("within(*List)"), getOut, FuzzyBoolean.NO);
-
- }
-
-
-// public void testMatchJP() {
-// Factory f = new Factory("WithinTestCase.java",WithinTestCase.class);
-//
-// JoinPoint.StaticPart inString = f.makeSJP(JoinPoint.CONSTRUCTOR_EXECUTION,f.makeConstructorSig(0,String.class,new Class[] {String.class},new String[]{"s"},new Class[0]),1);
-// JoinPoint.StaticPart inObject = f.makeSJP(JoinPoint.CONSTRUCTOR_EXECUTION,f.makeConstructorSig(0,Object.class,new Class[] {},new String[]{},new Class[0]),1);
-//
-// Pointcut withinString = new PatternParser("within(String)").parsePointcut().resolve();
-// Pointcut withinObject = new PatternParser("within(Object)").parsePointcut().resolve();
-// Pointcut withinObjectPlus = new PatternParser("within(Object+)").parsePointcut().resolve();
-//
-// checkMatches(withinString,inString,FuzzyBoolean.YES);
-// checkMatches(withinString,inObject,FuzzyBoolean.NO);
-// checkMatches(withinObject,inString,FuzzyBoolean.NO);
-// checkMatches(withinObject,inObject, FuzzyBoolean.YES);
-// checkMatches(withinObjectPlus,inString,FuzzyBoolean.YES);
-// checkMatches(withinObjectPlus,inObject,FuzzyBoolean.YES);
-// }
-//
-// private void checkMatches(Pointcut p, JoinPoint.StaticPart jpsp, FuzzyBoolean expected) {
-// assertEquals(expected,p.match(null,jpsp));
-// }
-//
- public Pointcut makePointcut(String pattern) {
- Pointcut pointcut0 = Pointcut.fromString(pattern);
-
- Bindings bindingTable = new Bindings(0);
- IScope scope = new SimpleScope(world, FormalBinding.NONE);
-
- pointcut0.resolveBindings(scope, bindingTable);
- Pointcut pointcut1 = pointcut0;
- return pointcut1.concretize1(null, null, new IntMap());
- }
-
-
- private void checkMatch(Pointcut p, Shadow s, FuzzyBoolean shouldMatch) throws IOException {
- FuzzyBoolean doesMatch = p.match(s);
- assertEquals(p + " matches " + s, shouldMatch, doesMatch);
- checkSerialization(p);
- }
-
- private void checkSerialization(Pointcut p) throws IOException {
- ByteArrayOutputStream bo = new ByteArrayOutputStream();
- DataOutputStream out = new DataOutputStream(bo);
- p.write(out);
- out.close();
-
- ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray());
- VersionedDataInputStream in = new VersionedDataInputStream(bi);
- Pointcut newP = Pointcut.read(in, null);
-
- assertEquals("write/read", p, newP);
- }
-
-}
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelAndOrNotTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelAndOrNotTestCase.java
new file mode 100644
index 000000000..d72960fea
--- /dev/null
+++ b/weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelAndOrNotTestCase.java
@@ -0,0 +1,24 @@
+/* *******************************************************************
+ * Copyright (c) 2008 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://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andy Clement
+ * ******************************************************************/
+package org.aspectj.weaver.patterns.bcel;
+
+import org.aspectj.weaver.World;
+import org.aspectj.weaver.bcel.BcelWorld;
+import org.aspectj.weaver.patterns.AndOrNotTestCase;
+
+public class BcelAndOrNotTestCase extends AndOrNotTestCase {
+
+ public World getWorld() {
+ return new BcelWorld();
+ }
+
+}
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelBindingTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelBindingTestCase.java
new file mode 100644
index 000000000..fac53dee1
--- /dev/null
+++ b/weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelBindingTestCase.java
@@ -0,0 +1,24 @@
+/* *******************************************************************
+ * Copyright (c) 2008 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://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andy Clement
+ * ******************************************************************/
+package org.aspectj.weaver.patterns.bcel;
+
+import org.aspectj.weaver.World;
+import org.aspectj.weaver.bcel.BcelWorld;
+import org.aspectj.weaver.patterns.BindingTestCase;
+
+public class BcelBindingTestCase extends BindingTestCase {
+
+ public World getWorld() {
+ return new BcelWorld();
+ }
+
+}
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelModifiersPatternTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelModifiersPatternTestCase.java
new file mode 100644
index 000000000..06b89dc15
--- /dev/null
+++ b/weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelModifiersPatternTestCase.java
@@ -0,0 +1,24 @@
+/* *******************************************************************
+ * Copyright (c) 2008 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://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andy Clement
+ * ******************************************************************/
+package org.aspectj.weaver.patterns.bcel;
+
+import org.aspectj.weaver.World;
+import org.aspectj.weaver.bcel.BcelWorld;
+import org.aspectj.weaver.patterns.ModifiersPatternTestCase;
+
+public class BcelModifiersPatternTestCase extends ModifiersPatternTestCase {
+
+ public World getWorld() {
+ return new BcelWorld();
+ }
+
+}
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelParserTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelParserTestCase.java
new file mode 100644
index 000000000..8d8f14d28
--- /dev/null
+++ b/weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelParserTestCase.java
@@ -0,0 +1,25 @@
+/* *******************************************************************
+ * Copyright (c) 2008 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://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andy Clement
+ * ******************************************************************/
+package org.aspectj.weaver.patterns.bcel;
+
+import org.aspectj.weaver.BcweaverTests;
+import org.aspectj.weaver.World;
+import org.aspectj.weaver.bcel.BcelWorld;
+import org.aspectj.weaver.patterns.ParserTestCase;
+
+public class BcelParserTestCase extends ParserTestCase {
+
+ public World getWorld() {
+ return new BcelWorld(BcweaverTests.TESTDATA_PATH + "/testcode.jar");
+ }
+
+}
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelPatternsTests.java b/weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelPatternsTests.java
new file mode 100644
index 000000000..877810a1a
--- /dev/null
+++ b/weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelPatternsTests.java
@@ -0,0 +1,46 @@
+/* *******************************************************************
+ * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
+ * 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://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * PARC initial implementation
+ * ******************************************************************/
+
+package org.aspectj.weaver.patterns.bcel;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.aspectj.weaver.patterns.AnnotationPatternMatchingTestCase;
+import org.aspectj.weaver.patterns.AnnotationPatternTestCase;
+
+public class BcelPatternsTests extends TestCase {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(BcelPatternsTests.class.getName());
+ // $JUnit-BEGIN$
+ suite.addTestSuite(BcelAndOrNotTestCase.class);
+ suite.addTestSuite(BcelBindingTestCase.class);
+ suite.addTestSuite(BcelWithinTestCase.class);
+ suite.addTestSuite(BcelModifiersPatternTestCase.class);
+ suite.addTestSuite(BcelTypePatternListTestCase.class);
+ suite.addTestSuite(BcelParserTestCase.class);
+ suite.addTestSuite(BcelSignaturePatternTestCase.class);
+ suite.addTestSuite(BcelTypePatternTestCase.class);
+
+ suite.addTestSuite(AnnotationPatternTestCase.class);
+ suite.addTestSuite(AnnotationPatternMatchingTestCase.class);
+ // $JUnit-END$
+ return suite;
+ }
+
+ public BcelPatternsTests(String name) {
+ super(name);
+ }
+
+}
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelSignaturePatternTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelSignaturePatternTestCase.java
new file mode 100644
index 000000000..e7f0f9890
--- /dev/null
+++ b/weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelSignaturePatternTestCase.java
@@ -0,0 +1,24 @@
+/* *******************************************************************
+ * Copyright (c) 2008 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://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andy Clement
+ * ******************************************************************/
+package org.aspectj.weaver.patterns.bcel;
+
+import org.aspectj.weaver.World;
+import org.aspectj.weaver.bcel.BcelWorld;
+import org.aspectj.weaver.patterns.SignaturePatternTestCase;
+
+public class BcelSignaturePatternTestCase extends SignaturePatternTestCase {
+
+ public World getWorld() {
+ return new BcelWorld();
+ }
+
+}
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelTypePatternListTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelTypePatternListTestCase.java
new file mode 100644
index 000000000..935533d3c
--- /dev/null
+++ b/weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelTypePatternListTestCase.java
@@ -0,0 +1,23 @@
+/* *******************************************************************
+ * Copyright (c) 2008 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://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andy Clement
+ * ******************************************************************/
+package org.aspectj.weaver.patterns.bcel;
+
+import org.aspectj.weaver.World;
+import org.aspectj.weaver.bcel.BcelWorld;
+import org.aspectj.weaver.patterns.TypePatternListTestCase;
+
+public class BcelTypePatternListTestCase extends TypePatternListTestCase {
+
+ public World getWorld() {
+ return new BcelWorld();
+ }
+}
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelTypePatternTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelTypePatternTestCase.java
new file mode 100644
index 000000000..47b2ce3af
--- /dev/null
+++ b/weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelTypePatternTestCase.java
@@ -0,0 +1,24 @@
+/* *******************************************************************
+ * Copyright (c) 2008 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://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andy Clement
+ * ******************************************************************/
+package org.aspectj.weaver.patterns.bcel;
+
+import org.aspectj.weaver.World;
+import org.aspectj.weaver.bcel.BcelWorld;
+import org.aspectj.weaver.patterns.TypePatternTestCase;
+
+public class BcelTypePatternTestCase extends TypePatternTestCase {
+
+ public World getWorld() {
+ return new BcelWorld();
+ }
+
+}
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelWithinTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelWithinTestCase.java
new file mode 100644
index 000000000..8da1c172f
--- /dev/null
+++ b/weaver/testsrc/org/aspectj/weaver/patterns/bcel/BcelWithinTestCase.java
@@ -0,0 +1,23 @@
+/* *******************************************************************
+ * Copyright (c) 2008 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://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andy Clement
+ * ******************************************************************/
+package org.aspectj.weaver.patterns.bcel;
+
+import org.aspectj.weaver.World;
+import org.aspectj.weaver.bcel.BcelWorld;
+import org.aspectj.weaver.patterns.WithinTestCase;
+
+public class BcelWithinTestCase extends WithinTestCase {
+
+ public World getWorld() {
+ return new BcelWorld();
+ }
+}