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.

Ajc121Tests.java 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. /* *******************************************************************
  2. * Copyright (c) 2004 IBM Corporation
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/epl-v10.html
  8. *
  9. * ******************************************************************/
  10. package org.aspectj.systemtest.ajc121;
  11. import java.net.URL;
  12. import org.aspectj.testing.XMLBasedAjcTestCase;
  13. import junit.framework.Test;
  14. public class Ajc121Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
  15. public static Test suite() {
  16. return XMLBasedAjcTestCase.loadSuite(Ajc121Tests.class);
  17. }
  18. protected URL getSpecFile() {
  19. return getClassResource("ajc121.xml");
  20. }
  21. public void test001(){
  22. runTest("false ambiguous binding error (introduced in 1.2rc2)");
  23. }
  24. public void test002(){
  25. runTest("An if() pointcut inside a perthis() clauses an ABORT - null pointer exception in ajc");
  26. }
  27. public void test003(){
  28. runTest("An if() pointcut inside a perthis() clauses an ABORT - null pointer exception in ajc");
  29. }
  30. public void test004(){
  31. runTest("An if() pointcut inside a perthis() clauses an ABORT - null pointer exception in ajc");
  32. }
  33. public void test005(){
  34. runTest("compiler aborts with 'conflicting dominates orders' with circular declare precedences");
  35. }
  36. public void test006(){
  37. runTest("'can't bind type' message has $ for . in type name for declare soft");
  38. }
  39. public void test007(){
  40. runTest("Hiding of Instance Methods by static methods");
  41. }
  42. public void test008(){
  43. runTest("if(false) optimisation");
  44. }
  45. public void test009(){
  46. runTest("if(true) optimisation");
  47. }
  48. public void test010(){
  49. runTest("java.lang.NullPointerException in WeaverMessageHandler class");
  50. }
  51. public void test011(){
  52. runTest("ClassCastException at BcelRenderer.java:169");
  53. }
  54. public void test012(){
  55. runTest("Front-end bug, shouldn't allow patterns of the form foo.., should be foo..*");
  56. }
  57. public void test013() {
  58. runTest("Nullpointer-Exception when defining a withincode() pointcut");
  59. }
  60. public void test014() {
  61. runTest("NPE, Incorrect XLint:unmatchedSuperTypeInCall warning");
  62. }
  63. public void test015_invalidXlint() { // keywords: "laurie hendren"
  64. runTest("invalid warning indicating no match when a match really occurs");
  65. }
  66. public void test016_ByteConversionInstructions() {
  67. runTest("RuntimeException thrown: Could not find instruction: org.apache.bcel.generic.B2I");
  68. String output = getLastRunResult().getStdErr();
  69. assertTrue("Expected to find [b2] in this output but didn't:"+output,output.indexOf("[b2]")!=-1);
  70. assertTrue("Expected to find [b127] in this output but didn't:"+output,output.indexOf("[b127]")!=-1);
  71. assertTrue("Expected to find [b0] in this output but didn't:"+output,output.indexOf("[b0]")!=-1);
  72. assertTrue("Expected to find [c65] in this output but didn't:"+output,output.indexOf("[c65]")!=-1);
  73. assertTrue("Expected to find [c66] in this output but didn't:"+output,output.indexOf("[c66]")!=-1);
  74. assertTrue("Expected to find [c67] in this output but didn't:"+output,output.indexOf("[c67]")!=-1);
  75. assertTrue("Expected to find [s1] in this output but didn't:"+output,output.indexOf("[s1]")!=-1);
  76. assertTrue("Expected to find [s32767] in this output but didn't:"+output,output.indexOf("[s32767]")!=-1);
  77. assertTrue("Expected to find [b0] in this output but didn't:"+output,output.indexOf("[b0]")!=-1);
  78. }
  79. public void test017_PrivateMethodCallsInAroundAdvice() {
  80. runTest("Cannot advise private method call in around advice");
  81. System.err.println(getLastRunResult().getStdErr());
  82. }
  83. public void test018_PrivateFieldSetsInAroundAdvice() {
  84. runTest("Cannot advise private field sets in around advice");
  85. System.err.println(getLastRunResult().getStdErr());
  86. }
  87. public void test019_PrivateFieldGetsInAroundAdvice() {
  88. runTest("Cannot advise private field gets in around advice");
  89. System.err.println(getLastRunResult().getStdErr());
  90. }
  91. // test takes over 5 minutes to run, so not included in normal suite run
  92. // public void test020_branchTargetOffsetTooLargeForShort() {
  93. // runTest("Branch target offset too large for short");
  94. // }
  95. // public void test021_BcelFailureWithVeryLargeClasses() {
  96. // runTest("Weaver fails in BCEL for large classes");
  97. // }
  98. //
  99. // public void test022_BcelFailureWithVeryLargeClasses_Binary() {
  100. // runTest("Weaver fails in BCEL for large classes (binary)");
  101. // }
  102. public void test023_proceedInAround1() {
  103. runTest("proceed used as method name in around advice (1)");
  104. }
  105. public void test024_proceedInAround2() {
  106. runTest("proceed used as method name in around advice (2)");
  107. }
  108. public void test025_proceedInAround3() {
  109. runTest("proceed used as method name in around advice (3)");
  110. }
  111. public void test026_bindingThisAndTargetToTheSameFormal() {
  112. runTest("ajc crashes when compiling the following program (binding this() and target())");
  113. }
  114. public void test027_itdsOnInnerClassesAsStatic() {
  115. runTest("ITDs on inner classes should be static context");
  116. }
  117. public void test028_itdsAndInitializers() {
  118. runTest("resolution of IT field inits");
  119. }
  120. public void test029_falseInvalidAbsoluteTypeName() {
  121. runTest("Valid but inaccessible type names should not be flagged by XLint:invalidAbsoluteTypeName");
  122. }
  123. public void test030_privateITDinitialisersBeingMatched() {
  124. runTest("intertype initialisers should match field set pointcuts");
  125. }
  126. public void test031_privateITDinitialisersBeingMatched_OxfordTest() {
  127. runTest("intertype initialisers should match field set pointcuts (oxford testcase)");
  128. //System.err.println(">"+getLastRunResult().getStdErr());
  129. String exp = ":set field set(int C.n):set field set(int C.m):get field get(int C.n):set field set(int C.n)";
  130. assertTrue("Expected output '"+exp+"' but got "+getLastRunResult().getStdErr(),
  131. getLastRunResult().getStdErr().equals(exp));
  132. }
  133. public void test032_stringConcatForDEOW() {
  134. runTest("Compile time declarations (warning and error) do not accept string concatenation (with +)");
  135. }
  136. public void test033_stringConcatForDEOWErrorCase() {
  137. runTest("Compile time declarations (warning and error) do not accept string concatenation (with +) (2)");
  138. }
  139. public void test034_scopeForITDS_pr61768() {
  140. runTest("scope for inter-type methods");
  141. }
  142. public void test035_innerAspectCallsPrivateMethod_pr71372() {
  143. runTest("NoSuchMethodError calling private method from around advice in inner aspect");
  144. String s = getLastRunResult().getStdErr();
  145. assertTrue("Expected ':before:around' but got "+s,
  146. s.equals(":before:around"));
  147. }
  148. public void test036_innerAspectCallsPrivateMethod_pr71372_2() {
  149. runTest("NoSuchMethodError calling private method from around advice in inner aspect (2)");
  150. String s = getLastRunResult().getStdErr();
  151. assertTrue("Expected ':before:around' but got "+s,
  152. s.equals(":before:around"));
  153. }
  154. public void test037_innerAspectCallsPrivateMethod_pr71372_3() {
  155. runTest("NoSuchMethodError calling private method from around advice in inner aspect (3)");
  156. String s = getLastRunResult().getStdErr();
  157. assertTrue("Expected ':before:around' but got "+s,
  158. s.equals(":before:around"));
  159. }
  160. public void test038_innerAspectCallsPrivateMethod_pr71372_4() {
  161. runTest("NoSuchMethodError calling private method from around advice in inner aspect (4)");
  162. String s = getLastRunResult().getStdErr();
  163. assertTrue("Expected ':before:around' but got "+s,
  164. s.equals(":before:around"));
  165. }
  166. public void test039_privilegedAspectAccessingPrivateMethods_pr67579() {
  167. runTest("NPE on privileged aspect error");
  168. }
  169. public void test040_privilegedAspectAccessingPrivateMethods_pr67579_2() {
  170. runTest("NPE on privileged aspect error (2)");
  171. }
  172. public void test041_ITDaccessingPrivateMethod_pr67578() {
  173. runTest("Privileged Aspect Access Problem Across Packages");
  174. }
  175. public void test042_ITDaccessingPrivateMethod_pr67578_2() {
  176. runTest("Privileged Aspect Access Problem Across Packages (2)");
  177. }
  178. public void test043_pr62642_ExceptionInInitializerError() {
  179. runTest("proper handling of ExceptionInIntializer inside clinit in presence of after throwing advice");
  180. String s = getLastRunResult().getStdErr();
  181. assertTrue("Output should contain java.lang.ExceptionInInitializerError but is '"+s+"'",
  182. s.indexOf("java.lang.ExceptionInInitializerError")!=-1);
  183. // No getCause on 1.3 JVMs
  184. // assertTrue("Output should contain 'CAUSE=org.aspectj.lang.NoAspectBoundException' but is '"+s+"'",
  185. // s.indexOf("CAUSE=org.aspectj.lang.NoAspectBoundException")!=-1);
  186. }
  187. public void test044_ITDnameClashes() {
  188. runTest("ITD name clashes with private members");
  189. }
  190. public void test045_ITDprotectedVisibility() {
  191. runTest("Inconsistency in scoping of protected members in ITDs");
  192. }
  193. public void test045_wrongLineForExecutionJoinPoint() {
  194. runTest("wrong line for method execution join point");
  195. }
  196. public void test046_interfaceITD_pr70794_1() {
  197. runTest("The introduction on interface causes the interface implementation class error (1)");
  198. }
  199. public void test047_interfaceITD_pr70794_2() {
  200. runTest("The introduction on interface causes the interface implementation class error (2)");
  201. }
  202. public void test048_interfaceITD_pr70794_3() {
  203. runTest("The introduction on interface causes the interface implementation class error (3)");
  204. }
  205. public void test049_interfaceITD_pr70794_4() {
  206. runTest("The introduction on interface causes the interface implementation class error (4)");
  207. }
  208. public void test050_typePatternMatchingWithArrays() {
  209. runTest("declare warning warns at wrong points");
  210. }
  211. public void test052_bogusMessage1() {
  212. runTest("Bogus error message: The abstract method ajc$pointcut$$tracingScope$a2 in type Tracing can only be defined by an abstract class (1)");
  213. }
  214. public void test053_bogusMessage2() {
  215. runTest("Bogus error message: The abstract method ajc$pointcut$$tracingScope$a2 in type Tracing can only be defined by an abstract class (2)");
  216. }
  217. public void test054_cnfe() {
  218. runTest("passing null to array arguments confuzes static join point signature. (1)");
  219. }
  220. public void test055_cnfe() {
  221. runTest("passing null to array arguments confuzes static join point signature. (2)");
  222. }
  223. public void test056_arrayCloning() {
  224. runTest("around advice throws java.lang.VerifyError at runtime");
  225. }
  226. public void test057_decSoftWithSuper() {
  227. runTest("declare soft can cause programs with invalid exception behaviour to be generated");
  228. }
  229. public void test058_npeOnTJPerror() {
  230. runTest("NPE on thisJoinPoint mistake");
  231. }
  232. public void test059_cflowOptimization_counters() {
  233. runTest("Optimization of cflow - counters (1)");
  234. }
  235. public void test060_cflowOptimization_counters() {
  236. runTest("Optimization of cflow - shared counters (2)");
  237. }
  238. public void test061_cflowOptimization_counters() {
  239. runTest("Optimization of cflow - shared stacks (3)");
  240. }
  241. public void test062_cflowOptimization_counters() {
  242. runTest("Optimization of cflow - counters (4)");
  243. }
  244. public void test063_cflowOptimization_countersWithAbstractPcuts() {
  245. runTest("Optimization of cflow - counters with abstract pointcuts (5)");
  246. }
  247. public void test064() {
  248. runTest("Anonymous classes unaware of introductions into abstract classes");
  249. }
  250. private int countLines(String s) {
  251. int lines = 0;
  252. int idx = 0;
  253. while (s.indexOf("\n",idx)!=-1) {
  254. lines++;
  255. idx = s.indexOf("\n",idx)+1;
  256. }
  257. return lines;
  258. }
  259. public void test065() {
  260. runTest("before,after not (cflow(within(Trace*))) prints nothing");
  261. String s = getLastRunResult().getStdErr();
  262. int lines = countLines(s);
  263. assertTrue("The actual output does not match the expected output. Expected 102 lines but got "+
  264. lines+" lines. Actual output =\n"+s,lines==102);
  265. // IF YOU WANT TO SEE THE EXPECTED OUTPUT, LOOK IN THE TEST PROGRAM bugs/WhatsGoingOn.java
  266. }
  267. }