1 22 package org.jboss.test.aop.test; 23 24 import javax.management.ObjectName ; 25 import javax.management.Attribute ; 26 27 import junit.framework.TestSuite; 28 import org.jboss.test.JBossTestSetup; 29 30 38 public class AOPClassLoaderHookTestSetup extends JBossTestSetup 39 { 40 public static String ASPECT_MANAGER_NAME = "jboss.aop:service=AspectManager"; 41 42 private String [] jars; 43 44 public AOPClassLoaderHookTestSetup(TestSuite suite, String jar) throws Exception 46 { 47 super(suite); 48 this.jars = jar.split(","); 49 } 50 51 protected void setUp() throws Exception 52 { 53 super.setUp(); 54 ObjectName aspectManager = new ObjectName (ASPECT_MANAGER_NAME); 55 Attribute enableTransformer = new Attribute ("EnableLoadtimeWeaving", Boolean.TRUE); 56 getServer().setAttribute(aspectManager, enableTransformer); 57 try 60 { 61 for (int i = 0 ; i < jars.length ; i++) 62 { 63 String jar = jars[i].trim(); 64 redeploy(jar); 65 } 66 } 67 catch(Exception e) 68 { 69 try 71 { 72 enableTransformer = new Attribute ("EnableLoadtimeWeaving", Boolean.FALSE); 73 getServer().setAttribute(aspectManager, enableTransformer); 74 } 77 catch(Exception ex) 78 { 79 getLog().error("Failed to set EnableLoadtimeWeaving to false", ex); 80 } 81 throw e; 82 } 83 } 84 protected void tearDown() throws Exception 85 { 86 Exception undeployException = null; 87 for (int i = 0 ; i < jars.length ; i++) 88 { 89 try 90 { 91 String jar = jars[i].trim(); 92 undeploy(jar); 93 } 94 catch(Exception e) 95 { 96 undeployException = e; 97 } 98 } 99 ObjectName aspectManager = new ObjectName (ASPECT_MANAGER_NAME); 100 Attribute enableTransformer = new Attribute ("EnableLoadtimeWeaving", Boolean.FALSE); 101 getServer().setAttribute(aspectManager, enableTransformer); 102 if( undeployException != null ) 103 throw undeployException; 104 super.tearDown(); 105 } 106 } 107 | Popular Tags |