1 22 package org.jboss.aop.microcontainer.junit; 23 24 import java.net.URL ; 25 26 import org.jboss.aop.AspectXmlLoader; 27 import org.jboss.test.AbstractTestDelegate; 28 29 35 public class AbstractProxyTestDelegate extends AbstractTestDelegate 36 { 37 43 public AbstractProxyTestDelegate(Class clazz) throws Exception 44 { 45 super(clazz); 46 } 47 48 public void setUp() throws Exception 49 { 50 super.setUp(); 51 52 log.debug("Security enabled: " + enableSecurity); 53 54 try 55 { 56 deploy(); 57 } 58 catch (RuntimeException e) 59 { 60 throw e; 61 } 62 catch (Exception e) 63 { 64 throw e; 65 } 66 catch (Error e) 67 { 68 throw e; 69 } 70 catch (Throwable e) 71 { 72 throw new RuntimeException (e); 73 } 74 } 75 76 public void tearDown() throws Exception 77 { 78 super.tearDown(); 79 undeploy(); 80 } 81 82 87 protected void deploy() throws Exception 88 { 89 String testName = clazz.getName(); 90 testName = testName.replace('.', '/') + ".xml"; 91 URL url = clazz.getClassLoader().getResource(testName); 92 if (url != null) 93 deploy(url); 94 else 95 throw new RuntimeException ("No test specific deployment " + testName); 96 } 97 98 101 protected void undeploy() 102 { 103 String testName = clazz.getName(); 104 testName = testName.replace('.', '/') + ".xml"; 105 URL url = clazz.getClassLoader().getResource(testName); 106 if (url != null) 107 undeploy(url); 108 else 109 log.debug("No test specific deployment " + testName); 110 } 111 112 117 protected URL getTestURL() 118 { 119 String testName = clazz.getName(); 120 testName = testName.replace('.', '/') + ".xml"; 121 return clazz.getClassLoader().getResource(testName); 122 } 123 124 130 protected void deploy(URL url) throws Exception 131 { 132 log.debug("Deploying " + url); 133 AspectXmlLoader.deployXML(url); 134 } 135 136 141 protected void undeploy(URL url) 142 { 143 try 144 { 145 log.debug("Undeploying " + url); 146 AspectXmlLoader.undeployXML(url); 147 } 148 catch (Exception e) 149 { 150 log.warn("Ignored error undeploying " + url, e); 151 } 152 } 153 } 154 | Popular Tags |