@@ -0,0 +1,29 @@ | |||
public class Basic { | |||
public static void main(String []argv) { | |||
Basic b = new Basic(); | |||
b.tm(); | |||
b.ntm(); | |||
b.tm(); | |||
} | |||
public void tm() { | |||
// trivial : <10 instructions | |||
} | |||
public void ntm() { | |||
// nontrivial | |||
StringBuffer sb = new StringBuffer(); | |||
for (int j=0;j<100;j++) { | |||
sb.append("a").append("b").append("c"); | |||
} | |||
} | |||
} | |||
aspect X { | |||
before(): execution(trivial * *m(..)) { | |||
System.err.println("Trivial method executing:"+thisJoinPoint.getSignature()); | |||
} | |||
} | |||
@@ -0,0 +1,29 @@ | |||
public class Basic2 { | |||
public static void main(String []argv) { | |||
Basic2 b = new Basic2(); | |||
b.tm(); | |||
b.ntm(); | |||
b.tm(); | |||
} | |||
public void tm() { | |||
// trivial : <10 instructions | |||
} | |||
public void ntm() { | |||
// nontrivial | |||
StringBuffer sb = new StringBuffer(); | |||
for (int j=0;j<100;j++) { | |||
sb.append("a").append("b").append("c"); | |||
} | |||
} | |||
} | |||
aspect X { | |||
before(): execution(!trivial * *m(..)) { | |||
System.err.println("Non trivial method executing:"+thisJoinPoint.getSignature()); | |||
} | |||
} | |||
@@ -0,0 +1,14 @@ | |||
public class Errors3 { | |||
} | |||
aspect X { | |||
pointcut p1(): execution(trivial * *(..)); | |||
pointcut p2_error(): call(trivial * *(..)); | |||
pointcut p3_error(): get(trivial * *(..)); | |||
pointcut p4(): execution(private !trivial * *(..)); | |||
pointcut p5_error(): call(public trivial * *(..)); | |||
pointcut p6_error(): get(protected !trivial * *(..)); | |||
} | |||
@@ -0,0 +1,9 @@ | |||
abstract aspect LTWAbstractAspect { | |||
abstract pointcut p(); | |||
before(): p() { | |||
System.err.println("Non trivial method executing:"+thisJoinPoint.getSignature()); | |||
} | |||
} | |||
@@ -0,0 +1,23 @@ | |||
public class LTWProgram { | |||
public static void main(String []argv) { | |||
LTWProgram b = new LTWProgram(); | |||
b.tm(); | |||
b.ntm(); | |||
b.tm(); | |||
} | |||
public void tm() { | |||
// trivial : <10 instructions | |||
} | |||
public void ntm() { | |||
// nontrivial | |||
StringBuffer sb = new StringBuffer(); | |||
for (int j=0;j<100;j++) { | |||
sb.append("a").append("b").append("c"); | |||
} | |||
} | |||
} | |||
@@ -0,0 +1,29 @@ | |||
public class ProgramOne { | |||
public static void main(String []argv) { | |||
ProgramOne b = new ProgramOne(); | |||
b.tm(); | |||
b.ntm(); | |||
b.tm(); | |||
} | |||
public void tm() { | |||
// trivial : <10 instructions | |||
} | |||
public void ntm() { | |||
// nontrivial | |||
StringBuffer sb = new StringBuffer(); | |||
for (int j=0;j<100;j++) { | |||
sb.append("a").append("b").append("c"); | |||
} | |||
} | |||
} | |||
aspect X { | |||
before(): ((execution(* *.*(..)) && !execution(trivial * *(..)))) { | |||
System.err.println("Non trivial method executing:"+thisJoinPoint.getSignature()); | |||
} | |||
} | |||
@@ -0,0 +1,9 @@ | |||
<aspectj> | |||
<aspects> | |||
<concrete-aspect name="Blah" extends="LTWAbstractAspect"> | |||
<pointcut name="p" expression="((execution(* *.*(..)) AND !execution(trivial * *(..))))"/> | |||
</concrete-aspect> | |||
</aspects> | |||
<weaver options="-Xjoinpoints:trivial"/> | |||
</aspectj> |
@@ -0,0 +1,9 @@ | |||
<aspectj> | |||
<aspects> | |||
<concrete-aspect name="Blah" extends="LTWAbstractAspect"> | |||
<pointcut name="p" expression="execution(!trivial * *.*(..))"/> | |||
</concrete-aspect> | |||
</aspects> | |||
<weaver options="-Xjoinpoints:trivial"/> | |||
</aspectj> |
@@ -21,7 +21,8 @@ public class AllTestsAspectJ152 { | |||
suite.addTest(Ajc152Tests.suite()); | |||
suite.addTest(SynchronizationTests.suite()); | |||
suite.addTest(SynchronizationTransformTests.suite()); | |||
suite.addTest(TrivialTests.suite()); | |||
//$JUnit-END$ | |||
return suite; | |||
} | |||
} | |||
} |
@@ -0,0 +1,40 @@ | |||
/******************************************************************************* | |||
* Copyright (c) 2006 IBM Corporation and others. | |||
* All rights reserved. This program and the accompanying materials | |||
* are made available under the terms of the Common Public License v1.0 | |||
* which accompanies this distribution, and is available at | |||
* http://www.eclipse.org/legal/epl-v10.html | |||
* | |||
* Contributors: | |||
* Andy Clement - initial implementation | |||
*******************************************************************************/ | |||
package org.aspectj.systemtest.ajc152; | |||
import java.io.File; | |||
import junit.framework.Test; | |||
import org.aspectj.testing.XMLBasedAjcTestCase; | |||
/** | |||
* | |||
*/ | |||
public class TrivialTests extends XMLBasedAjcTestCase { | |||
public void testBasic() { runTest("basic"); } | |||
public void testBasic2() { runTest("basic2"); } | |||
public void testErrorCases() { runTest("errors"); } | |||
public void testMorePointcuts_1() { runTest("pointcuts - 1");} | |||
public void testLTW() { runTest("trivial and ltw");} | |||
public void testLTW_2() { runTest("trivial and ltw - 2");} | |||
// --- | |||
public static Test suite() { | |||
return XMLBasedAjcTestCase.loadSuite(TrivialTests.class); | |||
} | |||
protected File getSpecFile() { | |||
return new File("../tests/src/org/aspectj/systemtest/ajc152/trivial.xml"); | |||
} | |||
} |
@@ -0,0 +1,70 @@ | |||
<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]> | |||
<!-- AspectJ v1.5.2 trivial modifier tests --> | |||
<suite> | |||
<ajc-test dir="features152/trivial" title="basic"> | |||
<compile files="Basic.aj" options="-showWeaveInfo -Xjoinpoints:trivial"> | |||
<message kind="weave" text="Join point 'method-execution(void Basic.tm())' in Type 'Basic' (Basic.aj:10) advised by before advice from 'X' (Basic.aj:25)"/> | |||
</compile> | |||
<run class="Basic"> | |||
<stderr> | |||
<line text="Trivial method executing:void Basic.tm()"/> | |||
<line text="Trivial method executing:void Basic.tm()"/> | |||
</stderr> | |||
</run> | |||
</ajc-test> | |||
<ajc-test dir="features152/trivial" title="basic2"> | |||
<compile files="Basic2.aj" options="-showWeaveInfo -Xjoinpoints:trivial"> | |||
<message kind="weave" text="Join point 'method-execution(void Basic2.ntm())' in Type 'Basic2' (Basic2.aj:14) advised by before advice from 'X' (Basic2.aj:25)"/> | |||
</compile> | |||
<run class="Basic2"> | |||
<stderr> | |||
<line text="Non trivial method executing:void Basic2.ntm()"/> | |||
</stderr> | |||
</run> | |||
</ajc-test> | |||
<ajc-test dir="features152/trivial" title="errors"> | |||
<compile files="Errors3.aj"> | |||
<message kind="error" line="8" text="Syntax error on token "trivial", "any modifier except 'trivial'" expected"/> | |||
<message kind="error" line="9" text="Syntax error on token "trivial", "any modifier except 'trivial'" expected"/> | |||
<message kind="error" line="11" text="Syntax error on token "trivial", "any modifier except 'trivial'" expected"/> | |||
<message kind="error" line="12" text="Syntax error on token "trivial", "any modifier except 'trivial'" expected"/> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="features152/trivial" title="pointcuts - 1"> | |||
<compile files="ProgramOne.java" options="-Xjoinpoints:trivial"/> | |||
<run class="ProgramOne"> | |||
<stderr> | |||
<line text="Non trivial method executing:void ProgramOne.main(String[])"/> | |||
<line text="Non trivial method executing:void ProgramOne.ntm()"/> | |||
</stderr> | |||
</run> | |||
</ajc-test> | |||
<ajc-test dir="features152/trivial" title="trivial and ltw"> | |||
<compile files="LTWAbstractAspect.java" options="-1.5"/> | |||
<compile files="LTWProgram.java" options="-1.5"/> | |||
<run class="LTWProgram" ltw="aop1.xml"> | |||
<stderr> | |||
<line text="Non trivial method executing:void LTWProgram.main(String[])"/> | |||
<line text="Non trivial method executing:void LTWProgram.ntm()"/> | |||
</stderr> | |||
</run> | |||
</ajc-test> | |||
<ajc-test dir="features152/trivial" title="trivial and ltw - 2"> | |||
<compile files="LTWAbstractAspect.java" options="-1.5"/> | |||
<compile files="LTWProgram.java" options="-1.5"/> | |||
<run class="LTWProgram" ltw="aop2.xml"> | |||
<stderr> | |||
<line text="Non trivial method executing:void LTWProgram.main(String[])"/> | |||
<line text="Non trivial method executing:void LTWProgram.ntm()"/> | |||
</stderr> | |||
</run> | |||
</ajc-test> | |||
</suite> |