@@ -1,6 +1,6 @@ | |||
import java.lang.reflect.*; | |||
class C { | |||
public class C { | |||
public static B.D[] arr = new B.D[5]; | |||
@@ -1,7 +1,18 @@ | |||
import java.util.List; | |||
import java.util.ArrayList; | |||
import java.util.Iterator; | |||
import org.aspectj.lang.JoinPoint.StaticPart; | |||
import org.aspectj.lang.JoinPoint; | |||
import org.aspectj.lang.Signature; | |||
public aspect ThisOrTargetTests { | |||
List<String> before1Matches = new ArrayList<String>(); | |||
List<String> before2Matches = new ArrayList<String>(); | |||
List<String> after1Matches = new ArrayList<String>(); | |||
List<String> after2Matches = new ArrayList<String>(); | |||
pointcut doSomethingExecution() : execution(* doSomething()); | |||
pointcut doSomethingCall() : call(* doSomething()); | |||
@@ -9,7 +20,7 @@ public aspect ThisOrTargetTests { | |||
// should match: | |||
// b.doSomething(), reallyB.doSomething() [with test], | |||
// c.doSomething() | |||
System.out.println("@this(@MyAnnotation): " + thisJoinPointStaticPart); | |||
add(before1Matches,thisJoinPointStaticPart); | |||
} | |||
before() : doSomethingExecution() && @this(@MyInheritableAnnotation) { | |||
@@ -17,14 +28,14 @@ public aspect ThisOrTargetTests { | |||
// c.doSomething() | |||
// d.doSomething() | |||
// reallyD.doSomething() | |||
System.out.println("@this(@MyInheritableAnnotation): " + thisJoinPointStaticPart); | |||
add(before2Matches,thisJoinPointStaticPart); | |||
} | |||
after() returning : doSomethingCall() && @target(@MyAnnotation) { | |||
// should match: | |||
// b.doSomething(), reallyB.doSomething() [with test], | |||
// c.doSomething() | |||
System.out.println("@target(@MyAnnotation): " + thisJoinPointStaticPart); | |||
add(after1Matches,thisJoinPointStaticPart); | |||
} | |||
after() returning : doSomethingCall() && @target(@MyInheritableAnnotation) { | |||
@@ -32,7 +43,37 @@ public aspect ThisOrTargetTests { | |||
// c.doSomething() | |||
// d.doSomething() | |||
// reallyD.doSomething() | |||
System.out.println("@target(@MyInheritableAnnotation): " + thisJoinPointStaticPart); | |||
add(after2Matches,thisJoinPointStaticPart); | |||
} | |||
private void add(List<String> toList, JoinPoint.StaticPart jpsp) { | |||
Signature sig = jpsp.getSignature(); | |||
String toAdd = sig.getDeclaringTypeName() + "." + sig.getName(); | |||
toList.add(toAdd); | |||
} | |||
after() returning : execution(* main(String[])) { | |||
assertMatches("before1",before1Matches, | |||
new String[] {"B.doSomething","C.doSomething","B.doSomething"} ); | |||
assertMatches("before2",before2Matches, | |||
new String[] {"C.doSomething","D.doSomething","D.doSomething"} ); | |||
assertMatches("after1",after1Matches, | |||
new String[] {"B.doSomething","C.doSomething","A.doSomething"} ); | |||
assertMatches("after2",after2Matches, | |||
new String[] {"C.doSomething","D.doSomething","C.doSomething"} ); | |||
} | |||
private void assertMatches(String name, List<String> matches,String[] spec) { | |||
if (matches.size() != spec.length) { | |||
for (Iterator<String> iter = matches.iterator(); iter.hasNext();) { | |||
String match = iter.next(); | |||
System.out.println(match); | |||
} | |||
throw new RuntimeException(name + ": Expected " + spec.length + " matches, got " + matches.size()); | |||
} | |||
for (int i = 0; i < spec.length; i++) { | |||
if (!matches.get(i).equals(spec[i])) throw new RuntimeException(name + ":Excepted " + spec[i] + " got " + matches.get(i)); | |||
} | |||
} | |||
} |
@@ -1,3 +0,0 @@ | |||
package java.lang; // Fake class to keep 1.4 JVM (that will be running the tests) happy | |||
public class Enum { | |||
} |
@@ -1,9 +1,10 @@ | |||
import java.lang.Enum; | |||
public aspect EnumAspect03 { | |||
declare parents: SimpleEnum implements java.io.Serializable; | |||
interface I {} | |||
declare parents: SimpleEnum implements I; | |||
class C extends Enum { } | |||
enum C {A,B,C}; | |||
declare parents: SimpleEnum extends C; | |||
class D {} |
@@ -1,6 +1,7 @@ | |||
import java.lang.Enum; | |||
public aspect EnumAspect04 { | |||
declare parents: SimpleE* implements java.io.Serializable; | |||
interface I {}; | |||
declare parents: SimpleE* implements I; | |||
} |
@@ -0,0 +1,51 @@ | |||
import java.util.*; | |||
/* | |||
* test case fodder for basic generic signature matching | |||
*/ | |||
public class GenericMethods { | |||
public List<Integer> returningListOfInteger() { | |||
return new LinkedList<Integer>(); | |||
} | |||
public List<Object> returningListOfObject() { | |||
return new LinkedList<Object>(); | |||
} | |||
public List returningRawList() { return new ArrayList(); } | |||
public LinkedList<Integer> returningSubtypeOfListOfInteger() { | |||
return new LinkedList<Integer>(); | |||
} | |||
public void takesAMap(Map<Double,Short> aMap) {} | |||
public void takesAHashmap(HashMap<Double,Short> aMap) {} | |||
public static void staticTakesAMap(Map<Double,Short> aMap) {} | |||
public void collectionOfAnything(Collection<?> aCollection) {} | |||
public void collectionOfAnyNumber(Collection<? extends Number> aNumberCollection) {} | |||
public void collectionOfAnythingTakingADouble(Collection<? super Double> aDoubleHandlingCollection) {} | |||
// now some fun with statics | |||
static <T> T findMax(List<T> ts) { return ts.get(0); } | |||
static <T extends Comparable<T>> T betterMax(Collection<T> collection) { | |||
return null; | |||
} | |||
static <T extends Comparable<? super T>> T evenBetterMax(Collection<T> coll) { | |||
return null; | |||
} | |||
static <T extends Object & Comparable<? super T>> T jdkMax(Collection<? extends T> coll) { | |||
return null; | |||
} | |||
static <T> void copy(List<T> dest, List<? extends T> src) {} | |||
static <T,S extends T> copyv2(List<T> dest, List<S> src) {} | |||
} |
@@ -0,0 +1,65 @@ | |||
import java.util.*; | |||
public aspect GenericParameterMatching { | |||
pointcut takesAMap() : execution(* *(Map<Double,Short>)); | |||
// matches takesAMap, staticTakesAMap | |||
pointcut takesAnyMapType() : execution(* *(Map+<Double,Short)); | |||
// matches takesAMap, staticTakesAMap, takesAHashmap | |||
pointcut collectionOfAnything() : execution(* *(Collection<?>)); | |||
// matches collectionOfAnything | |||
pointcut collectionOfAnyNumber() : execution(* *(Collection<? extends Number)); | |||
// matches collectionOfAnyNumber | |||
pointcut collectionOfTakingDouble() : execution(* *(Collection<? super Double>)); | |||
// matches collectionOfAnythingTakingADouble | |||
pointcut anyCollection() : execution(* *(Collection<*>)); | |||
// matches all 3 collection methods | |||
pointcut anyObjectOrSubtypeCollection() : execution(* *(Collection<? extends Object+>)); | |||
// matches collection of any number | |||
pointcut superTypePattern(): execution(* *(Collection<? super Number+>)); | |||
// matches collection of anything taking a double | |||
// RTT matching... | |||
pointcut mapargs() : args(Map<Double,Short>); | |||
// matches takesAMap, staticTakesAMap, takesAHashmap | |||
pointcut hashmapargs() : args(HashMap<Double,Short>); | |||
// matches takesAHashmap, RT test for takesAMap, staticTakesAmap | |||
pointcut nomapargs(): args(Map<Object,Object>); | |||
// no matches | |||
pointcut wildargs() : args(Map<? extends Number, Short>); | |||
// matches takesAMap, staticTakesAMap, takesAHashmap | |||
pointcut nowildargs() : args(Map<? extends String, Short>); | |||
// no matches | |||
pointcut wildsuperargs() : args(Map<Double, ? super Short>); | |||
// matches takesAmap, staticTakesAmap, takesAHashmap | |||
// RTT matching with signature wildcards | |||
pointcut collAnythingArgs() : args(Collection<?>); | |||
// matches all collection methods | |||
pointcut collNumberArgs() : args(Collection<Number>); | |||
// does NOT match collectionOfAnyNumber (can't insert safely) | |||
// does NOT match collectionOfAnythingTakingADouble (can't remove safely) | |||
pointcut collNumberArgsWild() : args(Collection<? extends Number>); | |||
// matches collection of any number | |||
pointcut superDoubleArgs(): args(Collection<? super Number+>); | |||
// matches coll taking a double | |||
// add max and copy tests here... | |||
} |
@@ -0,0 +1,21 @@ | |||
import java.util.*; | |||
public aspect ParameterizedMethodMatching { | |||
pointcut findMax() : execution(static<T> T *(List<T>)); | |||
// matches findMax | |||
// does not match e.g. Object foo(List<Object> foos) {...} | |||
pointcut findMax2() : execution(static<X> X * List<X>)); | |||
// matches findMax | |||
pointcut findMax3() : execution(static<T> T+ *(List<T>)); | |||
// CE | |||
pointcut listargs(): args(List<?>); | |||
// always matches findMax | |||
pointcut listNumberargs() : args(List<Number>); | |||
// may match findMax (RTT) | |||
} |
@@ -0,0 +1,19 @@ | |||
import java.util.*; | |||
/* | |||
* test case fodder for basic member matching with parameterized types | |||
*/ | |||
public class ParameterizedType<T,S> { | |||
T aTField; | |||
S anSField; | |||
T giveMeAT() { return null; } | |||
S giveMeAnS() { return null; } | |||
S sComesBeforeT(T t) { return null; } | |||
void theMadMapper(Map<T,S> aMap) {} | |||
static T convert(S s) { return null; } | |||
} |
@@ -0,0 +1,27 @@ | |||
import java.util.*; | |||
public aspect ReturningLists { | |||
pointcut listOfInteger() : execution(List<Integer> *(..)); | |||
// matches returningListOfInteger | |||
pointcut listOfObject() : execution(List<Object> *(..)); | |||
// matches returningListOfObject | |||
pointcut listOfObjects() : execution(List<Object+> *(..)); | |||
// matches returningListOfInteger and returningListofObject | |||
pointcut listOfAnything() : execution(List<*> *(..)); | |||
// matches returningListOfInteger and returningListofObject | |||
pointcut rawList() : execution(List *(..)); | |||
// matches returningRawList | |||
pointcut wildcardList() : execution(List<?> *(..)); | |||
// matches nothing | |||
pointcut anyListType() : execution(List+<*> *(..)); | |||
// matches returning list of integer, returning list of object, | |||
// returning subtype of list of integer | |||
} |
@@ -0,0 +1,21 @@ | |||
pointcut matching for constructor calls: | |||
call(List<Integer>.new()) ? | |||
call(List<Integer>.new(Integer i)) ?? | |||
call(<T> List<T>.new()) | |||
call(<T> List<T>.new(T)) | |||
execution likewise ? | |||
for methods and fields in parameterized types: | |||
call(<T> foo(T)) etc. ? | |||
There is only ONE class remember. | |||
get(<T> T foo*) | |||
does get(Object obj) match new Foo<Object>() with Foo<T> { T obj } ??? |
@@ -6,7 +6,7 @@ package org.aspectj.systemtest; | |||
import junit.framework.Test; | |||
import junit.framework.TestSuite; | |||
import org.aspectj.systemtest.ajc150.AllTestsAspectJ150_NeedJava15; | |||
import org.aspectj.systemtest.ajc150.AllTestsAspectJ150; | |||
public class AllTests15 { | |||
@@ -14,7 +14,7 @@ public class AllTests15 { | |||
TestSuite suite = new TestSuite("AspectJ System Test Suite - JDK 1.5"); | |||
//$JUnit-BEGIN$ | |||
suite.addTest(AllTests14.suite()); | |||
suite.addTestSuite(AllTestsAspectJ150_NeedJava15.class); | |||
suite.addTest(AllTestsAspectJ150.suite()); | |||
//$JUnit-END$ | |||
return suite; | |||
} |
@@ -10,12 +10,9 @@ | |||
package org.aspectj.systemtest.ajc121; | |||
import java.io.File; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import junit.framework.Test; | |||
import org.aspectj.bridge.WeaveMessage; | |||
import org.aspectj.testing.XMLBasedAjcTestCase; | |||
public class Ajc121Tests extends org.aspectj.testing.XMLBasedAjcTestCase { | |||
@@ -273,21 +270,6 @@ public class Ajc121Tests extends org.aspectj.testing.XMLBasedAjcTestCase { | |||
public void test050_typePatternMatchingWithArrays() { | |||
runTest("declare warning warns at wrong points"); | |||
} | |||
public void test051_arrayCloningInJava5() { | |||
runTest("AJC possible bug with static nested classes"); | |||
List l = ajc.getLastCompilationResult().getInfoMessages(); | |||
assertTrue("Should at least have had one weaving message",l!=null && l.size()>0); | |||
boolean gotWeaveMessage = false; | |||
for (Iterator msg = l.iterator(); msg.hasNext();) { | |||
Object element = (Object) msg.next(); | |||
if (element instanceof WeaveMessage) { | |||
WeaveMessage wm = (WeaveMessage)element; | |||
if (wm.getMessage().indexOf("advised by around advice from")!=-1) gotWeaveMessage = true; | |||
} | |||
} | |||
assertTrue("Expected a weaving message but only found "+l,gotWeaveMessage); | |||
} | |||
public void test052_bogusMessage1() { | |||
runTest("Bogus error message: The abstract method ajc$pointcut$$tracingScope$a2 in type Tracing can only be defined by an abstract class (1)"); |
@@ -406,12 +406,6 @@ | |||
<message kind="warning" line="22" text="*[] returning method called"/> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="bugs/java5/arrayCloning" pr="72150" | |||
title="AJC possible bug with static nested classes"> | |||
<compile files="A.java,OneFiveCode.jar" options="-showWeaveInfo"/> | |||
<!-- ARGH - Cant run it because run class is of type '49' run class="C"/--> | |||
</ajc-test> | |||
<ajc-test dir="bugs" pr="72699" | |||
title="Bogus error message: The abstract method ajc$pointcut$$tracingScope$a2 in type Tracing can only be defined by an abstract class (1)"> |
@@ -66,21 +66,7 @@ public class AccBridgeMethods extends org.aspectj.testing.XMLBasedAjcTestCase { | |||
*/ | |||
public void test001_bridgeMethodIgnored() { | |||
runTest("Ignore bridge methods"); | |||
List weaveMessages = getWeaveMessages(ajc.getLastCompilationResult(),false); | |||
assertTrue("Should only be two weave messages",weaveMessages.size()==2); | |||
} | |||
private List getWeaveMessages(CompilationResult cr,boolean printThem) { | |||
List weaveMessages = new ArrayList(); | |||
List infoMessages = cr.getInfoMessages(); | |||
for (Iterator iter = infoMessages.iterator(); iter.hasNext();) { | |||
IMessage element = (IMessage) iter.next(); | |||
if (element.getKind()==IMessage.WEAVEINFO) { | |||
weaveMessages.add(element); | |||
if (printThem) System.err.println(element); | |||
} | |||
} | |||
return weaveMessages; | |||
} | |||
} |
@@ -10,10 +10,18 @@ | |||
*******************************************************************************/ | |||
package org.aspectj.systemtest.ajc150; | |||
import java.io.ByteArrayOutputStream; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.io.PrintWriter; | |||
import junit.framework.Test; | |||
import org.aspectj.apache.bcel.classfile.JavaClass; | |||
import org.aspectj.apache.bcel.classfile.Method; | |||
import org.aspectj.apache.bcel.util.ClassPath; | |||
import org.aspectj.apache.bcel.util.SyntheticRepository; | |||
import org.aspectj.asm.AsmManager; | |||
import org.aspectj.testing.XMLBasedAjcTestCase; | |||
/** | |||
@@ -44,4 +52,85 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { | |||
public void test_ambiguousArgsDetection() { | |||
runTest("ambiguous args"); | |||
} | |||
public void testIncorrectExceptionTableWhenBreakInMethod_pr78021() { | |||
runTest("Injecting exception into while loop with break statement causes catch block to be ignored"); | |||
} | |||
public void testIncorrectExceptionTableWhenReturnInMethod_pr79554() { | |||
runTest("Return in try-block disables catch-block if final-block is present"); | |||
} | |||
public void testMissingDebugInfoForGeneratedMethods_pr82570() throws ClassNotFoundException { | |||
runTest("Weaved code does not include debug lines"); | |||
boolean f = false; | |||
JavaClass jc = getClassFrom(ajc.getSandboxDirectory(),"PR82570_1"); | |||
Method[] meths = jc.getMethods(); | |||
for (int i = 0; i < meths.length; i++) { | |||
Method method = meths[i]; | |||
if (f) System.err.println("Line number table for "+method.getName()+method.getSignature()+" = "+method.getLineNumberTable()); | |||
assertTrue("Didn't find a line number table for method "+method.getName()+method.getSignature(), | |||
method.getLineNumberTable()!=null); | |||
} | |||
// This test would determine the info isn't there if you pass -g:none ... | |||
// cR = ajc(baseDir,new String[]{"PR82570_1.java","-g:none"}); | |||
// assertTrue("Expected no compile problem:"+cR,!cR.hasErrorMessages()); | |||
// System.err.println(cR.getStandardError()); | |||
// jc = getClassFrom(ajc.getSandboxDirectory(),"PR82570_1"); | |||
// meths = jc.getMethods(); | |||
// for (int i = 0; i < meths.length; i++) { | |||
// Method method = meths[i]; | |||
// assertTrue("Found a line number table for method "+method.getName(), | |||
// method.getLineNumberTable()==null); | |||
// } | |||
} | |||
public void testCanOverrideProtectedMethodsViaITDandDecp_pr83303() { | |||
runTest("compiler error when mixing inheritance, overriding and polymorphism"); | |||
} | |||
public void testPerTypeWithinMissesNamedInnerTypes() { | |||
runTest("pertypewithin() handing of inner classes (1)"); | |||
} | |||
public void testPerTypeWithinMissesAnonymousInnerTypes() { | |||
runTest("pertypewithin() handing of inner classes (2)"); | |||
} | |||
public void testPerTypeWithinIncorrectlyMatchingInterfaces() { | |||
runTest("pertypewithin({interface}) illegal field modifier"); | |||
} | |||
public void test051_arrayCloningInJava5() { | |||
runTest("AJC possible bug with static nested classes"); | |||
} | |||
public void testBadASMforEnums() throws IOException { | |||
runTest("bad asm for enums"); | |||
if (System.getProperty("java.vm.version").startsWith("1.5")) { | |||
ByteArrayOutputStream baos = new ByteArrayOutputStream(); | |||
PrintWriter pw = new PrintWriter(baos); | |||
AsmManager.dumptree(pw,AsmManager.getDefault().getHierarchy().getRoot(),0); | |||
pw.flush(); | |||
String tree = baos.toString(); | |||
assertTrue("Expected 'Red [enumvalue]' somewhere in here:"+tree,tree.indexOf("Red [enumvalue]")!=-1); | |||
} | |||
} | |||
// helper methods..... | |||
public SyntheticRepository createRepos(File cpentry) { | |||
ClassPath cp = new ClassPath(cpentry+File.pathSeparator+System.getProperty("java.class.path")); | |||
return SyntheticRepository.getInstance(cp); | |||
} | |||
protected JavaClass getClassFrom(File where,String clazzname) throws ClassNotFoundException { | |||
SyntheticRepository repos = createRepos(where); | |||
return repos.loadClass(clazzname); | |||
} | |||
} |
@@ -1,96 +0,0 @@ | |||
/******************************************************************************* | |||
* Copyright (c) 2005 IBM | |||
* 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/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Andy Clement - initial API and implementation | |||
*******************************************************************************/ | |||
package org.aspectj.systemtest.ajc150; | |||
import java.io.File; | |||
import org.aspectj.apache.bcel.classfile.JavaClass; | |||
import org.aspectj.apache.bcel.classfile.Method; | |||
import org.aspectj.tools.ajc.CompilationResult; | |||
/** | |||
* These are tests that run on Java 1.4 and use the new ajctestcase format. | |||
* If you have a test that *needs* to run on Java 1.5 then look in Ajc150TestsRequireJava15.java | |||
*/ | |||
public class Ajc150TestsNoHarness extends TestUtils { | |||
protected void setUp() throws Exception { | |||
super.setUp(); | |||
baseDir = new File("../tests/bugs150"); | |||
} | |||
public void testIncorrectExceptionTableWhenBreakInMethod_pr78021() { | |||
CompilationResult cR=ajc(baseDir,new String[]{"PR78021.java"}); | |||
if (verbose) { System.err.println(cR); System.err.println(cR.getStandardError());} | |||
RunResult rR = run("PR78021"); | |||
if (verbose) {System.err.println(rR.getStdErr());} | |||
} | |||
public void testIncorrectExceptionTableWhenReturnInMethod_pr79554() { | |||
CompilationResult cR=ajc(baseDir,new String[]{"PR79554.java"}); | |||
if (verbose) { System.err.println(cR); System.err.println(cR.getStandardError());} | |||
RunResult rR = run("PR79554"); | |||
if (verbose) {System.err.println(rR.getStdErr());} | |||
} | |||
public void testMissingDebugInfoForGeneratedMethods_pr82570() throws ClassNotFoundException { | |||
boolean f = false; | |||
CompilationResult cR = ajc(baseDir,new String[]{"PR82570_1.java"}); | |||
System.err.println(cR.getStandardError()); | |||
assertTrue("Expected no compile problem:"+cR,!cR.hasErrorMessages()); | |||
JavaClass jc = getClassFrom(ajc.getSandboxDirectory(),"PR82570_1"); | |||
Method[] meths = jc.getMethods(); | |||
for (int i = 0; i < meths.length; i++) { | |||
Method method = meths[i]; | |||
if (f) System.err.println("Line number table for "+method.getName()+method.getSignature()+" = "+method.getLineNumberTable()); | |||
assertTrue("Didn't find a line number table for method "+method.getName()+method.getSignature(), | |||
method.getLineNumberTable()!=null); | |||
} | |||
// This test would determine the info isn't there if you pass -g:none ... | |||
// cR = ajc(baseDir,new String[]{"PR82570_1.java","-g:none"}); | |||
// assertTrue("Expected no compile problem:"+cR,!cR.hasErrorMessages()); | |||
// System.err.println(cR.getStandardError()); | |||
// jc = getClassFrom(ajc.getSandboxDirectory(),"PR82570_1"); | |||
// meths = jc.getMethods(); | |||
// for (int i = 0; i < meths.length; i++) { | |||
// Method method = meths[i]; | |||
// assertTrue("Found a line number table for method "+method.getName(), | |||
// method.getLineNumberTable()==null); | |||
// } | |||
} | |||
public void testCanOverrideProtectedMethodsViaITDandDecp_pr83303() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"PR83303.java"}); | |||
assertTrue("Should be no errors:"+cR,!cR.hasErrorMessages()); | |||
} | |||
public void testPerTypeWithinMissesNamedInnerTypes() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"PR83563_1.java"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("PR83563_1"); | |||
} | |||
public void testPerTypeWithinMissesAnonymousInnerTypes() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"PR83563_2.java"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("PR83563_2"); | |||
} | |||
public void testPerTypeWithinIncorrectlyMatchingInterfaces() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"PR83645.java"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("PR83645"); | |||
} | |||
} |
@@ -1,44 +0,0 @@ | |||
/******************************************************************************* | |||
* Copyright (c) 2005 IBM | |||
* 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/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Andy Clement - initial API and implementation | |||
*******************************************************************************/ | |||
package org.aspectj.systemtest.ajc150; | |||
import java.io.ByteArrayOutputStream; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.io.PrintWriter; | |||
import org.aspectj.asm.AsmManager; | |||
import org.aspectj.tools.ajc.CompilationResult; | |||
/** | |||
* These tests only execute in a 1.5 environment. | |||
*/ | |||
public class Ajc150TestsRequireJava15 extends TestUtils { | |||
protected void setUp() throws Exception { | |||
super.setUp(); | |||
baseDir = new File("../tests/bugs150"); | |||
} | |||
public void testBadASMforEnums() throws IOException { | |||
CompilationResult cR = ajc(baseDir,new String[]{"Rainbow.java","-emacssym","-1.5"}); | |||
// System.err.println(cR); | |||
ByteArrayOutputStream baos = new ByteArrayOutputStream(); | |||
PrintWriter pw = new PrintWriter(baos); | |||
AsmManager.dumptree(pw,AsmManager.getDefault().getHierarchy().getRoot(),0); | |||
pw.flush(); | |||
String tree = baos.toString(); | |||
assertTrue("Expected 'Red [enumvalue]' somewhere in here:"+tree,tree.indexOf("Red [enumvalue]")!=-1); | |||
} | |||
} |
@@ -19,24 +19,24 @@ import junit.framework.TestSuite; | |||
public class AllTestsAspectJ150 { | |||
public static Test suite() { | |||
TestSuite suite = new TestSuite("Java5 - binary weaving"); | |||
TestSuite suite = new TestSuite("Java5/AspectJ5 tests"); | |||
//$JUnit-BEGIN$ | |||
suite.addTestSuite(MigrationTests.class); | |||
suite.addTest(Ajc150Tests.suite()); | |||
suite.addTestSuite(Ajc150TestsNoHarness.class); | |||
suite.addTestSuite(SCCSFixTests.class); | |||
// These are binary weaving tests | |||
suite.addTest(AccBridgeMethods.suite()); | |||
suite.addTestSuite(CovarianceTests.class); | |||
suite.addTestSuite(Enums.class); | |||
suite.addTestSuite(AnnotationsBinaryWeaving.class); | |||
suite.addTestSuite(AnnotationPointcutsTests.class); | |||
suite.addTest(AnnotationsBinaryWeaving.suite()); | |||
suite.addTest(AnnotationPointcutsTests.suite()); | |||
suite.addTestSuite(VarargsTests.class); | |||
suite.addTestSuite(AnnotationRuntimeTests.class); | |||
suite.addTest(AnnotationRuntimeTests.suite()); | |||
suite.addTestSuite(PerTypeWithinTests.class); | |||
suite.addTest(Autoboxing.suite()); | |||
suite.addTest(Annotations.suite()); | |||
suite.addTest(AnnotationBinding.suite()); | |||
//$JUnit-END$ | |||
return suite; | |||
} |
@@ -1,32 +0,0 @@ | |||
/******************************************************************************* | |||
* Copyright (c) 2005 IBM | |||
* 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/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Andy Clement - initial API and implementation | |||
*******************************************************************************/ | |||
package org.aspectj.systemtest.ajc150; | |||
import junit.framework.Test; | |||
import junit.framework.TestSuite; | |||
/** | |||
* This is a superset of AllTestsAspectJ150 that includes tests that must be run on Java 1.5 | |||
*/ | |||
public class AllTestsAspectJ150_NeedJava15 { | |||
public static Test suite() { | |||
TestSuite suite = new TestSuite("Java5"); | |||
//$JUnit-BEGIN$ | |||
suite.addTestSuite(Ajc150TestsRequireJava15.class); | |||
suite.addTestSuite(Autoboxing.class); | |||
suite.addTestSuite(Annotations.class); | |||
suite.addTestSuite(AnnotationBinding.class); | |||
//$JUnit-END$ | |||
return suite; | |||
} | |||
} |
@@ -11,110 +11,84 @@ | |||
package org.aspectj.systemtest.ajc150; | |||
import java.io.File; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import org.aspectj.tools.ajc.CompilationResult; | |||
import junit.framework.Test; | |||
public class AnnotationBinding extends TestUtils { | |||
protected void setUp() throws Exception { | |||
super.setUp(); | |||
baseDir = new File("../tests/java5/annotations/binding"); | |||
import org.aspectj.testing.XMLBasedAjcTestCase; | |||
public class AnnotationBinding extends XMLBasedAjcTestCase { | |||
public static Test suite() { | |||
return XMLBasedAjcTestCase.loadSuite(AnnotationBinding.class); | |||
} | |||
protected File getSpecFile() { | |||
return new File("../tests/src/org/aspectj/systemtest/ajc150/ajc150.xml"); | |||
} | |||
///////////////////////////////////// @ANNOTATION and CALL | |||
// Very simple annotation binding for 'call() && @annotation()' | |||
public void testCallAnnotationBinding1() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"CallAnnBinding.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("CallAnnBinding"); | |||
runTest("call annotation binding 1"); | |||
} | |||
// 'call() && @annotation()' when the called method has multiple arguments | |||
public void testCallAnnotationBinding2() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"CallAnnBinding2.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("CallAnnBinding2"); | |||
runTest("call annotation binding 2"); | |||
} | |||
// 'call() && @annotation()' when the called method takes primitive arguments (YUCK!) | |||
public void testCallAnnotationBinding3() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"CallAnnBinding3.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("CallAnnBinding3"); | |||
runTest("call annotation binding 3"); | |||
} | |||
// 'call() && @annotation()' when runtime type will exhibit different annotation (due to interface implementing) | |||
public void testCallAnnotationBinding4() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"CallAnnBinding4.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("CallAnnBinding4"); | |||
runTest("call annotation binding 4"); | |||
} | |||
// 'call() && @annotation()' when target doesnt have an annotation ! | |||
public void testCallAnnotationBinding5() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"CallAnnBinding5.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("CallAnnBinding5"); | |||
runTest("call annotation binding 5"); | |||
} | |||
// 'call() && @annotation()' when runtime type will exhibit different annotation (due to subclassing) | |||
public void testCallAnnotationBinding6() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"CallAnnBinding6.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("CallAnnBinding6"); | |||
runTest("call annotation binding 6"); | |||
} | |||
// 'call() && @annotation()' using named pointcut | |||
public void testCallAnnotationBinding7() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"CallAnnBinding7.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("CallAnnBinding7"); | |||
runTest("call annotation binding 7"); | |||
} | |||
///////////////////////////////////// @TARGET | |||
// 'call() && @target()' | |||
public void testAtTargetAnnotationBinding1() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"AtTarget1.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("AtTarget1"); | |||
runTest("@target annotation binding 1"); | |||
} | |||
// 'call() && @target() && @target' | |||
public void testAtTargetAnnotationBinding2() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"AtTarget2.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("AtTarget2"); | |||
runTest("@target annotation binding 2"); | |||
} | |||
// 'call() && @target()' - using a type hierarchy where some levels are missing annotations | |||
public void testAtTargetAnnotationBinding3() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"AtTarget3.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("AtTarget3"); | |||
runTest("@target annotation binding 3"); | |||
} | |||
// 'call() && @target()' - using a type hierarchy where some levels are missing annotations | |||
// but the annotation is inherited | |||
public void testAtTargetAnnotationBinding4() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"AtTarget4.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("AtTarget4"); | |||
runTest("@target annotation binding 4"); | |||
} | |||
// @target() with an annotation in a package | |||
public void testAtTargetAnnotationBinding5() { | |||
CompilationResult cR = ajc(new File(baseDir,"usingPackageNames"), | |||
new String[]{"MyAspect.aj","MyAnnotation.java","MyClass.java","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("test.MyClass"); | |||
runTest("@target annotation binding 5"); | |||
} | |||
@@ -122,75 +96,55 @@ public class AnnotationBinding extends TestUtils { | |||
// 'call() && @this()' | |||
public void testAtThisAnnotationBinding1() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"AtThis1.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("AtThis1"); | |||
runTest("@this annotation binding 1"); | |||
} | |||
// 'call() && @this() && @this' | |||
public void testAtThisAnnotationBinding2() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"AtThis2.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("AtThis2"); | |||
runTest("@this annotation binding 2"); | |||
} | |||
// 'call() && @this()' - using a type hierarchy where some levels are missing annotations | |||
public void testAtThisAnnotationBinding3() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"AtThis3.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("AtThis3"); | |||
runTest("@this annotation binding 3"); | |||
} | |||
// 'call() && @this()' - using a type hierarchy where some levels are missing annotations | |||
// but the annotation is inherited | |||
public void testAtThisAnnotationBinding4() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"AtThis4.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("AtThis4"); | |||
runTest("@this annotation binding 4"); | |||
} | |||
// '@this() and @target()' used together | |||
public void testAtThisAtTargetAnnotationBinding() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"AtThis5.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("AtThis5"); | |||
runTest("@this annotation binding 5"); | |||
} | |||
///////////////////////////////////// @ARGS | |||
// complex case when there are 3 parameters | |||
public void testAtArgs1() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"AtArgs1.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("AtArgs1"); | |||
runTest("@args annotation binding 1"); | |||
} | |||
// simple case when there is only one parameter | |||
public void testAtArgs2() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"AtArgs2.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("AtArgs2"); | |||
runTest("@args annotation binding 2"); | |||
} | |||
// simple case when there is only one parameter and no binding | |||
public void testAtArgs3() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"AtArgs3.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("AtArgs3"); | |||
runTest("@args annotation binding 3"); | |||
} | |||
// complex case binding different annotation kinds | |||
public void testAtArgs4() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"AtArgs4.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("AtArgs4"); | |||
runTest("@args annotation binding 4"); | |||
} | |||
// check @args and execution() | |||
public void testAtArgs5() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"AtArgs5.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("AtArgs5"); | |||
runTest("@args annotation binding 5"); | |||
} | |||
@@ -198,96 +152,73 @@ public class AnnotationBinding extends TestUtils { | |||
// 'execution() && @annotation()' | |||
public void testExecutionAnnotationBinding1() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"ExecutionAnnBinding1.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("ExecutionAnnBinding1"); | |||
runTest("execution and @annotation"); | |||
} | |||
///////////////////////////////////// @ANNOTATION and SET | |||
// 'set() && @annotation()' | |||
public void testFieldAnnotationBinding1() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"FieldAnnBinding1.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("FieldAnnBinding1"); | |||
runTest("set and @annotation"); | |||
} | |||
// 'get() && @annotation()' | |||
public void testFieldAnnotationBinding2() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"FieldAnnBinding2.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("FieldAnnBinding2"); | |||
runTest("get and @annotation"); | |||
} | |||
// 'get() && @annotation()' when using array fields | |||
public void testFieldAnnotationBinding3() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"FieldAnnBinding3.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("FieldAnnBinding3"); | |||
runTest("get and @annotation with arrays"); | |||
} | |||
///////////////////////////////////// @ANNOTATION and CTOR-CALL | |||
// 'ctor-call(new) && @annotation()' | |||
public void testCtorCallAnnotationBinding1() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"CtorAnnBinding1.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("CtorAnnBinding1"); | |||
runTest("cons call and @annotation"); | |||
} | |||
///////////////////////////////////// @ANNOTATION and CTOR-CALL | |||
// 'ctor-execution() && @annotation()' | |||
public void testCtorExecAnnotationBinding1() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"CtorAnnBinding2.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("CtorAnnBinding2"); | |||
runTest("cons exe and @annotation"); | |||
} | |||
///////////////////////////////////// @ANNOTATION and STATICINITIALIZATION | |||
// 'staticinitialization() && @annotation()' | |||
public void testStaticInitAnnotationBinding1() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"StaticInitBinding.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("StaticInitBinding"); | |||
runTest("staticinit and @annotation"); | |||
} | |||
///////////////////////////////////// @ANNOTATION and PREINITIALIZATION | |||
// 'preinitialization() && @annotation()' | |||
public void testPreInitAnnotationBinding1() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"PreInitBinding.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("PreInitBinding"); | |||
runTest("preinit and @annotation"); | |||
} | |||
///////////////////////////////////// @ANNOTATION and INITIALIZATION | |||
// 'initialization() && @annotation()' | |||
public void testInitAnnotationBinding1() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"InitBinding.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("InitBinding"); | |||
runTest("init and @annotation"); | |||
} | |||
///////////////////////////////////// @ANNOTATION and ADVICEEXECUTION | |||
// 'adviceexecution() && @annotation()' | |||
public void testAdviceExecAnnotationBinding1() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"AdviceExecBinding.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("AdviceExecBinding"); | |||
runTest("adviceexecution and @annotation"); | |||
} | |||
///////////////////////////////////// @ANNOTATION and HANDLER | |||
// 'handler() && @annotation()' | |||
public void testHandlerAnnotationBinding1() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"HandlerBinding.aj","-1.5"}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("HandlerBinding"); | |||
runTest("handler and @annotation"); | |||
} | |||
@@ -295,43 +226,26 @@ public class AnnotationBinding extends TestUtils { | |||
// Using package names for the types (including the annotation) - NO BINDING | |||
public void testPackageNamedTypesNoBinding() { | |||
CompilationResult cR = ajc(new File(baseDir,"complexExample"), | |||
new String[]{"A.java","B.java","Color.java","X.java","-1.5","-d","."}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("a.b.c.A"); | |||
runTest("packages and no binding"); | |||
} | |||
// Using package names for the types (including the annotation) - INCLUDES BINDING | |||
public void testPackageNamedTypesWithBinding() { | |||
CompilationResult cR = ajc(new File(baseDir,"complexExample"), | |||
new String[]{"A.java","B.java","Color.java","X2.java","-1.5","-d","."}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("a.b.c.A"); | |||
runTest("packages and binding"); | |||
} | |||
// declare parents: @Color * implements Serializable | |||
public void testDeclareParentsWithAnnotatedAnyPattern() { | |||
CompilationResult cR = ajc(new File(baseDir,"complexExample"), | |||
new String[]{"A.java","B.java","C.java","Color.java","X3.java","-1.5","-d","."}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("g.h.i.C"); // C should now be serializable | |||
rR = run("a.b.c.A"); // A should not be serializable | |||
runTest("annotated any pattern"); | |||
} | |||
// Should error (in a nice way!) on usage of an annotation that isnt imported | |||
public void testAnnotationUsedButNotImported() { | |||
CompilationResult cR = ajc(new File(baseDir,"complexExample"), | |||
new String[]{"A.java","B.java","Color.java","X4.java","-1.5","-d","."}); | |||
List warnings = new ArrayList(); | |||
warnings.add(new Message(6)); | |||
assertMessages(cR,new MessageSpec(warnings,null)); | |||
RunResult rR = run("a.b.c.A"); | |||
runTest("annotation not imported"); | |||
} | |||
// Binding with calls/executions of static methods | |||
public void testCallsAndExecutionsOfStaticMethods() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"StaticMethods.java","-1.5","-d","."}); | |||
assertMessages(cR,new EmptyMessageSpec()); | |||
RunResult rR = run("StaticMethods"); | |||
runTest("binding with static methods"); | |||
} | |||
} |
@@ -11,63 +11,41 @@ | |||
package org.aspectj.systemtest.ajc150; | |||
import java.io.File; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import org.aspectj.tools.ajc.CompilationResult; | |||
import junit.framework.Test; | |||
import org.aspectj.testing.XMLBasedAjcTestCase; | |||
/** | |||
* Tests the use of Annotations in pointcuts | |||
*/ | |||
public class AnnotationPointcutsTests extends TestUtils { | |||
protected void setUp() throws Exception { | |||
super.setUp(); | |||
baseDir = new File("../tests/java5/annotations"); | |||
} | |||
public class AnnotationPointcutsTests extends XMLBasedAjcTestCase { | |||
public static Test suite() { | |||
return XMLBasedAjcTestCase.loadSuite(AnnotationPointcutsTests.class); | |||
} | |||
protected File getSpecFile() { | |||
return new File("../tests/src/org/aspectj/systemtest/ajc150/ajc150.xml"); | |||
} | |||
// before(): call(@SimpleAnnotation * *(..)) { } | |||
public void test001_usingAnnotationsInPointcuts() { | |||
CompilationResult cR = binaryWeave("testcode.jar","AnnotationAspect02.aj",0,0); | |||
System.err.println(cR.getStandardError()); | |||
System.err.println(cR.getErrorMessages()); | |||
System.err.println(cR.getInfoMessages()); | |||
verifyWeavingMessagesOutput(cR,new String[]{ | |||
"weaveinfo Type 'AnnotatedType' (AnnotatedType.java:3) advised by before advice from 'AnnotationAspect02' (AnnotationAspect02.aj:4)", | |||
"weaveinfo Type 'AnnotatedType' (AnnotatedType.java:3) advised by before advice from 'AnnotationAspect02' (AnnotationAspect02.aj:2)", | |||
"weaveinfo Type 'AnnotatedType' (AnnotatedType.java:4) advised by before advice from 'AnnotationAspect02' (AnnotationAspect02.aj:4)"}); | |||
runTest("annotation matching on call"); | |||
} | |||
public void test002_AtAnnotationMatching() { | |||
CompilationResult cR = binaryWeave("testcode.jar","AnnotationAspect03.aj",0,1); | |||
List expectedWarnings = new ArrayList(); | |||
expectedWarnings.add(new Message("@annotation matched here")); // L 8 | |||
assertMessages(cR, new MessageSpec(expectedWarnings, new ArrayList())); | |||
runTest("at annotation matching"); | |||
} | |||
public void test003_Within_Code() { | |||
baseDir = new File("../tests/java5/annotations/within_code"); | |||
CompilationResult cR = binaryWeave("TestingAnnotations.jar","WithinAndWithinCodeTests.java",0,5); | |||
List warnings = new ArrayList(); | |||
warnings.add(new Message(32,"@within match on non-inherited annotation")); | |||
warnings.add(new Message(39,"@within match on non-inherited annotation")); | |||
warnings.add(new Message(39,"@within match on inheritable annotation")); | |||
warnings.add(new Message(43,"@within match on inheritable annotation")); | |||
warnings.add(new Message(32,"@withincode match")); | |||
MessageSpec mSpec = new MessageSpec(warnings,new ArrayList()); | |||
assertMessages(cR,mSpec); | |||
runTest("annotations and within(code)"); | |||
} | |||
public void test004_Within() { | |||
baseDir = new File("../tests/java5/annotations/within"); | |||
CompilationResult cR = binaryWeave("PlainWithin.jar","PlainWithinTests.java",0,2); | |||
List warnings = new ArrayList(); | |||
warnings.add(new Message(21,"positive within match on annotation")); | |||
warnings.add(new Message(25,"negative within match on annotation")); | |||
MessageSpec mSpec = new MessageSpec(warnings,new ArrayList()); | |||
assertMessages(cR,mSpec); | |||
} | |||
runTest("annotations and within"); | |||
} | |||
// TODO extra tests | |||
// 3) @annotation on the different join point kinds, matches with inherited annotation |
@@ -11,20 +11,23 @@ | |||
package org.aspectj.systemtest.ajc150; | |||
import java.io.File; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import org.aspectj.tools.ajc.CompilationResult; | |||
import junit.framework.Test; | |||
import org.aspectj.testing.XMLBasedAjcTestCase; | |||
/** | |||
* Tests for @this, @target, @args | |||
*/ | |||
public class AnnotationRuntimeTests extends TestUtils { | |||
public class AnnotationRuntimeTests extends XMLBasedAjcTestCase { | |||
protected void setUp() throws Exception { | |||
super.setUp(); | |||
baseDir = new File("../tests/java5/annotations/thisOrtarget"); | |||
} | |||
public static Test suite() { | |||
return XMLBasedAjcTestCase.loadSuite(AnnotationRuntimeTests.class); | |||
} | |||
protected File getSpecFile() { | |||
return new File("../tests/src/org/aspectj/systemtest/ajc150/ajc150.xml"); | |||
} | |||
// No longer a limitation ASC 31Jan05 | |||
// public void test001_BindingWithAtTargetAllowed() { | |||
@@ -35,46 +38,23 @@ public class AnnotationRuntimeTests extends TestUtils { | |||
// } | |||
public void test002_MustHaveRuntimeRetention() { | |||
CompilationResult cR = binaryWeave("TestingAnnotations.jar","NotRuntimeRetention.aj",2,0); | |||
List errors = new ArrayList(); | |||
errors.add(new Message(7,"Annotation type MyClassRetentionAnnotation does not have runtime retention")); | |||
errors.add(new Message(13,"Annotation type MyClassRetentionAnnotation does not have runtime retention")); | |||
MessageSpec messageSpec = new MessageSpec(new ArrayList(), errors); | |||
assertMessages(cR, messageSpec); | |||
runTest("must have runtime retention"); | |||
} | |||
public void test003_InheritableOrNot() { | |||
CompilationResult cR = binaryWeave("TestingAnnotations.jar","ThisOrTargetTests.aj",0,0); | |||
runTest("inheritable or not"); | |||
} | |||
public void test004_CantUseinDecEoW() { | |||
CompilationResult cR = binaryWeave("TestingAnnotations.jar","DeclareEoW.java",4,0); | |||
List errors = new ArrayList(); | |||
errors.add(new Message(3,"this() pointcut designator cannot be used in declare statement")); | |||
errors.add(new Message(5,"target() pointcut designator cannot be used in declare statement")); | |||
MessageSpec messageSpec = new MessageSpec(new ArrayList(), errors); | |||
assertMessages(cR, messageSpec); | |||
runTest("use of @this/target in deow"); | |||
} | |||
// TODO extra tests | |||
// run the result of test003 and validate matches (needs 1.5 runtime) | |||
// test inheritable annotation not present on type [should generate runtime test] | |||
public void test005_ArgsSuite() { | |||
baseDir = new File("../tests/java5/annotations/args"); | |||
CompilationResult cR = binaryWeave("TestingArgsAnnotations.jar","AtArgsAspect.java",0,0); | |||
// TODO need to RUN the result of these tests... | |||
System.out.println(cR); | |||
runTest("@args tests"); | |||
} | |||
public void test006_CantUseinDecEoW() { | |||
baseDir = new File("../tests/java5/annotations/args"); | |||
CompilationResult cR = binaryWeave("TestingArgsAnnotations.jar","DeclareEoW.java",2,0); | |||
List errors = new ArrayList(); | |||
errors.add(new Message(3,"args() pointcut designator cannot be used in declare statement")); | |||
MessageSpec messageSpec = new MessageSpec(new ArrayList(), errors); | |||
assertMessages(cR, messageSpec); | |||
runTest("use of @args in deow"); | |||
} | |||
} |
@@ -11,40 +11,35 @@ | |||
package org.aspectj.systemtest.ajc150; | |||
import java.io.File; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import junit.framework.Test; | |||
import org.aspectj.apache.bcel.classfile.JavaClass; | |||
import org.aspectj.apache.bcel.classfile.Method; | |||
import org.aspectj.tools.ajc.CompilationResult; | |||
import org.aspectj.apache.bcel.util.ClassPath; | |||
import org.aspectj.apache.bcel.util.SyntheticRepository; | |||
import org.aspectj.testing.XMLBasedAjcTestCase; | |||
public class Annotations extends TestUtils { | |||
protected void setUp() throws Exception { | |||
super.setUp(); | |||
baseDir = new File("../tests/java5/annotations"); | |||
} | |||
public class Annotations extends XMLBasedAjcTestCase { | |||
public static Test suite() { | |||
return XMLBasedAjcTestCase.loadSuite(Annotations.class); | |||
} | |||
protected File getSpecFile() { | |||
return new File("../tests/src/org/aspectj/systemtest/ajc150/ajc150.xml"); | |||
} | |||
public void testCompilingAnnotation() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"SimpleAnnotation.java","-1.5"}); | |||
MessageSpec ms = new MessageSpec(null,null); | |||
assertMessages(cR,ms); | |||
runTest("compiling an annotation"); | |||
} | |||
public void testCompilingAnnotatedFile() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"AnnotatedType.java","SimpleAnnotation.java","-1.5"}); | |||
MessageSpec ms = new MessageSpec(null,null); | |||
assertMessages(cR,ms); | |||
runTest("compiling annotated file"); | |||
} | |||
public void testCompilingUsingWithinAndAnnotationTypePattern() { | |||
CompilationResult cR = ajc(new File(baseDir+File.separator+"within"), | |||
new String[]{"PlainWithin.java","PlainWithinTests.java","-1.5"}); | |||
List expectedInfoMessages = new ArrayList(); | |||
expectedInfoMessages.add(new Message(21,"positive within match on annotation")); | |||
expectedInfoMessages.add(new Message(25,"negative within match on annotation")); | |||
MessageSpec ms = new MessageSpec(expectedInfoMessages,null); | |||
assertMessages(cR,ms); | |||
runTest("annotations and within (src)"); | |||
} | |||
/** | |||
@@ -53,12 +48,7 @@ public class Annotations extends TestUtils { | |||
* a simple program then checks the annotations were copied across. | |||
*/ | |||
public void testBugWithAnnotationsLostOnWovenMethods() throws ClassNotFoundException { | |||
CompilationResult cR = ajc(new File(baseDir+File.separator+"attarget"), | |||
new String[]{"Program.java","AtTargetAspect.java","-1.5"}); | |||
//System.err.println(cR.getStandardError()); | |||
List expectedInfoMessages = new ArrayList(); | |||
MessageSpec ms = new MessageSpec(null,null); | |||
assertMessages(cR,ms); | |||
runTest("losing annotations..."); | |||
JavaClass jc = getClassFrom(ajc.getSandboxDirectory(),"Program"); | |||
Method[] meths = jc.getMethods(); | |||
@@ -69,4 +59,16 @@ public class Annotations extends TestUtils { | |||
} | |||
} | |||
} | |||
// helper methods..... | |||
public SyntheticRepository createRepos(File cpentry) { | |||
ClassPath cp = new ClassPath(cpentry+File.pathSeparator+System.getProperty("java.class.path")); | |||
return SyntheticRepository.getInstance(cp); | |||
} | |||
protected JavaClass getClassFrom(File where,String clazzname) throws ClassNotFoundException { | |||
SyntheticRepository repos = createRepos(where); | |||
return repos.loadClass(clazzname); | |||
} | |||
} |
@@ -12,8 +12,9 @@ package org.aspectj.systemtest.ajc150; | |||
import java.io.File; | |||
import org.aspectj.bridge.IMessage; | |||
import org.aspectj.tools.ajc.CompilationResult; | |||
import junit.framework.Test; | |||
import org.aspectj.testing.XMLBasedAjcTestCase; | |||
/** | |||
@@ -27,55 +28,29 @@ import org.aspectj.tools.ajc.CompilationResult; | |||
* 6. Compilation error if you explicitly identify an Annotation type. | |||
* 7. Lint warning if a non-explicit type pattern would match an annotation type. | |||
*/ | |||
public class AnnotationsBinaryWeaving extends TestUtils { | |||
protected void setUp() throws Exception { | |||
super.setUp(); | |||
baseDir = new File("../tests/java5/annotations"); | |||
} | |||
public class AnnotationsBinaryWeaving extends XMLBasedAjcTestCase { | |||
public static Test suite() { | |||
return XMLBasedAjcTestCase.loadSuite(AnnotationsBinaryWeaving.class); | |||
} | |||
protected File getSpecFile() { | |||
return new File("../tests/src/org/aspectj/systemtest/ajc150/ajc150.xml"); | |||
} | |||
// Cannot make ITD (c/m/f) on an annotation | |||
public void test001_itdsOnAnnotationsNotAllowed() { | |||
CompilationResult cR = binaryWeave("testcode.jar","AnnotationAspect01.aj",3,0); | |||
assertTrue("Expected three message about ITDs not allowed on Annotations but got: #"+ | |||
cR.getErrorMessages().size()+": \n"+cR.getErrorMessages(), | |||
cR.getErrorMessages().size()==3); | |||
IMessage msg1_ctor = (IMessage)cR.getErrorMessages().get(0); | |||
IMessage msg2_method = (IMessage)cR.getErrorMessages().get(1); | |||
IMessage msg3_field = (IMessage)cR.getErrorMessages().get(2); | |||
assertTrue("Expected message about ITDCs on annotations not allowed, but got: \n"+msg1_ctor, | |||
msg1_ctor.toString().indexOf("can't make inter-type constructor declarations")!=-1); | |||
assertTrue("Expected message about ITDMs on annotations not allowed, but got: \n"+msg2_method, | |||
msg2_method.toString().indexOf("can't make inter-type method declarations")!=-1); | |||
assertTrue("Expected message about ITDFs on annotations not allowed, but got: \n"+msg3_field, | |||
msg3_field.toString().indexOf("can't make inter-type field declarations")!=-1); | |||
verifyWeavingMessagesOutput(cR,new String[]{}); | |||
runTest("no itds on annotation types"); | |||
} | |||
// Deals with the cases where an explicit type is specified and it is an annotation type | |||
public void test002_decpOnAnnotationNotAllowed_errors() { | |||
CompilationResult cR = binaryWeave("testcode.jar","AnnotationAspect04.aj",3,0,true,new String[]{"-source","1.5"}); | |||
IMessage msg = (IMessage)cR.getErrorMessages().get(1); | |||
assertTrue("Expected a message about can't use decp to alter supertype of an annotation: "+msg, | |||
msg.toString().indexOf("to alter supertype of annotation type")!=-1); | |||
msg = (IMessage)cR.getErrorMessages().get(2); | |||
assertTrue("Expected a message about can't use decp to make annotation implement interface: "+msg, | |||
msg.toString().indexOf("implement an interface")!=-1); | |||
msg = (IMessage)cR.getErrorMessages().get(0); | |||
assertTrue("Expected a message about can't use decp to make Annotation parent of another type: "+msg, | |||
msg.toString().indexOf("the parent of type")!=-1); | |||
verifyWeavingMessagesOutput(cR,new String[]{}); | |||
runTest("no declare parents on annotation types"); | |||
} | |||
//Deals with the cases where an wild type pattern is specified and it hits an annotation type | |||
public void test004_decpOnAnnotationNotAllowed_xlints() { | |||
CompilationResult cR = binaryWeave("testcode.jar","AnnotationAspect05.aj",0,2,false); | |||
IMessage msg = (IMessage)cR.getWarningMessages().get(0); | |||
assertTrue("Expected a message about an annotation type matching a declare parents but being ignored: "+msg, | |||
msg.toString().indexOf("matches a declare parents type pattern")!=-1); | |||
msg = (IMessage)cR.getWarningMessages().get(1); | |||
assertTrue("Expected a message about an annotation type matching a declare parents but being ignored: "+msg, | |||
msg.toString().indexOf("matches a declare parents type pattern")!=-1); | |||
verifyWeavingMessagesOutput(cR,new String[]{}); | |||
runTest("declare parents wildcards matching annotation types"); | |||
} | |||
} |
@@ -12,144 +12,83 @@ package org.aspectj.systemtest.ajc150; | |||
import java.io.File; | |||
import org.aspectj.tools.ajc.CompilationResult; | |||
import junit.framework.Test; | |||
import org.aspectj.testing.XMLBasedAjcTestCase; | |||
/** | |||
This test must be run under a Java5 VM - so it is *not* currently | |||
in the test suite !!! | |||
*/ | |||
public class Autoboxing extends TestUtils { | |||
public class Autoboxing extends XMLBasedAjcTestCase { | |||
private boolean runningUnderJava5 = false; | |||
protected void setUp() throws Exception { | |||
super.setUp(); | |||
baseDir = new File("../tests/java5/autoboxing"); | |||
} | |||
public static Test suite() { | |||
return XMLBasedAjcTestCase.loadSuite(Autoboxing.class); | |||
} | |||
protected File getSpecFile() { | |||
return new File("../tests/src/org/aspectj/systemtest/ajc150/ajc150.xml"); | |||
} | |||
public void testSimpleBoxing() { | |||
CompilationResult cR = binaryWeave("testcode.jar","SimpleAutoboxingAspect.aj",0,0,"-1.5"); | |||
assertTrue("Expected two weaving messages (both on line 7) but got:"+getWeavingMessages(cR.getInfoMessages()).size(), | |||
getWeavingMessages(cR.getInfoMessages()).size()==2); | |||
RunResult rR = run("SimpleAutoboxing"); | |||
verify(rR.getStdErr(),"Matching by Integer:20000"); | |||
verify(rR.getStdErr(),"Matching by int:20000"); | |||
verify(rR.getStdErr(),"method_takes_Integer=20000"); | |||
runTest("simple boxing test"); | |||
} | |||
public void testIntegerBoxing() { | |||
CompilationResult cR = binaryWeave("testcode.jar","AspectInteger.aj",0,0,"-1.5"); | |||
System.err.println(cR.getStandardError()); | |||
assertTrue("Expected eight weaving messages but got: "+getWeavingMessages(cR.getInfoMessages()).size(), | |||
getWeavingMessages(cR.getInfoMessages()).size()==8); | |||
RunResult rR = run("AutoboxingI"); | |||
verify(rR.getStdErr(),"Matching by Integer:10000"); | |||
verify(rR.getStdErr(),"Matching by int:10000"); | |||
verify(rR.getStdErr(),"method_takes_Integer=10000"); | |||
verify(rR.getStdErr(),"Matching by Integer:20000"); | |||
verify(rR.getStdErr(),"Matching by int:20000"); | |||
verify(rR.getStdErr(),"method_takes_Integer=20000"); | |||
verify(rR.getStdErr(),"Matching by Integer:30000"); | |||
verify(rR.getStdErr(),"Matching by int:30000"); | |||
verify(rR.getStdErr(),"method_takes_int=30000"); | |||
verify(rR.getStdErr(),"Matching by Integer:40000"); | |||
verify(rR.getStdErr(),"Matching by int:40000"); | |||
verify(rR.getStdErr(),"method_takes_int=40000"); | |||
runTest("integer boxing"); | |||
} | |||
public void testCharacterBoxing() { | |||
CompilationResult cR = binaryWeave("testcode.jar","AspectChar.aj",0,0,"-1.5"); | |||
System.err.println(cR.getStandardError()); | |||
assertTrue("Expected eight weaving messages but got: "+getWeavingMessages(cR.getInfoMessages()).size(), | |||
getWeavingMessages(cR.getInfoMessages()).size()==8); | |||
RunResult rR = run("AutoboxingC"); | |||
int lines = countLines(rR.getStdErr()); | |||
assertTrue("Expected 12 lines of output but got: #"+lines+":\n"+rR.getStdErr(),lines==12); | |||
runTest("char boxing"); | |||
} | |||
public void testDoubleBoxing() { | |||
CompilationResult cR = binaryWeave("testcode.jar","AspectDouble.aj",0,0,"-1.5"); | |||
System.err.println(cR.getStandardError()); | |||
assertTrue("Expected eight weaving messages but got: "+getWeavingMessages(cR.getInfoMessages()).size(), | |||
getWeavingMessages(cR.getInfoMessages()).size()==8); | |||
RunResult rR = run("AutoboxingD"); | |||
int lines = countLines(rR.getStdErr()); | |||
assertTrue("Expected 12 lines of output but got: #"+lines+":\n"+rR.getStdErr(),lines==12); | |||
runTest("double boxing"); | |||
} | |||
public void testFloatBoxing() { | |||
CompilationResult cR = binaryWeave("testcode.jar","AspectFloat.aj",0,0,"-1.5"); | |||
System.err.println(cR.getStandardError()); | |||
assertTrue("Expected eight weaving messages but got: "+getWeavingMessages(cR.getInfoMessages()).size(), | |||
getWeavingMessages(cR.getInfoMessages()).size()==8); | |||
RunResult rR = run("AutoboxingF"); | |||
int lines = countLines(rR.getStdErr()); | |||
assertTrue("Expected 12 lines of output but got: #"+lines+":\n"+rR.getStdErr(),lines==12); | |||
runTest("float boxing"); | |||
} | |||
public void testShortBoxing() { | |||
CompilationResult cR = binaryWeave("testcode.jar","AspectShort.aj",0,0,"-1.5"); | |||
System.err.println(cR.getStandardError()); | |||
assertTrue("Expected eight weaving messages but got: "+getWeavingMessages(cR.getInfoMessages()).size(), | |||
getWeavingMessages(cR.getInfoMessages()).size()==8); | |||
RunResult rR = run("AutoboxingS"); | |||
int lines = countLines(rR.getStdErr()); | |||
assertTrue("Expected 12 lines of output but got: #"+lines+":\n"+rR.getStdErr(),lines==12); | |||
runTest("short boxing"); | |||
} | |||
public void testLongBoxing() { | |||
CompilationResult cR = binaryWeave("testcode.jar","AspectLong.aj",0,0,"-1.5"); | |||
System.err.println(cR.getStandardError()); | |||
assertTrue("Expected eight weaving messages but got: "+getWeavingMessages(cR.getInfoMessages()).size(), | |||
getWeavingMessages(cR.getInfoMessages()).size()==8); | |||
RunResult rR = run("AutoboxingJ"); | |||
int lines = countLines(rR.getStdErr()); | |||
assertTrue("Expected 12 lines of output but got: #"+lines+":\n"+rR.getStdErr(),lines==12); | |||
runTest("long boxing"); | |||
} | |||
public void testBooleanBoxing() { | |||
CompilationResult cR = binaryWeave("testcode.jar","AspectBoolean.aj",0,0,"-1.5"); | |||
System.err.println(cR.getStandardError()); | |||
assertTrue("Expected eight weaving messages but got: "+getWeavingMessages(cR.getInfoMessages()).size(), | |||
getWeavingMessages(cR.getInfoMessages()).size()==8); | |||
RunResult rR = run("AutoboxingZ"); | |||
int lines = countLines(rR.getStdErr()); | |||
assertTrue("Expected 12 lines of output but got: #"+lines+":\n"+rR.getStdErr(),lines==12); | |||
runTest("boolean boxing"); | |||
} | |||
public void testByteBoxing() { | |||
CompilationResult cR = binaryWeave("testcode.jar","AspectByte.aj",0,0,"-1.5"); | |||
System.err.println(cR.getStandardError()); | |||
assertTrue("Expected eight weaving messages but got: "+getWeavingMessages(cR.getInfoMessages()).size(), | |||
getWeavingMessages(cR.getInfoMessages()).size()==8); | |||
RunResult rR = run("AutoboxingB"); | |||
int lines = countLines(rR.getStdErr()); | |||
assertTrue("Expected 12 lines of output but got: #"+lines+":\n"+rR.getStdErr(),lines==12); | |||
runTest("byte boxing"); | |||
} | |||
public void testBoxingAfterReturning() { | |||
CompilationResult cR = binaryWeave("testcode.jar","AspectAfterReturning.aj",0,0,"-1.5"); | |||
//System.err.println(cR.getStandardError()); | |||
assertTrue("Expected six weaving messages but got: "+getWeavingMessages(cR.getInfoMessages()).size(), | |||
getWeavingMessages(cR.getInfoMessages()).size()==6); | |||
RunResult rR = run("AspectAfterReturning"); | |||
int lines = countLines(rR.getStdErr()); | |||
assertTrue("Expected 6 lines of output but got: #"+lines+":\n"+rR.getStdErr(),lines==6); | |||
runTest("boxing in after returning"); | |||
} | |||
public int countLines(String s) { | |||
int count = 0; | |||
while (s.indexOf("\n")!=-1) { | |||
count++; | |||
s = s.substring(s.indexOf("\n")+1); | |||
} | |||
return count; | |||
} | |||
protected void verify(String output,String lookingFor) { | |||
assertTrue("Didn't find expected string '"+lookingFor+"' in:\n"+output,output.indexOf(lookingFor)!=-1); | |||
} | |||
// CompilationResult cR = binaryWeave("testcode.jar","AspectAfterReturning.aj",0,0,"-1.5"); | |||
// //System.err.println(cR.getStandardError()); | |||
// assertTrue("Expected six weaving messages but got: "+getWeavingMessages(cR.getInfoMessages()).size(), | |||
// getWeavingMessages(cR.getInfoMessages()).size()==6); | |||
// RunResult rR = run("AspectAfterReturning"); | |||
// int lines = countLines(rR.getStdErr()); | |||
// assertTrue("Expected 6 lines of output but got: #"+lines+":\n"+rR.getStdErr(),lines==6); | |||
// } | |||
// | |||
// public int countLines(String s) { | |||
// int count = 0; | |||
// while (s.indexOf("\n")!=-1) { | |||
// count++; | |||
// s = s.substring(s.indexOf("\n")+1); | |||
// } | |||
// return count; | |||
// } | |||
// | |||
// protected void verify(String output,String lookingFor) { | |||
// assertTrue("Didn't find expected string '"+lookingFor+"' in:\n"+output,output.indexOf(lookingFor)!=-1); | |||
// } | |||
// | |||
} |
@@ -11,17 +11,10 @@ | |||
package org.aspectj.systemtest.ajc150; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.HashSet; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Set; | |||
import org.aspectj.bridge.IMessage; | |||
import org.aspectj.tools.ajc.AjcTestCase; | |||
import org.aspectj.tools.ajc.CompilationResult; | |||
import junit.framework.Test; | |||
import org.aspectj.testing.XMLBasedAjcTestCase; | |||
/* | |||
@@ -63,8 +56,15 @@ public class CovBaseProgram01 { | |||
/** | |||
* Covariance is simply where a type overrides some inherited implementation and narrows the return type. | |||
*/ | |||
public class CovarianceTests extends AjcTestCase { | |||
public class CovarianceTests extends XMLBasedAjcTestCase { | |||
public static Test suite() { | |||
return XMLBasedAjcTestCase.loadSuite(CovarianceTests.class); | |||
} | |||
protected File getSpecFile() { | |||
return new File("../tests/src/org/aspectj/systemtest/ajc150/ajc150.xml"); | |||
} | |||
private boolean verbose = false; | |||
@@ -72,11 +72,7 @@ public class CovarianceTests extends AjcTestCase { | |||
* call(* getCar()) should match both | |||
*/ | |||
public void testCOV001() { | |||
CompilationResult cR = binaryWeave("CovBaseProgram01.jar","CovAspect01.aj",0,0); | |||
verifyOutput(cR,new String[]{ | |||
"weaveinfo Type 'CovBaseProgram01' (CovBaseProgram01.java:26) advised by before advice from 'CovAspect01' (CovAspect01.aj:5)", | |||
"weaveinfo Type 'CovBaseProgram01' (CovBaseProgram01.java:27) advised by before advice from 'CovAspect01' (CovAspect01.aj:5)" | |||
}); | |||
runTest("covariance 1"); | |||
} | |||
@@ -99,11 +95,7 @@ public class CovarianceTests extends AjcTestCase { | |||
* a possibility. All the tests pass so I'll leave it like this for now. | |||
*/ | |||
public void testCOV002() { | |||
CompilationResult cR = binaryWeave("CovBaseProgram01.jar","CovAspect02.aj",0,0); | |||
verifyOutput(cR,new String[]{ | |||
"weaveinfo Type 'CovBaseProgram01' (CovBaseProgram01.java:26) advised by before advice from 'CovAspect02' (CovAspect02.aj:5)", | |||
"weaveinfo Type 'CovBaseProgram01' (CovBaseProgram01.java:27) advised by before advice from 'CovAspect02' (CovAspect02.aj:5)" | |||
}); | |||
runTest("covariance 2"); | |||
} | |||
/** | |||
@@ -112,12 +104,7 @@ public class CovarianceTests extends AjcTestCase { | |||
* Had to implement proper covariance support here... | |||
*/ | |||
public void testCOV003() { | |||
CompilationResult cR = binaryWeave("CovBaseProgram01.jar","CovAspect03.aj",0,0); | |||
verifyOutput(cR,new String[]{ | |||
"weaveinfo Type 'CovBaseProgram01' (CovBaseProgram01.java:26) advised by before advice from 'CovAspect03' (CovAspect03.aj:5)", | |||
"weaveinfo Type 'CovBaseProgram01' (CovBaseProgram01.java:27) advised by before advice from 'CovAspect03' (CovAspect03.aj:5)" | |||
}); | |||
runTest("covariance 3"); | |||
} | |||
/** | |||
@@ -125,10 +112,7 @@ public class CovarianceTests extends AjcTestCase { | |||
* call(Car Super.getCar()) should only match first call to getCar() | |||
*/ | |||
public void testCOV004() { | |||
CompilationResult cR = binaryWeave("CovBaseProgram02.jar","CovAspect04.aj",0,0); | |||
verifyOutput(cR,new String[]{ | |||
"weaveinfo Type 'CovBaseProgram02' (CovBaseProgram02.java:30) advised by before advice from 'CovAspect04' (CovAspect04.aj:5)" | |||
}); | |||
runTest("covariance 4"); | |||
} | |||
/** | |||
@@ -136,34 +120,21 @@ public class CovarianceTests extends AjcTestCase { | |||
* call(Car Super.getCar()) should match both | |||
*/ | |||
public void testCOV005() { | |||
CompilationResult cR = binaryWeave("CovBaseProgram01.jar","CovAspect05.aj",0,0); | |||
verifyOutput(cR,new String[]{ | |||
"weaveinfo Type 'CovBaseProgram01' (CovBaseProgram01.java:26) advised by before advice from 'CovAspect05' (CovAspect05.aj:5)", | |||
"weaveinfo Type 'CovBaseProgram01' (CovBaseProgram01.java:27) advised by before advice from 'CovAspect05' (CovAspect05.aj:5)" | |||
}); | |||
runTest("covariance 5"); | |||
} | |||
/** | |||
* call(Car Sub.getCar()) should not match anything | |||
*/ | |||
public void testCOV006() { | |||
CompilationResult cR = binaryWeave("CovBaseProgram01.jar","CovAspect06.aj",0,1); | |||
verifyOutput(cR,new String[]{/* no expected output! */}); | |||
assertTrue("Expected one xlint warning message for line 26, but got: "+cR.getWarningMessages(), | |||
cR.getWarningMessages().size()==1 && ((IMessage)cR.getWarningMessages().get(0)).toString().indexOf("26")!=-1); | |||
runTest("covariance 6"); | |||
} | |||
/** | |||
* call(Car+ Sub.getCar()) should match 2nd call with xlint for the 1st call | |||
*/ | |||
public void testCOV007() { | |||
CompilationResult cR = binaryWeave("CovBaseProgram01.jar","CovAspect07.aj",0,1); | |||
verifyOutput(cR,new String[]{ | |||
"weaveinfo Type 'CovBaseProgram01' (CovBaseProgram01.java:27) advised by before advice from 'CovAspect07' (CovAspect07.aj:5)" | |||
}); | |||
assertTrue("Expected one xlint warning message for line 26, but got: "+cR.getWarningMessages(), | |||
cR.getWarningMessages().size()==1 && ((IMessage)cR.getWarningMessages().get(0)).toString().indexOf("26")!=-1); | |||
runTest("covariance 7"); | |||
} | |||
/** | |||
@@ -172,128 +143,21 @@ public class CovarianceTests extends AjcTestCase { | |||
* call(FastCar Sub.getCar()) matches on 2nd call | |||
*/ | |||
public void testCOV008() { | |||
CompilationResult cR = binaryWeave("CovBaseProgram01.jar","CovAspect08.aj",0,0); | |||
verifyOutput(cR,new String[]{ | |||
"weaveinfo Type 'CovBaseProgram01' (CovBaseProgram01.java:27) advised by before advice from 'CovAspect08' (CovAspect08.aj:11)", | |||
"weaveinfo Type 'CovBaseProgram01' (CovBaseProgram01.java:27) advised by before advice from 'CovAspect08' (CovAspect08.aj:5)" | |||
}); | |||
runTest("covariance 8"); | |||
} | |||
/** | |||
* call(FastCar Super.getCar()) matches nothing | |||
*/ | |||
public void testCOV009() { | |||
CompilationResult cR = binaryWeave("CovBaseProgram01.jar","CovAspect09.aj",0,0); | |||
verifyOutput(cR,new String[]{/* No matches */}); | |||
assertTrue("Expected no warnings but got: "+cR.getWarningMessages(),cR.getWarningMessages().size()==0); | |||
runTest("covariance 9"); | |||
} | |||
/** | |||
* call(Car+ getCar()) matches both | |||
*/ | |||
public void testCOV010() { | |||
CompilationResult cR = binaryWeave("CovBaseProgram01.jar","CovAspect10.aj",0,0); | |||
verifyOutput(cR,new String[]{ | |||
"weaveinfo Type 'CovBaseProgram01' (CovBaseProgram01.java:26) advised by before advice from 'CovAspect10' (CovAspect10.aj:5)", | |||
"weaveinfo Type 'CovBaseProgram01' (CovBaseProgram01.java:27) advised by before advice from 'CovAspect10' (CovAspect10.aj:5)" | |||
}); | |||
runTest("covariance 10"); | |||
} | |||
//-------------------------------------------------------------------------------- | |||
//-------------------------------------------------------------------------------- | |||
//-------------------------------------------------------------------------------- | |||
private File baseDir; | |||
protected void setUp() throws Exception { | |||
super.setUp(); | |||
baseDir = new File("../tests/java5/covariance"); | |||
} | |||
private CompilationResult binaryWeave(String inpath, String insource,int expErrors,int expWarnings) { | |||
String[] args = new String[] {"-inpath",inpath,insource,"-showWeaveInfo"}; | |||
CompilationResult result = ajc(baseDir,args); | |||
if (verbose || result.hasErrorMessages()) System.out.println(result); | |||
assertTrue("Expected "+expErrors+" errors but got "+result.getErrorMessages().size()+":\n"+ | |||
formatCollection(result.getErrorMessages()),result.getErrorMessages().size()==expErrors); | |||
assertTrue("Expected "+expWarnings+" warnings but got "+result.getWarningMessages().size()+":\n"+ | |||
formatCollection(result.getWarningMessages()),result.getWarningMessages().size()==expWarnings); | |||
return result; | |||
} | |||
private List getWeavingMessages(List msgs) { | |||
List result = new ArrayList(); | |||
for (Iterator iter = msgs.iterator(); iter.hasNext();) { | |||
IMessage element = (IMessage) iter.next(); | |||
if (element.getKind()==IMessage.WEAVEINFO) { | |||
result.add(element.toString()); | |||
} | |||
} | |||
return result; | |||
} | |||
private void verifyOutput(CompilationResult cR,String[] expected) { | |||
List weavingmessages = getWeavingMessages(cR.getInfoMessages()); | |||
dump(weavingmessages); | |||
for (int i = 0; i < expected.length; i++) { | |||
boolean found = weavingmessages.contains(expected[i]); | |||
if (found) { | |||
weavingmessages.remove(expected[i]); | |||
} else { | |||
System.err.println(dump(getWeavingMessages(cR.getInfoMessages()))); | |||
fail("Expected message not found.\nExpected:\n"+expected[i]+"\nObtained:\n"+dump(getWeavingMessages(cR.getInfoMessages()))); | |||
} | |||
} | |||
if (weavingmessages.size()!=0) { | |||
fail("Unexpected messages obtained from program:\n"+dump(weavingmessages)); | |||
} | |||
} | |||
private String formatCollection(Collection s) { | |||
StringBuffer sb = new StringBuffer(); | |||
for (Iterator iter = s.iterator(); iter.hasNext();) { | |||
Object element = (Object) iter.next(); | |||
sb.append(element).append("\n"); | |||
} | |||
return sb.toString(); | |||
} | |||
private static Set split(String input) { | |||
Set l = new HashSet(); | |||
int idx = 0; | |||
while (input.indexOf("]",idx)!=-1) { | |||
int nextbreak = input.indexOf("]",idx); | |||
String s = input.substring(idx,nextbreak+1); | |||
l.add(s); | |||
idx = input.indexOf("[",nextbreak+1); | |||
if (idx==-1) break; | |||
} | |||
return l; | |||
} | |||
private void copyFile(String fromName) { | |||
copyFile(fromName,fromName); | |||
} | |||
private void copyFile(String from,String to) { | |||
try { | |||
org.aspectj.util.FileUtil.copyFile(new File(baseDir + File.separator + from), | |||
new File(ajc.getSandboxDirectory(),to)); | |||
} catch (IOException ioe) { | |||
ioe.printStackTrace(); | |||
} | |||
} | |||
private String dump(List l) { | |||
StringBuffer sb = new StringBuffer(); | |||
int i =0; | |||
sb.append("--- Weaving Messages ---\n"); | |||
for (Iterator iter = l.iterator(); iter.hasNext();) { | |||
sb.append(i+") "+iter.next()+"\n"); | |||
} | |||
sb.append("------------------------\n"); | |||
return sb.toString(); | |||
} | |||
} |
@@ -12,8 +12,9 @@ package org.aspectj.systemtest.ajc150; | |||
import java.io.File; | |||
import org.aspectj.bridge.IMessage; | |||
import org.aspectj.tools.ajc.CompilationResult; | |||
import junit.framework.Test; | |||
import org.aspectj.testing.XMLBasedAjcTestCase; | |||
/** | |||
@@ -29,64 +30,43 @@ import org.aspectj.tools.ajc.CompilationResult; | |||
* 8. Lint warning if a non-explicit type pattern would match an enum type. | |||
* | |||
*/ | |||
public class Enums extends TestUtils { | |||
protected void setUp() throws Exception { | |||
super.setUp(); | |||
baseDir = new File("../tests/java5/enums"); | |||
} | |||
public class Enums extends XMLBasedAjcTestCase { | |||
public static Test suite() { | |||
return XMLBasedAjcTestCase.loadSuite(Enums.class); | |||
} | |||
protected File getSpecFile() { | |||
return new File("../tests/src/org/aspectj/systemtest/ajc150/ajc150.xml"); | |||
} | |||
// Cannot make ITDC on an enum | |||
public void test001_itdcsOnEnumNotAllowed() { | |||
CompilationResult cR = binaryWeave("testcode.jar","EnumAspect01.aj",1,0); | |||
IMessage msg = (IMessage)cR.getErrorMessages().get(0); | |||
assertTrue("Expected a message about ITDCs not allowed on enums but got: "+msg, | |||
msg.toString().indexOf("can't make inter-type constructor declarations")!=-1); | |||
verifyWeavingMessagesOutput(cR,new String[]{}); | |||
runTest("cant itd constructor on enum"); | |||
} | |||
// Cannot make ITDM or ITDF on an enum | |||
public void test002_itdFieldOrMethodOnEnumNotAllowed() { | |||
CompilationResult cR = binaryWeave("testcode.jar","EnumAspect02.aj",2,0); | |||
IMessage msg1 = (IMessage)cR.getErrorMessages().get(0); | |||
IMessage msg2 = (IMessage)cR.getErrorMessages().get(1); | |||
assertTrue("Expected a message about ITD methods not allowed on enums but got: "+msg1, | |||
msg1.toString().indexOf("can't make inter-type method declarations")!=-1); | |||
assertTrue("Expected a message about ITD fields not allowed on enums but got: "+msg2, | |||
msg2.toString().indexOf("can't make inter-type field declarations")!=-1); | |||
verifyWeavingMessagesOutput(cR,new String[]{}); | |||
runTest("cant itd field or method on enum"); | |||
} | |||
// Deals with the cases where an explicit type is specified and it is an enum type | |||
public void test003_decpOnEnumNotAllowed_errors() { | |||
CompilationResult cR = binaryWeave("testcode.jar","EnumAspect03.aj",4,0,true); | |||
// THE ORDERING CAN BE SENSITIVE HERE... OUGHT TO FIX IT PROPERLY AND ALLOW FOR THEM | |||
// IN ANY POSITION | |||
IMessage msg = (IMessage)cR.getErrorMessages().get(1); | |||
assertTrue("Expected a message about can't use decp to alter supertype of an enum: "+msg, | |||
msg.toString().indexOf("to alter supertype of enum type")!=-1); | |||
msg = (IMessage)cR.getErrorMessages().get(2); | |||
assertTrue("Expected a message about can't use decp to make enum implement interface: "+msg, | |||
msg.toString().indexOf("implement an interface")!=-1); | |||
msg = (IMessage)cR.getErrorMessages().get(0); | |||
assertTrue("Expected a message about can't use decp to make Enum parent of another type: "+msg, | |||
msg.toString().indexOf("the parent of type")!=-1); | |||
msg = (IMessage)cR.getErrorMessages().get(3); | |||
assertTrue("Excpected message about not subclassing Enum: "+msg, | |||
msg.toString().indexOf("The type C may not subclass Enum explicitly")!=-1); | |||
verifyWeavingMessagesOutput(cR,new String[]{}); | |||
runTest("declare parents and enums"); | |||
} | |||
//Deals with the cases where an wild type pattern is specified and it hits an enum type | |||
public void test004_decpOnEnumNotAllowed_xlints() { | |||
CompilationResult cR = binaryWeave("testcode.jar","EnumAspect04.aj",0,2,false); | |||
IMessage msg = (IMessage)cR.getWarningMessages().get(0); | |||
assertTrue("Expected a message about an enum type matching a declare parents but being ignored: "+msg, | |||
msg.toString().indexOf("matches a declare parents type pattern")!=-1); | |||
msg = (IMessage)cR.getWarningMessages().get(1); | |||
assertTrue("Expected a message about an enum type matching a declare parents but being ignored: "+msg, | |||
msg.toString().indexOf("matches a declare parents type pattern")!=-1); | |||
verifyWeavingMessagesOutput(cR,new String[]{}); | |||
runTest("wildcard enum match in itd"); | |||
} | |||
// CompilationResult cR = binaryWeave("testcode.jar","EnumAspect04.aj",0,2,false); | |||
// IMessage msg = (IMessage)cR.getWarningMessages().get(0); | |||
// assertTrue("Expected a message about an enum type matching a declare parents but being ignored: "+msg, | |||
// msg.toString().indexOf("matches a declare parents type pattern")!=-1); | |||
// msg = (IMessage)cR.getWarningMessages().get(1); | |||
// assertTrue("Expected a message about an enum type matching a declare parents but being ignored: "+msg, | |||
// msg.toString().indexOf("matches a declare parents type pattern")!=-1); | |||
// verifyWeavingMessagesOutput(cR,new String[]{}); | |||
// } | |||
} |
@@ -12,19 +12,23 @@ package org.aspectj.systemtest.ajc150; | |||
import java.io.File; | |||
import org.aspectj.tools.ajc.CompilationResult; | |||
import junit.framework.Test; | |||
import org.aspectj.testing.XMLBasedAjcTestCase; | |||
/** | |||
* Checks if we are obeying migration rules. | |||
*/ | |||
public class MigrationTests extends TestUtils { | |||
protected void setUp() throws Exception { | |||
super.setUp(); | |||
baseDir = new File("../tests/migration"); | |||
} | |||
public class MigrationTests extends XMLBasedAjcTestCase { | |||
public static Test suite() { | |||
return XMLBasedAjcTestCase.loadSuite(MigrationTests.class); | |||
} | |||
protected File getSpecFile() { | |||
return new File("../tests/src/org/aspectj/systemtest/ajc150/ajc150.xml"); | |||
} | |||
/** | |||
* Compile a simple java class with an aspect library built with aspectj 1.2.1 - this | |||
* checks that we can load in attributes (especially pointcuts) that were written out | |||
@@ -32,13 +36,14 @@ public class MigrationTests extends TestUtils { | |||
* | |||
*/ | |||
public void testMigrationFrom121_pointcutsAndAdvice() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"-aspectpath","aspects121.jar","Program.java"}); | |||
System.err.println(cR.getStandardError()); | |||
assertTrue("Should not coredump: "+cR.getStandardError(),cR.getStandardError().indexOf("Dumping to ajcore")==-1); | |||
assertTrue("Should be no error messages: \n"+cR.getErrorMessages(),cR.getErrorMessages().size()==0); | |||
File f = new File(ajc.getSandboxDirectory()+File.separator+"Program.class"); | |||
assertTrue("Missing class file",f.exists()); | |||
run("Program"); | |||
runTest("load aspectj 1.2.1 aspects in aspectj 5"); | |||
// CompilationResult cR = ajc(baseDir,new String[]{"-aspectpath","aspects121.jar","Program.java"}); | |||
// System.err.println(cR.getStandardError()); | |||
// assertTrue("Should not coredump: "+cR.getStandardError(),cR.getStandardError().indexOf("Dumping to ajcore")==-1); | |||
// assertTrue("Should be no error messages: \n"+cR.getErrorMessages(),cR.getErrorMessages().size()==0); | |||
// File f = new File(ajc.getSandboxDirectory()+File.separator+"Program.class"); | |||
// assertTrue("Missing class file",f.exists()); | |||
// run("Program"); | |||
} | |||
// /** |
@@ -11,20 +11,23 @@ | |||
package org.aspectj.systemtest.ajc150; | |||
import java.io.File; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import org.aspectj.bridge.IMessage; | |||
import junit.framework.Test; | |||
import org.aspectj.testing.XMLBasedAjcTestCase; | |||
import org.aspectj.tools.ajc.CompilationResult; | |||
public class PerTypeWithinTests extends TestUtils { | |||
public class PerTypeWithinTests extends XMLBasedAjcTestCase { | |||
protected void setUp() throws Exception { | |||
super.setUp(); | |||
baseDir = new File("../tests/java5/pertypewithin"); | |||
} | |||
public static Test suite() { | |||
return XMLBasedAjcTestCase.loadSuite(PerTypeWithinTests.class); | |||
} | |||
protected File getSpecFile() { | |||
return new File("../tests/src/org/aspectj/systemtest/ajc150/ajc150.xml"); | |||
} | |||
/** | |||
* First few tests: | |||
@@ -41,111 +44,57 @@ public class PerTypeWithinTests extends TestUtils { | |||
* We test these assumptions in A,B,C,D,E. | |||
*/ | |||
public void testDoesItWorkAtAll() { | |||
CompilationResult cR=ajc(baseDir,new String[]{"A.java","B.java","C.java","D.java","Main.java","X.java"}); | |||
assertTrue("Expected no errors:"+cR,!cR.hasErrorMessages()); | |||
// if (verbose) { System.err.println(cR); System.err.println(cR.getStandardError());} | |||
RunResult rR = run("p.A"); | |||
// if (verbose) {System.err.println(rR.getStdErr());} | |||
assertTrue("Expected a report from the aspect about 2 calls to sayhi():"+rR.getStdErr(), | |||
rR.getStdErr().indexOf("callcount = 2")!=-1); | |||
runTest("basic ptw test"); | |||
} | |||
public void testCheckHasAspectWorks() { | |||
CompilationResult cR=ajc(baseDir,new String[]{"A.java","B.java","C.java","D.java","Main.java","X.java"}); | |||
assertTrue("Expected no errors:"+cR,!cR.hasErrorMessages()); | |||
// if (verbose) { System.err.println(cR); System.err.println(cR.getStandardError());} | |||
RunResult rR = run("p.A"); | |||
rR = run("p.B"); | |||
// if (verbose) {System.err.println(rR.getStdErr());} | |||
assertTrue("Expected a report from the aspect about 3 calls to sayhi():"+rR.getStdErr(), | |||
rR.getStdErr().indexOf("callcount = 3")!=-1); | |||
runTest("ptw hasAspect"); | |||
} | |||
public void testCheckAspectOfWorks() { | |||
CompilationResult cR=ajc(baseDir,new String[]{"A.java","B.java","C.java","D.java","Main.java","X.java"}); | |||
assertTrue("Expected no errors:"+cR,!cR.hasErrorMessages()); | |||
// if (verbose) { System.err.println(cR); System.err.println(cR.getStandardError());} | |||
RunResult rR = run("p.A"); | |||
rR = run("p.C"); | |||
// if (verbose) {System.err.println(rR.getStdErr());} | |||
} | |||
runTest("ptw aspectOf"); | |||
} | |||
/** | |||
* Aspects Q and R match P with a pertypewithin() - they shouldn't clash in any way | |||
* | |||
*/ | |||
public void testTwoAspectsHittingOneType() { | |||
CompilationResult cR=ajc(baseDir,new String[]{"P.java","Q.java","R.java"}); | |||
assertTrue("Expected no errors:"+cR,!cR.hasErrorMessages()); | |||
// if (verbose) { System.err.println(cR); System.err.println(cR.getStandardError());} | |||
RunResult rR = run("P"); | |||
// if (verbose) {System.err.println(rR.getStdErr());} | |||
assertTrue("Expected message about Q reporting 2: "+rR.getStdErr(), | |||
rR.getStdErr().indexOf("Q reporting 2")!=-1); | |||
assertTrue("Expected message about R reporting 3: "+rR.getStdErr(), | |||
rR.getStdErr().indexOf("R reporting 3")!=-1); | |||
runTest("ptw multi-aspects"); | |||
} | |||
/** | |||
* Checks the use of pertypewithin() doesn't result in extra join points (i.e. the | |||
* infrastructure is properly hidden in ajc$ or synthetic members) | |||
*/ | |||
public void testPervasivenessOfWeaving() { | |||
CompilationResult cR = ajc(baseDir,new String[]{"U.java","-showWeaveInfo"}); | |||
List l = cR.getInfoMessages(); | |||
int cnt = 0; | |||
for (Iterator iter = l.iterator(); iter.hasNext();) { | |||
IMessage element = (IMessage) iter.next(); | |||
if (element.getKind()==IMessage.WEAVEINFO) { | |||
//System.err.println(element); | |||
cnt++; | |||
} | |||
} | |||
int weavingMessagesFromNormalDeploymentModel = cnt; | |||
//System.err.println(cnt); | |||
CompilationResult cR = ajc(new File("../tests/java5/pertypewithin"),new String[]{"U.java","-showWeaveInfo"}); | |||
int weavingMessagesFromNormalDeploymentModel = cR.getWeaveMessages().size(); | |||
cR = ajc(new File("../tests/java5/pertypewithin"),new String[]{"V.java","-showWeaveInfo"}); | |||
int weavingMessagesFromPerTypeWithin = cR.getWeaveMessages().size(); | |||
cR = ajc(baseDir,new String[]{"V.java","-showWeaveInfo"}); | |||
l = cR.getInfoMessages(); | |||
cnt = 0; | |||
for (Iterator iter = l.iterator(); iter.hasNext();) { | |||
IMessage element = (IMessage) iter.next(); | |||
if (element.getKind()==IMessage.WEAVEINFO) { | |||
//System.err.println(element); | |||
cnt++; | |||
} | |||
} | |||
int weavingMessagesFromPerTypeWithin = cnt; | |||
//System.err.println(cnt); | |||
if (weavingMessagesFromNormalDeploymentModel!=weavingMessagesFromPerTypeWithin) | |||
fail("Expected same number of messages regardless of perclause but got "+ | |||
weavingMessagesFromNormalDeploymentModel+" and "+weavingMessagesFromPerTypeWithin); | |||
assertEquals("Expected same number of messages regardless of perclause", | |||
weavingMessagesFromNormalDeploymentModel,weavingMessagesFromPerTypeWithin); | |||
} | |||
public void testBinaryWeaving_ClassesAreBinary() { | |||
// Compile the 'ordinary' class G.java into classes | |||
CompilationResult cR = ajc(baseDir,new String[]{"G.java","-d","classes2"}); | |||
setShouldEmptySandbox(false); | |||
// Compile the aspect with G.class as input, should be binary woven correctly | |||
cR = ajc(baseDir,new String[]{"H.java","-inpath","classes2"}); | |||
RunResult rR = run("G"); | |||
assertTrue("Expected aspect related message 'advice running' in output from G", | |||
rR.getStdErr().indexOf("advice running")!=-1); | |||
setShouldEmptySandbox(true); | |||
} | |||
public void testBinaryWeaving_AspectsAreBinary() { | |||
// Compile the aspect H.java into classes3 | |||
CompilationResult cR = ajc(baseDir,new String[]{"H.java","-outjar","aspects.jar"}); | |||
setShouldEmptySandbox(false); | |||
// Compile the class with H.class as aspectpath, should be binary woven correctly | |||
cR = ajc(baseDir,new String[]{"G.java","-aspectpath","aspects.jar"}); | |||
RunResult rR = run("G"); | |||
assertTrue("Expected aspect related message 'advice running' in output from G", | |||
rR.getStdErr().indexOf("advice running")!=-1); | |||
setShouldEmptySandbox(true); | |||
public void testBinaryWeaving_ClassesAreBinary() { | |||
runTest("ptw binary"); | |||
} | |||
// binary weaving case ... | |||
public void testBinaryWeaving_AspectsAreBinary() { | |||
runTest("ptw binary aspect"); | |||
} | |||
// // Compile the aspect H.java into classes3 | |||
// CompilationResult cR = ajc(new File("../tests/java5/pertypewithin"),new String[]{"H.java","-outjar","aspects.jar"}); | |||
// setShouldEmptySandbox(false); | |||
// // Compile the class with H.class as aspectpath, should be binary woven correctly | |||
// cR = ajc(new File("../tests/java5/pertypewithin"),new String[]{"G.java","-aspectpath","aspects.jar"}); | |||
// RunResult rR = run("G"); | |||
// assertTrue("Expected aspect related message 'advice running' in output from G", | |||
// rR.getStdErr().indexOf("advice running")!=-1); | |||
// setShouldEmptySandbox(true); | |||
// } | |||
// | |||
// // binary weaving case ... | |||
} |
@@ -1,135 +0,0 @@ | |||
/******************************************************************************* | |||
* Copyright (c) 2004 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/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Andy Clement - initial implementation | |||
*******************************************************************************/ | |||
package org.aspectj.systemtest.ajc150; | |||
import java.io.File; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import org.aspectj.apache.bcel.classfile.JavaClass; | |||
import org.aspectj.apache.bcel.util.ClassPath; | |||
import org.aspectj.apache.bcel.util.SyntheticRepository; | |||
import org.aspectj.bridge.IMessage; | |||
import org.aspectj.tools.ajc.AjcTestCase; | |||
import org.aspectj.tools.ajc.CompilationResult; | |||
public abstract class TestUtils extends AjcTestCase { | |||
protected static final boolean verbose = false; | |||
protected File baseDir; | |||
protected CompilationResult binaryWeave(String inpath,String insource,int expErrors,int expWarnings) { | |||
return binaryWeave(inpath,insource,expErrors,expWarnings,false); | |||
} | |||
protected CompilationResult binaryWeave(String inpath, String insource,int expErrors,int expWarnings,boolean xlinterror) { | |||
return binaryWeave(inpath,insource,expErrors,expWarnings,xlinterror,(String[])null); | |||
} | |||
protected CompilationResult binaryWeave(String inpath, String insource,int expErrors,int expWarnings,String extraOption) { | |||
return binaryWeave(inpath,insource,expErrors,expWarnings,false,extraOption); | |||
} | |||
protected CompilationResult binaryWeave(String inpath, String insource,int expErrors,int expWarnings,boolean xlinterror,String extraOption) { | |||
return binaryWeave(inpath, insource, expErrors, expWarnings,xlinterror,new String[] {extraOption}); | |||
} | |||
protected CompilationResult binaryWeave(String inpath, String insource,int expErrors,int expWarnings,boolean xlinterror,String[] extraOptions) { | |||
String[] args = null; | |||
if (xlinterror) { | |||
if (extraOptions!=null && extraOptions.length > 0) { | |||
String[] firstargs = new String[] {"-inpath",inpath,insource,"-showWeaveInfo","-proceedOnError","-Xlint:warning"}; | |||
args = new String[firstargs.length + extraOptions.length]; | |||
System.arraycopy(firstargs,0,args,0,firstargs.length); | |||
System.arraycopy(extraOptions,0,args,firstargs.length,extraOptions.length); | |||
} | |||
else | |||
args = new String[] {"-inpath",inpath,insource,"-showWeaveInfo","-proceedOnError","-Xlint:warning"}; | |||
} else { | |||
if (extraOptions!=null && extraOptions.length>0) { | |||
String[] firstargs = new String[] {"-inpath",inpath,insource,"-showWeaveInfo","-proceedOnError"}; | |||
args = new String[firstargs.length + extraOptions.length]; | |||
System.arraycopy(firstargs,0,args,0,firstargs.length); | |||
System.arraycopy(extraOptions,0,args,firstargs.length,extraOptions.length); | |||
} | |||
else | |||
args = new String[] {"-inpath",inpath,insource,"-showWeaveInfo","-proceedOnError"}; | |||
} | |||
CompilationResult result = ajc(baseDir,args); | |||
if (verbose || result.hasErrorMessages()) System.out.println(result); | |||
assertTrue("Expected "+expErrors+" errors but got "+result.getErrorMessages().size()+":\n"+ | |||
formatCollection(result.getErrorMessages()),result.getErrorMessages().size()==expErrors); | |||
assertTrue("Expected "+expWarnings+" warnings but got "+result.getWarningMessages().size()+":\n"+ | |||
formatCollection(result.getWarningMessages()),result.getWarningMessages().size()==expWarnings); | |||
return result; | |||
} | |||
private String formatCollection(Collection s) { | |||
StringBuffer sb = new StringBuffer(); | |||
for (Iterator iter = s.iterator(); iter.hasNext();) { | |||
Object element = (Object) iter.next(); | |||
sb.append(element).append("\n"); | |||
} | |||
return sb.toString(); | |||
} | |||
protected List getWeavingMessages(List msgs) { | |||
List result = new ArrayList(); | |||
for (Iterator iter = msgs.iterator(); iter.hasNext();) { | |||
IMessage element = (IMessage) iter.next(); | |||
if (element.getKind()==IMessage.WEAVEINFO) { | |||
result.add(element.toString()); | |||
} | |||
} | |||
return result; | |||
} | |||
protected void verifyWeavingMessagesOutput(CompilationResult cR,String[] expected) { | |||
List weavingmessages = getWeavingMessages(cR.getInfoMessages()); | |||
dump(weavingmessages); | |||
for (int i = 0; i < expected.length; i++) { | |||
boolean found = weavingmessages.contains(expected[i]); | |||
if (found) { | |||
weavingmessages.remove(expected[i]); | |||
} else { | |||
System.err.println(dump(getWeavingMessages(cR.getInfoMessages()))); | |||
fail("Expected message not found.\nExpected:\n"+expected[i]+"\nObtained:\n"+dump(getWeavingMessages(cR.getInfoMessages()))); | |||
} | |||
} | |||
if (weavingmessages.size()!=0) { | |||
fail("Unexpected messages obtained from program:\n"+dump(weavingmessages)); | |||
} | |||
} | |||
private String dump(List l) { | |||
StringBuffer sb = new StringBuffer(); | |||
int i =0; | |||
sb.append("--- Weaving Messages ---\n"); | |||
for (Iterator iter = l.iterator(); iter.hasNext();) { | |||
sb.append(i+") "+iter.next()+"\n"); | |||
} | |||
sb.append("------------------------\n"); | |||
return sb.toString(); | |||
} | |||
public SyntheticRepository createRepos(File cpentry) { | |||
ClassPath cp = new ClassPath(cpentry+File.pathSeparator+System.getProperty("java.class.path")); | |||
return SyntheticRepository.getInstance(cp); | |||
} | |||
protected JavaClass getClassFrom(File where,String clazzname) throws ClassNotFoundException { | |||
SyntheticRepository repos = createRepos(where); | |||
return repos.loadClass(clazzname); | |||
} | |||
} |
@@ -12,8 +12,9 @@ package org.aspectj.systemtest.ajc150; | |||
import java.io.File; | |||
import org.aspectj.bridge.IMessage; | |||
import org.aspectj.tools.ajc.CompilationResult; | |||
import junit.framework.Test; | |||
import org.aspectj.testing.XMLBasedAjcTestCase; | |||
/** | |||
@@ -22,73 +23,46 @@ import org.aspectj.tools.ajc.CompilationResult; | |||
* 1. cannot match on a varargs method by using 'Object[]' in your signature, | |||
* this affects call/execution/initialization/withincode | |||
*/ | |||
public class VarargsTests extends TestUtils { | |||
protected void setUp() throws Exception { | |||
super.setUp(); | |||
baseDir = new File("../tests/java5/varargs"); | |||
} | |||
public class VarargsTests extends XMLBasedAjcTestCase { | |||
public static Test suite() { | |||
return XMLBasedAjcTestCase.loadSuite(VarargsTests.class); | |||
} | |||
protected File getSpecFile() { | |||
return new File("../tests/src/org/aspectj/systemtest/ajc150/ajc150.xml"); | |||
} | |||
// check when signature is from a call PCD | |||
// should get message: | |||
// "an array type as the last parameter in a signature does not match on the varargs declared method: <blah>" | |||
public void test001_cantMatchVarargsWithObjectArray_callPCD() { | |||
CompilationResult cR = binaryWeave("testcode.jar","VarargsAspect01.aj",0,3,true); | |||
assertTrue("Did not get expected message about a varargs mismatch, instead got: "+cR.getWarningMessages(), | |||
((IMessage)cR.getWarningMessages().get(0)).toString().indexOf("varargs declared method")!=-1); | |||
verifyWeavingMessagesOutput(cR,new String[]{}); | |||
runTest("varargs not matched by Object[] (call)"); | |||
} | |||
// check when signature is from an execution PCD | |||
public void test002_cantMatchVarargsWithObjectArray_execPCD() { | |||
CompilationResult cR = binaryWeave("testcode.jar","VarargsAspect02.aj",0,1,true); | |||
assertTrue("Did not get expected message about a varargs mismatch, instead got: "+cR.getWarningMessages(), | |||
((IMessage)cR.getWarningMessages().get(0)).toString().indexOf("varargs declared method")!=-1); | |||
verifyWeavingMessagesOutput(cR,new String[]{}); | |||
runTest("varargs not matched by Object[] (exe)"); | |||
} | |||
// check when signature is from an initialization PCD | |||
public void test003_cantMatchVarargsWithObjectArray_initPCD() { | |||
CompilationResult cR = binaryWeave("testcode.jar","VarargsAspect03.aj",0,1,true); | |||
assertTrue("Did not get expected message about a varags mismatch, instead got: "+cR.getWarningMessages(), | |||
((IMessage)cR.getWarningMessages().get(0)).toString().indexOf("varargs declared method")!=-1); | |||
verifyWeavingMessagesOutput(cR,new String[]{}); | |||
runTest("varargs not matched by Object[] (init)"); | |||
} | |||
// check when signature is from an withincode PCD | |||
public void test003_cantMatchVarargsWithObjectArray_withincodePCD() { | |||
CompilationResult cR = binaryWeave("testcode.jar","VarargsAspect04.aj",0,1,true); | |||
assertTrue("Did not get expected message about a varargs mismatch, instead got: "+cR.getWarningMessages(), | |||
((IMessage)cR.getWarningMessages().get(0)).toString().indexOf("varargs declared method")!=-1); | |||
verifyWeavingMessagesOutput(cR,new String[]{}); | |||
runTest("varargs not matched by Object[] (withincode)"); | |||
} | |||
// before(): call(* *(Integer...)) { } | |||
public void test_usingVarargsInPointcuts1() { | |||
CompilationResult cR = binaryWeave("testcode.jar","VarargsAspect05.aj",0,0,true); | |||
System.err.println(cR.getStandardError()); | |||
System.err.println(cR.getErrorMessages()); | |||
System.err.println(cR.getInfoMessages()); | |||
verifyWeavingMessagesOutput(cR,new String[]{ | |||
"weaveinfo Type 'SimpleVarargs' (SimpleVarargs.java:20) advised by before advice from 'VarargsAspect05' (VarargsAspect05.aj:3)", | |||
"weaveinfo Type 'SimpleVarargs' (SimpleVarargs.java:21) advised by before advice from 'VarargsAspect05' (VarargsAspect05.aj:3)", | |||
"weaveinfo Type 'SimpleVarargs' (SimpleVarargs.java:22) advised by before advice from 'VarargsAspect05' (VarargsAspect05.aj:3)"}); | |||
runTest("call with varargs signature"); | |||
} | |||
// before(): call(* *(int,Integer...)) { } - slightly more complex pcut | |||
public void test_usingVarargsInPointcuts2() { | |||
CompilationResult cR = binaryWeave("testcode.jar","VarargsAspect06.aj",0,0,true); | |||
System.err.println(cR.getStandardError()); | |||
System.err.println(cR.getErrorMessages()); | |||
System.err.println(cR.getInfoMessages()); | |||
verifyWeavingMessagesOutput(cR,new String[]{ | |||
"weaveinfo Type 'SimpleVarargs' (SimpleVarargs.java:25) advised by before advice from 'VarargsAspect06' (VarargsAspect06.aj:3)", | |||
"weaveinfo Type 'SimpleVarargs' (SimpleVarargs.java:26) advised by before advice from 'VarargsAspect06' (VarargsAspect06.aj:3)", | |||
"weaveinfo Type 'SimpleVarargs' (SimpleVarargs.java:27) advised by before advice from 'VarargsAspect06' (VarargsAspect06.aj:3)"}); | |||
} | |||
runTest("call with varargs multi-signature"); | |||
} | |||
} |
@@ -1,31 +0,0 @@ | |||
<!-- AspectJ v1.5.0 Tests --> | |||
<ajc-test dir="java5/bridgeMethods" pr="72766" title="Ignore bridge methods"> | |||
<compile files="AspectX.aj" inpath="testcode.jar" options="-showWeaveInfo"> | |||
<message kind="warning" line="7" text="pointcut did not match on the method call to a bridge method."/> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="decp" pr="80249" title="Order of types passed to compiler determines weaving behavior"> | |||
<compile files="A.java,B.java,AspectX.java"/> | |||
<run class="B"/> | |||
<compile files="B.java,A.java,AspectX.java"/> | |||
<run class="B"/> | |||
</ajc-test> | |||
<ajc-test dir="bugs" pr="61568" title="Various kinds of ambiguous bindings"> | |||
<compile files="AmbiguousBindings.aj"> | |||
<message line="17" text="ambiguous binding of parameter(s) foo across '||' in pointcut"></message> | |||
<message line="19" text="ambiguous binding of parameter(s) foo across '||' in pointcut"></message> | |||
<message line="21" text="ambiguous binding of parameter(s) foo across '||' in pointcut"></message> | |||
<message line="23" text="ambiguous binding of parameter(s) x across '||' in pointcut"></message> | |||
<message line="25" text="ambiguous binding of parameter(s) foo across '||' in pointcut"></message> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="bugs" pr="61658" title="ambiguous args"> | |||
<compile files="PR61658.java"> | |||
<message line="17" text="ambiguous binding of parameter(s) a, b across '||' in pointcut"></message> | |||
</compile> | |||
</ajc-test> |
@@ -1,12 +1,901 @@ | |||
<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[ | |||
<!ENTITY tests SYSTEM "../tests/src/org/aspectj/systemtest/ajc150/ajc150-tests.xml"> | |||
]> | |||
<!-- AspectJ v1.5.0 Tests --> | |||
<suite> | |||
&tests; | |||
<ajc-test dir="java5/bridgeMethods" pr="72766" title="Ignore bridge methods"> | |||
<compile files="AspectX.aj" inpath="testcode.jar" options="-showWeaveInfo"> | |||
<message kind="warning" line="7" text="pointcut did not match on the method call to a bridge method."/> | |||
<message kind="weave" text="(AspectX.aj:18) advised by before advice from 'AspectX'"/> | |||
<message kind="weave" text="(Number.java:5) advised by before advice from 'AspectX'"/> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="migration" title="load aspectj 1.2.1 aspects in aspectj 5"> | |||
<compile files="Program.java" aspectpath="aspects121.jar"> | |||
</compile> | |||
<run class="Program"/> | |||
</ajc-test> | |||
<ajc-test dir="bugs/java5/arrayCloning" pr="72150" vm="1.5" | |||
title="AJC possible bug with static nested classes"> | |||
<compile files="A.java,C.java" options="-1.5,-showWeaveInfo"> | |||
<message kind="weave" text="Type 'C' (C.java:14) advised by around advice from 'A' (A.java:2)"/> | |||
</compile> | |||
<run class="C"/> | |||
</ajc-test> | |||
<ajc-test dir="decp" pr="80249" title="Order of types passed to compiler determines weaving behavior"> | |||
<compile files="A.java,B.java,AspectX.java"/> | |||
<run class="B"/> | |||
<compile files="B.java,A.java,AspectX.java"/> | |||
<run class="B"/> | |||
</ajc-test> | |||
<ajc-test dir="bugs" pr="61568" title="Various kinds of ambiguous bindings"> | |||
<compile files="AmbiguousBindings.aj"> | |||
<message line="17" text="ambiguous binding of parameter(s) foo across '||' in pointcut"></message> | |||
<message line="19" text="ambiguous binding of parameter(s) foo across '||' in pointcut"></message> | |||
<message line="21" text="ambiguous binding of parameter(s) foo across '||' in pointcut"></message> | |||
<message line="23" text="ambiguous binding of parameter(s) x across '||' in pointcut"></message> | |||
<message line="25" text="ambiguous binding of parameter(s) foo across '||' in pointcut"></message> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="bugs" pr="61658" title="ambiguous args"> | |||
<compile files="PR61658.java"> | |||
<message line="17" text="ambiguous binding of parameter(s) a, b across '||' in pointcut"></message> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="bugs150" pr="78021" title="Injecting exception into while loop with break statement causes catch block to be ignored"> | |||
<compile files="PR78021.java"/> | |||
<run class="PR78021"/> | |||
</ajc-test> | |||
<ajc-test dir="bugs150" pr="79554" title="Return in try-block disables catch-block if final-block is present"> | |||
<compile files="PR79554.java"/> | |||
<run class="PR79554"/> | |||
</ajc-test> | |||
<ajc-test dir="bugs150" pr="82570" title="Weaved code does not include debug lines"> | |||
<compile files="PR82570_1.java"/> | |||
</ajc-test> | |||
<ajc-test dir="bugs150" pr="83303" title="compiler error when mixing inheritance, overriding and polymorphism"> | |||
<compile files="PR83303.java"/> | |||
</ajc-test> | |||
<ajc-test dir="bugs150" pr="83563" title="pertypewithin() handing of inner classes (1)"> | |||
<compile files="PR83563_1.java"/> | |||
<run class="PR83563_1"/> | |||
</ajc-test> | |||
<ajc-test dir="bugs150" pr="83563" title="pertypewithin() handing of inner classes (2)"> | |||
<compile files="PR83563_2.java"/> | |||
<run class="PR83563_2"/> | |||
</ajc-test> | |||
<ajc-test dir="bugs150" pr="83645" title="pertypewithin({interface}) illegal field modifier"> | |||
<compile files="PR83645.java"/> | |||
<run class="PR83645"/> | |||
</ajc-test> | |||
<ajc-test dir="bugs150" title="bad asm for enums" vm="1.5"> | |||
<compile files="Rainbow.java" options="-emacssym,-1.5"/> | |||
</ajc-test> | |||
<!-- Annotation binding tests --> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="call annotation binding 1"> | |||
<compile files="CallAnnBinding.aj" options="-1.5"/> | |||
<run class="CallAnnBinding"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="call annotation binding 2"> | |||
<compile files="CallAnnBinding2.aj" options="-1.5"/> | |||
<run class="CallAnnBinding2"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="call annotation binding 3"> | |||
<compile files="CallAnnBinding3.aj" options="-1.5"/> | |||
<run class="CallAnnBinding3"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="call annotation binding 4"> | |||
<compile files="CallAnnBinding4.aj" options="-1.5"/> | |||
<run class="CallAnnBinding4"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="call annotation binding 5"> | |||
<compile files="CallAnnBinding5.aj" options="-1.5"/> | |||
<run class="CallAnnBinding5"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="call annotation binding 6"> | |||
<compile files="CallAnnBinding6.aj" options="-1.5"/> | |||
<run class="CallAnnBinding6"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="call annotation binding 7"> | |||
<compile files="CallAnnBinding7.aj" options="-1.5"/> | |||
<run class="CallAnnBinding7"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="@target annotation binding 1"> | |||
<compile files="AtTarget1.aj" options="-1.5"/> | |||
<run class="AtTarget1"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="@target annotation binding 2"> | |||
<compile files="AtTarget2.aj" options="-1.5"/> | |||
<run class="AtTarget2"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="@target annotation binding 3"> | |||
<compile files="AtTarget3.aj" options="-1.5"/> | |||
<run class="AtTarget3"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="@target annotation binding 4"> | |||
<compile files="AtTarget4.aj" options="-1.5"/> | |||
<run class="AtTarget4"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding/usingPackageNames" vm="1.5" title="@target annotation binding 5"> | |||
<compile files="MyAspect.aj,MyAnnotation.java,MyClass.java" options="-1.5"/> | |||
<run class="test.MyClass"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="@this annotation binding 1"> | |||
<compile files="AtThis1.aj" options="-1.5"/> | |||
<run class="AtThis1"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="@this annotation binding 2"> | |||
<compile files="AtThis2.aj" options="-1.5"/> | |||
<run class="AtThis2"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="@this annotation binding 3"> | |||
<compile files="AtThis3.aj" options="-1.5"/> | |||
<run class="AtThis3"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="@this annotation binding 4"> | |||
<compile files="AtThis4.aj" options="-1.5"/> | |||
<run class="AtThis4"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="@this annotation binding 5"> | |||
<compile files="AtThis5.aj" options="-1.5"/> | |||
<run class="AtThis5"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="@args annotation binding 1"> | |||
<compile files="AtArgs1.aj" options="-1.5"/> | |||
<run class="AtArgs1"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="@args annotation binding 2"> | |||
<compile files="AtArgs2.aj" options="-1.5"/> | |||
<run class="AtArgs2"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="@args annotation binding 3"> | |||
<compile files="AtArgs3.aj" options="-1.5"/> | |||
<run class="AtArgs3"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="@args annotation binding 4"> | |||
<compile files="AtArgs4.aj" options="-1.5"/> | |||
<run class="AtArgs4"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="@args annotation binding 5"> | |||
<compile files="AtArgs5.aj" options="-1.5"/> | |||
<run class="AtArgs5"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="execution and @annotation"> | |||
<compile files="ExecutionAnnBinding1.aj" options="-1.5"/> | |||
<run class="ExecutionAnnBinding1"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="set and @annotation"> | |||
<compile files="FieldAnnBinding1.aj" options="-1.5"/> | |||
<run class="FieldAnnBinding1"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="get and @annotation"> | |||
<compile files="FieldAnnBinding2.aj" options="-1.5"/> | |||
<run class="FieldAnnBinding2"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="get and @annotation with arrays"> | |||
<compile files="FieldAnnBinding3.aj" options="-1.5"/> | |||
<run class="FieldAnnBinding3"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="cons call and @annotation"> | |||
<compile files="CtorAnnBinding1.aj" options="-1.5"/> | |||
<run class="CtorAnnBinding1"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="cons exe and @annotation"> | |||
<compile files="CtorAnnBinding2.aj" options="-1.5"/> | |||
<run class="CtorAnnBinding2"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="staticinit and @annotation"> | |||
<compile files="StaticInitBinding.aj" options="-1.5"/> | |||
<run class="StaticInitBinding"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="preinit and @annotation"> | |||
<compile files="PreInitBinding.aj" options="-1.5"/> | |||
<run class="PreInitBinding"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="init and @annotation"> | |||
<compile files="InitBinding.aj" options="-1.5"/> | |||
<run class="InitBinding"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="adviceexecution and @annotation"> | |||
<compile files="AdviceExecBinding.aj" options="-1.5"/> | |||
<run class="AdviceExecBinding"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="handler and @annotation"> | |||
<compile files="HandlerBinding.aj" options="-1.5"/> | |||
<run class="HandlerBinding"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding/complexExample" vm="1.5" title="packages and no binding"> | |||
<compile files="A.java,B.java,Color.java,X.java" options="-1.5"/> | |||
<run class="a.b.c.A"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding/complexExample" vm="1.5" title="packages and binding"> | |||
<compile files="A.java,B.java,Color.java,X2.java" options="-1.5"/> | |||
<run class="a.b.c.A"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding" vm="1.5" title="binding with static methods"> | |||
<compile files="StaticMethods.java" options="-1.5"/> | |||
<run class="StaticMethods"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations" vm="1.5" title="annotation matching on call"> | |||
<weave classesFiles="AnnotatedType.java,SimpleAnnotation.java,SimpleAnnotation2.java" | |||
aspectsFiles="AnnotationAspect02.aj" | |||
options="-1.5,-showWeaveInfo"> | |||
<message kind="weave" text="Type 'AnnotatedType' (AnnotatedType.java:3) advised by before advice from 'AnnotationAspect02' (AnnotationAspect02.aj:4)"/> | |||
<message kind="weave" text="Type 'AnnotatedType' (AnnotatedType.java:3) advised by before advice from 'AnnotationAspect02' (AnnotationAspect02.aj:2)"/> | |||
<message kind="weave" text="Type 'AnnotatedType' (AnnotatedType.java:4) advised by before advice from 'AnnotationAspect02' (AnnotationAspect02.aj:4)"/> | |||
</weave> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations" vm="1.5" title="at annotation matching"> | |||
<weave classesFiles="AnnotatedType.java,SimpleAnnotation.java,SimpleAnnotation2.java" | |||
aspectsFiles="AnnotationAspect03.aj" | |||
options="-1.5,-showWeaveInfo"> | |||
<message kind="warning" line="8" text="@annotation matched here"/> | |||
</weave> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/within_code" vm="1.5" title="annotations and within(code)"> | |||
<weave classesFiles="TestingAnnotations.java" | |||
aspectsFiles="WithinAndWithinCodeTests.java" | |||
options="-1.5,-showWeaveInfo"> | |||
<message kind="warning" line="31" text="@within match on non-inherited annotation"/> | |||
<message kind="warning" line="39" text="@within match on non-inherited annotation"/> | |||
<message kind="warning" line="39" text="@within match on inheritable annotation"/> | |||
<message kind="warning" line="43" text="@within match on inheritable annotation"/> | |||
<message kind="warning" line="32" text="@withincode match"/> | |||
</weave> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/within" vm="1.5" title="annotations and within"> | |||
<weave classesFiles="PlainWithin.java" | |||
aspectsFiles="PlainWithinTests.java" | |||
options="-1.5,-showWeaveInfo"> | |||
<message kind="warning" line="21" text="positive within match on annotation"/> | |||
<message kind="warning" line="25" text="negative within match on annotation"/> | |||
</weave> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/thisOrtarget" vm="1.5" title="must have runtime retention"> | |||
<compile options="-1.5" files="TestingAnnotations.java,NotRuntimeRetention.aj"> | |||
<message kind="error" line="7" text="Annotation type MyClassRetentionAnnotation does not have runtime retention"/> | |||
<message kind="error" line="13" text="Annotation type MyClassRetentionAnnotation does not have runtime retention"/> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/thisOrtarget" vm="1.5" title="inheritable or not"> | |||
<compile options="-1.5" files="TestingAnnotations.java,ThisOrTargetTests.aj"> | |||
</compile> | |||
<run class="TestingAnnotations"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/thisOrtarget" vm="1.5" title="use of @this/target in deow"> | |||
<compile options="-1.5" files="TestingAnnotations.java,DeclareEoW.java"> | |||
<message kind="error" line="3" text="this() pointcut designator cannot be used in declare statement"/> | |||
<message kind="error" line="5" text="target() pointcut designator cannot be used in declare statement"/> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/args" vm="1.5" title="@args tests"> | |||
<compile options="-1.5" files="TestingArgsAnnotations.java,AtArgsAspect.java"> | |||
</compile> | |||
<run class="TestingArgsAnnotations"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/args" vm="1.5" title="use of @args in deow"> | |||
<compile options="-1.5" files="TestingArgsAnnotations.java,DeclareEoW.java"> | |||
<message kind="error" line="3" text="args() pointcut designator cannot be used in declare statement"/> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations" vm="1.5" title="compiling an annotation"> | |||
<compile options="-1.5" files="SimpleAnnotation.java"> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations" vm="1.5" title="compiling annotated file"> | |||
<compile options="-1.5" files="SimpleAnnotation.java,AnnotatedType.java"> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/within" vm="1.5" title="annotations and within (src)"> | |||
<compile files="PlainWithin.java,PlainWithinTests.java" | |||
aspectsFiles="PlainWithinTests.java" | |||
options="-1.5"> | |||
<message kind="warning" line="21" text="positive within match on annotation"/> | |||
<message kind="warning" line="25" text="negative within match on annotation"/> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/attarget" vm="1.5" title="losing annotations..."> | |||
<compile options="-1.5" files="Program.java,AtTargetAspect.java"> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations" vm="1.5" title="no itds on annotation types"> | |||
<compile files="AnnotatedType.java,SimpleAnnotation.java,SimpleAnnotation2.java,AnnotationAspect01.aj" | |||
options="-1.5"> | |||
<message kind="error" line="4" text="can't make inter-type constructor declarations"/> | |||
<message kind="error" line="8" text="can't make inter-type method declarations"/> | |||
<message kind="error" line="13" text="can't make inter-type field declarations"/> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations" vm="1.5" title="no declare parents on annotation types"> | |||
<compile files="AnnotatedType.java,SimpleAnnotation.java,SimpleAnnotation2.java,AnnotationAspect04.aj" | |||
options="-1.5"> | |||
<message kind="error" line="7" text="can't use declare parents to alter supertype of annotation type SimpleAnnotation"/> | |||
<message kind="error" line="10" text="can't use declare parents to make 'java.lang.annotation.Annotation' the parent of type"/> | |||
<message kind="error" line="4" text="can't use declare parents to make annotation type SimpleAnnotation implement an interface"/> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations" vm="1.5" title="declare parents wildcards matching annotation types"> | |||
<compile files="AnnotatedType.java,SimpleAnnotation.java,SimpleAnnotation2.java,AnnotationAspect05.aj" | |||
options="-1.5"> | |||
<message kind="warning" line="4" text="annotation type SimpleAnnotation2 matches a declare parents type pattern but is being ignored"/> | |||
<message kind="warning" line="4" text="annotation type SimpleAnnotation matches a declare parents type pattern but is being ignored"/> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding/complexExample" vm="1.5" title="annotated any pattern"> | |||
<compile files="A.java,B.java,C.java,Color.java,X3.java" | |||
options="-1.5"> | |||
</compile> | |||
<run class="g.h.i.C"/> | |||
<run class="a.b.c.A"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/annotations/binding/complexExample" vm="1.5" title="annotation not imported"> | |||
<compile files="A.java,B.java,C.java,Color.java,X4.java" | |||
options="-1.5"> | |||
<message kind="warning" line="6" text="no match for this type name: Color"/> | |||
</compile> | |||
<run class="a.b.c.A"/> | |||
</ajc-test> | |||
<!-- ======================================================================================= --> | |||
<!-- Autoboxing tests --> | |||
<!-- ======================================================================================= --> | |||
<ajc-test dir="java5/autoboxing" vm="1.5" title="simple boxing test"> | |||
<compile files="AutoboxingB.java,AutoboxingC.java,AutoboxingD.java,AutoboxingF.java,AutoboxingI.java,AutoboxingJ.java,AutoboxingS.java,AutoboxingZ.java,SimpleAutoboxing.java,SimpleAutoboxingAspect.aj" | |||
options="-1.5,-showWeaveInfo"> | |||
<message kind="weave" text="Type 'SimpleAutoboxing' (SimpleAutoboxing.java:7) advised by before advice from 'SimpleAutoboxingAspect' (SimpleAutoboxingAspect.aj:8)"/> | |||
<message kind="weave" text="Type 'SimpleAutoboxing' (SimpleAutoboxing.java:7) advised by before advice from 'SimpleAutoboxingAspect' (SimpleAutoboxingAspect.aj:4)"/> | |||
</compile> | |||
<run class="SimpleAutoboxing"> | |||
<stderr> | |||
<line text="Matching by Integer:20000"/> | |||
<line text="Matching by int:20000"/> | |||
<line text="method_takes_Integer=20000"/> | |||
</stderr> | |||
</run> | |||
</ajc-test> | |||
<ajc-test dir="java5/autoboxing" vm="1.5" title="integer boxing"> | |||
<compile files="AutoboxingB.java,AutoboxingC.java,AutoboxingD.java,AutoboxingF.java,AutoboxingI.java,AutoboxingJ.java,AutoboxingS.java,AutoboxingZ.java,SimpleAutoboxing.java,AspectInteger.aj" | |||
options="-1.5,-showWeaveInfo"> | |||
<message kind="weave" text="Type 'AutoboxingI' (AutoboxingI.java:11) advised by before advice from 'AspectInteger' (AspectInteger.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingI' (AutoboxingI.java:11) advised by before advice from 'AspectInteger' (AspectInteger.aj:4)"/> | |||
<message kind="weave" text="Type 'AutoboxingI' (AutoboxingI.java:12) advised by before advice from 'AspectInteger' (AspectInteger.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingI' (AutoboxingI.java:12) advised by before advice from 'AspectInteger' (AspectInteger.aj:4)"/> | |||
<message kind="weave" text="Type 'AutoboxingI' (AutoboxingI.java:13) advised by before advice from 'AspectInteger' (AspectInteger.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingI' (AutoboxingI.java:13) advised by before advice from 'AspectInteger' (AspectInteger.aj:4)"/> | |||
<message kind="weave" text="Type 'AutoboxingI' (AutoboxingI.java:14) advised by before advice from 'AspectInteger' (AspectInteger.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingI' (AutoboxingI.java:14) advised by before advice from 'AspectInteger' (AspectInteger.aj:4)"/> | |||
</compile> | |||
<run class="AutoboxingI"> | |||
<stderr> | |||
<line text="Matching by Integer:10000"/> | |||
<line text="Matching by int:10000"/> | |||
<line text="method_takes_Integer=10000"/> | |||
<line text="Matching by Integer:20000"/> | |||
<line text="Matching by int:20000"/> | |||
<line text="method_takes_Integer=20000"/> | |||
<line text="Matching by Integer:30000"/> | |||
<line text="Matching by int:30000"/> | |||
<line text="method_takes_int=30000"/> | |||
<line text="Matching by Integer:40000"/> | |||
<line text="Matching by int:40000"/> | |||
<line text="method_takes_int=40000"/> | |||
</stderr> | |||
</run> | |||
</ajc-test> | |||
<ajc-test dir="java5/autoboxing" vm="1.5" title="char boxing"> | |||
<compile files="AutoboxingB.java,AutoboxingC.java,AutoboxingD.java,AutoboxingF.java,AutoboxingI.java,AutoboxingJ.java,AutoboxingS.java,AutoboxingZ.java,SimpleAutoboxing.java,AspectChar.aj" | |||
options="-1.5,-showWeaveInfo"> | |||
<message kind="weave" text="Type 'AutoboxingC' (AutoboxingC.java:11) advised by before advice from 'AspectChar' (AspectChar.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingC' (AutoboxingC.java:11) advised by before advice from 'AspectChar' (AspectChar.aj:4)"/> | |||
<message kind="weave" text="Type 'AutoboxingC' (AutoboxingC.java:12) advised by before advice from 'AspectChar' (AspectChar.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingC' (AutoboxingC.java:12) advised by before advice from 'AspectChar' (AspectChar.aj:4)"/> | |||
<message kind="weave" text="Type 'AutoboxingC' (AutoboxingC.java:13) advised by before advice from 'AspectChar' (AspectChar.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingC' (AutoboxingC.java:13) advised by before advice from 'AspectChar' (AspectChar.aj:4)"/> | |||
<message kind="weave" text="Type 'AutoboxingC' (AutoboxingC.java:14) advised by before advice from 'AspectChar' (AspectChar.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingC' (AutoboxingC.java:14) advised by before advice from 'AspectChar' (AspectChar.aj:4)"/> | |||
</compile> | |||
<run class="AutoboxingC"> | |||
<stderr> | |||
<line text="Character:1"/> | |||
<line text="char:1"/> | |||
<line text="method_takes_Character=1"/> | |||
<line text="Character:2"/> | |||
<line text="char:2"/> | |||
<line text="method_takes_Character=2"/> | |||
<line text="Character:3"/> | |||
<line text="char:3"/> | |||
<line text="method_takes_char=3"/> | |||
<line text="Character:4"/> | |||
<line text="char:4"/> | |||
<line text="method_takes_char=4"/> | |||
</stderr> | |||
</run> | |||
</ajc-test> | |||
<ajc-test dir="java5/autoboxing" vm="1.5" title="double boxing"> | |||
<compile files="AutoboxingB.java,AutoboxingC.java,AutoboxingD.java,AutoboxingF.java,AutoboxingI.java,AutoboxingJ.java,AutoboxingS.java,AutoboxingZ.java,SimpleAutoboxing.java,AspectDouble.aj" | |||
options="-1.5,-showWeaveInfo"> | |||
<message kind="weave" text="Type 'AutoboxingD' (AutoboxingD.java:11) advised by before advice from 'AspectDouble' (AspectDouble.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingD' (AutoboxingD.java:11) advised by before advice from 'AspectDouble' (AspectDouble.aj:4)"/> | |||
<message kind="weave" text="Type 'AutoboxingD' (AutoboxingD.java:12) advised by before advice from 'AspectDouble' (AspectDouble.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingD' (AutoboxingD.java:12) advised by before advice from 'AspectDouble' (AspectDouble.aj:4)"/> | |||
<message kind="weave" text="Type 'AutoboxingD' (AutoboxingD.java:13) advised by before advice from 'AspectDouble' (AspectDouble.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingD' (AutoboxingD.java:13) advised by before advice from 'AspectDouble' (AspectDouble.aj:4)"/> | |||
<message kind="weave" text="Type 'AutoboxingD' (AutoboxingD.java:14) advised by before advice from 'AspectDouble' (AspectDouble.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingD' (AutoboxingD.java:14) advised by before advice from 'AspectDouble' (AspectDouble.aj:4)"/> | |||
</compile> | |||
<run class="AutoboxingD"> | |||
<stderr> | |||
<line text="Double:100.0"/> | |||
<line text="double:100.0"/> | |||
<line text="method_takes_Double=100.0"/> | |||
<line text="Double:200.0"/> | |||
<line text="double:200.0"/> | |||
<line text="method_takes_Double=200.0"/> | |||
<line text="Double:300.0"/> | |||
<line text="double:300.0"/> | |||
<line text="method_takes_double=300.0"/> | |||
<line text="Double:400.0"/> | |||
<line text="double:400.0"/> | |||
<line text="method_takes_double=400.0"/> | |||
</stderr> | |||
</run> | |||
</ajc-test> | |||
<ajc-test dir="java5/autoboxing" vm="1.5" title="float boxing"> | |||
<compile files="AutoboxingB.java,AutoboxingC.java,AutoboxingD.java,AutoboxingF.java,AutoboxingI.java,AutoboxingJ.java,AutoboxingS.java,AutoboxingZ.java,SimpleAutoboxing.java,AspectFloat.aj" | |||
options="-1.5,-showWeaveInfo"> | |||
<message kind="weave" text="Type 'AutoboxingF' (AutoboxingF.java:11) advised by before advice from 'AspectFloat' (AspectFloat.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingF' (AutoboxingF.java:11) advised by before advice from 'AspectFloat' (AspectFloat.aj:4)"/> | |||
<message kind="weave" text="Type 'AutoboxingF' (AutoboxingF.java:12) advised by before advice from 'AspectFloat' (AspectFloat.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingF' (AutoboxingF.java:12) advised by before advice from 'AspectFloat' (AspectFloat.aj:4)"/> | |||
<message kind="weave" text="Type 'AutoboxingF' (AutoboxingF.java:13) advised by before advice from 'AspectFloat' (AspectFloat.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingF' (AutoboxingF.java:13) advised by before advice from 'AspectFloat' (AspectFloat.aj:4)"/> | |||
<message kind="weave" text="Type 'AutoboxingF' (AutoboxingF.java:14) advised by before advice from 'AspectFloat' (AspectFloat.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingF' (AutoboxingF.java:14) advised by before advice from 'AspectFloat' (AspectFloat.aj:4)"/> | |||
</compile> | |||
<run class="AutoboxingF"> | |||
<stderr> | |||
<line text="Float:100.0"/> | |||
<line text="float:100.0"/> | |||
<line text="method_takes_Float=100.0"/> | |||
<line text="Float:200.0"/> | |||
<line text="float:200.0"/> | |||
<line text="method_takes_Float=200.0"/> | |||
<line text="Float:300.0"/> | |||
<line text="float:300.0"/> | |||
<line text="method_takes_float=300.0"/> | |||
<line text="Float:400.0"/> | |||
<line text="float:400.0"/> | |||
<line text="method_takes_float=400.0"/> | |||
</stderr> | |||
</run> | |||
</ajc-test> | |||
<ajc-test dir="java5/autoboxing" vm="1.5" title="short boxing"> | |||
<compile files="AutoboxingB.java,AutoboxingC.java,AutoboxingD.java,AutoboxingF.java,AutoboxingI.java,AutoboxingJ.java,AutoboxingS.java,AutoboxingZ.java,SimpleAutoboxing.java,AspectShort.aj" | |||
options="-1.5,-showWeaveInfo"> | |||
<message kind="weave" text="Type 'AutoboxingS' (AutoboxingS.java:11) advised by before advice from 'AspectShort' (AspectShort.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingS' (AutoboxingS.java:11) advised by before advice from 'AspectShort' (AspectShort.aj:4)"/> | |||
<message kind="weave" text="Type 'AutoboxingS' (AutoboxingS.java:12) advised by before advice from 'AspectShort' (AspectShort.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingS' (AutoboxingS.java:12) advised by before advice from 'AspectShort' (AspectShort.aj:4)"/> | |||
<message kind="weave" text="Type 'AutoboxingS' (AutoboxingS.java:13) advised by before advice from 'AspectShort' (AspectShort.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingS' (AutoboxingS.java:13) advised by before advice from 'AspectShort' (AspectShort.aj:4)"/> | |||
<message kind="weave" text="Type 'AutoboxingS' (AutoboxingS.java:14) advised by before advice from 'AspectShort' (AspectShort.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingS' (AutoboxingS.java:14) advised by before advice from 'AspectShort' (AspectShort.aj:4)"/> | |||
</compile> | |||
<run class="AutoboxingS"> | |||
<stderr> | |||
<line text="Short:100"/> | |||
<line text="short:100"/> | |||
<line text="method_takes_Short=100"/> | |||
<line text="Short:200"/> | |||
<line text="short:200"/> | |||
<line text="method_takes_Short=200"/> | |||
<line text="Short:300"/> | |||
<line text="short:300"/> | |||
<line text="method_takes_short=300"/> | |||
<line text="Short:400"/> | |||
<line text="short:400"/> | |||
<line text="method_takes_short=400"/> | |||
</stderr> | |||
</run> | |||
</ajc-test> | |||
<ajc-test dir="java5/autoboxing" vm="1.5" title="long boxing"> | |||
<compile files="AutoboxingB.java,AutoboxingC.java,AutoboxingD.java,AutoboxingF.java,AutoboxingI.java,AutoboxingJ.java,AutoboxingS.java,AutoboxingZ.java,SimpleAutoboxing.java,AspectLong.aj" | |||
options="-1.5,-showWeaveInfo"> | |||
<message kind="weave" text="Type 'AutoboxingJ' (AutoboxingJ.java:11) advised by before advice from 'AspectLong' (AspectLong.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingJ' (AutoboxingJ.java:11) advised by before advice from 'AspectLong' (AspectLong.aj:4)"/> | |||
<message kind="weave" text="Type 'AutoboxingJ' (AutoboxingJ.java:12) advised by before advice from 'AspectLong' (AspectLong.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingJ' (AutoboxingJ.java:12) advised by before advice from 'AspectLong' (AspectLong.aj:4)"/> | |||
<message kind="weave" text="Type 'AutoboxingJ' (AutoboxingJ.java:13) advised by before advice from 'AspectLong' (AspectLong.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingJ' (AutoboxingJ.java:13) advised by before advice from 'AspectLong' (AspectLong.aj:4)"/> | |||
<message kind="weave" text="Type 'AutoboxingJ' (AutoboxingJ.java:14) advised by before advice from 'AspectLong' (AspectLong.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingJ' (AutoboxingJ.java:14) advised by before advice from 'AspectLong' (AspectLong.aj:4)"/> | |||
</compile> | |||
<run class="AutoboxingJ"> | |||
<stderr> | |||
<line text="Long:1000000"/> | |||
<line text="long:1000000"/> | |||
<line text="method_takes_Long=1000000"/> | |||
<line text="Long:2000000"/> | |||
<line text="long:2000000"/> | |||
<line text="method_takes_Long=2000000"/> | |||
<line text="Long:3000000"/> | |||
<line text="long:3000000"/> | |||
<line text="method_takes_long=3000000"/> | |||
<line text="Long:4000000"/> | |||
<line text="long:4000000"/> | |||
<line text="method_takes_long=4000000"/> | |||
</stderr> | |||
</run> | |||
</ajc-test> | |||
<ajc-test dir="java5/autoboxing" vm="1.5" title="boolean boxing"> | |||
<compile files="AutoboxingB.java,AutoboxingC.java,AutoboxingD.java,AutoboxingF.java,AutoboxingI.java,AutoboxingJ.java,AutoboxingS.java,AutoboxingZ.java,SimpleAutoboxing.java,AspectBoolean.aj" | |||
options="-1.5,-showWeaveInfo"> | |||
<message kind="weave" text="Type 'AutoboxingZ' (AutoboxingZ.java:9) advised by before advice from 'AspectBoolean' (AspectBoolean.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingZ' (AutoboxingZ.java:9) advised by before advice from 'AspectBoolean' (AspectBoolean.aj:4)"/> | |||
<message kind="weave" text="Type 'AutoboxingZ' (AutoboxingZ.java:10) advised by before advice from 'AspectBoolean' (AspectBoolean.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingZ' (AutoboxingZ.java:10) advised by before advice from 'AspectBoolean' (AspectBoolean.aj:4)"/> | |||
<message kind="weave" text="Type 'AutoboxingZ' (AutoboxingZ.java:11) advised by before advice from 'AspectBoolean' (AspectBoolean.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingZ' (AutoboxingZ.java:11) advised by before advice from 'AspectBoolean' (AspectBoolean.aj:4)"/> | |||
<message kind="weave" text="Type 'AutoboxingZ' (AutoboxingZ.java:12) advised by before advice from 'AspectBoolean' (AspectBoolean.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingZ' (AutoboxingZ.java:12) advised by before advice from 'AspectBoolean' (AspectBoolean.aj:4)"/> | |||
</compile> | |||
<run class="AutoboxingZ"> | |||
<stderr> | |||
<line text="Boolean:false"/> | |||
<line text="boolean:false"/> | |||
<line text="method_takes_Boolean=false"/> | |||
<line text="Boolean:false"/> | |||
<line text="boolean:false"/> | |||
<line text="method_takes_Boolean=false"/> | |||
<line text="Boolean:false"/> | |||
<line text="boolean:false"/> | |||
<line text="method_takes_boolean=false"/> | |||
<line text="Boolean:false"/> | |||
<line text="boolean:false"/> | |||
<line text="method_takes_boolean=false"/> | |||
</stderr> | |||
</run> | |||
</ajc-test> | |||
<ajc-test dir="java5/autoboxing" vm="1.5" title="byte boxing"> | |||
<compile files="AutoboxingB.java,AutoboxingC.java,AutoboxingD.java,AutoboxingF.java,AutoboxingI.java,AutoboxingJ.java,AutoboxingS.java,AutoboxingZ.java,SimpleAutoboxing.java,AspectByte.aj" | |||
options="-1.5,-showWeaveInfo"> | |||
<message kind="weave" text="Type 'AutoboxingB' (AutoboxingB.java:11) advised by before advice from 'AspectByte' (AspectByte.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingB' (AutoboxingB.java:11) advised by before advice from 'AspectByte' (AspectByte.aj:4)"/> | |||
<message kind="weave" text="Type 'AutoboxingB' (AutoboxingB.java:12) advised by before advice from 'AspectByte' (AspectByte.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingB' (AutoboxingB.java:12) advised by before advice from 'AspectByte' (AspectByte.aj:4)"/> | |||
<message kind="weave" text="Type 'AutoboxingB' (AutoboxingB.java:13) advised by before advice from 'AspectByte' (AspectByte.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingB' (AutoboxingB.java:13) advised by before advice from 'AspectByte' (AspectByte.aj:4)"/> | |||
<message kind="weave" text="Type 'AutoboxingB' (AutoboxingB.java:14) advised by before advice from 'AspectByte' (AspectByte.aj:8)"/> | |||
<message kind="weave" text="Type 'AutoboxingB' (AutoboxingB.java:14) advised by before advice from 'AspectByte' (AspectByte.aj:4)"/> | |||
</compile> | |||
<run class="AutoboxingB"> | |||
<stderr> | |||
<line text="Byte:1"/> | |||
<line text="byte:1"/> | |||
<line text="method_takes_Byte=1"/> | |||
<line text="Byte:50"/> | |||
<line text="byte:50"/> | |||
<line text="method_takes_Byte=50"/> | |||
<line text="Byte:3"/> | |||
<line text="byte:3"/> | |||
<line text="method_takes_byte=3"/> | |||
<line text="Byte:52"/> | |||
<line text="byte:52"/> | |||
<line text="method_takes_byte=52"/> | |||
</stderr> | |||
</run> | |||
</ajc-test> | |||
<ajc-test dir="java5/autoboxing" vm="1.5" title="boxing in after returning"> | |||
<compile files="AutoboxingB.java,AutoboxingC.java,AutoboxingD.java,AutoboxingF.java,AutoboxingI.java,AutoboxingJ.java,AutoboxingS.java,AutoboxingZ.java,SimpleAutoboxing.java,AspectAfterReturning.aj" | |||
options="-1.5,-showWeaveInfo"> | |||
<message kind="weave" text="Type 'AspectAfterReturning' (AspectAfterReturning.aj:18) advised by afterReturning advice from 'AspectAfterReturning' (AspectAfterReturning.aj:4)"/> | |||
<message kind="weave" text="Type 'AspectAfterReturning' (AspectAfterReturning.aj:18) advised by afterReturning advice from 'AspectAfterReturning' (AspectAfterReturning.aj:8)"/> | |||
<message kind="weave" text="Type 'AspectAfterReturning' (AspectAfterReturning.aj:18) advised by afterReturning advice from 'AspectAfterReturning' (AspectAfterReturning.aj:12)"/> | |||
<message kind="weave" text="Type 'AspectAfterReturning' (AspectAfterReturning.aj:19) advised by afterReturning advice from 'AspectAfterReturning' (AspectAfterReturning.aj:4)"/> | |||
<message kind="weave" text="Type 'AspectAfterReturning' (AspectAfterReturning.aj:19) advised by afterReturning advice from 'AspectAfterReturning' (AspectAfterReturning.aj:8)"/> | |||
<message kind="weave" text="Type 'AspectAfterReturning' (AspectAfterReturning.aj:19) advised by afterReturning advice from 'AspectAfterReturning' (AspectAfterReturning.aj:12)"/> | |||
</compile> | |||
<run class="AspectAfterReturning"> | |||
<stderr> | |||
<line text="Returning I=5"/> | |||
<line text="Returning Integer=5"/> | |||
<line text="Returning Object=5"/> | |||
<line text="Returning I=10"/> | |||
<line text="Returning Integer=10"/> | |||
<line text="Returning Object=10"/> | |||
</stderr> | |||
</run> | |||
</ajc-test> | |||
<!-- ======================================================================================= --> | |||
<!-- Covariance tests --> | |||
<!-- ======================================================================================= --> | |||
<ajc-test dir="java5/covariance" vm="1.5" title="covariance 1"> | |||
<compile options="-1.5,-showWeaveInfo" files="CovBaseProgram01.java,CovAspect01.aj"> | |||
<message kind="weave" text="Type 'CovBaseProgram01' (CovBaseProgram01.java:26) advised by before advice from 'CovAspect01' (CovAspect01.aj:5)"/> | |||
<message kind="weave" text="Type 'CovBaseProgram01' (CovBaseProgram01.java:27) advised by before advice from 'CovAspect01' (CovAspect01.aj:5)"/> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/covariance" vm="1.5" title="covariance 2"> | |||
<compile options="-1.5,-showWeaveInfo" files="CovBaseProgram01.java,CovAspect02.aj"> | |||
<message kind="weave" text="Type 'CovBaseProgram01' (CovBaseProgram01.java:26) advised by before advice from 'CovAspect02' (CovAspect02.aj:5)"/> | |||
<message kind="weave" text="Type 'CovBaseProgram01' (CovBaseProgram01.java:27) advised by before advice from 'CovAspect02' (CovAspect02.aj:5)"/> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/covariance" vm="1.5" title="covariance 3"> | |||
<compile options="-1.5,-showWeaveInfo" files="CovBaseProgram01.java,CovAspect03.aj"> | |||
<message kind="weave" text="Type 'CovBaseProgram01' (CovBaseProgram01.java:26) advised by before advice from 'CovAspect03' (CovAspect03.aj:5)"/> | |||
<message kind="weave" text="Type 'CovBaseProgram01' (CovBaseProgram01.java:27) advised by before advice from 'CovAspect03' (CovAspect03.aj:5)"/> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/covariance" vm="1.5" title="covariance 4"> | |||
<compile options="-1.5,-showWeaveInfo" files="CovBaseProgram02.java,CovAspect04.aj"> | |||
<message kind="weave" text="Type 'CovBaseProgram02' (CovBaseProgram02.java:30) advised by before advice from 'CovAspect04' (CovAspect04.aj:5)"/> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/covariance" vm="1.5" title="covariance 5"> | |||
<compile options="-1.5,-showWeaveInfo" files="CovBaseProgram01.java,CovAspect05.aj"> | |||
<message kind="weave" text="Type 'CovBaseProgram01' (CovBaseProgram01.java:26) advised by before advice from 'CovAspect05' (CovAspect05.aj:5)"/> | |||
<message kind="weave" text="Type 'CovBaseProgram01' (CovBaseProgram01.java:27) advised by before advice from 'CovAspect05' (CovAspect05.aj:5)"/> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/covariance" vm="1.5" title="covariance 6"> | |||
<compile options="-1.5,-showWeaveInfo" files="CovBaseProgram01.java,CovAspect06.aj"> | |||
<message kind="warning" line="3" text="does not match because declaring type is Super"/> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/covariance" vm="1.5" title="covariance 7"> | |||
<compile options="-1.5,-showWeaveInfo" files="CovBaseProgram01.java,CovAspect07.aj"> | |||
<message kind="weave" text="Type 'CovBaseProgram01' (CovBaseProgram01.java:27) advised by before advice from 'CovAspect07' (CovAspect07.aj:5)"/> | |||
<message kind="warning" line="3" text="does not match because declaring type is Super"/> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/covariance" vm="1.5" title="covariance 8"> | |||
<compile options="-1.5,-showWeaveInfo" files="CovBaseProgram01.java,CovAspect08.aj"> | |||
<message kind="weave" text="Type 'CovBaseProgram01' (CovBaseProgram01.java:27) advised by before advice from 'CovAspect08' (CovAspect08.aj:11)"/> | |||
<message kind="weave" text="Type 'CovBaseProgram01' (CovBaseProgram01.java:27) advised by before advice from 'CovAspect08' (CovAspect08.aj:5)"/> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/covariance" vm="1.5" title="covariance 9"> | |||
<compile options="-1.5,-showWeaveInfo" files="CovBaseProgram01.java,CovAspect09.aj"> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/covariance" vm="1.5" title="covariance 10"> | |||
<compile options="-1.5,-showWeaveInfo" files="CovBaseProgram01.java,CovAspect10.aj"> | |||
<message kind="weave" text="Type 'CovBaseProgram01' (CovBaseProgram01.java:26) advised by before advice from 'CovAspect10' (CovAspect10.aj:5)"/> | |||
<message kind="weave" text="Type 'CovBaseProgram01' (CovBaseProgram01.java:27) advised by before advice from 'CovAspect10' (CovAspect10.aj:5)"/> | |||
</compile> | |||
</ajc-test> | |||
<!-- ======================================================================================= --> | |||
<!-- Enum tests --> | |||
<!-- ======================================================================================= --> | |||
<ajc-test dir="java5/enums" vm="1.5" title="cant itd constructor on enum"> | |||
<compile files="SimpleEnum.java,SimpleEnum2.java,EnumAspect01.aj" options="-1.5"> | |||
<message kind="error" line="2" text="can't make inter-type constructor declarations on enum types"/> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/enums" vm="1.5" title="cant itd field or method on enum"> | |||
<compile files="SimpleEnum.java,SimpleEnum2.java,EnumAspect02.aj" options="-1.5"> | |||
<message kind="error" line="2" text="can't make inter-type method declarations on enum types"/> | |||
<message kind="error" line="6" text="can't make inter-type field declarations on enum types"/> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/enums" vm="1.5" title="declare parents and enums"> | |||
<compile files="SimpleEnum.java,SimpleEnum2.java,EnumAspect03.aj" options="-1.5"> | |||
<message kind="error" line="5" text="can't use declare parents to make enum type SimpleEnum implement an interface"/> | |||
<message kind="error" line="8" text="can't use declare parents to alter supertype of enum type SimpleEnum"/> | |||
<message kind="error" line="11" text="can't use declare parents to make 'java.lang.Enum' the parent of type EnumAspect03$D"/> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/enums" vm="1.5" title="wildcard enum match in itd"> | |||
<compile files="SimpleEnum.java,SimpleEnum2.java,EnumAspect04.aj" options="-1.5"> | |||
<message kind="warning" line="5" text="enum type SimpleEnum2 matches a declare parents type pattern but is being ignored"/> | |||
<message kind="warning" line="5" text="enum type SimpleEnum matches a declare parents type pattern but is being ignored"/> | |||
</compile> | |||
</ajc-test> | |||
<!-- ======================================================================================= --> | |||
<!-- pertypewithin tests --> | |||
<!-- ======================================================================================= --> | |||
<ajc-test dir="java5/pertypewithin" title="basic ptw test"> | |||
<compile files="A.java,B.java,C.java,D.java,Main.java,X.java"/> | |||
<run class="p.A"> | |||
<stderr> | |||
<line text="hi from A"/> | |||
<line text="after() returning from a method call to sayhi()"/> | |||
<line text="hi from A"/> | |||
<line text="after() returning from a method call to sayhi()"/> | |||
<line text="Tests in A have passed"/> | |||
<line text="callcount = 2"/> | |||
</stderr> | |||
</run> | |||
</ajc-test> | |||
<ajc-test dir="java5/pertypewithin" title="ptw hasAspect"> | |||
<compile files="A.java,B.java,C.java,D.java,Main.java,X.java"/> | |||
<run class="p.B"> | |||
<stderr> | |||
<line text="hi from B"/> | |||
<line text="after() returning from a method call to sayhi()"/> | |||
<line text="hi from B"/> | |||
<line text="after() returning from a method call to sayhi()"/> | |||
<line text="hi from B"/> | |||
<line text="after() returning from a method call to sayhi()"/> | |||
<line text="callcount = 3"/> | |||
</stderr> | |||
</run> | |||
</ajc-test> | |||
<ajc-test dir="java5/pertypewithin" title="ptw aspectOf"> | |||
<compile files="A.java,B.java,C.java,D.java,Main.java,X.java"/> | |||
<run class="p.C"/> | |||
</ajc-test> | |||
<ajc-test dir="java5/pertypewithin" title="ptw multi-aspects"> | |||
<compile files="P.java,Q.java,R.java"/> | |||
<run class="P"> | |||
<stderr> | |||
<line text="Q reporting 2"/> | |||
<line text="R reporting 3"/> | |||
</stderr> | |||
</run> | |||
</ajc-test> | |||
<ajc-test dir="java5/pertypewithin" title="ptw binary"> | |||
<weave classesFiles="G.java" aspectsFiles="H.java"/> | |||
<run class="G"> | |||
<stderr> | |||
<line text="advice running"/> | |||
</stderr> | |||
</run> | |||
</ajc-test> | |||
<ajc-test dir="java5/pertypewithin" title="ptw binary aspect"> | |||
<compile files="H.java" outjar="aspects.jar"> | |||
<message kind="warning" line="1" text="no match for this type name: G"/> | |||
</compile> | |||
<compile files="G.java" aspectpath="aspects.jar"/> | |||
<run class="G"> | |||
<stderr> | |||
<line text="advice running"/> | |||
</stderr> | |||
</run> | |||
</ajc-test> | |||
<!-- ======================================================================================= --> | |||
<!-- varargs tests --> | |||
<!-- ======================================================================================= --> | |||
<ajc-test dir="java5/varargs" vm="1.5" title="varargs not matched by Object[] (call)"> | |||
<compile files="SimpleVarargs.java,VarargsAspect01.aj" options="-1.5,-showWeaveInfo"> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/varargs" vm="1.5" title="varargs not matched by Object[] (exe)"> | |||
<compile files="SimpleVarargs.java,VarargsAspect02.aj" options="-1.5,-showWeaveInfo"> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/varargs" vm="1.5" title="varargs not matched by Object[] (init)"> | |||
<compile files="SimpleVarargs.java,VarargsAspect03.aj" options="-1.5,-showWeaveInfo"> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/varargs" vm="1.5" title="varargs not matched by Object[] (withincode)"> | |||
<compile files="SimpleVarargs.java,VarargsAspect04.aj" options="-1.5,-showWeaveInfo"> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/varargs" vm="1.5" title="call with varargs signature"> | |||
<compile files="SimpleVarargs.java,VarargsAspect05.aj" options="-1.5,-showWeaveInfo"> | |||
<message kind="weave" text="Type 'SimpleVarargs' (SimpleVarargs.java:20) advised by before advice from 'VarargsAspect05' (VarargsAspect05.aj:3)"/> | |||
<message kind="weave" text="Type 'SimpleVarargs' (SimpleVarargs.java:21) advised by before advice from 'VarargsAspect05' (VarargsAspect05.aj:3)"/> | |||
<message kind="weave" text="Type 'SimpleVarargs' (SimpleVarargs.java:22) advised by before advice from 'VarargsAspect05' (VarargsAspect05.aj:3)"/> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="java5/varargs" vm="1.5" title="call with varargs multi-signature"> | |||
<compile files="SimpleVarargs.java,VarargsAspect06.aj" options="-1.5,-showWeaveInfo"> | |||
<message kind="weave" text="Type 'SimpleVarargs' (SimpleVarargs.java:25) advised by before advice from 'VarargsAspect06' (VarargsAspect06.aj:3)"/> | |||
<message kind="weave" text="Type 'SimpleVarargs' (SimpleVarargs.java:26) advised by before advice from 'VarargsAspect06' (VarargsAspect06.aj:3)"/> | |||
<message kind="weave" text="Type 'SimpleVarargs' (SimpleVarargs.java:27) advised by before advice from 'VarargsAspect06' (VarargsAspect06.aj:3)"/> | |||
</compile> | |||
</ajc-test> | |||
</suite> | |||