diff options
author | Andy Clement <aclement@pivotal.io> | 2018-02-14 14:03:53 -0800 |
---|---|---|
committer | Andy Clement <aclement@pivotal.io> | 2018-02-14 14:03:53 -0800 |
commit | cf7484b3d30f12ea64eb2a936e1cbd05f2da8291 (patch) | |
tree | 8e4dde6a4b2f01d0c397afa1241bdc68e81f5d78 /tests | |
parent | 53262b4d0ba9b01de0979fca222838dd846396e9 (diff) | |
download | aspectj-cf7484b3d30f12ea64eb2a936e1cbd05f2da8291.tar.gz aspectj-cf7484b3d30f12ea64eb2a936e1cbd05f2da8291.zip |
more tests around module options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/bugs190/modules/ggg/aaa/bbb/A.java | 9 | ||||
-rw-r--r-- | tests/bugs190/modules/ggg/ddd/D.java | 5 | ||||
-rw-r--r-- | tests/bugs190/modules/ggg/foo.jar | bin | 0 -> 318 bytes | |||
-rw-r--r-- | tests/bugs190/modules/ggg/module-info.java | 3 | ||||
-rw-r--r-- | tests/bugs190/modules/hhh/aaa/bbb/A.java | 9 | ||||
-rw-r--r-- | tests/bugs190/modules/hhh/ddd/D.java | 5 | ||||
-rw-r--r-- | tests/bugs190/modules/hhh/module-info-a.java | 3 | ||||
-rw-r--r-- | tests/bugs190/modules/hhh/module-info-b.java | 3 | ||||
-rw-r--r-- | tests/bugs190/modules/iii/UsesJAXB.java | 21 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc190/Ajc190Tests.java | 7 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc190/ModuleTests.java | 39 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc190/ajc190.xml | 63 |
12 files changed, 147 insertions, 20 deletions
diff --git a/tests/bugs190/modules/ggg/aaa/bbb/A.java b/tests/bugs190/modules/ggg/aaa/bbb/A.java new file mode 100644 index 000000000..ca15681c6 --- /dev/null +++ b/tests/bugs190/modules/ggg/aaa/bbb/A.java @@ -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 index 000000000..d5a992d6e --- /dev/null +++ b/tests/bugs190/modules/ggg/ddd/D.java @@ -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 Binary files differnew file mode 100644 index 000000000..d17415c0e --- /dev/null +++ b/tests/bugs190/modules/ggg/foo.jar diff --git a/tests/bugs190/modules/ggg/module-info.java b/tests/bugs190/modules/ggg/module-info.java new file mode 100644 index 000000000..60e9fdc99 --- /dev/null +++ b/tests/bugs190/modules/ggg/module-info.java @@ -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 index 000000000..ca15681c6 --- /dev/null +++ b/tests/bugs190/modules/hhh/aaa/bbb/A.java @@ -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 index 000000000..d5a992d6e --- /dev/null +++ b/tests/bugs190/modules/hhh/ddd/D.java @@ -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 index 000000000..c6a7a0321 --- /dev/null +++ b/tests/bugs190/modules/hhh/module-info-a.java @@ -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 index 000000000..2300541ab --- /dev/null +++ b/tests/bugs190/modules/hhh/module-info-b.java @@ -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 index 000000000..5eb9e59bc --- /dev/null +++ b/tests/bugs190/modules/iii/UsesJAXB.java @@ -0,0 +1,21 @@ +import javax.xml.transform.TransformerFactory;
+import javax.xml.bind.JAXBContext;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+//import org.slf4j.Logger;
+//import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+
+public class UsesJAXB {
+
+ // private static final Logger LOG = LoggerFactory.getLogger(UsesJAXB.class);
+
+ TransformerFactory tf = TransformerFactory.newInstance();
+
+ public UsesJAXB() {
+ // LOG.error("UMS001");
+ Document document;
+ JAXBContext context;
+ }
+
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc190/Ajc190Tests.java b/tests/src/org/aspectj/systemtest/ajc190/Ajc190Tests.java index 607f723fc..52830ab28 100644 --- a/tests/src/org/aspectj/systemtest/ajc190/Ajc190Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc190/Ajc190Tests.java @@ -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"); + } // --- diff --git a/tests/src/org/aspectj/systemtest/ajc190/ModuleTests.java b/tests/src/org/aspectj/systemtest/ajc190/ModuleTests.java index 5b5efb15b..9828aa17a 100644 --- a/tests/src/org/aspectj/systemtest/ajc190/ModuleTests.java +++ b/tests/src/org/aspectj/systemtest/ajc190/ModuleTests.java @@ -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"); } diff --git a/tests/src/org/aspectj/systemtest/ajc190/ajc190.xml b/tests/src/org/aspectj/systemtest/ajc190/ajc190.xml index c2da5de60..2239d62c4 100644 --- a/tests/src/org/aspectj/systemtest/ajc190/ajc190.xml +++ b/tests/src/org/aspectj/systemtest/ajc190/ajc190.xml @@ -78,6 +78,69 @@ </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"/> |