FileDocCategorySizeDatePackage
AOPTestSetup.javaAPI DocJBoss 4.2.13039Fri Jul 13 21:02:24 BST 2007org.jboss.test.aop.test

AOPTestSetup

public class AOPTestSetup extends org.jboss.test.JBossTestSetup
A test setup wrapper that enables the AspectManager transformation mode on setUp and disables it on tearDown.
author
Scott.Stark@jboss.org
version
$Revision: 57186 $

Fields Summary
public static String
ASPECT_MANAGER_NAME
private String
jar
Constructors Summary
public AOPTestSetup(TestSuite suite, String jar)


   // Create an initializer for the test suite
         
   
      super(suite);
      this.jar = jar;
   
Methods Summary
protected voidsetUp()

      super.setUp();
      ObjectName aspectManager = new ObjectName(ASPECT_MANAGER_NAME);
      Attribute enableTransformer = new Attribute("EnableTransformer", Boolean.TRUE);
      getServer().setAttribute(aspectManager, enableTransformer);
      try
      {
         redeploy(jar);
      }
      catch(Exception e)
      {
         // Reset the EnableTransformer to false
         try
         {
            enableTransformer = new Attribute("EnableTransformer", Boolean.FALSE);
            getServer().setAttribute(aspectManager, enableTransformer);
         }
         catch(Exception ex)
         {
            getLog().error("Failed to set EnableTransformer to false", ex);
         }
         throw e;
      }
   
protected voidtearDown()

      Exception undeployException = null;
      try
      {
         undeploy(jar);
      }
      catch(Exception e)
      {
         undeployException = e;
      }
      ObjectName aspectManager = new ObjectName(ASPECT_MANAGER_NAME);
      Attribute enableTransformer = new Attribute("EnableTransformer", Boolean.FALSE);
      getServer().setAttribute(aspectManager, enableTransformer);
      if( undeployException != null )
         throw undeployException;
      super.tearDown();