]> source.dussan.org Git - aspectj.git/commitdiff
more tests around module options
authorAndy Clement <aclement@pivotal.io>
Wed, 14 Feb 2018 22:03:53 +0000 (14:03 -0800)
committerAndy Clement <aclement@pivotal.io>
Wed, 14 Feb 2018 22:03:53 +0000 (14:03 -0800)
12 files changed:
tests/bugs190/modules/ggg/aaa/bbb/A.java [new file with mode: 0644]
tests/bugs190/modules/ggg/ddd/D.java [new file with mode: 0644]
tests/bugs190/modules/ggg/foo.jar [new file with mode: 0644]
tests/bugs190/modules/ggg/module-info.java [new file with mode: 0644]
tests/bugs190/modules/hhh/aaa/bbb/A.java [new file with mode: 0644]
tests/bugs190/modules/hhh/ddd/D.java [new file with mode: 0644]
tests/bugs190/modules/hhh/module-info-a.java [new file with mode: 0644]
tests/bugs190/modules/hhh/module-info-b.java [new file with mode: 0644]
tests/bugs190/modules/iii/UsesJAXB.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc190/Ajc190Tests.java
tests/src/org/aspectj/systemtest/ajc190/ModuleTests.java
tests/src/org/aspectj/systemtest/ajc190/ajc190.xml

diff --git a/tests/bugs190/modules/ggg/aaa/bbb/A.java b/tests/bugs190/modules/ggg/aaa/bbb/A.java
new file mode 100644 (file)
index 0000000..ca15681
--- /dev/null
@@ -0,0 +1,9 @@
+package aaa.bbb;
+import ddd.D;
+
+public class A {
+  public static void main(String []argv) {
+         System.out.println("A running");
+         D.foo();
+  }
+}
diff --git a/tests/bugs190/modules/ggg/ddd/D.java b/tests/bugs190/modules/ggg/ddd/D.java
new file mode 100644 (file)
index 0000000..d5a992d
--- /dev/null
@@ -0,0 +1,5 @@
+package ddd;
+
+public class D {
+       public static void foo() {}
+}
diff --git a/tests/bugs190/modules/ggg/foo.jar b/tests/bugs190/modules/ggg/foo.jar
new file mode 100644 (file)
index 0000000..d17415c
Binary files /dev/null and b/tests/bugs190/modules/ggg/foo.jar differ
diff --git a/tests/bugs190/modules/ggg/module-info.java b/tests/bugs190/modules/ggg/module-info.java
new file mode 100644 (file)
index 0000000..60e9fdc
--- /dev/null
@@ -0,0 +1,3 @@
+module my.module {
+  exports aaa.bbb;
+}
diff --git a/tests/bugs190/modules/hhh/aaa/bbb/A.java b/tests/bugs190/modules/hhh/aaa/bbb/A.java
new file mode 100644 (file)
index 0000000..ca15681
--- /dev/null
@@ -0,0 +1,9 @@
+package aaa.bbb;
+import ddd.D;
+
+public class A {
+  public static void main(String []argv) {
+         System.out.println("A running");
+         D.foo();
+  }
+}
diff --git a/tests/bugs190/modules/hhh/ddd/D.java b/tests/bugs190/modules/hhh/ddd/D.java
new file mode 100644 (file)
index 0000000..d5a992d
--- /dev/null
@@ -0,0 +1,5 @@
+package ddd;
+
+public class D {
+       public static void foo() {}
+}
diff --git a/tests/bugs190/modules/hhh/module-info-a.java b/tests/bugs190/modules/hhh/module-info-a.java
new file mode 100644 (file)
index 0000000..c6a7a03
--- /dev/null
@@ -0,0 +1,3 @@
+module my.module.a {
+  exports ddd;
+}
diff --git a/tests/bugs190/modules/hhh/module-info-b.java b/tests/bugs190/modules/hhh/module-info-b.java
new file mode 100644 (file)
index 0000000..2300541
--- /dev/null
@@ -0,0 +1,3 @@
+module my.module.b {
+  exports aaa.bbb;
+}
diff --git a/tests/bugs190/modules/iii/UsesJAXB.java b/tests/bugs190/modules/iii/UsesJAXB.java
new file mode 100644 (file)
index 0000000..5eb9e59
--- /dev/null
@@ -0,0 +1,21 @@
+import javax.xml.transform.TransformerFactory;\r
+import javax.xml.bind.JAXBContext;\r
+import javax.xml.parsers.DocumentBuilderFactory;\r
+\r
+//import org.slf4j.Logger;\r
+//import org.slf4j.LoggerFactory;\r
+import org.w3c.dom.Document;\r
+\r
+public class UsesJAXB {\r
+\r
+ //   private static final Logger LOG = LoggerFactory.getLogger(UsesJAXB.class);\r
+    \r
+    TransformerFactory tf = TransformerFactory.newInstance();\r
+    \r
+    public UsesJAXB() {\r
+  //      LOG.error("UMS001");\r
+        Document document;\r
+        JAXBContext context;\r
+    }\r
+\r
+}\r
index 607f723fcc46605f170401057a238abab8ad491c..52830ab28e0cd12bca74c2699a1f035b042ac5f8 100644 (file)
@@ -13,13 +13,14 @@ package org.aspectj.systemtest.ajc190;
 import java.io.File;
 
 import org.aspectj.testing.XMLBasedAjcTestCase;
+import org.aspectj.testing.XMLBasedAjcTestCaseForJava9OrLater;
 
 import junit.framework.Test;
 
 /**
  * @author Andy Clement
  */
-public class Ajc190Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
+public class Ajc190Tests extends XMLBasedAjcTestCaseForJava9OrLater {
 
        public void testAnnotMethodHasMember_pr156962_1() { // From similar in Ajc153Tests
                runTest("Test Annot Method Has Member 1");
@@ -37,6 +38,10 @@ public class Ajc190Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
        public void testWeaveModule() throws Exception {
                runTest("weave module");
        }
+       
+       public void testUsesJaxb() {
+               runTest("java use of java.xml.bind");
+       }
 
        // ---
 
index 5b5efb15bd97db6eaf30568b8974809aed6c2ae4..9828aa17af3991017a61f960d0b8c320396e6524 100644 (file)
@@ -9,21 +9,22 @@ package org.aspectj.systemtest.ajc190;
 
 import java.io.File;
 
-import junit.framework.Test;
-
 import org.aspectj.apache.bcel.classfile.Attribute;
 import org.aspectj.apache.bcel.classfile.Code;
 import org.aspectj.apache.bcel.classfile.JavaClass;
 import org.aspectj.apache.bcel.classfile.Method;
 import org.aspectj.testing.XMLBasedAjcTestCase;
+import org.aspectj.testing.XMLBasedAjcTestCaseForJava9OrLater;
+
+import junit.framework.Test;
 
 /**
- * Building and weaving with modules in the picture...
+ * Building and weaving with modules in the picture.
  * 
  * @author Andy Clement
  * 
  */
-public class ModuleTests extends org.aspectj.testing.XMLBasedAjcTestCase {
+public class ModuleTests extends XMLBasedAjcTestCaseForJava9OrLater {
 
        public void testBuildAModule() {
                runTest("build a module");
@@ -44,31 +45,30 @@ public class ModuleTests extends org.aspectj.testing.XMLBasedAjcTestCase {
        public void testBuildModuleIncludingAspects() {
                runTest("compile module including aspects");
        }
+       
+       public void testBuildModuleAndApplyAspectsFromAspectPath() {
+               runTest("compile module and apply aspects via aspectpath");
+       }
 
        public void testBinaryWeavingAModuleJar() {
                // Pass a module on inpath, does it weave ok with a source aspect, does it run afterwards?
                runTest("binary weaving module");
        }
 
-       // can't really write these tests now... pure jdt seems to allow type resolution against module path for types
-       // not in modules being compiled but javac does not
-
-       public void xtestReferenceTypesFromModuleInBuildingSomeCode() {
-               runTest("compile regular code using module code");
-       }
-
-       public void xtestReferenceTypesFromModuleInBuildingSomeCodeButCantSeeThem() {
-               runTest("compile regular code using module code that isn't visible");
+       public void testModulepathClasspathResolution1() {
+               runTest("module path vs classpath 1");
        }
 
-       public void xtestBinaryWeavingInvolvingTypesOnModulePath() {
-               fail();
+//     public void testModulepathClasspathResolution2() {
+//             runTest("module path vs classpath 2");
+//     }
+       
+       // This tests that when using --add-modules with one of the JDK modules (in the jmods subfolder of the JDK)
+       // that it can be found without needing to set --module-path (this seems to be implicitly included by javac too)
+       public void testAddModules1() {
+               runTest("java use of java.xml.bind");
        }
 
-       public void xtestLoadtimeWeavingWithModulePathContainingTypes() {
-               fail();
-       }
-       
        /* For the specified class, check that each method has a stackmap attribute */
        private void checkStackMapExistence(String classname, String toIgnore) throws ClassNotFoundException {
                toIgnore = "_" + (toIgnore == null ? "" : toIgnore) + "_";
@@ -131,6 +131,7 @@ public class ModuleTests extends org.aspectj.testing.XMLBasedAjcTestCase {
                return XMLBasedAjcTestCase.loadSuite(ModuleTests.class);
        }
 
+       @Override
        protected File getSpecFile() {
                return getClassResource("ajc190.xml");
        }
index c2da5de602ee3197ae56b23313cc866d844520e0..2239d62c4e429d7ca579442a1284b85bdd619f05 100644 (file)
     </run>
   </ajc-test>
   
+  <ajc-test dir="bugs190/modules/eee" title="compile module and apply aspects via aspectpath">
+    <compile files="module-info.java aaa/bbb/A.java" options="-1.9" outjar="my.module.jar"/>
+    <file deletefile="module-info.java"/>
+    <file deletefile="aaa"/>
+    <compile files="Azpect.java" outjar="azpects.jar"/>
+    <compile options="-showWeaveInfo" inpath="my.module.jar" aspectpath="azpects.jar" outjar="my.module.woven.jar">
+               <message kind="weave" text="Join point 'method-execution(void aaa.bbb.A.main(java.lang.String[]))' in Type 'aaa.bbb.A' (A.java:4) advised by before advice from 'aspects.Azpect' (azpects.jar!Azpect.class:4(from Azpect.java))"/>    
+    </compile>
+    <file deletefile="my.module.jar"/>
+    <run classpath="my.module.woven.jar:azpects.jar" class="aaa.bbb.A">
+      <stdout>
+      <line text="Azpect running"/>
+      <line text="A running"/>
+      </stdout>
+    </run>
+  </ajc-test>
+  
+  <ajc-test dir="bugs190/modules/ggg" title="module path vs classpath 1">
+    <!-- build some simple code into a jar we can depend on *not a module* -->
+    <compile files="ddd/D.java" options="-1.9" outjar="foo.jar"/>
+    <file deletefile="ddd/D.java"/>
+    <!-- compile a module that depends on that -->
+    <!-- this fails because if you start working with modules you commit to the modules story and classpath
+         becomes irrelevant -->
+    <compile files="module-info.java aaa/bbb/A.java" options="-1.9" outjar="module.jar" classpath="foo.jar">
+    <message kind="error" text="The import ddd cannot be resolved"/>
+    <message kind="error" text="D cannot be resolved"/>
+    </compile>
+  </ajc-test>
+  
+  <ajc-test dir="bugs190/modules/hhh" title="module path vs classpath 2">
+    <!-- build some simple code into a jar we can depend on *not a module* -->
+    <file renamefrom="module-info-a.java" renameto="module-info.java"/>
+    <compile files="module-info.java ddd/D.java" options="-1.9" outjar="my.module.a.jar"/>
+    <!-- 
+    <file renamefrom="module-info-b.java" renameto="module-info.java"/>
+    <compile files="module-info.java aaa/bbb/A.java" options="-1.9" outjar="my.module.b.jar" modulepath="my.module.a.jar"/>
+     -->
+  </ajc-test>
+  
+  <ajc-test dir="bugs190/modules/iii" title="java use of java.xml.bind">
+    <compile files="UsesJAXB.java" options="--add-modules java.xml.bind -1.9"/>
+  </ajc-test>
+    
+  <!-- 
+    <compile files="module-info.java aaa/bbb/A.java" options="-1.9" outjar="module.jar" aspectpath="foo.jar"/>
+    <compile files="module-info.java aaa/bbb/A.java" options="-1.9" outjar="my.module.jar"/>
+    <file deletefile="module-info.java"/>
+    <file deletefile="aaa"/>
+    <compile files="Azpect.java" outjar="azpects.jar"/>
+    <compile options="-showWeaveInfo" inpath="my.module.jar" aspectpath="azpects.jar" outjar="my.module.woven.jar">
+               <message kind="weave" text="Join point 'method-execution(void aaa.bbb.A.main(java.lang.String[]))' in Type 'aaa.bbb.A' (A.java:4) advised by before advice from 'aspects.Azpect' (azpects.jar!Azpect.class:4(from Azpect.java))"/>    
+    </compile>
+    <file deletefile="my.module.jar"/>
+    <run classpath="my.module.woven.jar:azpects.jar" class="aaa.bbb.A">
+      <stdout>
+      <line text="Azpect running"/>
+      <line text="A running"/>
+      </stdout>
+    </run>
+  </ajc-test>
+     -->
+  
   <ajc-test dir="bugs190/modules" title="weave module">
     <compile files="aspect1/Azpect1.java" inpath="module1/module-one.jar" outjar="runner.jar" options="-1.8"/>
     <java classpath="runner.jar" class="a.b.c.Code"/>