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.

AtAjLTWTests.java 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. /*******************************************************************************
  2. * Copyright (c) 2005 Contributors.
  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://eclipse.org/legal/epl-v10.html
  8. *
  9. * Contributors:
  10. * Alexandre Vasseur initial implementation
  11. *******************************************************************************/
  12. package org.aspectj.systemtest.ajc150.ataspectj;
  13. import java.io.File;
  14. import java.io.FilenameFilter;
  15. import junit.framework.Test;
  16. import org.aspectj.testing.XMLBasedAjcTestCase;
  17. import org.aspectj.util.FileUtil;
  18. /**
  19. * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
  20. */
  21. public class AtAjLTWTests extends XMLBasedAjcTestCase {
  22. public static Test suite() {
  23. return XMLBasedAjcTestCase.loadSuite(org.aspectj.systemtest.ajc150.ataspectj.AtAjLTWTests.class);
  24. }
  25. protected File getSpecFile() {
  26. return new File("../tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml");
  27. }
  28. public void testRunThemAllWithJavacCompiledAndLTW() {
  29. runTest("RunThemAllWithJavacCompiledAndLTW");
  30. }
  31. public void testAjcLTWPerClauseTest_XterminateAfterCompilation() {
  32. runTest("AjcLTW PerClauseTest -XterminateAfterCompilation");
  33. }
  34. public void testAjcLTWPerClauseTest_Xreweavable() {
  35. runTest("AjcLTW PerClauseTest -Xreweavable");
  36. }
  37. public void testJavaCAjcLTWPerClauseTest() {
  38. runTest("JavaCAjcLTW PerClauseTest");
  39. }
  40. public void testAjcLTWAroundInlineMungerTest_XterminateAfterCompilation() {
  41. runTest("AjcLTW AroundInlineMungerTest -XterminateAfterCompilation");
  42. }
  43. public void testAjcLTWAroundInlineMungerTest_Xreweavable() {
  44. runTest("AjcLTW AroundInlineMungerTest");
  45. }
  46. public void testAjcLTWAroundInlineMungerTest() {
  47. runTest("AjcLTW AroundInlineMungerTest");
  48. }
  49. public void testAjcLTWAroundInlineMungerTest_XnoInline_Xreweavable() {
  50. runTest("AjcLTW AroundInlineMungerTest -XnoInline -Xreweavable");
  51. }
  52. public void testAjcLTWAroundInlineMungerTest2() {
  53. runTest("AjcLTW AroundInlineMungerTest2");
  54. }
  55. public void testLTWDumpNone() {
  56. runTest("LTW DumpTest none");
  57. File f = new File("_ajdump/ataspectj/DumpTest.class");
  58. assertFalse(f.exists());
  59. f = new File("_ajdump/_before/ataspectj/DumpTestTheDump.class");
  60. assertFalse(f.exists());
  61. f = new File("_ajdump/ataspectj/DumpTestTheDump.class");
  62. assertFalse(f.exists());
  63. }
  64. public void testLTWDump() {
  65. runTest("LTW DumpTest");
  66. File f = new File("_ajdump/ataspectj/DumpTest.class");
  67. assertFalse(f.exists());
  68. f = new File("_ajdump/_before/ataspectj/DumpTestTheDump.class");
  69. assertFalse(f.exists());
  70. f = new File("_ajdump/ataspectj/DumpTestTheDump.class");
  71. assertTrue(f.exists());
  72. // tidy up...
  73. f = new File("_ajdump");
  74. FileUtil.deleteContents(f);
  75. f.delete();
  76. }
  77. public void testLTWDumpBeforeAndAfter() {
  78. runTest("LTW DumpTest before and after");
  79. // before
  80. File f = new File("_ajdump/_before/com/foo/bar");
  81. CountingFilenameFilter cff = new CountingFilenameFilter();
  82. f.listFiles(cff);
  83. assertEquals("Expected dump file in " + f.getAbsolutePath(),1,cff.getCount());
  84. // after
  85. f = new File("_ajdump/com/foo/bar");
  86. cff = new CountingFilenameFilter();
  87. f.listFiles(cff);
  88. assertEquals("Expected dump file in " + f.getAbsolutePath(),1,cff.getCount());
  89. // tidy up...
  90. f = new File("_ajdump");
  91. FileUtil.deleteContents(f);
  92. f.delete();
  93. }
  94. public void testLTWDumpClosure() {
  95. runTest("LTW DumpTest closure");
  96. File f = new File("_ajdump/ataspectj/DumpTestTheDump$AjcClosure1.class");
  97. assertTrue("Missing dump file " + f.getAbsolutePath(),f.exists());
  98. // tidy up...
  99. f = new File("_ajdump");
  100. FileUtil.deleteContents(f);
  101. f.delete();
  102. }
  103. public void testLTWDumpProxy() {
  104. runTest("LTW DumpTest proxy");
  105. // The working directory is different because this test must be forked
  106. File dir = new File("../tests/java5/ataspectj");
  107. File f = new File(dir,"_ajdump/_before");
  108. CountingFilenameFilter cff = new CountingFilenameFilter();
  109. f.listFiles(cff);
  110. assertEquals("Expected dump file in " + f.getAbsolutePath(),1,cff.getCount());
  111. f = new File(dir,"_ajdump");
  112. cff = new CountingFilenameFilter();
  113. f.listFiles(cff);
  114. assertEquals(1,cff.getCount());
  115. // tidy up...
  116. f = new File(dir,"_ajdump");
  117. FileUtil.deleteContents(f);
  118. f.delete();
  119. }
  120. public void testAjcAspect1LTWAspect2_Xreweavable() {
  121. runTest("Ajc Aspect1 LTW Aspect2 -Xreweavable");
  122. }
  123. public void testLTWLogSilent() {
  124. runTest("LTW Log silent");
  125. }
  126. public void testLTWLogVerbose() {
  127. runTest("LTW Log verbose");
  128. }
  129. public void testLTWLogVerboseAndShow() {
  130. runTest("LTW Log verbose and showWeaveInfo");
  131. }
  132. public void testLTWLogMessageHandlerClass() {
  133. runTest("LTW Log messageHandlerClass");
  134. }
  135. public void testLTWUnweavable() {
  136. // actually test that we do LTW proxy and jit classes
  137. runTest("LTW Unweavable");
  138. }
  139. public void testLTWDecp() {
  140. runTest("LTW Decp");
  141. }
  142. public void testLTWDecp2() {
  143. runTest("LTW Decp2");
  144. }
  145. public void testCompileTimeAspectsDeclaredToLTWWeaver() {
  146. runTest("Compile time aspects declared to ltw weaver");
  147. }
  148. public void testConcreteAtAspect() {
  149. runTest("Concrete@Aspect");
  150. }
  151. public void testConcreteAspect() {
  152. runTest("ConcreteAspect");
  153. }
  154. public void testConcretePrecedenceAspect() {
  155. runTest("ConcretePrecedenceAspect");
  156. }
  157. public void testAspectOfWhenAspectNotInInclude() {
  158. runTest("AspectOfWhenAspectNotInInclude");
  159. }
  160. public void testAspectOfWhenAspectExcluded_pr152873() {
  161. runTest("AspectOfWhenAspectExcluded");
  162. }
  163. public void testAspectOfWhenNonAspectExcluded_pr152873() {
  164. runTest("AspectOfWhenNonAspectExcluded");
  165. }
  166. public void testAppContainer() {
  167. runTest("AppContainer");
  168. }
  169. public void testCflowBelowStack() {
  170. runTest("CflowBelowStack");
  171. }
  172. private static class CountingFilenameFilter implements FilenameFilter {
  173. private int count;
  174. public boolean accept(File dir, String name) {
  175. if (name.endsWith(".class")) count++;
  176. return false;
  177. }
  178. public int getCount() {
  179. return count;
  180. }
  181. }
  182. }