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 2.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 junit.framework.Test;
  17. import org.aspectj.testing.XMLBasedAjcTestCase;
  18. import org.aspectj.weaver.tools.WeavingAdaptor;
  19. public class LTWTests extends org.aspectj.testing.XMLBasedAjcTestCase {
  20. public static Test suite() {
  21. return XMLBasedAjcTestCase.loadSuite(LTWTests.class);
  22. }
  23. protected File getSpecFile() {
  24. return new File("../tests/src/org/aspectj/systemtest/ajc150/ltw/ltw.xml");
  25. }
  26. public void test001(){
  27. runTest("Ensure 1st aspect is rewoven when weaving 2nd aspect");
  28. }
  29. public void testOutxmlFile (){
  30. runTest("Ensure valid aop.xml file is generated");
  31. }
  32. public void testOutxmlJar (){
  33. runTest("Ensure valid aop.xml is generated for -outjar");
  34. }
  35. public void testNoAopxml(){
  36. setSystemProperty(WeavingAdaptor.WEAVING_ADAPTOR_VERBOSE,"true");
  37. runTest("Ensure no weaving without visible aop.xml");
  38. }
  39. public void testDefineConcreteAspect(){
  40. runTest("Define concrete sub-aspect using aop.xml");
  41. }
  42. public void testDeclareAbstractAspect(){
  43. // setSystemProperty(WeavingAdaptor.WEAVING_ADAPTOR_VERBOSE,"true");
  44. // setSystemProperty(WeavingAdaptor.SHOW_WEAVE_INFO_PROPERTY,"true");
  45. runTest("Use abstract aspect for ITD using aop.xml");
  46. }
  47. /*
  48. * Allow system properties to be set and restored
  49. * TODO maw move to XMLBasedAjcTestCase or RunSpec
  50. */
  51. private final static String NULL = "null";
  52. private Properties savedProperties;
  53. protected void setSystemProperty (String key, String value) {
  54. Properties systemProperties = System.getProperties();
  55. copyProperty(key,systemProperties,savedProperties);
  56. systemProperties.setProperty(key,value);
  57. }
  58. private static void copyProperty (String key, Properties from, Properties to) {
  59. String value = from.getProperty(key,NULL);
  60. to.setProperty(key,value);
  61. }
  62. protected void setUp() throws Exception {
  63. super.setUp();
  64. savedProperties = new Properties();
  65. }
  66. protected void tearDown() throws Exception {
  67. super.tearDown();
  68. /* Restore system properties */
  69. Properties systemProperties = System.getProperties();
  70. for (Enumeration enu = savedProperties.keys(); enu.hasMoreElements(); ) {
  71. String key = (String)enu.nextElement();
  72. String value = savedProperties.getProperty(key);
  73. if (value == NULL) systemProperties.remove(key);
  74. else systemProperties.setProperty(key,value);
  75. }
  76. }
  77. }