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.

ParameterAnnotationMatchingTests.java 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* *******************************************************************
  2. * Copyright (c) 2008 Contributors
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/epl-v10.html
  8. *
  9. * Contributors
  10. * Andy Clement
  11. * ******************************************************************/
  12. package org.aspectj.systemtest.ajc160;
  13. import org.aspectj.testing.XMLBasedAjcTestCase;
  14. import junit.framework.Test;
  15. /**
  16. * Parameter annotation matching
  17. *
  18. * The full implementation will require static matching, binding and possibly runtime
  19. * matching (need to check on inheritance of annotations specified in these positions).
  20. * The extension to the syntax for method-signatures is to require parentheses when
  21. * specifying annotations relating to parameters and parameter types - the position of
  22. * the parentheses enable the distinction to be made between annotations attached to
  23. * the type of the parameter and annotations attached to the parameter itself.
  24. *
  25. * For example:
  26. *
  27. * public void goo(MyType s) {} // where MyType has annotation @B
  28. * public void foo(@A String s) {} // String has no annotations, @A is a parameter annotation
  29. *
  30. * A method signature to match the former would be:
  31. * execution(public void goo(@B MyType))
  32. * or execution(public void goo((@B MyType)))
  33. *
  34. * To match the latter:
  35. * execution(public void foo(@A (String)))
  36. * The parentheses around String are telling us that there are no annotations attached to the
  37. * parameter type we are interested in, and @A should be treated as an intent to match on
  38. * parameter annotation A.
  39. *
  40. * In a more complex case:
  41. * public void hoo(@A MyType s) {} // now there are two potential annotations we are interested in
  42. * the match expression is:
  43. * execution(public void hoo(@A (@B MyType)))
  44. * the parentheses associating @B with the type of the parameter leaving @A outside to be
  45. * treated as a parameter annotation.
  46. *
  47. * Testplan:
  48. * Test cases for the parameter annotation matching:
  49. * DONE:
  50. * 1. Basic pointcut parsing for the new method signature syntax
  51. * 2. Expression matching with the new syntax
  52. * 3. Real static matching with the new syntax
  53. * 4. hasmethod should pick up the new syntax
  54. * 5. ellipsis usage not impacted
  55. * 6. recognizing varargs
  56. * 7. constructor matching
  57. * 8. binary weaving
  58. *
  59. * NOT DONE:
  60. * . New pointcut designator parsing
  61. * . Expression matching with the new syntax
  62. * . Real matching with the new syntax
  63. * . Binding with the new syntax.
  64. * . complaining about annotations that dont target the right type
  65. * . itds
  66. * . annotation visibility tests
  67. * . wildcarded @Ann*1 - broken (not my doing)
  68. * . ltw
  69. *
  70. */
  71. public class ParameterAnnotationMatchingTests extends XMLBasedAjcTestCase {
  72. public void testDeow() { runTest("deow"); }
  73. public void testDeow2() { runTest("deow2"); }
  74. public void testNoWarningForWrongType() { runTest("no xlint for wrong target");}
  75. public void testVariousCombinations() { runTest("various combinations"); }
  76. public void testVariousCombinationsCtors() { runTest("various combinations - ctors"); }
  77. public void testHasMethod() { runTest("hasmethod"); }
  78. public void testBinaryWeaving() { runTest("binary weaving"); }
  79. // this is broken and it was already broken before I added parameter annotation matching !
  80. // public void testWildcardedAnnotationMatching() { runTest("wildcarded matching"); }
  81. /////////////////////////////////////////
  82. public static Test suite() {
  83. return XMLBasedAjcTestCase.loadSuite(ParameterAnnotationMatchingTests.class);
  84. }
  85. protected java.net.URL getSpecFile() {
  86. return getClassResource("parameterAnnotations.xml");
  87. }
  88. }