diff options
author | Andy Clement <aclement@pivotal.io> | 2017-09-20 21:34:21 -0700 |
---|---|---|
committer | Andy Clement <aclement@pivotal.io> | 2017-09-20 21:34:21 -0700 |
commit | 03752862ba3bc6ef132195673903dcf9109e8b93 (patch) | |
tree | 949971954474b167cbcef83fa3161de4c4a4a7c8 /tests/src | |
parent | ee99996fb7f727d34a5393374b5661dba1ec9f9f (diff) | |
parent | 784906d2ee0cb1b432a9aff6973c12cfd865db6e (diff) | |
download | aspectj-03752862ba3bc6ef132195673903dcf9109e8b93.tar.gz aspectj-03752862ba3bc6ef132195673903dcf9109e8b93.zip |
Merged post 1.8.5 changes into Java9 branch
Diffstat (limited to 'tests/src')
20 files changed, 900 insertions, 18 deletions
diff --git a/tests/src/org/aspectj/systemtest/AllTests18.java b/tests/src/org/aspectj/systemtest/AllTests18.java index 80e113ce2..2eadcb823 100644 --- a/tests/src/org/aspectj/systemtest/AllTests18.java +++ b/tests/src/org/aspectj/systemtest/AllTests18.java @@ -10,21 +10,31 @@ *******************************************************************************/ package org.aspectj.systemtest; -import junit.framework.Test; -import junit.framework.TestSuite; - import org.aspectj.systemtest.ajc180.AllTestsAspectJ180; import org.aspectj.systemtest.ajc181.AllTestsAspectJ181; -import org.aspectj.systemtest.ajc182.AllTestsAspectJ182; +import org.aspectj.systemtest.ajc1810.AllTestsAspectJ1810; +import org.aspectj.systemtest.ajc182.AllTestsAspectJ182; import org.aspectj.systemtest.ajc183.AllTestsAspectJ183; import org.aspectj.systemtest.ajc184.AllTestsAspectJ184; import org.aspectj.systemtest.ajc185.AllTestsAspectJ185; +import org.aspectj.systemtest.ajc186.AllTestsAspectJ186; +import org.aspectj.systemtest.ajc187.AllTestsAspectJ187; +import org.aspectj.systemtest.ajc188.AllTestsAspectJ188; +import org.aspectj.systemtest.ajc189.AllTestsAspectJ189; + +import junit.framework.Test; +import junit.framework.TestSuite; public class AllTests18 { public static Test suite() { TestSuite suite = new TestSuite("AspectJ System Test Suite - 1.8"); // $JUnit-BEGIN$ + suite.addTest(AllTestsAspectJ1810.suite()); + suite.addTest(AllTestsAspectJ189.suite()); + suite.addTest(AllTestsAspectJ188.suite()); + suite.addTest(AllTestsAspectJ187.suite()); + suite.addTest(AllTestsAspectJ186.suite()); suite.addTest(AllTestsAspectJ185.suite()); suite.addTest(AllTestsAspectJ184.suite()); suite.addTest(AllTestsAspectJ183.suite()); diff --git a/tests/src/org/aspectj/systemtest/ajc163/ajc163.xml b/tests/src/org/aspectj/systemtest/ajc163/ajc163.xml index 0664d78a1..c26204aa5 100644 --- a/tests/src/org/aspectj/systemtest/ajc163/ajc163.xml +++ b/tests/src/org/aspectj/systemtest/ajc163/ajc163.xml @@ -42,13 +42,13 @@ <run class="CallTest"> <stdout> <line text="public abstract boolean Authorization.mayPerform(java.lang.String,java.lang.String)"/> - <line text="public abstract interface boolean AuthorizationAdmin.mayPerform(java.lang.String, java.lang.String)"/> + <line text="public abstract boolean AuthorizationAdmin.mayPerform(java.lang.String, java.lang.String)"/> <line text="mayPerform() executing"/> <line text="public abstract boolean AuthorizationAdmin.mayPerform2(java.lang.String,java.lang.String)"/> - <line text="public abstract interface boolean AuthorizationAdmin.mayPerform2(java.lang.String, java.lang.String)"/> + <line text="public abstract boolean AuthorizationAdmin.mayPerform2(java.lang.String, java.lang.String)"/> <line text="mayPerform2() executing"/> <line text="public abstract boolean Authorization.mayPerform(java.lang.String,java.lang.String)"/> - <line text="public abstract interface boolean Authorization.mayPerform(java.lang.String, java.lang.String)"/> + <line text="public abstract boolean Authorization.mayPerform(java.lang.String, java.lang.String)"/> <line text="mayPerform() executing"/> </stdout> </run> diff --git a/tests/src/org/aspectj/systemtest/ajc181/Ajc181Tests.java b/tests/src/org/aspectj/systemtest/ajc181/Ajc181Tests.java index a15231dcf..3aa41837e 100644 --- a/tests/src/org/aspectj/systemtest/ajc181/Ajc181Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc181/Ajc181Tests.java @@ -21,10 +21,6 @@ import org.aspectj.testing.XMLBasedAjcTestCase; * @author Andy Clement */ public class Ajc181Tests extends org.aspectj.testing.XMLBasedAjcTestCase { - - public void testJarWeaving_433351() { - runTest("jar weaving"); - } public void testParameterNamesAttribute_436531() { runTest("parameter names attribute"); diff --git a/tests/src/org/aspectj/systemtest/ajc181/ajc181.xml b/tests/src/org/aspectj/systemtest/ajc181/ajc181.xml index 314aaf712..1a8b1acfc 100644 --- a/tests/src/org/aspectj/systemtest/ajc181/ajc181.xml +++ b/tests/src/org/aspectj/systemtest/ajc181/ajc181.xml @@ -2,13 +2,6 @@ <suite> - <ajc-test dir="bugs181/433351" title="jar weaving"> - <compile options="-1.5" files="InterfaceProj1.java" outjar="code.jar"/> - <compile options="-1.5 -showWeaveInfo" inpath="code.jar" files="Extender.aj InterfaceProj2.java"> - <message kind="weave" text="Extending interface set for type 'test.InterfaceProj1' (InterfaceProj1.java) to include 'test.extender.InterfaceProj2' (Extender.aj)"/> - </compile> - </ajc-test> - <ajc-test dir="bugs181/436531" title="parameter names attribute"> <compile options="-1.8" files="Azpect.java" inpath="code.jar"/> </ajc-test> diff --git a/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java b/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java new file mode 100644 index 000000000..cff7a3b7b --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java @@ -0,0 +1,147 @@ +/******************************************************************************* + * Copyright (c) 2016 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 + * + * Contributors: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc1810; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.apache.bcel.Constants; +import org.aspectj.apache.bcel.classfile.Attribute; +import org.aspectj.apache.bcel.classfile.Constant; +import org.aspectj.apache.bcel.classfile.ConstantClass; +import org.aspectj.apache.bcel.classfile.ConstantPool; +import org.aspectj.apache.bcel.classfile.ConstantUtf8; +import org.aspectj.apache.bcel.classfile.InnerClass; +import org.aspectj.apache.bcel.classfile.InnerClasses; +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * @author Andy Clement + */ +public class Ajc1810Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testInvokeDynamic_490315() { + runTest("indy"); + } + + // http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.6 + public void testInnerClassesAttributeStructure_493554() throws Exception { + runTest("pertarget"); + + // Testcode commented out below is for full analysis of the inner class attribute but under + // 493554 we are going to remove that attribute for this class + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "example/aspect/FooAspect$ajcMightHaveAspect"); + assertNotNull(jc); + assertEquals(Constants.ACC_PUBLIC | Constants.ACC_INTERFACE | Constants.ACC_ABSTRACT,jc.getModifiers()); + Attribute[] attributes = jc.getAttributes(); + for (Attribute attribute: attributes) { + if (attribute.getName().equals("InnerClasses")) { + fail("Did not expect to find InnerClasses attribute"); + } + } + +// // Is InnerClasses attribute well formed for the pertarget interface? +// JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "example/aspect/FooAspect$ajcMightHaveAspect"); +// assertNotNull(jc); +// assertEquals(Constants.ACC_PUBLIC | Constants.ACC_INTERFACE | Constants.ACC_ABSTRACT,jc.getModifiers()); +// Attribute attr = getAttributeStartsWith(jc.getAttributes(), "InnerClasses"); +// assertNotNull(attr); +// InnerClasses innerClasses = (InnerClasses)attr; +// InnerClass[] innerClassArray = innerClasses.getInnerClasses(); +// assertEquals(1,innerClassArray.length); +// InnerClass innerClass = innerClassArray[0]; +// ConstantPool cp = jc.getConstantPool(); +// +// // The value of the inner_class_info_index item must be a valid index into the +// // constant_pool table. The constant_pool entry at that index must be a CONSTANT_Class_info +// // structure representing C. +// int innerClassIndex = innerClass.getInnerClassIndex(); +// ConstantClass cc = (ConstantClass)cp.getConstant(innerClassIndex); +// ConstantUtf8 utf8 = cp.getConstantUtf8(cc.getNameIndex()); +// assertEquals("example/aspect/FooAspect$ajcMightHaveAspect",utf8.getStringValue()); +// +// // The remaining items in the classes array entry give information about C. +// // The value of the outer_class_info_index item must be a valid index into the +// // constant_pool table, and the entry at that index must be a CONSTANT_Class_info +// // structure representing the class or interface of which C is a member. +// int outerClassIndex = innerClass.getOuterClassIndex(); +// cc = (ConstantClass)cp.getConstant(outerClassIndex); +// utf8 = cp.getConstantUtf8(cc.getNameIndex()); +// assertEquals("example/aspect/FooAspect",utf8.getStringValue()); +// +// // The value of the inner_name_index item must be a valid index into the constant_pool table, +// // and the entry at that index must be a CONSTANT_Utf8_info structure (ยง4.4.7) that represents +// // the original simple name of C, as given in the source code from which this class file was compiled. +// int innerNameIndex = innerClass.getInnerNameIndex(); +// utf8 = cp.getConstantUtf8(innerNameIndex); +// assertEquals("ajcMightHaveAspect",utf8.getStringValue()); +// +// int innerAccessFlags = innerClass.getInnerAccessFlags(); +// assertEquals(Constants.ACC_PUBLIC | Constants.ACC_ABSTRACT | Constants.ACC_INTERFACE | Constants.ACC_STATIC,innerAccessFlags); +// +// // Is InnerClasses attribute well formed for the containing type? +// jc = getClassFrom(ajc.getSandboxDirectory(), "example/aspect/FooAspect"); +// assertNotNull(jc); +// attr = getAttributeStartsWith(jc.getAttributes(), "InnerClasses"); +// assertNotNull(attr); +// innerClasses = (InnerClasses)attr; +// innerClassArray = innerClasses.getInnerClasses(); +// assertEquals(1,innerClassArray.length); +// innerClass = innerClassArray[0]; +// cp = jc.getConstantPool(); +// System.out.println(innerClass); +// +// // inner class name +// innerClassIndex = innerClass.getInnerClassIndex(); +// cc = (ConstantClass)cp.getConstant(innerClassIndex); +// utf8 = cp.getConstantUtf8(cc.getNameIndex()); +// assertEquals("example/aspect/FooAspect$ajcMightHaveAspect",utf8.getStringValue()); +// +// // outer class name +// outerClassIndex = innerClass.getOuterClassIndex(); +// cc = (ConstantClass)cp.getConstant(outerClassIndex); +// utf8 = cp.getConstantUtf8(cc.getNameIndex()); +// assertEquals("example/aspect/FooAspect",utf8.getStringValue()); +// +// // Simple name +// innerNameIndex = innerClass.getInnerNameIndex(); +// utf8 = cp.getConstantUtf8(innerNameIndex); +// assertEquals("ajcMightHaveAspect",utf8.getStringValue()); +// +// // inner modifiers +// innerAccessFlags = innerClass.getInnerAccessFlags(); +// assertEquals(Constants.ACC_ABSTRACT | Constants.ACC_INTERFACE | Constants.ACC_STATIC,innerAccessFlags); +// +// // Reflection work getDeclaredClasses? +// +// // What about other interfaces? + } + + + +// public void testOverweaving_352389() throws Exception { +// runTest("overweaving"); +// } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc1810Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc1810.xml"); + } + +} diff --git a/tests/src/org/aspectj/systemtest/ajc1810/AllTestsAspectJ1810.java b/tests/src/org/aspectj/systemtest/ajc1810/AllTestsAspectJ1810.java new file mode 100644 index 000000000..b4fe6a8f3 --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc1810/AllTestsAspectJ1810.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2016 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 + * + * Contributors: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc1810; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ1810 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.8.10 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc1810Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml b/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml new file mode 100644 index 000000000..dd4237d22 --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml @@ -0,0 +1,15 @@ +<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]> + +<suite> + + <ajc-test dir="bugs1810/490315" title="indy"> + <compile options="-1.8" files="FailingAspect.java SomeAnno.java SomeContext.java SomeCriteria.java SomeDTO.java SomeEnum.java SomePiece.java SomePropertyDTO.java SomeService.java SomeServiceImpl.java"/> + </ajc-test> + + <ajc-test dir="bugs1810/493554" title="pertarget"> + <compile options="-1.8" files="Dep.java FooAspect.aj Cmd.java"/> + <run class="example.kusedep.Cmd"></run> + </ajc-test> + + +</suite> diff --git a/tests/src/org/aspectj/systemtest/ajc186/Ajc186Tests.java b/tests/src/org/aspectj/systemtest/ajc186/Ajc186Tests.java new file mode 100644 index 000000000..1625f96d1 --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc186/Ajc186Tests.java @@ -0,0 +1,162 @@ +/******************************************************************************* + * Copyright (c) 2014 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 + * + * Contributors: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc186; + +import java.io.File; +import java.lang.reflect.Method; +import java.net.URL; +import java.net.URLClassLoader; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.weaver.tools.ContextBasedMatcher; +import org.aspectj.weaver.tools.DefaultMatchingContext; +import org.aspectj.weaver.tools.FuzzyBoolean; +import org.aspectj.weaver.tools.MatchingContext; +import org.aspectj.weaver.tools.PointcutDesignatorHandler; +import org.aspectj.weaver.tools.PointcutExpression; +import org.aspectj.weaver.tools.PointcutParser; + +/** + * @author Andy Clement + */ +public class Ajc186Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + private class FooDesignatorHandler implements PointcutDesignatorHandler { + + private String askedToParse; + public boolean simulateDynamicTest = false; + + public String getDesignatorName() { + return "foo"; + } + + public ContextBasedMatcher parse(String expression) { + this.askedToParse = expression; + return new FooPointcutExpression(expression, this.simulateDynamicTest); + } + + public String getExpressionLastAskedToParse() { + return this.askedToParse; + } + } + + private class FooPointcutExpression implements ContextBasedMatcher { + + private final String beanNamePattern; + private final boolean simulateDynamicTest; + + public FooPointcutExpression(String beanNamePattern, + boolean simulateDynamicTest) { + this.beanNamePattern = beanNamePattern; + this.simulateDynamicTest = simulateDynamicTest; + } + + public boolean couldMatchJoinPointsInType(Class aClass) { + System.out.println("wubble?"); + return true; + } + + public boolean couldMatchJoinPointsInType(Class aClass, + MatchingContext context) { + System.out.println("wibble?"); + if (this.beanNamePattern.equals(context.getBinding("beanName"))) { + return true; + } else { + return false; + } + } + + public boolean mayNeedDynamicTest() { + return this.simulateDynamicTest; + } + + public FuzzyBoolean matchesStatically(MatchingContext matchContext) { + System.out.println("wobble?"); + if (this.simulateDynamicTest) + return FuzzyBoolean.MAYBE; + if (this.beanNamePattern + .equals(matchContext.getBinding("beanName"))) { + return FuzzyBoolean.YES; + } else { + return FuzzyBoolean.NO; + } + } + + public boolean matchesDynamically(MatchingContext matchContext) { + System.out.println("wabble?"); + return this.beanNamePattern.equals(matchContext + .getBinding("beanName")); + } + } + + public void testLambdaBeans() throws Exception { + runTest("lambda beans"); + + // Load the 1.8 compiled code + URLClassLoader ucl = new URLClassLoader(new URL[] {ajc.getSandboxDirectory().toURI().toURL()},this.getClass().getClassLoader()); + Class<?> applicationClass = Class.forName("Application",false,ucl); + assertNotNull(applicationClass); + Object instance = applicationClass.newInstance(); + Method works = applicationClass.getDeclaredMethod("fromInnerClass"); + works.setAccessible(true); + Runnable r = (Runnable) works.invoke(instance); + // r.getClass().getName() == Application$1 + + Method fails = applicationClass.getDeclaredMethod("fromLambdaExpression"); + fails.setAccessible(true); + Runnable r2 = (Runnable) fails.invoke(instance); + // r2.getClass().getName() == Application$$Lambda$1/1652149987 + +// JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "Application"); + PointcutParser parser = PointcutParser + .getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(ucl); + FooDesignatorHandler beanHandler = new FooDesignatorHandler(); + parser.registerPointcutDesignatorHandler(beanHandler); + PointcutExpression pc = parser.parsePointcutExpression("foo(myBean)"); + DefaultMatchingContext context = new DefaultMatchingContext(); + pc.setMatchingContext(context); + + context.addContextBinding("beanName", "myBean"); + assertTrue(pc.couldMatchJoinPointsInType(r.getClass())); + + context.addContextBinding("beanName", "yourBean"); + assertFalse(pc.couldMatchJoinPointsInType(r.getClass())); + + context.addContextBinding("beanName", "myBean"); + assertTrue(pc.couldMatchJoinPointsInType(r2.getClass())); + + context.addContextBinding("beanName", "yourBean"); + assertFalse(pc.couldMatchJoinPointsInType(r2.getClass())); + } + + + public void testMissingExtends() throws Exception { + runTest("missing extends on generic target"); + } + + public void testMissingMethod_462821() throws Exception { + runTest("missing method"); + } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc186Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc186.xml"); + } + +} diff --git a/tests/src/org/aspectj/systemtest/ajc186/AllTestsAspectJ186.java b/tests/src/org/aspectj/systemtest/ajc186/AllTestsAspectJ186.java new file mode 100644 index 000000000..ff67705de --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc186/AllTestsAspectJ186.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2014 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 + * + * Contributors: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc186; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ186 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.8.6 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc186Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/org/aspectj/systemtest/ajc186/ajc186.xml b/tests/src/org/aspectj/systemtest/ajc186/ajc186.xml new file mode 100644 index 000000000..4f1394a95 --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc186/ajc186.xml @@ -0,0 +1,25 @@ +<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]> + +<suite> + +<ajc-test dir="bugs186/lambdaBeans" title="lambda beans"> +<compile files="Foo.java Application.java" options="-1.8"> +</compile> +</ajc-test> + +<ajc-test dir="bugs186/462821" title="missing method"> +<compile files="FooService.java AbstractLoggerAspect.java FooServiceLoggerAspect.java" options="-1.8"> +</compile> +</ajc-test> + +<ajc-test dir="bugs186/romain" title="missing extends on generic target"> +<compile files="Code.java SubCode.java" options="-1.5" outjar="code.jar"/> +<compile files="X.java Runner1.java" options="-1.5" inpath="code.jar"/> +<run class="Runner1"> +<stdout> +<line text="foo"/> +</stdout> +</run> +</ajc-test> + +</suite> diff --git a/tests/src/org/aspectj/systemtest/ajc187/Ajc187Tests.java b/tests/src/org/aspectj/systemtest/ajc187/Ajc187Tests.java new file mode 100644 index 000000000..754864fd7 --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc187/Ajc187Tests.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2014 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 + * + * Contributors: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc187; + +import java.io.File; +import java.lang.reflect.Method; +import java.net.URL; +import java.net.URLClassLoader; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * @author Andy Clement + */ +public class Ajc187Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testCompileError_476245() throws Exception { + runTest("compile error"); + } + + public void testMissingJoinpoint_307147() throws Exception { + runTest("missing joinpoint"); + } + + public void testMissingJoinpoint_307147_2() throws Exception { + runTest("missing joinpoint 2"); + } + + public void testInfiniteLoop_475152() throws Exception { + runTest("infinite loop"); + } + + public void testAnnoConversion_474165() throws Exception { + runTest("anno conversion"); + } + + public void testLambda_470633() throws Exception { + runTest("lambda"); + } + +// public void testBrokenJava_469889() throws Exception { +// runTest("broken java"); +// } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc187Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc187.xml"); + } + +} diff --git a/tests/src/org/aspectj/systemtest/ajc187/AllTestsAspectJ187.java b/tests/src/org/aspectj/systemtest/ajc187/AllTestsAspectJ187.java new file mode 100644 index 000000000..79634df8c --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc187/AllTestsAspectJ187.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2014 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 + * + * Contributors: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc187; + +import junit.framework.Test; +import junit.framework.TestSuite; +import org.aspectj.systemtest.apt.AptTests; + +public class AllTestsAspectJ187 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.8.7 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc187Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/org/aspectj/systemtest/ajc187/ajc187.xml b/tests/src/org/aspectj/systemtest/ajc187/ajc187.xml new file mode 100644 index 000000000..dfa22f696 --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc187/ajc187.xml @@ -0,0 +1,67 @@ +<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]> + +<suite> + +<ajc-test dir="bugs187/476245" title="compile error"> +<compile files="Testing.java" options="-1.8"/> +</ajc-test> + +<ajc-test dir="bugs187/307147" title="missing joinpoint"> +<compile files="Test.java TestAspect.aj ITDAspect.aj" options="-1.8"/> +<run class="test.Test"> +<stdout> +<line text="Around call(void test.Test.function())"/> +<line text="Normal function"/> +<line text="Around call(void test.Test.privateMethod())"/> +<line text="private method"/> +<line text="Around call(void test.Test.publicMethod())"/> +<line text="public method"/> +<line text="Around call(void test.Test.itdFunction())"/> +<line text="ITD function"/> +<line text="Around call(void test.Test.privateMethod())"/> +<line text="private method"/> +<line text="Around call(void test.Test.publicMethod())"/> +<line text="public method"/> +</stdout></run> +</ajc-test> + +<ajc-test dir="bugs187/307147_2" title="missing joinpoint 2"> +<compile files="Test.java TestAspect.aj ITDAspect.aj" options="-1.8"/> +<run class="test.Test"> +<stdout> +<line text="ITD function"/> +<line text="Around call(void test.Test.privateMethod(String))"/> +<line text="Captured Foo"/> +<line text="hello FOO"/> +</stdout></run> +</ajc-test> + +<ajc-test dir="bugs187/475152" title="infinite loop"> +<compile files="AbstractAspect.aj, BaseAspect.aj, TestClass.java, AjTarget.java, TestAspect.aj" options="-1.8"/> +</ajc-test> + +<ajc-test dir="bugs187/469889" title="broken java"> +<!-- +<compile files="A.java B.java AbstractA.java BImpl.java Main.java" options="-1.8"/> +--> +<compile files="Code.java" options="-1.8"/> +<run class="Code"> +<stdout> +<line text="B"/> +</stdout> +</run> +</ajc-test> + + +<ajc-test dir="bugs187/470633" title="lambda"> +<compile files="Maps.java" options="-1.8"/> +</ajc-test> + +<ajc-test dir="bugs187/474165" title="anno conversion"> +<compile files="B.java" options="-XhasMember -1.8 -showWeaveInfo"> +<message kind="weave" text="Extending interface set for type 'B' (B.java) to include 'java.io.Serializable' (B.java)"/> +</compile> +<run class="B"></run> +</ajc-test> + +</suite> diff --git a/tests/src/org/aspectj/systemtest/ajc188/Ajc188Tests.java b/tests/src/org/aspectj/systemtest/ajc188/Ajc188Tests.java new file mode 100644 index 000000000..c2f5e888c --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc188/Ajc188Tests.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2015 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 + * + * Contributors: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc188; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * @author Andy Clement + */ +public class Ajc188Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testClassCast() throws Exception { + runTest("classcast"); + } + + public void testAnnotationDiscoveryNpe() throws Exception { + runTest("annotation discovery npe"); + } + + public void testDefaultMethodsWithXnoInline() throws Exception { + runTest("default methods 1"); + } + + public void testDefaultMethodsWithoutXnoInline() throws Exception { + runTest("default methods 2"); + } + + public void testCompileError_478003() throws Exception { + runTest("compile error"); + } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc188Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc188.xml"); + } + +} diff --git a/tests/src/org/aspectj/systemtest/ajc188/AllTestsAspectJ188.java b/tests/src/org/aspectj/systemtest/ajc188/AllTestsAspectJ188.java new file mode 100644 index 000000000..8867d9174 --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc188/AllTestsAspectJ188.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2014 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 + * + * Contributors: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc188; + +import junit.framework.Test; +import junit.framework.TestSuite; +import org.aspectj.systemtest.apt.AptTests; + +public class AllTestsAspectJ188 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.8.8 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc188Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/org/aspectj/systemtest/ajc188/ajc188.xml b/tests/src/org/aspectj/systemtest/ajc188/ajc188.xml new file mode 100644 index 000000000..685b50240 --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc188/ajc188.xml @@ -0,0 +1,44 @@ +<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]> + +<suite> + + + <ajc-test dir="bugs188/485055" title="classcast"> + <compile files="AspectWithConstant.aj" options="-1.5"/> + <run class="AspectWithConstant"> + <stdout> + <line text="MAXS=hello"/> + <line text="@AspectWithConstant$Loggable()"/> + </stdout></run> + </ajc-test> + +<ajc-test dir="bugs188/484941" title="annotation discovery npe"> +<compile files="Test2.java" options="-1.8 -XnoInline"/> +</ajc-test> + +<ajc-test dir="bugs188/defaultmethods" title="default methods 1"> +<compile files="Code.java" options="-1.8 -XnoInline"/> +<run class="Code"> +<stdout> +<line text="a"/> +<line text="b"/> +</stdout> +</run> +</ajc-test> + + +<ajc-test dir="bugs188/defaultmethods" title="default methods 2"> +<compile files="Code2.java" options="-1.8"/> +<run class="Code2"> +<stdout> +<line text="a"/> +<line text="b"/> +</stdout> +</run> +</ajc-test> + +<ajc-test dir="bugs188/478003" title="compile error"> +<compile files="OrientDBKeyIO.java" options="-1.8"/> +</ajc-test> + +</suite> diff --git a/tests/src/org/aspectj/systemtest/ajc189/Ajc189Tests.java b/tests/src/org/aspectj/systemtest/ajc189/Ajc189Tests.java new file mode 100644 index 000000000..456c4a41f --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc189/Ajc189Tests.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2016 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 + * + * Contributors: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc189; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * @author Andy Clement + */ +public class Ajc189Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testJarWeaving_433351() { + runTest("jar weaving"); + } + + public void testJarWeaving_433351_4() { + runTest("jar weaving 4"); + } + + public void testJarWeaving_433351_3() { + runTest("jar weaving 3"); + } + + public void testJarWeaving_433351_2() { + runTest("jar weaving 2"); + } + + public void testNPEAtAspectJ() throws Exception { + runTest("NPE at aspectj"); + } + + public void testLostBounds() throws Exception { + runTest("lost bounds"); + // This type has I added via declare parents + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "B"); + assertEquals("<T:LSomeClass;:LSomeInterface;>LC<TT;>;Ljava/io/Serializable;LI;",jc.getGenericSignature()); + jc = getClassFrom(ajc.getSandboxDirectory(), "D"); + assertEquals("<T::LSomeInterface;:LSomeOtherInterface;>Ljava/lang/Object;LI;",jc.getGenericSignature()); + } + + public void testWhileNPE_486203() throws Exception { + runTest("while npe"); + } + +// public void testOverweaving_352389() throws Exception { +// runTest("overweaving"); +// } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc189Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc189.xml"); + } + +} diff --git a/tests/src/org/aspectj/systemtest/ajc189/AllTestsAspectJ189.java b/tests/src/org/aspectj/systemtest/ajc189/AllTestsAspectJ189.java new file mode 100644 index 000000000..546ef02de --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc189/AllTestsAspectJ189.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2016 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 + * + * Contributors: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc189; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ189 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.8.9 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc189Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/org/aspectj/systemtest/ajc189/ajc189.out.xml b/tests/src/org/aspectj/systemtest/ajc189/ajc189.out.xml new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc189/ajc189.out.xml diff --git a/tests/src/org/aspectj/systemtest/ajc189/ajc189.xml b/tests/src/org/aspectj/systemtest/ajc189/ajc189.xml new file mode 100644 index 000000000..8693c1e24 --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc189/ajc189.xml @@ -0,0 +1,102 @@ +<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]> + +<suite> + + <ajc-test dir="bugs189/433351" title="jar weaving"> + <compile options="-1.5" files="InterfaceProj1.java" outjar="code.jar"/> + <compile options="-1.5 -showWeaveInfo" inpath="code.jar" files="Extender.aj InterfaceProj2.java"> + <message kind="weave" text="Extending interface set for type 'test.InterfaceProj1' (InterfaceProj1.java) to include 'test.extender.InterfaceProj2' (Extender.aj)"/> + </compile> + </ajc-test> + + <ajc-test dir="bugs189/433351" title="jar weaving 2"> + <compile options="-1.5" files="InterfaceProj1.java ClassProj1.java" outjar="code.jar"/> + <compile options="-1.5 -showWeaveInfo" inpath="code.jar" files="Extender2.aj" outjar="code2.jar"> + <message kind="weave" text="Extending interface set for type 'test.InterfaceProj1' (InterfaceProj1.java) to include 'java.io.Serializable' (Extender2.aj)"/> + </compile> + </ajc-test> + + <ajc-test dir="bugs189/433351" title="jar weaving 3"> + <compile options="-1.5" files="InterfaceProj1.java ClassProj1.java" outjar="code.jar"/> + <compile options="-1.5 -showWeaveInfo" inpath="code.jar" files="Extender3.aj InterfaceProj2.java ClassProj2.java" outjar="code2.jar"> + <message kind="weave" text="Setting superclass of type 'test.ClassProj1' (ClassProj1.java) to 'test.extender.ClassProj2' (Extender3.aj)"/> + <message kind="weave" text="Extending interface set for type 'test.InterfaceProj1' (InterfaceProj1.java) to include 'test.extender.InterfaceProj2' (Extender3.aj)"/> + </compile> + </ajc-test> + + <ajc-test dir="bugs189/433351" title="jar weaving 4"> + <compile options="-1.5" files="ClassProj1.java InterfaceProj1.java" outjar="code.jar"/> + <compile options="-1.5 -showWeaveInfo" inpath="code.jar" files="Extender2.aj" outjar="code2.jar"> + <message kind="weave" text="Extending interface set for type 'test.InterfaceProj1' (InterfaceProj1.java) to include 'java.io.Serializable' (Extender2.aj)"/> + </compile> + </ajc-test> + +<ajc-test dir="bugs189/485583" title="NPE at aspectj"> + <compile files="Foo.aj Bar.aj" options="-1.8"> + <message kind="error" text="The abstract pointcut deprecatedCode can only be defined in an aspect"/> + </compile> +</ajc-test> + +<ajc-test dir="bugs189/486612" title="lost bounds"> + <compile files="Code.java Azpect.java" options="-1.8"/> +</ajc-test> + + +<ajc-test dir="bugs189/486203" title="while npe"> +<compile files="While.java" options="-1.8"/> +</ajc-test> + +<ajc-test dir="bugs189/352389" title="overweaving"> + + <compile files="A.java Code.java" outjar="one.jar" options="-1.8 -showWeaveInfo"> + <message kind="weave" text="Join point 'method-execution(void Code.m())' in Type 'Code' (Code.java:6) advised by before advice from 'A' (A.java:2)"/> + </compile> + <run class="Code" classpath="$sandbox/one.jar"> + <stdout> + <line text="a"/> + </stdout> + </run> + + <!-- The non overweaving case would look like this --> + <compile files="B.java" inpath="one.jar" options="-1.8 -showWeaveInfo" outjar="two.jar"> + <message kind="weave" text="Join point 'method-execution(void Code.m())' in Type 'Code' (Code.java:6) advised by before advice from 'B' (B.java:2)"/> + <message kind="weave" text="Join point 'method-execution(void Code.m())' in Type 'Code' (Code.java:6) advised by before advice from 'A' (one.jar!A.class:2(from A.java))"/> + </compile> + + <!-- With overweaving it looks like the advice from A isn't applying but it just isn't applying during this weave step, it + remains in the bytecode applied from before. --> + <compile files="B.java" inpath="one.jar" options="-1.8 -Xset:pipelineCompilation=false{overWeaving=true -showWeaveInfo" outjar="two.jar"> + <message kind="warning" text="advice defined in A has not been applied [Xlint:adviceDidNotMatch]"/> + <message kind="weave" text="Join point 'method-execution(void Code.m())' in Type 'Code' (Code.java:6) advised by before advice from 'B' (B.java:2)"/> + </compile> + <!-- Note: with overweaving output is b>a without overweaving it is a>b --> + <run class="Code" classpath="$sandbox/two.jar"> + <stdout> + <line text="b"/> + <line text="a"/> + </stdout> + </run> + + <compile files="C.java" inpath="two.jar" options="-1.8 -Xset:overWeaving=true -showWeaveInfo" outjar="three.jar"> + <message kind="warning" text="advice defined in A has not been applied [Xlint:adviceDidNotMatch]"/> + <message kind="warning" text="advice defined in B has not been applied [Xlint:adviceDidNotMatch]"/> + <message kind="weave" text="Join point 'method-execution(void Code.m())' in Type 'Code' (Code.java:6) advised by before advice from 'C' (C.java:2)"/> + </compile> + <!-- + <compile files="C.java" inpath="two.jar" options="-1.8 -showWeaveInfo" outjar="three.jar"> + <message kind="weave" text="Join point 'method-execution(void Code.m())' in Type 'Code' (Code.java:6) advised by before advice from 'C' (C.java:2)"/> + <message kind="weave" text="Join point 'method-execution(void Code.m())' in Type 'Code' (Code.java:6) advised by before advice from 'B' (two.jar!B.class:2(from B.java))"/> + <message kind="weave" text="Join point 'method-execution(void Code.m())' in Type 'Code' (Code.java:6) advised by before advice from 'A' (two.jar!A.class:2(from A.java))"/> + </compile> + --> + <!-- Note: with overweaving c>b>a but without overweaving a>b>c --> + <run class="Code" classpath="$sandbox/three.jar"> + <stdout> + <line text="c"/> + <line text="b"/> + <line text="a"/> + </stdout> + </run> +</ajc-test> + +</suite> |