From: Andy Clement Date: Fri, 20 Oct 2017 19:35:24 +0000 (-0700) Subject: 1.9 test changes and new module tests X-Git-Tag: V1_9_0_RC3~2^2~27 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d6025b5d3d6d37b026e91fb1a32f3b214d881bf4;p=aspectj.git 1.9 test changes and new module tests --- 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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; + } + }