From ab4df7e110b0a4ddfc9cc1ec1653d3433c9605c4 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Fri, 16 Dec 2016 15:47:37 -0800 Subject: [PATCH] 1.8.11 test setup and wip tests --- tests/bugs1811/509235/Code.java | 17 ++++ tests/bugs1811/509235/Code2.java | 17 ++++ .../bugs1811/parameterizedWithInner/Code.java | 20 +++++ .../org/aspectj/systemtest/AllTests18.java | 2 + .../systemtest/ajc1811/Ajc1811Tests.java | 86 +++++++++++++++++++ .../ajc1811/AllTestsAspectJ1811.java | 25 ++++++ .../aspectj/systemtest/ajc1811/ajc1811.xml | 29 +++++++ 7 files changed, 196 insertions(+) create mode 100644 tests/bugs1811/509235/Code.java create mode 100644 tests/bugs1811/509235/Code2.java create mode 100644 tests/bugs1811/parameterizedWithInner/Code.java create mode 100644 tests/src/org/aspectj/systemtest/ajc1811/Ajc1811Tests.java create mode 100644 tests/src/org/aspectj/systemtest/ajc1811/AllTestsAspectJ1811.java create mode 100644 tests/src/org/aspectj/systemtest/ajc1811/ajc1811.xml diff --git a/tests/bugs1811/509235/Code.java b/tests/bugs1811/509235/Code.java new file mode 100644 index 000000000..be7bb10e0 --- /dev/null +++ b/tests/bugs1811/509235/Code.java @@ -0,0 +1,17 @@ +public class Code { + public static void main(String []argv) { + foo("fooname"); + bar("crap","barname"); + } + + public static void foo(String username) {} + + public static void bar(String a, String username) { } +} + +aspect X { + before(String username): (execution(public static * foo(..)) && args(username,..)) || + (execution(public static * bar(..)) && args(*,username,..)) { + System.out.println("username = "+username); + } +} diff --git a/tests/bugs1811/509235/Code2.java b/tests/bugs1811/509235/Code2.java new file mode 100644 index 000000000..67765c1cb --- /dev/null +++ b/tests/bugs1811/509235/Code2.java @@ -0,0 +1,17 @@ +public class Code2 { + public static void main(String []argv) { + foo("fooname"); + bar("crap","barname"); + } + + public static void foo(String username) {} + + public static void bar(String a, String username) { } +} + +aspect X { + before(String username): (execution(public static * foo(..)) && args(username)) || + (execution(public static * bar(..)) && args(*,username)) { + System.out.println("username = "+username); + } +} diff --git a/tests/bugs1811/parameterizedWithInner/Code.java b/tests/bugs1811/parameterizedWithInner/Code.java new file mode 100644 index 000000000..182a01d88 --- /dev/null +++ b/tests/bugs1811/parameterizedWithInner/Code.java @@ -0,0 +1,20 @@ +public class Code { + public static void main(String []argv) { + } +} + +class Outer { + class Inner { + T t; + Inner(T t) { + this.t =t ; + } + } + + public Inner m() {return null;} + public Outer.Inner m2() { + Outer os = new Outer(); + return os.new Inner("foo"); + } + public Outer.Inner m3() {return null;} +} diff --git a/tests/src/org/aspectj/systemtest/AllTests18.java b/tests/src/org/aspectj/systemtest/AllTests18.java index 2eadcb823..9c2387b0d 100644 --- a/tests/src/org/aspectj/systemtest/AllTests18.java +++ b/tests/src/org/aspectj/systemtest/AllTests18.java @@ -13,6 +13,7 @@ package org.aspectj.systemtest; import org.aspectj.systemtest.ajc180.AllTestsAspectJ180; import org.aspectj.systemtest.ajc181.AllTestsAspectJ181; import org.aspectj.systemtest.ajc1810.AllTestsAspectJ1810; +import org.aspectj.systemtest.ajc1811.AllTestsAspectJ1811; import org.aspectj.systemtest.ajc182.AllTestsAspectJ182; import org.aspectj.systemtest.ajc183.AllTestsAspectJ183; import org.aspectj.systemtest.ajc184.AllTestsAspectJ184; @@ -30,6 +31,7 @@ public class AllTests18 { public static Test suite() { TestSuite suite = new TestSuite("AspectJ System Test Suite - 1.8"); // $JUnit-BEGIN$ + suite.addTest(AllTestsAspectJ1811.suite()); suite.addTest(AllTestsAspectJ1810.suite()); suite.addTest(AllTestsAspectJ189.suite()); suite.addTest(AllTestsAspectJ188.suite()); diff --git a/tests/src/org/aspectj/systemtest/ajc1811/Ajc1811Tests.java b/tests/src/org/aspectj/systemtest/ajc1811/Ajc1811Tests.java new file mode 100644 index 000000000..0c6663692 --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc1811/Ajc1811Tests.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * 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.ajc1811; + +import java.io.File; + +import org.aspectj.apache.bcel.Constants; +import org.aspectj.apache.bcel.classfile.Attribute; +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.Method; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.weaver.ResolvedMember; +import org.aspectj.weaver.ResolvedType; +import org.aspectj.weaver.UnresolvedType; +import org.aspectj.weaver.bcel.BcelWorld; + +import junit.framework.Test; + +/** + * @author Andy Clement + */ +public class Ajc1811Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + +// public void testParameterizedWithInner() throws Exception { +// runTest("parameterized with inner"); +// JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "Outer"); +// assertNotNull(jc); +// BcelWorld world = new BcelWorld(ajc.getSandboxDirectory().toString()); +// +// ResolvedType outerType = world.resolve(UnresolvedType.forName("Outer")); +// ResolvedMember m = findMethod(outerType,"m"); +// +// UnresolvedType type = m.getReturnType(); +// assertEquals("LOuter$Inner;",type.getSignature()); +// +// type = m.getGenericReturnType(); +// assertEquals("LOuter$Inner;",type.getSignature()); +// +// ResolvedType resolvedType = world.resolve(type); +// ResolvedType outerResolvedType = resolvedType.getOuterClass(); +// assertEquals("LOuter;",outerResolvedType.getSignature()); +// +// ResolvedMember m2 = findMethod(outerType,"m2"); +// type = m2.getReturnType(); +// assertEquals("LOuter$Inner;",type.getSignature()); +// +// type = m2.getGenericReturnType(); +// assertEquals("LOuter$Inner;",type.getSignature()); +// +// // public Inner m() { ... } +// Method m = findMethod(jc,"m"); +// System.out.println(m); +// System.out.println(">"+m.getReturnType()); +// assertNotNull(returnType); +// +// // public Outer.Inner m2() { ... } +// } +// +// public void testMultiArgs_509235() { +// runTest("multiargs"); +// } +// +// public void testMultiArgs_509235_2() { +// runTest("multiargs - no ellipsis"); +// } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc1811Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc1811.xml"); + } + +} diff --git a/tests/src/org/aspectj/systemtest/ajc1811/AllTestsAspectJ1811.java b/tests/src/org/aspectj/systemtest/ajc1811/AllTestsAspectJ1811.java new file mode 100644 index 000000000..b8aca6712 --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc1811/AllTestsAspectJ1811.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.ajc1811; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ1811 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.8.11 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc1811Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/org/aspectj/systemtest/ajc1811/ajc1811.xml b/tests/src/org/aspectj/systemtest/ajc1811/ajc1811.xml new file mode 100644 index 000000000..f4e321e5c --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc1811/ajc1811.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.39.5