You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Ajc151Tests.java 9.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. /*******************************************************************************
  2. * Copyright (c) 2006 IBM
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors:
  9. * Andy Clement - initial API and implementation
  10. *******************************************************************************/
  11. package org.aspectj.systemtest.ajc151;
  12. import java.io.IOException;
  13. import org.aspectj.asm.AsmManager;
  14. import org.aspectj.asm.IHierarchy;
  15. import org.aspectj.asm.IProgramElement;
  16. import org.aspectj.systemtest.ajc150.GenericsTests;
  17. import org.aspectj.testing.XMLBasedAjcTestCase;
  18. import junit.framework.Test;
  19. public class Ajc151Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
  20. // Some @DeclareParents testing
  21. public void testAtDecp_1() {
  22. runTest("atDecp - simple");
  23. }
  24. public void testAtDecp_2() {
  25. runTest("atDecp - annotation");
  26. }
  27. public void testAtDecp_3() {
  28. runTest("atDecp - binary interface");
  29. }
  30. public void testAtDecp_4() {
  31. runTest("atDecp - binary interface - 2");
  32. }
  33. public void testAnnotationsAndItds_pr98901() {
  34. runTest("annotations and itds");
  35. }
  36. public void testAnnotationsAndItds_pr98901_2() {
  37. runTest("annotations and itds - 2");
  38. }
  39. public void testCircularGenerics_pr133307() {
  40. runTest("circular generics");
  41. }
  42. public void testDeca() {
  43. runTest("doubly annotating a method with declare");
  44. }
  45. public void testDeca2() {
  46. runTest("doubly annotating a method with declare - 2");
  47. }
  48. public void testCrashingWithASM_pr132926_1() {
  49. runTest("crashing on annotation type resolving with asm - 1");
  50. }
  51. public void testCrashingWithASM_pr132926_2() {
  52. runTest("crashing on annotation type resolving with asm - 2");
  53. }
  54. public void testCrashingWithASM_pr132926_3() {
  55. runTest("crashing on annotation type resolving with asm - 3");
  56. }
  57. public void testGenericAdviceParameters_pr123553() {
  58. runTest("generic advice parameters");
  59. }
  60. public void testMemberTypesInGenericTypes_pr122458() {
  61. runTest("member types in generic types");
  62. }
  63. public void testMemberTypesInGenericTypes_pr122458_2() {
  64. runTest("member types in generic types - 2");
  65. }
  66. public void testNPEOnDeclareAnnotation_pr123695() {
  67. runTest("Internal nullptr exception with complex declare annotation");
  68. }
  69. public void testHasMemberPackageProblem_pr124105() {
  70. runTest("hasMember problems with packages");
  71. }
  72. public void testDifferentNumbersofTVars_pr124803() {
  73. runTest("generics and different numbers of type variables");
  74. }
  75. public void testDifferentNumbersofTVars_pr124803_2() {
  76. runTest("generics and different numbers of type variables - classes");
  77. }
  78. public void testParameterizedCollectionFieldMatching_pr124808() {
  79. runTest("parameterized collection fields matched via pointcut");
  80. }
  81. public void testGenericAspectsAndAnnotations_pr124654() {
  82. runTest("generic aspects and annotations");
  83. }
  84. public void testCallInheritedGenericMethod_pr124999() {
  85. runTest("calling inherited generic method from around advice");
  86. }
  87. public void testIncorrectlyReferencingPointcuts_pr122452() {
  88. runTest("incorrectly referencing pointcuts");
  89. }
  90. public void testIncorrectlyReferencingPointcuts_pr122452_2() {
  91. runTest("incorrectly referencing pointcuts - 2");
  92. }
  93. public void testInlinevisitorNPE_pr123901() {
  94. runTest("inlinevisitor NPE");
  95. }
  96. // public void testExposingWithintype_enh123423() { runTest("exposing withintype");}
  97. // public void testMissingImport_pr127299() { runTest("missing import gives funny message");}
  98. public void testUnusedInterfaceMessage_pr120527() {
  99. runTest("incorrect unused interface message");
  100. }
  101. public void testAtAspectInheritsAdviceWithTJPAndThis_pr125699() {
  102. runTest("inherit advice with this() and thisJoinPoint");
  103. }
  104. public void testAtAspectInheritsAdviceWithTJPAndThis_pr125699_2() {
  105. runTest("inherit advice with this() and thisJoinPoint - 2");
  106. }
  107. public void testBrokenLTW_pr128744() {
  108. runTest("broken ltw");
  109. }
  110. public void testAtAspectNoInvalidAbsoluteTypeName_pr126560() {
  111. runTest("@AJ deow doesn't throw an invalidAbsoluteTypeName when specify type in the same package");
  112. }
  113. public void testAtAspectNoInvalidAbsoluteTypeName_pr126560_2() {
  114. runTest("@AJ deow doesn't throw an invalidAbsoluteTypeName when specify type in the same file");
  115. }
  116. public void testArrayindexoutofbounds_pr129566() {
  117. runTest("arrayindexoutofbounds");
  118. // public class SkipList<T extends Comparable> extends Object implements Set<T>, Iterable<T>
  119. GenericsTests.verifyClassSignature(ajc, "common.SkipList",
  120. "<T::Ljava/lang/Comparable;>Ljava/lang/Object;Ljava/util/Set<TT;>;Ljava/lang/Iterable<TT;>;");
  121. // protected class SkipListElement<E> extends Object
  122. GenericsTests.verifyClassSignature(ajc, "common.SkipList$SkipListElement", "<E:Ljava/lang/Object;>Ljava/lang/Object;");
  123. // protected class SkipListIterator<E> implements Iterator<T>
  124. GenericsTests.verifyClassSignature(ajc, "common.SkipList$SkipListIterator",
  125. "<E:Ljava/lang/Object;>Ljava/lang/Object;Ljava/util/Iterator<TT;>;");
  126. }
  127. public void testMixingNumbersOfTypeParameters_pr125080() {
  128. runTest("mixing numbers of type parameters");
  129. GenericsTests.verifyClassSignature(ajc, "AspectInterface", "<T:Ljava/lang/Object;S:Ljava/lang/Object;>Ljava/lang/Object;");
  130. GenericsTests.verifyClassSignature(ajc, "AbstractAspect",
  131. "<T:Ljava/lang/Object;>Ljava/lang/Object;LAspectInterface<TT;Ljava/lang/Integer;>;");
  132. GenericsTests.verifyClassSignature(ajc, "ConcreteAspect", "LAbstractAspect<Ljava/lang/String;>;");
  133. }
  134. public void testMixingNumbersOfTypeParameters_pr125080_2() {
  135. runTest("mixing numbers of type parameters - 2");
  136. GenericsTests.verifyClassSignature(ajc, "AspectInterface", "<T:Ljava/lang/Object;S:Ljava/lang/Number;>Ljava/lang/Object;");
  137. GenericsTests.verifyClassSignature(ajc, "AbstractAspect",
  138. "<T:Ljava/lang/Object;>Ljava/lang/Object;LAspectInterface<TT;Ljava/lang/Integer;>;");
  139. GenericsTests.verifyClassSignature(ajc, "ConcreteAspect", "LAbstractAspect<LStudent;>;");
  140. }
  141. public void testIProgramElementMethods_pr125295() throws IOException {
  142. runTest("new IProgramElement methods");
  143. IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy();
  144. IProgramElement typeC = top.findElementForType("pkg", "C");
  145. IProgramElement pe = top.findElementForSignature(typeC, IProgramElement.Kind.METHOD, "foo(int,java.lang.Object)");
  146. assertNotNull("Couldn't find 'foo' element in the tree", pe);
  147. // check that the defaults return the fully qualified arg
  148. assertEquals("foo(int,java.lang.Object)", pe.toLabelString());
  149. assertEquals("C.foo(int,java.lang.Object)", pe.toLinkLabelString());
  150. assertEquals("foo(int,java.lang.Object)", pe.toSignatureString());
  151. // check that can get hold of the non qualified args
  152. assertEquals("foo(int,Object)", pe.toLabelString(false));
  153. assertEquals("C.foo(int,Object)", pe.toLinkLabelString(false));
  154. assertEquals("foo(int,Object)", pe.toSignatureString(false));
  155. IProgramElement typeA = top.findElementForType("pkg", "A");
  156. IProgramElement pe2 = top.findElementForSignature(typeA,IProgramElement.Kind.METHOD,"printParameters(org.aspectj.lang.JoinPoint)");
  157. assertNotNull("Couldn't find 'printParameters' element in the tree", pe2);
  158. // the argument is org.aspectj.lang.JoinPoint, check that this is added
  159. assertFalse("printParameters method should have arguments", pe2.getParameterSignatures().isEmpty());
  160. }
  161. public void testParameterizedEnum_pr126316() {
  162. runTest("E extends Enum(E) again");
  163. }
  164. public void testSwallowedException() {
  165. runTest("swallowed exceptions");
  166. }
  167. public void testAtAspectVerifyErrorWithAfterThrowingAndthisJoinPoint_pr122742() {
  168. runTest("@AJ VerifyError with @AfterThrowing and thisJoinPoint argument");
  169. }
  170. public void testAtAspectVerifyErrorWithAfterReturningAndthisJoinPoint_pr122742() {
  171. runTest("@AJ VerifyError with @AfterReturning and thisJoinPoint argument");
  172. }
  173. public void testSwallowedExceptionIgnored() {
  174. runTest("swallowed exceptions with xlint");
  175. }
  176. public void testGenericAspectWithUnknownType_pr131933() {
  177. runTest("no ClassCastException with generic aspect and unknown type");
  178. }
  179. /*
  180. * @AspectJ bugs and enhancements
  181. */
  182. // public void testAtAspectInheritsAdviceWithTJPAndThis_pr125699 () {
  183. // runTest("inherit adivce with this() and thisJoinPoint");
  184. // }
  185. public void testAtAspectInheritsAbstractPointcut_pr125810() {
  186. runTest("warning when inherited pointcut not made concrete");
  187. }
  188. public void testAtAspectWithoutJoinPointImport_pr121616() {
  189. runTest("@AJ without JoinPoint import");
  190. }
  191. public void testAtAspectDeclareParentsRetainsFieldState_pr122370() {
  192. runTest("@AJ declare parents retains field state");
  193. }
  194. public void testAtAspectNoNPEWithPcdContainingOrThisAndWildcard_pr128237() {
  195. runTest("@AJ no npe with pointcut containing or, this and a wildcard");
  196. }
  197. /*
  198. * Load-time weaving bugs and enhancements
  199. */
  200. public void testEmptyPointcutInAtAspectJ_pr125475() {
  201. runTest("define empty pointcut using an annotation");
  202. }
  203. public void testEmptyPointcutInAtAspectJ_pr125475_2() {
  204. runTest("define empty pointcut using an annotation - 2");
  205. }
  206. public void testEmptyPointcutInAtAspectJWithLTW_pr125475() {
  207. runTest("define empty pointcut using aop.xml");
  208. }
  209. public void testGenericAspectsWithAnnotationTypeParameters() {
  210. runTest("Generic aspects with annotation type parameters");
  211. }
  212. public void testPointcutInterfaces_pr130869() {
  213. runTest("Pointcut interfaces");
  214. }
  215. // ///////////////////////////////////////
  216. public static Test suite() {
  217. return XMLBasedAjcTestCase.loadSuite(Ajc151Tests.class);
  218. }
  219. protected java.net.URL getSpecFile() {
  220. return getClassResource("ajc151.xml");
  221. }
  222. }