4 Replies Latest reply on Mar 20, 2006 7:56 AM by Adrian Brock

    AOP Test support

    Adrian Brock Master

      I want to write some test support for aop.

      This will be similar to what I did for the MC where
      it looks for configuration like the test name.

      e.g.
      org.jboss.test.aop.foo.Bar.class
      will use
      /org/jboss/test/aop/foo/Bar-aop.xml

      I've wasted most of today trying to figure out a way to
      customize classloading so it will work in Junit inside Eclipse.

      This looks like an impossible task. Basically, I need a mechanism
      to either install an agent or insert my own classloader so
      I can intercept defineClass() and pass it to AOP.

      The two best solutions are:

      * Something AntClassLoader which "hides" part of the classpath
      so you can create a custom classloader to load the rest of the classpath.
      But there is no portable mechanism to determine which parts of the
      classpath are from the jre and which are in the classpath.

      * Forking off a process to run the junit tests and using a remote
      test runner similar to EJBUnit.
      But this is a bit convulted.

        • 1. Re: AOP Test support
          Adrian Brock Master

          Given that failed, what is your preferred mechanism for
          configuring JBossAOP when running it from the command line?

          There are a lot of choices :-)
          http://docs.jboss.org/aop/1.3/aspect-framework/reference/en/html/running.html

          • 2. Re: AOP Test support
            Kabir Khan Master

            Assuming that loadtime is what you want, the preferred is to use the -javaagent with JDK 5 and -Xbootclasspath on JDK 1.4

            To debug in eclipse:
            http://wiki.jboss.org/wiki/Wiki.jsp?page=DebuggingJBossAOPInEclipse

            To do loadtime (with JDK 5) in Eclipse add this to the vm arguments:
            -javaagent:/some/where/jboss-aop-jdk50.jar

            • 3. Re: AOP Test support
              Adrian Brock Master

              I went for the System classloader since I want these tests
              to run in JDK1.4 and -Xbootclasspath is not portable either.

              The MicrocontainerAOP smoke test is failing because of an
              invalid assumption:

              2006-03-20 12:31:45,799 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] Error installing to Instantiated: name=TestIntercepted state=Described
              java.lang.ExceptionInInitializerError
               at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
               at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
               at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
               at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
               at org.jboss.reflect.plugins.introspection.ReflectionUtils.newInstance(ReflectionUtils.java:136)
               at org.jboss.reflect.plugins.introspection.ReflectConstructorInfoImpl.newInstance(ReflectConstructorInfoImpl.java:103)
               at org.jboss.joinpoint.plugins.BasicConstructorJoinPoint.dispatch(BasicConstructorJoinPoint.java:80)
               at org.jboss.aop.microcontainer.prototype.AOPConstructorJoinpoint.dispatch(AOPConstructorJoinpoint.java:58)
               at org.jboss.kernel.plugins.dependency.KernelControllerContextActions.dispatchJoinPoint(KernelControllerContextActions.java:100)
               at org.jboss.kernel.plugins.dependency.KernelControllerContextActions$InstantiateAction.installAction(KernelControllerContextActions.java:384)
               at org.jboss.kernel.plugins.dependency.KernelControllerContextActions$KernelControllerContextAction.install(KernelControllerContextActions.java:175)
               at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
               at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:226)
               at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:593)
               at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:346)
               at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:438)
               at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:379)
               at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:225)
               at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:151)
               at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBean(AbstractKernelDeployer.java:291)
               at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBeans(AbstractKernelDeployer.java:261)
               at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deploy(AbstractKernelDeployer.java:117)
               at org.jboss.kernel.plugins.deployment.BasicKernelDeployer.deploy(BasicKernelDeployer.java:64)
               at org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer.deploy(BasicXMLDeployer.java:77)
               at org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer.deploy(BasicXMLDeployer.java:146)
               at org.jboss.test.kernel.junit.MicrocontainerTestDelegate.deploy(MicrocontainerTestDelegate.java:182)
               at org.jboss.test.kernel.junit.MicrocontainerTestDelegate.deploy(MicrocontainerTestDelegate.java:253)
               at org.jboss.test.kernel.junit.MicrocontainerTestDelegate.setUp(MicrocontainerTestDelegate.java:76)
               at org.jboss.test.AbstractTestSetup.setUp(AbstractTestSetup.java:57)
               at junit.extensions.TestSetup$1.protect(TestSetup.java:18)
               at junit.framework.TestResult.runProtected(TestResult.java:124)
               at junit.extensions.TestSetup.run(TestSetup.java:23)
               at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:297)
               at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:672)
               at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:567)
              Caused by: java.lang.ClassCastException: org.jboss.aop.proxy.container.ClassProxyContainer
               at org.jboss.aop.AspectManager.findAdvisor(AspectManager.java:454)
               at org.jboss.aop.AspectManager.findAdvisor(AspectManager.java:446)
               at org.jboss.aop.AspectManager.getAdvisor(AspectManager.java:496)
               at org.jboss.test.aop.junit.TestIntercepted.<clinit>(TestIntercepted.java)
               ... 35 more
              


              • 4. Re: AOP Test support
                Adrian Brock Master

                To run this test

                ./build.sh -f build-test.xml test -Dtest=aop/junit