您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Annotations.java 4.6KB

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