1 22 package org.jboss.test.proxyfactory; 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 try 53 { 54 deploy(); 55 } 56 catch (RuntimeException e) 57 { 58 throw e; 59 } 60 catch (Exception e) 61 { 62 throw e; 63 } 64 catch (Error e) 65 { 66 throw e; 67 } 68 catch (Throwable e) 69 { 70 throw new RuntimeException (e); 71 } 72 } 73 74 public void tearDown() throws Exception 75 { 76 super.tearDown(); 77 undeploy(); 78 } 79 80 85 protected void deploy() throws Exception 86 { 87 String testName = clazz.getName(); 88 testName = testName.replace('.', '/') + ".xml"; 89 URL url = clazz.getClassLoader().getResource(testName); 90 if (url != null) 91 deploy(url); 92 else 93 throw new RuntimeException ("No test specific deployment " + testName); 94 } 95 96 99 protected void undeploy() 100 { 101 String testName = clazz.getName(); 102 testName = testName.replace('.', '/') + ".xml"; 103 URL url = clazz.getClassLoader().getResource(testName); 104 if (url != null) 105 undeploy(url); 106 else 107 log.debug("No test specific deployment " + testName); 108 } 109 110 115 protected URL getTestURL() 116 { 117 String testName = clazz.getName(); 118 testName = testName.replace('.', '/') + ".xml"; 119 return clazz.getClassLoader().getResource(testName); 120 } 121 122 128 protected void deploy(URL url) throws Exception 129 { 130 log.debug("Deploying " + url); 131 AspectXmlLoader.deployXML(url); 132 } 133 134 139 protected void undeploy(URL url) 140 { 141 try 142 { 143 log.debug("Undeploying " + url); 144 AspectXmlLoader.undeployXML(url); 145 } 146 catch (Exception e) 147 { 148 log.warn("Ignored error undeploying " + url, e); 149 } 150 } 151 } 152 | Popular Tags |