aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/src/org/aspectj/systemtest/ajc190/AllTestsAspectJ190.java1
-rw-r--r--tests/src/org/aspectj/systemtest/ajc190/ModuleTests.java138
-rw-r--r--tests/src/org/aspectj/systemtest/ajc190/SanityTests19.java87
-rw-r--r--tests/src/org/aspectj/systemtest/ajc190/ajc190.xml72
-rw-r--r--tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java10
5 files changed, 263 insertions, 45 deletions
diff --git a/tests/src/org/aspectj/systemtest/ajc190/AllTestsAspectJ190.java b/tests/src/org/aspectj/systemtest/ajc190/AllTestsAspectJ190.java
index 139e99e69..4f795f960 100644
--- a/tests/src/org/aspectj/systemtest/ajc190/AllTestsAspectJ190.java
+++ b/tests/src/org/aspectj/systemtest/ajc190/AllTestsAspectJ190.java
@@ -20,6 +20,7 @@ public class AllTestsAspectJ190 {
// $JUnit-BEGIN$
suite.addTest(Ajc190Tests.suite());
suite.addTest(SanityTests19.suite());
+ suite.addTest(ModuleTests.suite());
suite.addTest(Annotations.suite());
// $JUnit-END$
return suite;
diff --git a/tests/src/org/aspectj/systemtest/ajc190/ModuleTests.java b/tests/src/org/aspectj/systemtest/ajc190/ModuleTests.java
new file mode 100644
index 000000000..5b5efb15b
--- /dev/null
+++ b/tests/src/org/aspectj/systemtest/ajc190/ModuleTests.java
@@ -0,0 +1,138 @@
+/*******************************************************************************
+ * Copyright (c) 2017 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
+ *******************************************************************************/
+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;
+
+/**
+ * Building and weaving with modules in the picture...
+ *
+ * @author Andy Clement
+ *
+ */
+public class ModuleTests extends org.aspectj.testing.XMLBasedAjcTestCase {
+
+ public void testBuildAModule() {
+ runTest("build a module");
+ }
+
+ public void testRunModuleClassPath() {
+ runTest("run a module - classpath");
+ }
+
+ public void testRunModuleModulePath() {
+ runTest("run a module - modulepath");
+ }
+
+ public void testPackageAndRunModuleFromModulePath() {
+ runTest("package and run a module - modulepath");
+ }
+
+ public void testBuildModuleIncludingAspects() {
+ runTest("compile module including aspects");
+ }
+
+ 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 xtestBinaryWeavingInvolvingTypesOnModulePath() {
+ fail();
+ }
+
+ 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) + "_";
+ JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname);
+ Method[] methods = jc.getMethods();
+ for (int i = 0; i < methods.length; i++) {
+ Method method = methods[i];
+ if (toIgnore.contains("_" + method.getName() + "_")) {
+ continue;
+ }
+ boolean hasStackMapAttribute = findAttribute(method.getAttributes(), "StackMapTable");
+ if (!hasStackMapAttribute) {
+ fail("Could not find StackMap attribute for method " + method.getName());
+ }
+ }
+ }
+
+ private boolean findAttribute(Attribute[] attrs, String attributeName) {
+ if (attrs == null) {
+ return false;
+ }
+ for (int i = 0; i < attrs.length; i++) {
+ Attribute attribute = attrs[i];
+ if (attribute.getName().equals(attributeName)) {
+ return true;
+ }
+ // System.out.println(attribute.getName());
+ if (attribute.getName().equals("Code")) {
+ Code c = (Code) attribute;
+ Attribute[] codeAttributes = c.getAttributes();
+ for (int j = 0; j < codeAttributes.length; j++) {
+ Attribute codeAttribute = codeAttributes[j];
+ if (codeAttribute.getName().equals(attributeName)) {
+ return true;
+ // System.out.println(codeAttribute.getName());
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ private void checkVersion(String classname, int major, int minor) throws ClassNotFoundException {
+ JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname);
+ if (jc.getMajor() != major) {
+ fail("Expected major version to be " + major + " but was " + jc.getMajor());
+ }
+ if (jc.getMinor() != minor) {
+ fail("Expected minor version to be " + minor + " but was " + jc.getMinor());
+ }
+ }
+
+ // Check the stackmap stuff is removed when a method gets woven (for now...)
+ // public void testStackMapAttributesDeletedInWovenCode() {
+ // fail("Not implemented");
+ // }
+
+ // ///////////////////////////////////////
+ public static Test suite() {
+ return XMLBasedAjcTestCase.loadSuite(ModuleTests.class);
+ }
+
+ protected File getSpecFile() {
+ return getClassResource("ajc190.xml");
+ }
+
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc190/SanityTests19.java b/tests/src/org/aspectj/systemtest/ajc190/SanityTests19.java
index 3317c51d3..5544022c4 100644
--- a/tests/src/org/aspectj/systemtest/ajc190/SanityTests19.java
+++ b/tests/src/org/aspectj/systemtest/ajc190/SanityTests19.java
@@ -12,14 +12,11 @@ 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 junit.framework.Test;
+
/*
* Some very trivial tests that help verify things are OK.
* These are a copy of the earlier Sanity Tests created for 1.6 but these supply the -1.9 option
@@ -88,46 +85,46 @@ public class SanityTests19 extends org.aspectj.testing.XMLBasedAjcTestCase {
// }
/* 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) + "_";
- JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname);
- Method[] methods = jc.getMethods();
- for (int i = 0; i < methods.length; i++) {
- Method method = methods[i];
- if (toIgnore.contains("_" + method.getName() + "_")) {
- continue;
- }
- boolean hasStackMapAttribute = findAttribute(method.getAttributes(), "StackMapTable");
- if (!hasStackMapAttribute) {
- fail("Could not find StackMap attribute for method " + method.getName());
- }
- }
- }
-
- private boolean findAttribute(Attribute[] attrs, String attributeName) {
- if (attrs == null) {
- return false;
- }
- for (int i = 0; i < attrs.length; i++) {
- Attribute attribute = attrs[i];
- if (attribute.getName().equals(attributeName)) {
- return true;
- }
- // System.out.println(attribute.getName());
- if (attribute.getName().equals("Code")) {
- Code c = (Code) attribute;
- Attribute[] codeAttributes = c.getAttributes();
- for (int j = 0; j < codeAttributes.length; j++) {
- Attribute codeAttribute = codeAttributes[j];
- if (codeAttribute.getName().equals(attributeName)) {
- return true;
- // System.out.println(codeAttribute.getName());
- }
- }
- }
- }
- return false;
- }
+// private void checkStackMapExistence(String classname, String toIgnore) throws ClassNotFoundException {
+// toIgnore = "_" + (toIgnore == null ? "" : toIgnore) + "_";
+// JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname);
+// Method[] methods = jc.getMethods();
+// for (int i = 0; i < methods.length; i++) {
+// Method method = methods[i];
+// if (toIgnore.contains("_" + method.getName() + "_")) {
+// continue;
+// }
+// boolean hasStackMapAttribute = findAttribute(method.getAttributes(), "StackMapTable");
+// if (!hasStackMapAttribute) {
+// fail("Could not find StackMap attribute for method " + method.getName());
+// }
+// }
+// }
+
+// private boolean findAttribute(Attribute[] attrs, String attributeName) {
+// if (attrs == null) {
+// return false;
+// }
+// for (int i = 0; i < attrs.length; i++) {
+// Attribute attribute = attrs[i];
+// if (attribute.getName().equals(attributeName)) {
+// return true;
+// }
+// // System.out.println(attribute.getName());
+// if (attribute.getName().equals("Code")) {
+// Code c = (Code) attribute;
+// Attribute[] codeAttributes = c.getAttributes();
+// for (int j = 0; j < codeAttributes.length; j++) {
+// Attribute codeAttribute = codeAttributes[j];
+// if (codeAttribute.getName().equals(attributeName)) {
+// return true;
+// // System.out.println(codeAttribute.getName());
+// }
+// }
+// }
+// }
+// return false;
+// }
private void checkVersion(String classname, int major, int minor) throws ClassNotFoundException {
JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname);
diff --git a/tests/src/org/aspectj/systemtest/ajc190/ajc190.xml b/tests/src/org/aspectj/systemtest/ajc190/ajc190.xml
index c2cb7cee8..c2da5de60 100644
--- a/tests/src/org/aspectj/systemtest/ajc190/ajc190.xml
+++ b/tests/src/org/aspectj/systemtest/ajc190/ajc190.xml
@@ -2,10 +2,82 @@
<suite>
+ <ajc-test dir="bugs190/modules/aaa" title="build a module">
+ <compile files="module-info.java com/foo1/C1.java" options="-1.9"/>
+ </ajc-test>
+
+ <ajc-test dir="bugs190/modules/bbb" title="run a module - classpath">
+ <compile files="module-info.java aaa/bbb/A.java" options="-1.9"/>
+ <run class="aaa.bbb.A">
+ <stdout>
+ <line text="A running"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="bugs190/modules/bbb" title="run a module - modulepath">
+ <compile files="module-info.java aaa/bbb/A.java" options="-1.9"/>
+ <run modulepath="$sandbox" module="my.module/aaa.bbb.A">
+ <stdout>
+ <line text="A running"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="bugs190/modules/bbb" title="package and run a module - modulepath">
+ <compile files="module-info.java aaa/bbb/A.java" options="-1.9" outjar="my.module.jar"/>
+ <file deletefile="module-info.java"/>
+ <file deletefile="aaa"/>
+ <run modulepath="my.module.jar" module="my.module/aaa.bbb.A">
+ <stdout>
+ <line text="A running"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="bugs190/modules/ccc" title="compile regular code using module code">
+ <compile files="module-info.java aaa/bbb/A.java" options="-1.9" outjar="modules/my.module.jar"/>
+ <file deletefile="module-info.java"/>
+ <file deletefile="aaa"/>
+ <compile files="InvokeA.java" options="-1.9" modulepath="$sandbox/modules/my.module.jar"/>
+ </ajc-test>
+
+ <ajc-test dir="bugs190/modules/ddd" title="compile regular code using module code that isn't visible">
+ <compile files="module-info.java aaa/bbb/A.java" options="-1.9" outjar="modules/my.module.jar"/>
+ <compile files="InvokeA.java" options="-1.9" modulepath="$sandbox/modules/my.module.jar">
+ <message kind="error" text="package aaa.bbb is not visible"/>
+ </compile>
+ </ajc-test>
+
+
+ <ajc-test dir="bugs190/modules/eee" title="binary weaving module">
+ <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" inpath="my.module.jar" outjar="my.module.woven.jar"/>
+ <run modulepath="my.module.woven.jar" module="my.module/aaa.bbb.A">
+ <stdout>
+ <line text="Azpect running"/>
+ <line text="A running"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+
<ajc-test dir="bugs190/520135" title="funny signature with method reference">
<compile files="FailsApectJ.java" options="-1.8"/>
</ajc-test>
+ <ajc-test dir="bugs190/modules/fff" title="compile module including aspects">
+ <compile files="module-info.java pkg/Demo.java otherpkg/Azpect.java" modulepath="$runtime" outjar="demomodule.jar" options="-1.9"/>
+ <run modulepath="$runtime:demomodule.jar" module="demo/pkg.Demo">
+ <stdout>
+ <line text="Azpect running"/>
+ <line text="Demo 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"/>
diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java
index a07bd87aa..cd80218b2 100644
--- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java
+++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java
@@ -262,4 +262,14 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio
return this.processorPath;
}
+ @Override
+ public String getModulepath() {
+ return null;
+ }
+
+ @Override
+ public String getModuleSourcepath() {
+ return null;
+ }
+
}