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.

LTWTests.java 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. * Matthew Webster initial implementation
  11. *******************************************************************************/
  12. package org.aspectj.systemtest.ajc150.ltw;
  13. import java.io.File;
  14. import java.util.Enumeration;
  15. import java.util.Properties;
  16. import org.aspectj.testing.XMLBasedAjcTestCase;
  17. import org.aspectj.weaver.tools.WeavingAdaptor;
  18. import junit.framework.Test;
  19. public class LTWTests extends org.aspectj.testing.XMLBasedAjcTestCase {
  20. public static Test suite() {
  21. return XMLBasedAjcTestCase.loadSuite(LTWTests.class);
  22. }
  23. protected java.net.URL getSpecFile() {
  24. return getClassResource("ltw.xml");
  25. }
  26. public void testInclusionAndPattern() {
  27. runTest("Inclusion and patterns");
  28. }
  29. public void testExclusionAndPattern() {
  30. runTest("Exclusion and patterns");
  31. }
  32. public void testAndPatternsAspects() {
  33. runTest("And patterns aspects");
  34. }
  35. public void test001(){
  36. runTest("Ensure 1st aspect is rewoven when weaving 2nd aspect");
  37. }
  38. public void testOutxmlFile (){
  39. runTest("Ensure valid aop.xml file is generated");
  40. }
  41. public void testOutxmlJar (){
  42. runTest("Ensure valid aop.xml is generated for -outjar");
  43. }
  44. public void testNoAopxml(){
  45. setSystemProperty(WeavingAdaptor.WEAVING_ADAPTOR_VERBOSE,"true");
  46. runTest("Ensure no weaving without visible aop.xml");
  47. }
  48. public void testDefineConcreteAspect(){
  49. runTest("Define concrete sub-aspect using aop.xml");
  50. }
  51. public void testDeclareAbstractAspect(){
  52. // setSystemProperty(WeavingAdaptor.WEAVING_ADAPTOR_VERBOSE,"true");
  53. // setSystemProperty(WeavingAdaptor.SHOW_WEAVE_INFO_PROPERTY,"true");
  54. runTest("Use abstract aspect for ITD using aop.xml");
  55. }
  56. public void testAspectsInclude () {
  57. runTest("Ensure a subset of inherited aspects is used for weaving");
  58. }
  59. public void testAspectsIncludeWithLintWarning () {
  60. runTest("Ensure weaver lint warning issued when an aspect is not used for weaving");
  61. }
  62. public void testXsetEnabled () {
  63. runTest("Set Xset properties enabled");
  64. }
  65. public void testXsetDisabled () {
  66. runTest("Set Xset properties disabled");
  67. }
  68. public void testXlintfileEmpty () {
  69. runTest("Empty Xlint.properties file");
  70. }
  71. public void testXlintfileMissing () {
  72. runTest("Warning with missing Xlint.properties file");
  73. }
  74. public void testXlintWarningAdviceDidNotMatchSuppressed () {
  75. runTest("Warning when advice doesn't match suppressed for LTW");
  76. }
  77. public void testXlintfile () {
  78. runTest("Override suppressing of warning when advice doesn't match using -Xlintfile");
  79. }
  80. public void testXlintDefault () {
  81. runTest("Warning when advice doesn't match using -Xlint:default");
  82. }
  83. public void testXlintWarning () {
  84. runTest("Override suppressing of warning when advice doesn't match using -Xlint:warning");
  85. }
  86. public void testNonstandardJarFiles() {
  87. runTest("Nonstandard jar file extensions");
  88. }
  89. public void testOddzipOnClasspath() {
  90. runTest("Odd zip on classpath");
  91. }
  92. public void testJ14LTWWithXML() {
  93. runTest("JDK14 LTW with XML");
  94. }
  95. // public void testJ14LTWWithASPECTPATH() {
  96. // runTest("JDK14 LTW with ASPECTPATH");
  97. // }
  98. //public void testDiscardingWovenTypes() {
  99. // runTest("discarding woven types - 1");
  100. //}
  101. public void testWeavingTargetOfCallAggressivelyInLTW_DeclareParents_pr133770() {
  102. runTest("aggressive ltw - decp");
  103. }
  104. public void testWeavingTargetOfCallAggressivelyInLTW_DeclareParents_pr133770_Deactivate() {
  105. runTest("aggressive ltw - decp - deactivate");
  106. }
  107. public void testWeavingTargetOfCallAggressivelyInLTW_DeclareParents_Nested_pr133770() {
  108. runTest("aggressive ltw - decp - 2");
  109. }
  110. public void testWeavingTargetOfCallAggressivelyInLTW_DeclareParents_Hierarchy_pr133770() {
  111. runTest("aggressive ltw - hierarchy");
  112. }
  113. public void testSeparateCompilationDeclareParentsCall_pr133770() {
  114. runTest("separate compilation with ltw: declare parents and call");
  115. }
  116. public void testConfigurationSystemProperty_pr149289() {
  117. runTest("override default path using -Dorg.aspectj.weaver.loadtime.configuration");
  118. }
  119. public void testSimpleLTW_pr159854 () {
  120. runTest("simple LTW");
  121. }
  122. public void testDumpOnError_pr155033 () {
  123. runTest("dump on error");
  124. File dir = getSandboxDirectory();
  125. CountingFilenameFilter cff = new CountingFilenameFilter(".txt");
  126. dir.listFiles(cff);
  127. assertEquals("Missing ajcore file in " + dir.getAbsolutePath(),1,cff.getCount());
  128. }
  129. public void testMultipleDumpOnError_pr155033 () {
  130. runTest("multiple dump on error");
  131. File dir = getSandboxDirectory();
  132. CountingFilenameFilter cff = new CountingFilenameFilter(".txt");
  133. dir.listFiles(cff);
  134. assertEquals("Missing ajcore file in " + dir.getAbsolutePath(),2,cff.getCount());
  135. }
  136. /*
  137. * Allow system properties to be set and restored
  138. * TODO maw move to XMLBasedAjcTestCase or RunSpec
  139. */
  140. private final static String NULL = "null";
  141. private Properties savedProperties;
  142. protected void setSystemProperty (String key, String value) {
  143. Properties systemProperties = System.getProperties();
  144. copyProperty(key,systemProperties,savedProperties);
  145. systemProperties.setProperty(key,value);
  146. }
  147. private static void copyProperty (String key, Properties from, Properties to) {
  148. String value = from.getProperty(key,NULL);
  149. to.setProperty(key,value);
  150. }
  151. protected void setUp() throws Exception {
  152. super.setUp();
  153. savedProperties = new Properties();
  154. }
  155. protected void tearDown() throws Exception {
  156. super.tearDown();
  157. /* Restore system properties */
  158. Properties systemProperties = System.getProperties();
  159. for (Enumeration enu = savedProperties.keys(); enu.hasMoreElements(); ) {
  160. String key = (String)enu.nextElement();
  161. String value = savedProperties.getProperty(key);
  162. if (value == NULL) systemProperties.remove(key);
  163. else systemProperties.setProperty(key,value);
  164. }
  165. }
  166. }