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

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