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.

AnnotationBinding.java 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /*******************************************************************************
  2. * Copyright (c) 2004 IBM
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Common Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/cpl-v10.html
  7. *
  8. * Contributors:
  9. * Andy Clement - initial API and implementation
  10. *******************************************************************************/
  11. package org.aspectj.systemtest.ajc150;
  12. import java.io.File;
  13. import junit.framework.Test;
  14. import org.aspectj.testing.XMLBasedAjcTestCase;
  15. public class AnnotationBinding extends XMLBasedAjcTestCase {
  16. public static Test suite() {
  17. return XMLBasedAjcTestCase.loadSuite(AnnotationBinding.class);
  18. }
  19. protected File getSpecFile() {
  20. return new File("../tests/src/org/aspectj/systemtest/ajc150/ajc150.xml");
  21. }
  22. ///////////////////////////////////// @ANNOTATION and CALL
  23. // Very simple annotation binding for 'call() && @annotation()'
  24. public void testCallAnnotationBinding1() {
  25. runTest("call annotation binding 1");
  26. }
  27. // 'call() && @annotation()' when the called method has multiple arguments
  28. public void testCallAnnotationBinding2() {
  29. runTest("call annotation binding 2");
  30. }
  31. // 'call() && @annotation()' when the called method takes primitive arguments (YUCK!)
  32. public void testCallAnnotationBinding3() {
  33. runTest("call annotation binding 3");
  34. }
  35. // 'call() && @annotation()' when runtime type will exhibit different annotation (due to interface implementing)
  36. public void testCallAnnotationBinding4() {
  37. runTest("call annotation binding 4");
  38. }
  39. // 'call() && @annotation()' when target doesnt have an annotation !
  40. public void testCallAnnotationBinding5() {
  41. runTest("call annotation binding 5");
  42. }
  43. // 'call() && @annotation()' when runtime type will exhibit different annotation (due to subclassing)
  44. public void testCallAnnotationBinding6() {
  45. runTest("call annotation binding 6");
  46. }
  47. // 'call() && @annotation()' using named pointcut
  48. public void testCallAnnotationBinding7() {
  49. runTest("call annotation binding 7");
  50. }
  51. ///////////////////////////////////// @TARGET
  52. // 'call() && @target()'
  53. public void testAtTargetAnnotationBinding1() {
  54. runTest("@target annotation binding 1");
  55. }
  56. // 'call() && @target() && @target'
  57. public void testAtTargetAnnotationBinding2() {
  58. runTest("@target annotation binding 2");
  59. }
  60. // 'call() && @target()' - using a type hierarchy where some levels are missing annotations
  61. public void testAtTargetAnnotationBinding3() {
  62. runTest("@target annotation binding 3");
  63. }
  64. // 'call() && @target()' - using a type hierarchy where some levels are missing annotations
  65. // but the annotation is inherited
  66. public void testAtTargetAnnotationBinding4() {
  67. runTest("@target annotation binding 4");
  68. }
  69. // @target() with an annotation in a package
  70. public void testAtTargetAnnotationBinding5() {
  71. runTest("@target annotation binding 5");
  72. }
  73. ///////////////////////////////////// @THIS
  74. // 'call() && @this()'
  75. public void testAtThisAnnotationBinding1() {
  76. runTest("@this annotation binding 1");
  77. }
  78. // 'call() && @this() && @this'
  79. public void testAtThisAnnotationBinding2() {
  80. runTest("@this annotation binding 2");
  81. }
  82. // 'call() && @this()' - using a type hierarchy where some levels are missing annotations
  83. public void testAtThisAnnotationBinding3() {
  84. runTest("@this annotation binding 3");
  85. }
  86. // 'call() && @this()' - using a type hierarchy where some levels are missing annotations
  87. // but the annotation is inherited
  88. public void testAtThisAnnotationBinding4() {
  89. runTest("@this annotation binding 4");
  90. }
  91. // '@this() and @target()' used together
  92. public void testAtThisAtTargetAnnotationBinding() {
  93. runTest("@this annotation binding 5");
  94. }
  95. ///////////////////////////////////// @ARGS
  96. // complex case when there are 3 parameters
  97. public void testAtArgs1() {
  98. runTest("@args annotation binding 1");
  99. }
  100. // simple case when there is only one parameter
  101. public void testAtArgs2() {
  102. runTest("@args annotation binding 2");
  103. }
  104. // simple case when there is only one parameter and no binding
  105. public void testAtArgs3() {
  106. runTest("@args annotation binding 3");
  107. }
  108. // complex case binding different annotation kinds
  109. public void testAtArgs4() {
  110. runTest("@args annotation binding 4");
  111. }
  112. // check @args and execution()
  113. public void testAtArgs5() {
  114. runTest("@args annotation binding 5");
  115. }
  116. ///////////////////////////////////// @ANNOTATION and EXECUTION
  117. // 'execution() && @annotation()'
  118. public void testExecutionAnnotationBinding1() {
  119. runTest("execution and @annotation");
  120. }
  121. ///////////////////////////////////// @ANNOTATION and SET
  122. // 'set() && @annotation()'
  123. public void testFieldAnnotationBinding1() {
  124. runTest("set and @annotation");
  125. }
  126. // 'get() && @annotation()'
  127. public void testFieldAnnotationBinding2() {
  128. runTest("get and @annotation");
  129. }
  130. // 'get() && @annotation()' when using array fields
  131. public void testFieldAnnotationBinding3() {
  132. runTest("get and @annotation with arrays");
  133. }
  134. ///////////////////////////////////// @ANNOTATION and CTOR-CALL
  135. // 'ctor-call(new) && @annotation()'
  136. public void testCtorCallAnnotationBinding1() {
  137. runTest("cons call and @annotation");
  138. }
  139. ///////////////////////////////////// @ANNOTATION and CTOR-CALL
  140. // 'ctor-execution() && @annotation()'
  141. public void testCtorExecAnnotationBinding1() {
  142. runTest("cons exe and @annotation");
  143. }
  144. ///////////////////////////////////// @ANNOTATION and STATICINITIALIZATION
  145. // 'staticinitialization() && @annotation()'
  146. public void testStaticInitAnnotationBinding1() {
  147. runTest("staticinit and @annotation");
  148. }
  149. ///////////////////////////////////// @ANNOTATION and PREINITIALIZATION
  150. // 'preinitialization() && @annotation()'
  151. public void testPreInitAnnotationBinding1() {
  152. runTest("preinit and @annotation");
  153. }
  154. ///////////////////////////////////// @ANNOTATION and INITIALIZATION
  155. // 'initialization() && @annotation()'
  156. public void testInitAnnotationBinding1() {
  157. runTest("init and @annotation");
  158. }
  159. ///////////////////////////////////// @ANNOTATION and ADVICEEXECUTION
  160. // 'adviceexecution() && @annotation()'
  161. public void testAdviceExecAnnotationBinding1() {
  162. runTest("adviceexecution and @annotation");
  163. }
  164. ///////////////////////////////////// @ANNOTATION and HANDLER
  165. // 'handler() && @annotation()'
  166. public void testHandlerAnnotationBinding1() {
  167. runTest("handler and @annotation");
  168. }
  169. ///////////////////////////////////// @ANNOTATION complex tests
  170. // Using package names for the types (including the annotation) - NO BINDING
  171. public void testPackageNamedTypesNoBinding() {
  172. runTest("packages and no binding");
  173. }
  174. // Using package names for the types (including the annotation) - INCLUDES BINDING
  175. public void testPackageNamedTypesWithBinding() {
  176. runTest("packages and binding");
  177. }
  178. // declare parents: @Color * implements Serializable
  179. public void testDeclareParentsWithAnnotatedAnyPattern() {
  180. runTest("annotated any pattern");
  181. }
  182. // Should error (in a nice way!) on usage of an annotation that isnt imported
  183. public void testAnnotationUsedButNotImported() {
  184. runTest("annotation not imported");
  185. }
  186. // Binding with calls/executions of static methods
  187. public void testCallsAndExecutionsOfStaticMethods() {
  188. runTest("binding with static methods");
  189. }
  190. }