diff options
author | aclement <aclement> | 2006-10-03 14:30:21 +0000 |
---|---|---|
committer | aclement <aclement> | 2006-10-03 14:30:21 +0000 |
commit | 7b831ff7356725b9872a9635d1e0eeb035f2790b (patch) | |
tree | 4f91fdbd2b9e0ece6ddc1aabaaf6d3fff8f59482 | |
parent | a67ec0d3c573b37b0d1bbc8b2400da430dfb2faa (diff) | |
download | aspectj-7b831ff7356725b9872a9635d1e0eeb035f2790b.tar.gz aspectj-7b831ff7356725b9872a9635d1e0eeb035f2790b.zip |
test and fixes for 152366: support AND in include/exclude/dump
-rw-r--r-- | loadtime/src/org/aspectj/weaver/loadtime/definition/DocumentParser.java | 14 | ||||
-rw-r--r-- | tests/ltw/inclExcl/aop-aspectinclexcl.xml | 10 | ||||
-rw-r--r-- | tests/ltw/inclExcl/aop-exclude.xml | 9 | ||||
-rw-r--r-- | tests/ltw/inclExcl/aop-include.xml | 10 | ||||
-rw-r--r-- | tests/ltw/inclExcl/pkg/Main.aj | 46 | ||||
-rw-r--r-- | tests/ltw/inclExcl/pkg/sub/Foo.aj | 5 | ||||
-rw-r--r-- | tests/ltw/inclExcl/tracing/Tracer.aj | 7 | ||||
-rw-r--r-- | tests/ltw/inclExcl/tracing/staticinit/Tracer.aj | 7 | ||||
-rw-r--r-- | tests/ltw/inclExcl/tracing/staticinit/sub/Tracer.aj | 7 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc150/ltw/LTWTests.java | 14 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml | 45 |
11 files changed, 167 insertions, 7 deletions
diff --git a/loadtime/src/org/aspectj/weaver/loadtime/definition/DocumentParser.java b/loadtime/src/org/aspectj/weaver/loadtime/definition/DocumentParser.java index 2800ebece..2e109527a 100644 --- a/loadtime/src/org/aspectj/weaver/loadtime/definition/DocumentParser.java +++ b/loadtime/src/org/aspectj/weaver/loadtime/definition/DocumentParser.java @@ -193,17 +193,17 @@ public class DocumentParser extends DefaultHandler { } else if (ASPECTS_ELEMENT.equals(qName)) { m_inAspects = true; } else if (INCLUDE_ELEMENT.equals(qName) && m_inWeaver) { - String typePattern = attributes.getValue(WITHIN_ATTRIBUTE); + String typePattern = getWithinAttribute(attributes); if (!isNull(typePattern)) { m_definition.getIncludePatterns().add(typePattern); } } else if (EXCLUDE_ELEMENT.equals(qName) && m_inWeaver) { - String typePattern = attributes.getValue(WITHIN_ATTRIBUTE); + String typePattern = getWithinAttribute(attributes); if (!isNull(typePattern)) { m_definition.getExcludePatterns().add(typePattern); } } else if (DUMP_ELEMENT.equals(qName) && m_inWeaver) { - String typePattern = attributes.getValue(WITHIN_ATTRIBUTE); + String typePattern = getWithinAttribute(attributes); if (!isNull(typePattern)) { m_definition.getDumpPatterns().add(typePattern); } @@ -212,12 +212,12 @@ public class DocumentParser extends DefaultHandler { m_definition.setDumpBefore(true); } } else if (EXCLUDE_ELEMENT.equals(qName) && m_inAspects) { - String typePattern = attributes.getValue(WITHIN_ATTRIBUTE); + String typePattern = getWithinAttribute(attributes); if (!isNull(typePattern)) { m_definition.getAspectExcludePatterns().add(typePattern); } } else if (INCLUDE_ELEMENT.equals(qName) && m_inAspects) { - String typePattern = attributes.getValue(WITHIN_ATTRIBUTE); + String typePattern = getWithinAttribute(attributes); if (!isNull(typePattern)) { m_definition.getAspectIncludePatterns().add(typePattern); } @@ -227,6 +227,10 @@ public class DocumentParser extends DefaultHandler { super.startElement(uri, localName, qName, attributes); } + private String getWithinAttribute(Attributes attributes) { + return replaceXmlAnd(attributes.getValue(WITHIN_ATTRIBUTE)); + } + public void endElement(String uri, String localName, String qName) throws SAXException { if (CONCRETE_ASPECT_ELEMENT.equals(qName)) { m_lastConcreteAspect = null; diff --git a/tests/ltw/inclExcl/aop-aspectinclexcl.xml b/tests/ltw/inclExcl/aop-aspectinclexcl.xml new file mode 100644 index 000000000..5f4c88d50 --- /dev/null +++ b/tests/ltw/inclExcl/aop-aspectinclexcl.xml @@ -0,0 +1,10 @@ +<aspectj> +<aspects> +<aspect name="tracing.Tracer"/> +<aspect name="tracing.staticinit.Tracer"/> +<aspect name="tracing.staticinit.sub.Tracer"/> +<include within="tracing..* AND !tracing.staticinit.sub..*"/> +<exclude within="tracing..* AND !tracing.staticinit..*"/> +</aspects> +</aspectj> + diff --git a/tests/ltw/inclExcl/aop-exclude.xml b/tests/ltw/inclExcl/aop-exclude.xml new file mode 100644 index 000000000..b13fcf099 --- /dev/null +++ b/tests/ltw/inclExcl/aop-exclude.xml @@ -0,0 +1,9 @@ +<aspectj> +<weaver> +<exclude within="pkg..* AND !pkg.sub..*"/> +</weaver> +<aspects> +<aspect name="tracing.Tracer"/> +</aspects> +</aspectj> + diff --git a/tests/ltw/inclExcl/aop-include.xml b/tests/ltw/inclExcl/aop-include.xml new file mode 100644 index 000000000..afdac0f49 --- /dev/null +++ b/tests/ltw/inclExcl/aop-include.xml @@ -0,0 +1,10 @@ +<aspectj> +<weaver> +<include within="pkg..* AND !pkg.sub..*"/> +<dump within="pkg..* AND !pkg.sub..*"/> +</weaver> +<aspects> +<aspect name="tracing.Tracer"/> +</aspects> +</aspectj> + diff --git a/tests/ltw/inclExcl/pkg/Main.aj b/tests/ltw/inclExcl/pkg/Main.aj new file mode 100644 index 000000000..6cf8ae986 --- /dev/null +++ b/tests/ltw/inclExcl/pkg/Main.aj @@ -0,0 +1,46 @@ +package pkg; + +import java.io.File; + +public class Main { + public static void main(String argz[]) { + foo(); + } + + public static void foo() { + (new pkg.sub.Foo()).foo(); + + File dumpDir = new File("_ajdump"); + lsLR(dumpDir); + + // the LTW harness should clean up _ajdump files! + cleanup(dumpDir); + } + + public static void lsLR(File dir) { + String[] files = dir.list(); + if (files == null) return; + for (int i=0; i<files.length; i++) { + File f = new File(dir, files[i]); + if (f.isFile()) { + System.err.println(files[i]); + } else { + lsLR(f); + } + } + } + + public static void cleanup(File dir) { + String[] files = dir.list(); + if (files == null) return; + for (int i=0; i<files.length; i++) { + File f = new File(dir, files[i]); + if (f.isFile()) { + f.delete(); + } else { + cleanup(f); + } + } + dir.delete(); + } +} diff --git a/tests/ltw/inclExcl/pkg/sub/Foo.aj b/tests/ltw/inclExcl/pkg/sub/Foo.aj new file mode 100644 index 000000000..f93bcf259 --- /dev/null +++ b/tests/ltw/inclExcl/pkg/sub/Foo.aj @@ -0,0 +1,5 @@ +package pkg.sub; + +public class Foo { + public void foo() {} +} diff --git a/tests/ltw/inclExcl/tracing/Tracer.aj b/tests/ltw/inclExcl/tracing/Tracer.aj new file mode 100644 index 000000000..691eefcbe --- /dev/null +++ b/tests/ltw/inclExcl/tracing/Tracer.aj @@ -0,0 +1,7 @@ +package tracing; + +public aspect Tracer { + before() : execution(* foo()) { + System.err.println(thisJoinPoint); + } +} diff --git a/tests/ltw/inclExcl/tracing/staticinit/Tracer.aj b/tests/ltw/inclExcl/tracing/staticinit/Tracer.aj new file mode 100644 index 000000000..8ceebd2a8 --- /dev/null +++ b/tests/ltw/inclExcl/tracing/staticinit/Tracer.aj @@ -0,0 +1,7 @@ +package tracing.staticinit; + +public aspect Tracer { + before() : staticinitialization(pkg..*) { + System.err.println(thisJoinPoint); + } +} diff --git a/tests/ltw/inclExcl/tracing/staticinit/sub/Tracer.aj b/tests/ltw/inclExcl/tracing/staticinit/sub/Tracer.aj new file mode 100644 index 000000000..2cc3d628a --- /dev/null +++ b/tests/ltw/inclExcl/tracing/staticinit/sub/Tracer.aj @@ -0,0 +1,7 @@ +package tracing.staticinit.sub; + +public aspect Tracer { + before() : staticinitialization(pkg..*) { + System.err.println("sub: "+thisJoinPoint); + } +} diff --git a/tests/src/org/aspectj/systemtest/ajc150/ltw/LTWTests.java b/tests/src/org/aspectj/systemtest/ajc150/ltw/LTWTests.java index cf59b8cb1..31783f6d6 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ltw/LTWTests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/ltw/LTWTests.java @@ -30,8 +30,18 @@ public class LTWTests extends org.aspectj.testing.XMLBasedAjcTestCase { return new File("../tests/src/org/aspectj/systemtest/ajc150/ltw/ltw.xml"); } - - + public void testInclusionAndPattern() { + runTest("Inclusion and patterns"); + } + + public void testExclusionAndPattern() { + runTest("Exclusion and patterns"); + } + + public void testAndPatternsAspects() { + runTest("And patterns aspects"); + } + public void test001(){ runTest("Ensure 1st aspect is rewoven when weaving 2nd aspect"); } diff --git a/tests/src/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml b/tests/src/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml index 01167c34e..120829aab 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml @@ -593,5 +593,50 @@ </stdout> </ant> </ajc-test> + + <ajc-test dir="ltw/inclExcl" title="Inclusion and patterns" keywords="ltw"> + <compile + files="pkg\sub\Foo.aj, pkg\Main.aj" + options="-outjar base.jar" + /> + <compile + files="tracing/Tracer.aj" + /> + <run class="pkg.Main" ltw="aop-include.xml"> + <stderr> + <line text="execution(void pkg.Main.foo())"/> + <line text="Main.class"/> + </stderr> + </run> + </ajc-test> + <ajc-test dir="ltw/inclExcl" title="Exclusion and patterns" keywords="ltw"> + <compile + files="pkg\sub\Foo.aj, pkg\Main.aj" + options="-outjar base.jar" + /> + <compile + files="tracing/Tracer.aj" + /> + <run class="pkg.Main" ltw="aop-exclude.xml"> + <stderr> + <line text="execution(void pkg.sub.Foo.foo())"/> + </stderr> + </run> + </ajc-test> + <ajc-test dir="ltw/inclExcl" title="And patterns aspects" keywords="ltw"> + <compile + files="pkg\sub\Foo.aj, pkg\Main.aj" + options="-outjar base.jar" + /> + <compile + files="tracing/Tracer.aj, tracing/staticinit/Tracer.aj, tracing/staticinit/sub/Tracer.aj" + /> + <run class="pkg.Main" ltw="aop-aspectinclexcl.xml"> + <stderr> + <line text="staticinitialization(pkg.Main.<clinit>)"/> + <line text="staticinitialization(pkg.sub.Foo.<clinit>)"/> + </stderr> + </run> + </ajc-test>
\ No newline at end of file |