]> source.dussan.org Git - aspectj.git/commitdiff
Add Ajc164Tests::testMultipleXMLFiles
authorAlexander Kriegisch <Alexander@Kriegisch.name>
Wed, 21 Feb 2024 03:35:44 +0000 (10:35 +0700)
committerAlexander Kriegisch <Alexander@Kriegisch.name>
Thu, 22 Feb 2024 03:28:03 +0000 (10:28 +0700)
While researching how and what to document for AJJ option
'-xmlConfigured', I needed to find out what happens in case of multiple
XML config files. Result: They are merged. the new test case for the old
1.6.4 release verifies and documents that. It can also serve as an
example for reference in case of user questions.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
tests/features164/aopconfig/one/A3.java [new file with mode: 0644]
tests/features164/aopconfig/one/multi1.xml [new file with mode: 0644]
tests/features164/aopconfig/one/multi2.xml [new file with mode: 0644]
tests/features164/aopconfig/one/multi3.xml [new file with mode: 0644]
tests/src/test/java/org/aspectj/systemtest/ajc164/Ajc164Tests.java
tests/src/test/resources/org/aspectj/systemtest/ajc164/ajc164.xml

diff --git a/tests/features164/aopconfig/one/A3.java b/tests/features164/aopconfig/one/A3.java
new file mode 100644 (file)
index 0000000..9339f20
--- /dev/null
@@ -0,0 +1,3 @@
+aspect A3 {
+  before():staticinitialization(*) {}
+}
diff --git a/tests/features164/aopconfig/one/multi1.xml b/tests/features164/aopconfig/one/multi1.xml
new file mode 100644 (file)
index 0000000..0aeec1b
--- /dev/null
@@ -0,0 +1,9 @@
+<aspectj>
+  <aspects>
+    <aspect name="A" scope="B"/>
+  </aspects>
+  <weaver>
+    <!-- Do not apply on any aspects -->
+    <exclude within="A*"/>
+  </weaver>
+</aspectj>
diff --git a/tests/features164/aopconfig/one/multi2.xml b/tests/features164/aopconfig/one/multi2.xml
new file mode 100644 (file)
index 0000000..9c2c39c
--- /dev/null
@@ -0,0 +1,5 @@
+<aspectj>
+  <aspects>
+    <aspect name="A2" scope="B2"/>
+  </aspects>
+</aspectj>
diff --git a/tests/features164/aopconfig/one/multi3.xml b/tests/features164/aopconfig/one/multi3.xml
new file mode 100644 (file)
index 0000000..18c1513
--- /dev/null
@@ -0,0 +1,5 @@
+<aspectj>
+  <aspects>
+    <aspect name="A3"/>
+  </aspects>
+</aspectj>
index 04b4b15d382181a8db5c1f0f05559364cfe2d12b..d9cbd381cc5d9f3203b6f9340393bf03971fff92 100644 (file)
@@ -221,6 +221,56 @@ public class Ajc164Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
                runTest("aop config - 5");
        }
 
+       /**
+        * If multiple XML files are given together with {@code -xmlConfigured}, they will be logically merged into one.
+        * I.e., given the following three XML config files:
+        *
+        * <pre>{@code
+        * <aspectj>
+        *   <aspects>
+        *     <aspect name="A" scope="B"/>
+        *   </aspects>
+        *   <weaver>
+        *     <exclude within="A*"/>
+        *   </weaver>
+        * </aspectj>
+        * }</pre>
+        *
+        * <pre>{@code
+        * <aspectj>
+        *   <aspects>
+        *     <aspect name="A2" scope="B2"/>
+        *   </aspects>
+        * </aspectj>
+        * }</pre>
+        *
+        * <pre>{@code
+        * <aspectj>
+        *   <aspects>
+        *     <aspect name="A3"/>
+        *   </aspects>
+        * </aspectj>
+        * }</pre>
+        *
+        * The result will be as if only one XML config file with this content was specified:
+        *
+        * <pre>{@code
+        * <aspectj>
+        *   <aspects>
+        *     <aspect name="A" scope="B"/>
+        *     <aspect name="A2" scope="B2"/>
+        *     <aspect name="A3"/>
+        *   </aspects>
+        *   <weaver>
+        *     <exclude within="A*"/>
+        *   </weaver>
+        * </aspectj>
+        * }</pre>
+        */
+       public void testMultipleXMLFiles() {
+               runTest("aop config - multiple XML files");
+       }
+
        public void testAjcThisNotRead() {
                runTest("ajcthis not read");
        }
index a14d8d0e7c1d94c15f5410a44191d6b153b7c98e..c59523f92615eea4481d1b9162fee56bd4e02e8c 100644 (file)
       </compile>
     </ajc-test>
 
+    <ajc-test dir="features164/aopconfig/one" title="aop config - multiple XML files">
+      <!-- Java, AspectJ and XML files can be specified in any order. See how they are mixed here. -->
+      <compile files="A.java A2.java A3.java multi1.xml multi2.xml B.java B2.java multi3.xml" options="-1.5 -showWeaveInfo -xmlConfigured">
+        <message kind="weave" text="Join point 'staticinitialization(void B.&lt;clinit&gt;())' in Type 'B' (B.java:1) advised by before advice from 'A3' (A3.java:2)"/>
+        <message kind="weave" text="Join point 'staticinitialization(void B.&lt;clinit&gt;())' in Type 'B' (B.java:1) advised by before advice from 'A' (A.java:2)"/>
+        <message kind="weave" text="Join point 'staticinitialization(void B2.&lt;clinit&gt;())' in Type 'B2' (B2.java:1) advised by before advice from 'A3' (A3.java:2)"/>
+        <message kind="weave" text="Join point 'staticinitialization(void B2.&lt;clinit&gt;())' in Type 'B2' (B2.java:1) advised by before advice from 'A2' (A2.java:2)"/>
+      </compile>
+    </ajc-test>
+
     <ajc-test dir="bugs164/pr263310" title="inner handles">
       <compile files="HandleTestingAspect.java" options="-1.5 -emacssym -Xlint:ignore"/>
     </ajc-test>