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.

Annotations.java 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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 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.ajc150;
  12. import org.aspectj.apache.bcel.classfile.JavaClass;
  13. import org.aspectj.apache.bcel.classfile.Method;
  14. import org.aspectj.testing.XMLBasedAjcTestCase;
  15. import junit.framework.Test;
  16. public class Annotations extends XMLBasedAjcTestCase {
  17. public static Test suite() {
  18. return XMLBasedAjcTestCase.loadSuite(Annotations.class);
  19. }
  20. protected java.net.URL getSpecFile() {
  21. return getClassResource("ajc150.xml");
  22. }
  23. public void testCompilingAnnotation() {
  24. runTest("compiling an annotation");
  25. }
  26. public void testCompilingAnnotatedFile() {
  27. runTest("compiling annotated file");
  28. }
  29. public void testCompilingUsingWithinAndAnnotationTypePattern() {
  30. runTest("annotations and within (src)");
  31. }
  32. /**
  33. * We had a bug where annotations were not present in the output class file for methods
  34. * that got woven. This was due to unpacking bugs in LazyMethodGen. This test compiles
  35. * a simple program then checks the annotations were copied across.
  36. */
  37. public void testBugWithAnnotationsLostOnWovenMethods() throws ClassNotFoundException {
  38. runTest("losing annotations...");
  39. if (getCurrentTest().canRunOnThisVM()) {
  40. JavaClass jc = getClassFrom(ajc.getSandboxDirectory(),"Program");
  41. Method[] meths = jc.getMethods();
  42. for (int i = 0; i < meths.length; i++) {
  43. Method method = meths[i];
  44. if (method.getName().equals("m1")) {
  45. assertTrue("Didn't have annotations - were they lost? method="+method.getName(),method.getAnnotations().length==1);
  46. }
  47. }
  48. }
  49. }
  50. public void testAnnotatedAnnotations() {
  51. runTest("annotated annotations (@Target)");
  52. }
  53. public void testSimpleAnnotatedAspectMembers() {
  54. runTest("simple annotated aspect members");
  55. }
  56. public void testAnnotatedAspectMembersWithWrongAnnotationType() {
  57. runTest("simple annotated aspect members with bad target");
  58. }
  59. // more implementation work needed before this test passes
  60. public void testAnnotatedITDs() {
  61. runTest("annotated itds");
  62. }
  63. public void testAnnotatedITDs2() {
  64. runTest("annotated public itds");
  65. }
  66. public void testAnnotatedITDs3() {
  67. runTest("annotated public itds - values");
  68. }
  69. public void testAnnotatedITDs4() {
  70. runTest("annotated public itds - multiple complex annotations");
  71. }
  72. public void testAnnotatedITDsWithWrongAnnotationType() {
  73. runTest("annotated itds with bad target");
  74. }
  75. public void testAnnotatedAdvice() {
  76. runTest("annotated advice");
  77. }
  78. public void testAnnotatedAdviceWithWrongAnnotationType() {
  79. runTest("annotated advice with bad target");
  80. }
  81. public void testAnnotatedPointcut() {
  82. runTest("annotated pointcut");
  83. }
  84. // FIXME asc uncomment this test when parser is opened up
  85. // public void testAnnotatedDeclareStatements() {
  86. // runTest("annotated declare statements");
  87. // }
  88. public void testBasicDeclareAnnotation() {
  89. runTest("basic declare annotation parse test");
  90. }
  91. public void testAJDKAnnotatingAspects() {
  92. runTest("ajdk: annotating aspects chapter");
  93. }
  94. public void testAJDKAnnotatingAspects2() {
  95. runTest("ajdk: annotating aspects chapter, ex 2");
  96. }
  97. public void testAnnotationPatterns() {
  98. runTest("ajdk: annotation pattern matching");
  99. }
  100. public void testAnnotationTypePatterns() {
  101. runTest("ajdk: annotation type pattern matching");
  102. }
  103. public void testAnnotationSigPatterns() {
  104. runTest("ajdk: annotations in sig patterns");
  105. }
  106. public void testAnnotationRuntimeMatching() {
  107. runTest("ajdk: runtime annotations");
  108. }
  109. public void testAnnotationRetentionChecking() {
  110. runTest("ajdk: @retention checking");
  111. }
  112. public void testAnnotationInheritance() {
  113. runTest("ajdk: @inherited");
  114. }
  115. public void testAnnotationDEOW() {
  116. runTest("ajdk: deow-ann");
  117. }
  118. public void testAnnotationDecp() {
  119. runTest("ajdk: decp-ann");
  120. }
  121. public void testAnnotationDecPrecedence() {
  122. runTest("ajdk: dec precedence");
  123. }
  124. public void testAnnotationDecAnnotation() {
  125. runTest("ajdk: dec annotation");
  126. }
  127. public void testAnnotationsAndITDs() {
  128. runTest("nasty annotation and itds test");
  129. }
  130. // helper methods.....
  131. }