From do-not-reply at jboss.com Mon Jan 1 02:04:53 2007 Content-Type: multipart/mixed; boundary="===============8841386975653034596==" MIME-Version: 1.0 From: scott.stark at jboss.org To: jboss-dev-forums at lists.jboss.org Subject: [jboss-dev-forums] [Design of AOP on JBoss (Aspects/JBoss)] - Update AOPTestDelegate to better integrate into eclipse Date: Mon, 01 Jan 2007 02:04:53 -0500 Message-ID: <654045.1167635093379.JavaMail.jboss@colo-br-02.atl.jboss.com> --===============8841386975653034596== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Currently you cannot run the tests easily from within eclise using the run = as junit... capability because the test harness does not locate the jboss-a= op.xml based on the classpath. Something like this does this: | package org.jboss.test.aop; | = | import java.net.URL; | import java.util.Properties; | = | import org.jboss.aop.AspectXmlLoader; | import org.jboss.test.AbstractTestDelegate; | = | /** | * = | * @author Kabir Khan | * @version $Revision: 45977 $ | */ | public class AOPTestDelegate extends AbstractTestDelegate | { | /** The AOP URL used */ | private URL aopURL; | = | Properties systemProps; | = | public AOPTestDelegate(Class clazz) | { | // FIXME AOPTestDelegate constructor | super(clazz); | systemProps =3D (Properties)System.getProperties().clone(); | } | = | public Properties getSystemProperties() | { | return systemProps; | } | = | /** | * Look for a test specific aop descriptor based on the ctor | * class first, and if none is found, the ManagedTest.class. | */ | public void setUp() throws Exception | { | super.setUp(); | deployAOP(clazz); | } | = | /** | * Undeployment any test specific aop descriptor deployed in setUp. | */ | public void tearDown() throws Exception | { | super.tearDown(); | undeployAOP(); | } | = | /** | * Look for a test specific resource name by appending "-aop.xml" | * to the referenceClass name as a resource. For example, a.b.SomeTe= st | * would produce a a/b/SomeTest-aop.xml resource that is queried | * for using clazz.getClassLoader().getResource("a/b/SomeTest-aop.xm= l"); | * = | * @param referenceClass - the class to use as the aop descriptor ba= se name. | * @return true if the aop descriptor was found and deployed, | * false otherwise. | * @throws Exception on failure to deploy the aop descriptor. | */ | protected boolean deployAOP(Class referenceClass) throws Exception | { | String testName =3D referenceClass.getName(); | String pkg =3D referenceClass.getPackage().getName(); | int dot =3D pkg.lastIndexOf('.'); | if( dot > 0 ) | pkg =3D pkg.substring(dot+1); | testName =3D pkg + "/jboss-aop.xml"; | URL url =3D clazz.getClassLoader().getResource(testName); | if (url !=3D null) | { | log.debug("Deploying " + url); | aopURL =3D url; | try | { | AspectXmlLoader.deployXML(aopURL); | } | catch (Throwable t) | { | throw new RuntimeException("Error deploying: " + url, t); | } | return true; | } | else | { | log.debug("No test specific deployment " + testName); | return false; | } | } | = | /** | * Undeploy the aop descriptor deployed in deployAOP if | * one was found. | * | */ | protected void undeployAOP() | { | if (aopURL =3D=3D null) | return; | try | { | log.debug("Undeploying " + aopURL); | AspectXmlLoader.undeployXML(aopURL); | } | catch (Exception e) | { | log.warn("Ignored error undeploying " + aopURL, e); | } | } | = | } | = Although this does deploy the aspects, the test I tried this with (org.jbos= s.test.aop.precedence.PrecedenceTester) is still failing. Can you look into= getting this working Kabir? View the original post : http://www.jboss.com/index.html?module=3Dbb&op=3Dv= iewtopic&p=3D3997099#3997099 Reply to the post : http://www.jboss.com/index.html?module=3Dbb&op=3Dpostin= g&mode=3Dreply&p=3D3997099 --===============8841386975653034596==--