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.

Ajc1612Tests.java 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. /*******************************************************************************
  2. * Copyright (c) 2008 Contributors
  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.ajc1612;
  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.asm.internal.ProgramElement;
  17. import org.aspectj.testing.XMLBasedAjcTestCase;
  18. /**
  19. * @author Andy Clement
  20. */
  21. public class Ajc1612Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
  22. // public void testAnnoCopying_345515() {
  23. // runTest("anno copying");
  24. // }
  25. // public void testDoubleITDF() throws Exception {
  26. // runTest("double itdf");
  27. // }
  28. // public void testItdSplitCompilation_354683() throws Exception {
  29. // runTest("itd split compilation");
  30. // }
  31. public void testXmlDefs() {
  32. runTest("xml defined advice");
  33. }
  34. public void testXmlDefs2() {
  35. runTest("xml defined advice 2");
  36. }
  37. // using a parameter
  38. public void testXmlDefs3() {
  39. runTest("xml defined advice 3");
  40. }
  41. // using bad parameters
  42. public void testXmlDefs4() {
  43. runTest("xml defined advice 4");
  44. }
  45. // binding
  46. public void testXmlDefs5() {
  47. runTest("xml defined advice 5");
  48. }
  49. // before and after advice
  50. public void testXmlDefs6() {
  51. runTest("xml defined advice 6");
  52. }
  53. // thisJoinPoint
  54. public void testXmlDefs7() {
  55. runTest("xml defined advice 7");
  56. }
  57. // thisJoinPointStaticPart
  58. public void testXmlDefs8() {
  59. runTest("xml defined advice 8");
  60. }
  61. // void around advice
  62. public void testXmlDefs9() {
  63. runTest("xml defined advice 9");
  64. }
  65. // non-void around advice
  66. public void testXmlDefs10() {
  67. runTest("xml defined advice 10");
  68. }
  69. // non-void around advice with proceed
  70. public void testXmlDefs11() {
  71. runTest("xml defined advice 11");
  72. }
  73. // non primitive return (that is actually used) and proceed
  74. public void testXmlDefs12() {
  75. runTest("xml defined advice 12");
  76. }
  77. // delegate type in package
  78. public void testXmlDefs13() {
  79. runTest("xml defined advice 13");
  80. }
  81. public void testCorrespondingType_357582() {
  82. for (int i = 0; i < 100000; i++) {
  83. assertEquals("AAA", convert("AAA"));
  84. assertEquals("AAA", convert("a.b.c.AAA"));
  85. assertEquals("A", convert("aa.ba.ca.A"));
  86. assertEquals("AAA<>", convert("a.b.c.AAA<>"));
  87. assertEquals("AAA<A>", convert("a.b.c.AAA<A>"));
  88. assertEquals("AAA<A>", convert("a.b.c.AAA<aa.A>"));
  89. assertEquals("AAA<A,B>", convert("a.b.c.AAA<aa.A,bb.B>"));
  90. assertEquals("AAA<A<B>>", convert("a.b.c.AAA<aa.A<bb.B>>"));
  91. assertEquals("AAA<A<B>,AA<GG<KK>>>", convert("a.b.c.AAA<aa.A<bb.B>,a.b.c.AA<GG<KK>>>"));
  92. }
  93. long time = System.currentTimeMillis();
  94. for (int i = 0; i < 1000000; i++) {
  95. assertEquals("AAA", convert("AAA"));
  96. assertEquals("AAA", convert("a.b.c.AAA"));
  97. assertEquals("A", convert("aa.ba.ca.A"));
  98. assertEquals("AAA<>", convert("a.b.c.AAA<>"));
  99. assertEquals("AAA<A>", convert("a.b.c.AAA<A>"));
  100. assertEquals("AAA<A>", convert("a.b.c.AAA<aa.A>"));
  101. assertEquals("AAA<A,B>", convert("a.b.c.AAA<aa.A,bb.B>"));
  102. assertEquals("AAA<A<B>>", convert("a.b.c.AAA<aa.A<bb.B>>"));
  103. assertEquals("AAA<A<B>,AA<GG<KK>>>", convert("a.b.c.AAA<aa.A<bb.B>,a.b.c.AA<GG<KK>>>"));
  104. }
  105. System.out.println(System.currentTimeMillis() - time);
  106. }
  107. private String convert(String totrim) {
  108. return ProgramElement.trim(totrim);
  109. }
  110. public void testPervasivePerthis_354470() throws Exception {
  111. runTest("perthis too pervasive");
  112. }
  113. public void testPervasivePerthis_354470_2() throws Exception {
  114. runTest("perthis too pervasive 2");
  115. }
  116. public void testPervasivePerthis_354470_3() throws Exception {
  117. runTest("perthis too pervasive 3");
  118. }
  119. public void testNotEqualWithAnnotationValues_357013() throws Exception {
  120. runTest("annotation values not equal");
  121. }
  122. public void testNotEqualWithAnnotationValues_357013_2() throws Exception {
  123. runTest("annotation values not equal 2");
  124. }
  125. public void testClassRef_357012() throws Exception {
  126. runTest("class reference in annotation value");
  127. }
  128. public void testClassRefInvalidName_357012_2() throws Exception {
  129. runTest("class reference in annotation value - invalid typename");
  130. }
  131. public void testClassRef_357012_3() throws Exception {
  132. runTest("class reference in annotation value 3");
  133. }
  134. public void testAnnotationFieldBindingOptimization_356612() throws Exception {
  135. runTest("annotation field binding optimization");
  136. }
  137. public void testAnnotationFieldBindingOptimization_356612_2() throws Exception {
  138. runTest("annotation field binding optimization - 2");
  139. }
  140. public void testThisAspectInstance_239649_1() throws Exception {
  141. // simple case
  142. runTest("thisAspectInstance - 1");
  143. }
  144. public void testThisAspectInstance_239649_2() throws Exception {
  145. // before advice toggling on/off through if called method
  146. runTest("thisAspectInstance - 2");
  147. }
  148. public void testThisAspectInstance_239649_3() throws Exception {
  149. // after advice toggling on/off through if called method
  150. runTest("thisAspectInstance - 3");
  151. }
  152. public void testThisAspectInstance_239649_4() throws Exception {
  153. // before advice, also using thisJoinPointStaticPart
  154. runTest("thisAspectInstance - 4");
  155. }
  156. public void testThisAspectInstance_239649_5() throws Exception {
  157. // before advice, also using thisJoinPoint
  158. runTest("thisAspectInstance - 5");
  159. }
  160. public void testThisAspectInstance_239649_6() throws Exception {
  161. // before advice, also using thisEnclosingJoinPointStaticPart
  162. runTest("thisAspectInstance - 6");
  163. }
  164. public void testThisAspectInstance_239649_7() throws Exception {
  165. // before advice, also using thisJoinPoint and thisJoinPointStaticPart
  166. runTest("thisAspectInstance - 7");
  167. }
  168. public void testThisAspectInstance_239649_8() throws Exception {
  169. // before advice, also using abstract aspects
  170. runTest("thisAspectInstance - 8");
  171. }
  172. public void testThisAspectInstance_239649_9() throws Exception {
  173. // before advice, also using abstract aspects 2
  174. runTest("thisAspectInstance - 9");
  175. }
  176. public void testThisAspectInstance_239649_10() throws Exception {
  177. // aspects in a package
  178. runTest("thisAspectInstance - 10");
  179. }
  180. public void testThisAspectInstance_239649_11() throws Exception {
  181. // non-singleton aspect - should be an error for now
  182. runTest("thisAspectInstance - 11");
  183. }
  184. public void testThisAspectInstance_239649_12() throws Exception {
  185. // arg binding and tjpsp
  186. runTest("thisAspectInstance - 12");
  187. }
  188. public void testThisAspectInstance_239649_13() throws Exception {
  189. // pass instance
  190. runTest("thisAspectInstance - 13");
  191. }
  192. public void testThisAspectInstance_239649_14() throws Exception {
  193. // multiple ifs
  194. runTest("thisAspectInstance - 14");
  195. }
  196. public void testThisAspectInstance_239649_15() throws Exception {
  197. // abstract aspects
  198. runTest("thisAspectInstance - 15");
  199. }
  200. // public void testVerifyPerthis() throws Exception {
  201. // runTest("verify perthis");
  202. // }
  203. public void testRangeForLocalVariables_353936() throws ClassNotFoundException {
  204. runTest("local variable tables");
  205. JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "X");
  206. Method[] meths = jc.getMethods();
  207. boolean checked = false;
  208. for (int i = 0; i < meths.length; i++) {
  209. Method method = meths[i];
  210. if (method.getName().equals("ajc$before$X$2$3444dde4")) {
  211. System.out.println(method.getName());
  212. System.out.println(stringify(method.getLocalVariableTable()));
  213. System.out.println(method.getCode().getLength());
  214. checked = true;
  215. assertEquals("LX; this(0) start=0 len=48", stringify(method.getLocalVariableTable(), 0));
  216. assertEquals("Lorg/aspectj/lang/JoinPoint; thisJoinPoint(1) start=0 len=48",
  217. stringify(method.getLocalVariableTable(), 1));
  218. assertEquals("I i(2) start=8 len=22", stringify(method.getLocalVariableTable(), 2));
  219. }
  220. }
  221. assertTrue(checked);
  222. }
  223. public void testEmptyPattern_pr352363() {
  224. runTest("empty pattern");
  225. }
  226. public void testGenericsIssue_pr351592() {
  227. runTest("generics issue");
  228. }
  229. public void testGenericsIssue_pr351592_2() {
  230. runTest("generics issue - 2");
  231. }
  232. public void testGenericsNpe_pr350800() {
  233. runTest("generics npe");
  234. }
  235. public void testGenericsNpe_pr350800_code() {
  236. runTest("generics npe - code");
  237. }
  238. public void testGenericsNpe_pr350800_3() {
  239. runTest("generics npe - 3");
  240. }
  241. public void testOrdering_pr349961() {
  242. runTest("ordering");
  243. }
  244. public void testOrdering_pr349961_2() {
  245. runTest("ordering - 2");
  246. }
  247. /*
  248. * public void testVerifyError_pr347395() { runTest("verifyerror - inline"); }
  249. */
  250. public void testDuplicateMethods_349398() {
  251. runTest("duplicate methods");
  252. }
  253. public void testBindingInts_347684() {
  254. runTest("binding ints");
  255. }
  256. public void testBindingInts_347684_2() {
  257. runTest("binding ints - 2");
  258. }
  259. public void testBindingInts_347684_3() {
  260. runTest("binding ints - 3");
  261. }
  262. public void testBindingInts_347684_4() {
  263. runTest("binding ints - 4");
  264. }
  265. public void testBindingInts_347684_5() {
  266. runTest("binding ints - 5");
  267. }
  268. public void testBindingInts_347684_6() {
  269. runTest("binding ints - 6");
  270. }
  271. public void testIncorrectAnnos_345172() {
  272. runTest("incorrect annos");
  273. }
  274. public void testIncorrectAnnos_345172_2() {
  275. runTest("incorrect annos 2");
  276. }
  277. public void testIncorrectAnnos_345172_3() {
  278. runTest("incorrect annos 3");
  279. }
  280. public void testSyntheticMethods_327867() {
  281. runTest("synthetic methods");
  282. }
  283. // public void testSignedJarLtw_328099() {
  284. // runTest("signed jar ltw");
  285. // }
  286. public void testVerifyError_315398() {
  287. runTest("verifyerror");
  288. }
  289. public void testVerifyError_315398_2() {
  290. runTest("verifyerror - 2");
  291. }
  292. public void testRawTypePointcut_327134() {
  293. runTest("rawtype pointcut");
  294. }
  295. public void testRawTypeWarning_335810() {
  296. runTest("rawtype warning");
  297. }
  298. // public void testDecpGenerics_344005() {
  299. // runTest("decp generics");
  300. // }
  301. public void testIllegalAccessError_343051() {
  302. runTest("illegalaccesserror");
  303. }
  304. public void testItitNpe_339974() {
  305. runTest("itit npe");
  306. }
  307. // public void testNoImportError_342605() {
  308. // runTest("noimporterror");
  309. // }
  310. public void testClashingLocalTypes_342323() {
  311. runTest("clashing local types");
  312. }
  313. public void testITIT_338175() {
  314. runTest("itit");
  315. }
  316. public void testThrowsClause_292239() {
  317. runTest("throws clause");
  318. }
  319. public void testThrowsClause_292239_2() {
  320. runTest("throws clause - 2");
  321. }
  322. // ---
  323. public static Test suite() {
  324. return XMLBasedAjcTestCase.loadSuite(Ajc1612Tests.class);
  325. }
  326. @Override
  327. protected File getSpecFile() {
  328. return new File("../tests/src/org/aspectj/systemtest/ajc1612/ajc1612.xml");
  329. }
  330. }