Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

LTWTests.java 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. public void testAspectsInclude () {
  48. runTest("Ensure a subset of inherited aspects is used for weaving");
  49. }
  50. public void testAspectsIncludeWithLintWarning () {
  51. runTest("Ensure weaver lint warning issued when an aspect is not used for weaving");
  52. }
  53. /*
  54. * Allow system properties to be set and restored
  55. * TODO maw move to XMLBasedAjcTestCase or RunSpec
  56. */
  57. private final static String NULL = "null";
  58. private Properties savedProperties;
  59. protected void setSystemProperty (String key, String value) {
  60. Properties systemProperties = System.getProperties();
  61. copyProperty(key,systemProperties,savedProperties);
  62. systemProperties.setProperty(key,value);
  63. }
  64. private static void copyProperty (String key, Properties from, Properties to) {
  65. String value = from.getProperty(key,NULL);
  66. to.setProperty(key,value);
  67. }
  68. protected void setUp() throws Exception {
  69. super.setUp();
  70. savedProperties = new Properties();
  71. }
  72. protected void tearDown() throws Exception {
  73. super.tearDown();
  74. /* Restore system properties */
  75. Properties systemProperties = System.getProperties();
  76. for (Enumeration enu = savedProperties.keys(); enu.hasMoreElements(); ) {
  77. String key = (String)enu.nextElement();
  78. String value = savedProperties.getProperty(key);
  79. if (value == NULL) systemProperties.remove(key);
  80. else systemProperties.setProperty(key,value);
  81. }
  82. }
  83. }