aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/test/java/org/aspectj/systemtest/ajc186
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2019-01-30 16:55:38 -0800
committerAndy Clement <aclement@pivotal.io>2019-01-30 16:55:38 -0800
commit2b24e7377da7c849fe7f9f4fa06a701664f9d27d (patch)
tree64c36c8fcf29633af7a5e2f7405b94cbec629ca8 /tests/src/test/java/org/aspectj/systemtest/ajc186
parentd60de8d0b3e62eb36b612a824bb9345d865c0155 (diff)
downloadaspectj-2b24e7377da7c849fe7f9f4fa06a701664f9d27d.tar.gz
aspectj-2b24e7377da7c849fe7f9f4fa06a701664f9d27d.zip
mavenizing tests - wip
Diffstat (limited to 'tests/src/test/java/org/aspectj/systemtest/ajc186')
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc186/Ajc186Tests.java162
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc186/AllTestsAspectJ186.java25
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc186/ajc186.xml25
3 files changed, 212 insertions, 0 deletions
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc186/Ajc186Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc186/Ajc186Tests.java
new file mode 100644
index 000000000..1625f96d1
--- /dev/null
+++ b/tests/src/test/java/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/test/java/org/aspectj/systemtest/ajc186/AllTestsAspectJ186.java b/tests/src/test/java/org/aspectj/systemtest/ajc186/AllTestsAspectJ186.java
new file mode 100644
index 000000000..ff67705de
--- /dev/null
+++ b/tests/src/test/java/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/test/java/org/aspectj/systemtest/ajc186/ajc186.xml b/tests/src/test/java/org/aspectj/systemtest/ajc186/ajc186.xml
new file mode 100644
index 000000000..4f1394a95
--- /dev/null
+++ b/tests/src/test/java/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>