1 22 package org.jboss.aop.microcontainer.junit; 23 24 import java.net.URL ; 25 import java.util.Iterator ; 26 27 import org.jboss.aop.AspectXmlLoader; 28 import org.jboss.test.kernel.junit.MicrocontainerTestDelegate; 29 30 import EDU.oswego.cs.dl.util.concurrent.CopyOnWriteArrayList; 31 32 39 public class AOPMicrocontainerTestDelegate extends MicrocontainerTestDelegate 40 { 41 42 private static final CopyOnWriteArrayList urls = new CopyOnWriteArrayList(); 43 44 50 public AOPMicrocontainerTestDelegate(Class clazz) throws Exception 51 { 52 super(clazz); 53 } 54 55 public void setUp() throws Exception 56 { 57 super.setUp(); 58 log.debug("Security enabled: " + enableSecurity); 59 } 60 61 62 63 protected void deploy() throws Exception 64 { 65 String testName = clazz.getName(); 66 testName = testName.replace('.', '/') + "-aop.xml"; 67 URL url = clazz.getClassLoader().getResource(testName); 68 if (url != null) 69 deployAOP(url); 70 else 71 log.debug("No test specific deployment " + testName); 72 73 super.deploy(); 74 } 75 76 protected void undeploy() 77 { 78 79 super.undeploy(); 80 for (Iterator i = urls.iterator(); i.hasNext();) 81 { 82 URL url = (URL ) i.next(); 83 undeployAOP(url); 84 } 85 } 86 87 93 protected void deployAOP(URL url) throws Exception 94 { 95 log.debug("Deploying " + url); 96 urls.add(url); 97 AspectXmlLoader.deployXML(url); 98 } 99 100 105 protected void undeployAOP(URL url) 106 { 107 try 108 { 109 log.debug("Undeploying " + url); 110 urls.remove(url); 111 AspectXmlLoader.undeployXML(url); 112 } 113 catch (Exception e) 114 { 115 log.warn("Ignored error undeploying " + url, e); 116 } 117 } 118 } 119 | Popular Tags |