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.

Ajc153Tests.java 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  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.ajc153;
  12. import java.net.URL;
  13. import org.aspectj.asm.AsmManager;
  14. import org.aspectj.asm.IHierarchy;
  15. import org.aspectj.asm.IProgramElement;
  16. import org.aspectj.testing.XMLBasedAjcTestCase;
  17. import org.aspectj.weaver.bcel.Utility;
  18. import junit.framework.Test;
  19. public class Ajc153Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
  20. public void testFormalCommentsAreSetForConstructorIPEs_pr164340() {
  21. runTest("formal comments are set for constructor ipes");
  22. IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy();
  23. IProgramElement ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.CONSTRUCTOR, "C()");
  24. assertNotNull("expected formal comment to be non null but" + " found that it was null", ipe.getFormalComment());
  25. }
  26. // public void testGenericsProblem_pr151978() { runTest("generics problem");}
  27. // public void testArgnamesAndJavac_pr148381() { runTest("argNames and javac");}
  28. // public void testCFlowXMLAspectLTW_pr149096() { runTest("cflow xml concrete aspect"); }
  29. // public void testAmbiguousBinding_pr121805() { runTest("ambiguous binding");}
  30. // public void testNegatedAnnotationMatchingProblem_pr153464() { runTest("negated annotation matching problem");}
  31. public void testAnnotationStyleBcException_pr162135() {
  32. runTest("bcexception in annotation style around advice");
  33. }
  34. public void testAnnotationStyleBcException_pr162135_2() {
  35. runTest("bcexception in annotation style around advice - 2");
  36. }
  37. public void testAnnotationStyleBcException_pr162135_3() {
  38. runTest("bcexception in annotation style around advice - 3");
  39. }
  40. public void testAnnotationStyleBcException_pr162135_4() {
  41. runTest("bcexception in annotation style around advice - 4");
  42. }
  43. public void testAnnotationStyleBcException_pr162135_5() {
  44. runTest("bcexception in annotation style around advice - 5");
  45. }
  46. public void testAnnotationStyleBcException_pr162135_6() {
  47. runTest("bcexception in annotation style around advice - 6");
  48. }
  49. public void testAnnotationStyleBcException_pr162135_7() {
  50. runTest("bcexception in annotation style around advice - 7");
  51. }
  52. public void testIncompatibleClassChangeWithITD_pr164633() {
  53. runTest("incompatibleclasschange");
  54. }
  55. public void testComplexPointcut_pr162657() {
  56. runTest("complex pointcut");
  57. }
  58. public void testGenericsInPointcuts_pr161502() {
  59. runTest("generics in pointcuts");
  60. }
  61. public void testGenericsInPointcuts_pr161502_2() {
  62. runTest("generics in pointcuts - 2");
  63. }
  64. public void testNoNPEDueToMissingType_pr149908() {
  65. runTest("ensure no npe due to missing type");
  66. }
  67. public void testNoNPEDueToMember_pr149908() {
  68. runTest("ensure no npe due to missing member");
  69. }
  70. public void testPTWgetWithinTypeName_pr123423_1() {
  71. runTest("basic usage of getWithinTypeName");
  72. }
  73. public void testPTWgetWithinTypeName_pr123423_2() {
  74. runTest("basic usage of getWithinTypeName - multiple types");
  75. }
  76. public void testPTWgetWithinTypeName_pr123423_3() {
  77. runTest("basic usage of getWithinTypeName - non matching types");
  78. }
  79. public void testPTWgetWithinTypeName_pr123423_4() {
  80. runTest("basic usage of getWithinTypeName - types in packages");
  81. }
  82. public void testPTWgetWithinTypeName_pr123423_5() {
  83. runTest("basic usage of getWithinTypeName - annotation style");
  84. }
  85. public void testTurningOffBcelCaching_pr160674() {
  86. runTest("turning off bcel caching");
  87. }
  88. public void testNoIllegalStateExceptionWithGenericInnerAspect_pr156058() {
  89. runTest("no IllegalStateException with generic inner aspect");
  90. }
  91. public void testNoIllegalStateExceptionWithGenericInnerAspect_pr156058_2() {
  92. runTest("no IllegalStateException with generic inner aspect - 2");
  93. }
  94. public void testDeclareMethodAnnotations_pr159143() {
  95. runTest("declare method annotations");
  96. }
  97. public void testVisibilityProblem_pr149071() {
  98. runTest("visibility problem");
  99. }
  100. public void testMissingLineNumbersInStacktraceAfter_pr145442() {
  101. runTest("missing line numbers in stacktrace after");
  102. }
  103. public void testMissingLineNumbersInStacktraceAround_pr145442() {
  104. runTest("missing line numbers in stacktrace around");
  105. }
  106. public void testGenericArrays_pr158624() {
  107. runTest("generics and arrays");
  108. }
  109. public void testMissingLineNumbersInStacktraceBefore_pr145442() {
  110. runTest("missing line numbers in stacktrace before");
  111. }
  112. public void testMissingLineNumbersInStacktraceBefore_pr145442_Binary() {
  113. runTest("missing line numbers in stacktrace before - binary");
  114. }
  115. public void testAnnotationStylePointcutNPE_pr158412() {
  116. runTest("annotation style pointcut npe");
  117. }
  118. public void testAnnotationStylePointcutNPE_pr158412_2() {
  119. runTest("annotation style pointcut npe - 2");
  120. }
  121. public void testAnnotationsCallConstructors_pr158126() {
  122. runTest("annotations, call and constructors problem");
  123. }
  124. public void testIllegalStateExceptionGenerics_pr153845() {
  125. runTest("IllegalStateException at GenericSignatureParser.java");
  126. }
  127. public void testNoIllegalStateExceptionFromAsmDelegate_pr153490_1() {
  128. runTest("no illegal state exception from AsmDelegate - 1");
  129. }
  130. public void testNoIllegalStateExceptionFromAsmDelegate_pr153490_2() {
  131. runTest("no illegal state exception from AsmDelegate - 2");
  132. }
  133. public void testNoIllegalStateExceptionFromAsmDelegate_pr153490_3() {
  134. runTest("no illegal state exception from AsmDelegate - 3");
  135. }
  136. public void testAnnotMethod_pr156962() {
  137. runTest("Test Annot Method");
  138. }
  139. public void testAnnotMethodHasMember_pr156962() {
  140. runTest("Test Annot Method Has Member");
  141. }
  142. public void testMixingGenerics_pr152848() {
  143. runTest("mixing generics");
  144. }
  145. public void testIncorrectStaticinitializationWeaving_pr149560_1() {
  146. runTest("incorrect staticinitialization weaving - codestyle");
  147. }
  148. public void testIncorrectStaticinitializationWeaving_pr149560_2() {
  149. runTest("incorrect staticinitialization weaving - annstyle");
  150. }
  151. public void testIncorrectDeprecatedAnnotationProcessing_pr154332() {
  152. runTest("incorrect deprecated annotation processing");
  153. }
  154. public void testPipeliningProblemWithAnnotationsDecp_pr153380_1() {
  155. runTest("pipelining decps");
  156. }
  157. public void testUnwantedPointcutWarning_pr148219() {
  158. runTest("unwanted warning for pointcut");
  159. }
  160. public void testDecpAndCflowadderMungerClash_pr152631() {
  161. runTest("decp and cflowadder munger clash");
  162. }
  163. public void testGenericInheritanceDecp_pr150095() {
  164. runTest("generics, inheritance and decp");
  165. }
  166. public void testIllegalStateException_pr148737() {
  167. runTest("illegalstateexception for non generic type");
  168. }
  169. public void testAtajInheritance_pr149305_1() {
  170. runTest("ataj inheritance - 1");
  171. }
  172. public void testAtajInheritance_pr149305_2() {
  173. runTest("ataj inheritance - 2");
  174. }
  175. public void testAtajInheritance_pr149305_3() {
  176. runTest("ataj inheritance - 3");
  177. }
  178. // public void testVerificationFailureForAspectOf_pr148693() {
  179. // runTest("verification problem"); // build the code
  180. // Utils.verifyClass(ajc, "mypackage.MyAspect"); // verify it <<< BRAND NEW VERIFY UTILITY FOR EVERYONE TO TRY ;)
  181. // }
  182. public void testIncorrectAnnotationValue_pr148537() {
  183. runTest("incorrect annotation value");
  184. }
  185. public void testVerifyErrNoTypeCflowField_pr145693_1() {
  186. runTest("verifyErrNoTypeCflowField");
  187. }
  188. public void testVerifyErrInpathNoTypeCflowField_pr145693_2() {
  189. runTest("verifyErrInpathNoTypeCflowField");
  190. }
  191. public void testCpathNoTypeCflowField_pr145693_3() {
  192. runTest("cpathNoTypeCflowField");
  193. }
  194. // public void testAdviceNotWovenAspectPath_pr147841() { runTest("advice not woven on aspectpath");}
  195. public void testGenericSignatures_pr148409() {
  196. runTest("generic signature problem");
  197. }
  198. public void testCantFindType_pr149322_01() {
  199. runTest("can't find type on interface call 1");
  200. }
  201. public void testCantFindType_pr149322_02() {
  202. runTest("can't find type on interface call 2");
  203. }
  204. public void testCantFindType_pr149322_03() {
  205. runTest("can't find type on interface call 3");
  206. }
  207. public void testParsingBytecodeLess_pr152871() {
  208. Utility.testingParseCounter = 0;
  209. runTest("parsing bytecode less");
  210. assertTrue("Should have called parse 2 times, not " + Utility.testingParseCounter + " times",
  211. Utility.testingParseCounter == 2);
  212. // 5 means: // 3 of these are gone with change to UnwovenClassFileWTPMB to take a classname in ctor
  213. // (1)=registerAspect
  214. // (2,3)=checkingIfShouldWeave,AcceptingResult for class
  215. // (4,5)=checkingIfShouldWeave,AcceptingResult for aspect
  216. }
  217. public void testMatchVolatileField_pr150671() {
  218. runTest("match volatile field");
  219. }
  220. public void testDuplicateJVMTIAgents_pr151938() {
  221. runTest("Duplicate JVMTI agents");
  222. }
  223. public void testLTWWorldWithAnnotationMatching_pr153572() {
  224. runTest("LTWWorld with annotation matching");
  225. }
  226. public void testReweavableAspectNotRegistered_pr129525() {
  227. runTest("reweavableAspectNotRegistered error");
  228. }
  229. public void testNPEinConstructorSignatureImpl_pr155972() {
  230. runTest("NPE in ConstructorSignatureImpl");
  231. }
  232. public void testNPEinFieldSignatureImpl_pr155972() {
  233. runTest("NPE in FieldSignatureImpl");
  234. }
  235. public void testNPEinInitializerSignatureImpl_pr155972() {
  236. runTest("NPE in InitializerSignatureImpl");
  237. }
  238. public void testLineNumberTableCorrectWithGenericsForEachAndContinue_pr155763() {
  239. runTest("ensure LineNumberTable correct with generics, for each and continue");
  240. }
  241. public void testDeclareSoftDoesntAllowUndeclaredExInAnonInnerClass_pr151772() {
  242. runTest("ensure declare soft doesn't allow undeclared exception in anonymous inner class");
  243. }
  244. public void testDeclareSoftDoesntAllowUndeclaredExInAnonInnerClass_pr151772_2() {
  245. runTest("ensure declare soft doesn't allow undeclared exception in anonymous inner class - 2");
  246. }
  247. public void testDeclareSoftAndInnerClasses_pr125981() {
  248. runTest("declare soft and inner classes");
  249. }
  250. public void testGetSourceSignature_pr148908() {
  251. runTest("ensure getSourceSignature correct with static field");
  252. IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy();
  253. IProgramElement ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, "MY_COMPARATOR");
  254. String expected = "static final Comparator MY_COMPARATOR = null;\n";
  255. assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
  256. .getSourceSignature());
  257. ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, "aString");
  258. expected = "static final String aString = \"Constant String\";\n";
  259. assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
  260. .getSourceSignature());
  261. ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, "bString");
  262. expected = "static final String bString = aString;\n";
  263. assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
  264. .getSourceSignature());
  265. ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, "cString");
  266. expected = "static final String cString = (aString + bString);\n";
  267. assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
  268. .getSourceSignature());
  269. ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, "dString");
  270. expected = "static final String dString = ((aString + \" and \") + bString);\n";
  271. assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
  272. .getSourceSignature());
  273. ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, "eString");
  274. expected = "static final String eString = \"Hello World\";\n";
  275. assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
  276. .getSourceSignature());
  277. ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, "aList");
  278. expected = "public List<String> aList = null;\n";
  279. assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
  280. .getSourceSignature());
  281. ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, "bList");
  282. expected = "public List<String> bList = null;\n";
  283. assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
  284. .getSourceSignature());
  285. ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, "cList");
  286. expected = "public List<String> cList = null;\n";
  287. assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
  288. .getSourceSignature());
  289. }
  290. // public void testNPEWithCustomAgent_pr158205() {
  291. // runTest("NPE with custom agent");
  292. // }
  293. public void testWeaveConcreteSubaspectWithAdvice_pr132080() {
  294. runTest("Weave concrete sub-aspect with advice");
  295. }
  296. public void testWeaveConcreteSubaspectWithITD_pr132080() {
  297. runTest("Weave concrete sub-aspect with ITD");
  298. }
  299. public void testWeaveConcreteSubaspectWithAroundClosure_pr132080() {
  300. runTest("Weave concrete sub-aspect with around closure");
  301. }
  302. public void testWeaveConcreteSubaspectWithCflow_pr132080() {
  303. runTest("Weave concrete sub-aspect with cflow");
  304. }
  305. public void testNPEWithLTWPointcutLibraryAndMissingAspectDependency_pr158957() {
  306. runTest("NPE with LTW, pointcut library and missing aspect dependency");
  307. }
  308. public void testNoInvalidAbsoluteTypeNameWarning_pr156904_1() {
  309. runTest("ensure no invalidAbsoluteTypeName when do match - 1");
  310. }
  311. public void testNoInvalidAbsoluteTypeNameWarning_pr156904_2() {
  312. runTest("ensure no invalidAbsoluteTypeName when do match - 2");
  313. }
  314. public void testNoInvalidAbsoluteTypeNameWarning_pr156904_3() {
  315. runTest("ensure no invalidAbsoluteTypeName when do match - 3");
  316. }
  317. public void testNoInvalidAbsoluteTypeNameWarning_pr156904_4() {
  318. runTest("ensure no invalidAbsoluteTypeName when do match - 4");
  319. }
  320. public void testNoNPEWithThrownExceptionWarningAndAtAspectj_pr161217() {
  321. runTest("NPE with thrown exception warning and at aspectj");
  322. }
  323. public void testJavadocCommentsAreSetIfHaveNormalComments_pr164340() {
  324. runTest("javadoc comments are set if have normal comments");
  325. IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy();
  326. IProgramElement ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.METHOD, "foo()");
  327. assertNotNull("expected formal comment to be non null but" + " found that it was null", ipe.getFormalComment());
  328. ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.METHOD, "bar()");
  329. assertNotNull("expected formal comment to be non null but" + " found that it was null", ipe.getFormalComment());
  330. ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.METHOD, "goo()");
  331. assertNull("expected formal comment to be null but" + " found that it was " + ipe.getFormalComment(), ipe
  332. .getFormalComment());
  333. }
  334. public void testBinaryWeavingIntoJava6Library_pr164384() {
  335. runTest("binary weaving into java 6 library");
  336. }
  337. public void testCompilanceJava6ThrowsUsageError_pr164384() {
  338. runTest("compliance java 6 throws usage error");
  339. }
  340. public void testSourceLevelJava6ThrowsUsageError_pr164384() {
  341. runTest("source level java 6 throws usage error");
  342. }
  343. public void testTargetLevelJava6ThrowsUsageError_pr164384() {
  344. runTest("target level java 6 throws usage error");
  345. }
  346. public void testStaticImport() {
  347. runTest("ensure static import reference have static modifier set");
  348. IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy();
  349. IProgramElement ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.IMPORT_REFERENCE,
  350. "ABC.StaticImport.Alphabet.A");
  351. String expected = "import static ABC.StaticImport.Alphabet.A;";
  352. assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
  353. .getSourceSignature());
  354. }
  355. public void testAspected_Annotation() {
  356. runTest("ensure Annotations are added to import list");
  357. IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy();
  358. IProgramElement ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.IMPORT_REFERENCE, "annotation.A");
  359. String expected = "import annotation.A;";
  360. assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
  361. .getSourceSignature());
  362. }
  363. public void testGetSourceSignature_GenericMethods() {
  364. runTest("ensure getSourceSignature correct with generic method");
  365. IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy();
  366. IProgramElement ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.METHOD, "returnT(T)");
  367. String expected = "public <T> T returnT(T a)";
  368. assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
  369. .getSourceSignature());
  370. ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.METHOD, "returnQ(Q)");
  371. expected = "public <Q extends List> Q returnQ(Q a)";
  372. assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
  373. .getSourceSignature());
  374. ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.METHOD, "doubleGeneric(Q,T)");
  375. expected = "public <T, Q> void doubleGeneric(Q a, T b)";
  376. assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
  377. .getSourceSignature());
  378. // Generic Method Constructor
  379. ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.CONSTRUCTOR, "C(T)");
  380. expected = "public <T> C(T b)";
  381. assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe
  382. .getSourceSignature());
  383. }
  384. // ///////////////////////////////////////
  385. public static Test suite() {
  386. return XMLBasedAjcTestCase.loadSuite(Ajc153Tests.class);
  387. }
  388. protected URL getSpecFile() {
  389. return getClassResource("ajc153.xml");
  390. }
  391. }