summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndy Clement <andrew.clement@gmail.com>2013-01-21 17:56:20 -0800
committerAndy Clement <andrew.clement@gmail.com>2013-01-21 17:56:20 -0800
commitf54f44a104806b06ab72b223c55d71476c95415d (patch)
tree990b928064e6cc988086f8402c9da22681c5534c /tests
parent96ebaaed65fe5d507cae3d56126d76f217a9f13a (diff)
downloadaspectj-f54f44a104806b06ab72b223c55d71476c95415d.tar.gz
aspectj-f54f44a104806b06ab72b223c55d71476c95415d.zip
Allow code generation hints for generated compiler names
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs172/pr398246/Code.java19
-rw-r--r--tests/bugs172/pr398246/Code2.java20
-rw-r--r--tests/bugs172/pr398246/Code3.java21
-rw-r--r--tests/bugs172/pr398246/Code4.java21
-rw-r--r--tests/bugs172/pr398246/CodeExtra4.java11
-rw-r--r--tests/src/org/aspectj/systemtest/ajc172/Ajc172Tests.java32
-rw-r--r--tests/src/org/aspectj/systemtest/ajc172/ajc172.xml51
7 files changed, 175 insertions, 0 deletions
diff --git a/tests/bugs172/pr398246/Code.java b/tests/bugs172/pr398246/Code.java
new file mode 100644
index 000000000..beacd74b4
--- /dev/null
+++ b/tests/bugs172/pr398246/Code.java
@@ -0,0 +1,19 @@
+import org.aspectj.lang.annotation.control.*;
+import java.lang.annotation.*;
+
+public class Code {
+ public static boolean isTrue = true;
+
+ public void m() {
+ }
+ public static void main(String []argv) {
+ new Code().m();
+ }
+}
+
+aspect X {
+ @CodeGenerationHint(ifNameSuffix="andy")
+ before(): execution(* Code.*(..)) && if(Code.isTrue) {
+ System.out.println("advice");
+ }
+}
diff --git a/tests/bugs172/pr398246/Code2.java b/tests/bugs172/pr398246/Code2.java
new file mode 100644
index 000000000..c8c0baafb
--- /dev/null
+++ b/tests/bugs172/pr398246/Code2.java
@@ -0,0 +1,20 @@
+import org.aspectj.lang.annotation.control.*;
+import java.lang.annotation.*;
+
+public class Code2 {
+ public static boolean isTrue = true;
+
+ public void m() {
+ }
+ public static void main(String []argv) {
+ new Code2().m();
+ }
+}
+
+aspect X {
+ @CodeGenerationHint(ifNameSuffix="fred")
+ pointcut p(): execution(* Code2.*(..)) && if(Code2.isTrue);
+ before(): p() {
+ System.out.println("advice");
+ }
+}
diff --git a/tests/bugs172/pr398246/Code3.java b/tests/bugs172/pr398246/Code3.java
new file mode 100644
index 000000000..5588905f1
--- /dev/null
+++ b/tests/bugs172/pr398246/Code3.java
@@ -0,0 +1,21 @@
+import java.lang.annotation.*;
+
+public class Code3 {
+ public static boolean isTrue = true;
+
+ public void m() {
+ }
+ public static void main(String []argv) {
+ new Code3().m();
+ }
+}
+
+aspect X {
+
+ @org.aspectj.lang.annotation.control.CodeGenerationHint(ifNameSuffix="barney")
+ pointcut p(): execution(* Code3.*(..)) && if(Code3.isTrue);
+
+ before(): p() {
+ System.out.println("advice");
+ }
+}
diff --git a/tests/bugs172/pr398246/Code4.java b/tests/bugs172/pr398246/Code4.java
new file mode 100644
index 000000000..488092d93
--- /dev/null
+++ b/tests/bugs172/pr398246/Code4.java
@@ -0,0 +1,21 @@
+import java.lang.annotation.*;
+
+public class Code4 {
+ public static boolean isTrue = true;
+
+ public void m() {
+ }
+ public static void main(String []argv) {
+ new Code4().m();
+ }
+}
+
+aspect X {
+
+ @org.aspectj.lang.annotation.control.CodeGenerationHint(ifNameSuffix="sid")
+ pointcut p(): execution(* Code*.*(..)) && if(Code4.isTrue);
+
+ before(): p() {
+ System.out.println("advice");
+ }
+}
diff --git a/tests/bugs172/pr398246/CodeExtra4.java b/tests/bugs172/pr398246/CodeExtra4.java
new file mode 100644
index 000000000..e192328d6
--- /dev/null
+++ b/tests/bugs172/pr398246/CodeExtra4.java
@@ -0,0 +1,11 @@
+import java.lang.annotation.*;
+
+public class CodeExtra4 {
+ public static boolean isTrue = true;
+
+ public void m() { }
+
+ public static void main(String []argv) {
+ new CodeExtra4().m();
+ }
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc172/Ajc172Tests.java b/tests/src/org/aspectj/systemtest/ajc172/Ajc172Tests.java
index 292efcbee..eea4030d0 100644
--- a/tests/src/org/aspectj/systemtest/ajc172/Ajc172Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc172/Ajc172Tests.java
@@ -14,6 +14,8 @@ import java.io.File;
import junit.framework.Test;
+import org.aspectj.apache.bcel.classfile.JavaClass;
+import org.aspectj.apache.bcel.classfile.Method;
import org.aspectj.testing.XMLBasedAjcTestCase;
/**
@@ -21,6 +23,36 @@ import org.aspectj.testing.XMLBasedAjcTestCase;
*/
public class Ajc172Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
+ public void testIfPointcutNames_pr398246() throws Exception{
+ runTest("if pointcut names");
+ JavaClass jc = getClassFrom(ajc.getSandboxDirectory(),"X");
+ Method m = getMethodStartsWith(jc,"ajc$if");
+ assertEquals("ajc$if$andy",m.getName());
+ }
+
+ public void testIfPointcutNames_pr398246_2() throws Exception {
+ runTest("if pointcut names 2");
+ JavaClass jc = getClassFrom(ajc.getSandboxDirectory(),"X");
+ Method m = getMethodStartsWith(jc,"ajc$if");
+ assertEquals("ajc$if$fred",m.getName());
+ }
+
+ // fully qualified annotation name is used
+ public void testIfPointcutNames_pr398246_3() throws Exception {
+ runTest("if pointcut names 3");
+ JavaClass jc = getClassFrom(ajc.getSandboxDirectory(),"X");
+ Method m = getMethodStartsWith(jc,"ajc$if");
+ assertEquals("ajc$if$barney",m.getName());
+ }
+
+ // compiling a class later than the initial build - does it pick up the right if clause name?
+ public void testIfPointcutNames_pr398246_4() throws Exception{
+ runTest("if pointcut names 4");
+ JavaClass jc = getClassFrom(ajc.getSandboxDirectory(),"X");
+ Method m = getMethodStartsWith(jc,"ajc$if");
+ assertEquals("ajc$if$sid",m.getName());
+ }
+
public void testOptionalAspects_pr398588() {
runTest("optional aspects");
}
diff --git a/tests/src/org/aspectj/systemtest/ajc172/ajc172.xml b/tests/src/org/aspectj/systemtest/ajc172/ajc172.xml
index 81217b60f..7dc6ce11b 100644
--- a/tests/src/org/aspectj/systemtest/ajc172/ajc172.xml
+++ b/tests/src/org/aspectj/systemtest/ajc172/ajc172.xml
@@ -33,6 +33,57 @@
</stdout>
</run>
</ajc-test>
+
+ <ajc-test dir="bugs172/pr398246" title="if pointcut names">
+ <compile files="Code.java" options="-1.5">
+ </compile>
+ <run class="Code" options="-1.5">
+ <stdout>
+ <line text="advice"/>
+ <line text="advice"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="bugs172/pr398246" title="if pointcut names 2">
+ <compile files="Code2.java" options="-1.5">
+ </compile>
+ <run class="Code2" options="-1.5">
+ <stdout>
+ <line text="advice"/>
+ <line text="advice"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="bugs172/pr398246" title="if pointcut names 3">
+ <compile files="Code3.java" options="-1.5">
+ </compile>
+ <run class="Code3" options="-1.5">
+ <stdout>
+ <line text="advice"/>
+ <line text="advice"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="bugs172/pr398246" title="if pointcut names 4">
+ <compile files="Code4.java" options="-1.5"></compile>
+ <compile files="Code4.java" options="-1.5" outjar="aspects.jar"/>
+ <run class="Code4" options="-1.5">
+ <stdout>
+ <line text="advice"/>
+ <line text="advice"/>
+ </stdout>
+ </run>
+ <compile files="CodeExtra4.java" aspectpath="aspects.jar" options="-1.5"></compile>
+ <run class="CodeExtra4" options="-1.5">
+ <stdout>
+ <line text="advice"/>
+ <line text="advice"/>
+ </stdout>
+ </run>
+ </ajc-test>
<ajc-test dir="bugs172/pr389750" title="inconsistent class file">
<compile files="Code.aj" options="-1.5">