[jboss-cvs] JBossAS SVN: r60900 - in projects/microcontainer/trunk/aop-mc-int/src: resources/tests/org/jboss/test/microcontainer/test and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Feb 26 04:59:42 EST 2007


Author: alesj
Date: 2007-02-26 04:59:42 -0500 (Mon, 26 Feb 2007)
New Revision: 60900

Added:
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/junit/ScopingAOPMicrocontainerTestDelegate.java
   projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/ScopingAopTestCase.xml
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/ScopingAopTestCase.java
Modified:
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/AspectMCAllTestSuite.java
Log:
Simple scoping + AOP test case.
Currently failing - aspect applied outside scope.

Added: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/junit/ScopingAOPMicrocontainerTestDelegate.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/junit/ScopingAOPMicrocontainerTestDelegate.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/junit/ScopingAOPMicrocontainerTestDelegate.java	2007-02-26 09:59:42 UTC (rev 60900)
@@ -0,0 +1,94 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.aop.microcontainer.junit;
+
+import org.jboss.dependency.plugins.AbstractController;
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ *
+ * A ScopingAOPMicrocontainerTestDelegate.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ScopingAOPMicrocontainerTestDelegate extends AOPMicrocontainerTestDelegate
+{
+   public ScopingAOPMicrocontainerTestDelegate(Class clazz)
+         throws Exception
+   {
+      super(clazz);
+   }
+
+   protected KernelControllerContext getControllerContext(final Object name, final ControllerState state)
+   {
+      try
+      {
+         Controller controller = new TestController((AbstractController)kernel.getController());
+         KernelControllerContext context = (KernelControllerContext)controller.getContext(name, state);
+         if (context == null)
+            throw new IllegalStateException("Bean not found " + name + " at state " + state);
+         return context;
+      }
+      catch (Exception e)
+      {
+         throw new Error(e);
+      }
+   }
+
+   private class TestController extends AbstractController
+   {
+      private AbstractController delegate;
+
+      public TestController(AbstractController controller) throws Exception
+      {
+         this.delegate = controller;
+      }
+
+      public ControllerContext getContext(Object name, ControllerState state)
+      {
+         return findContext(delegate, name, state);
+      }
+
+      private ControllerContext findContext(AbstractController controller, Object name, ControllerState state)
+      {
+         ControllerContext context = controller.getContext(name, state);
+         if (context != null)
+         {
+            return context;
+         }
+         else
+         {
+            for (AbstractController childController : controller.getControllers())
+            {
+               ControllerContext ctx = findContext(childController, name, state);
+               if (ctx != null)
+                  return ctx;
+            }
+         }
+         return null;
+      }
+   }
+
+}

Added: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/ScopingAopTestCase.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/ScopingAopTestCase.xml	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/ScopingAopTestCase.xml	2007-02-26 09:59:42 UTC (rev 60900)
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+<beanfactory name="InterceptedAdvice" class="org.jboss.test.microcontainer.support.CalledInterceptor"/>
+
+   <bean name="AspectManager" class="org.jboss.aop.AspectManager">
+      <annotation>@org.jboss.metadata.plugins.scope.ApplicationScope("testApp")</annotation>
+      <annotation>@org.jboss.metadata.plugins.scope.DeploymentScope("deployment1")</annotation>
+      <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
+   </bean>
+
+   <bean name="InterceptedAspect" class="org.jboss.aop.microcontainer.beans.Aspect">
+      <annotation>@org.jboss.metadata.plugins.scope.ApplicationScope("testApp")</annotation>
+      <annotation>@org.jboss.metadata.plugins.scope.DeploymentScope("deployment1")</annotation>
+      <property name="advice"><inject bean="InterceptedAdvice"/></property>
+      <property name="manager"><inject bean="AspectManager"/></property>
+   </bean>
+
+   <bean name="InterceptedBinding" class="org.jboss.aop.microcontainer.beans.AspectBinding">
+      <annotation>@org.jboss.metadata.plugins.scope.ApplicationScope("testApp")</annotation>
+      <annotation>@org.jboss.metadata.plugins.scope.DeploymentScope("deployment1")</annotation>
+      <property name="pointcut">execution(* $instanceof{org.jboss.test.microcontainer.support.SimpleBeanImpl}->*(..))</property>
+      <property name="aspect"><inject bean="InterceptedAspect" property="definition"/></property>
+      <property name="manager"><inject bean="AspectManager"/></property>
+   </bean>
+
+   <bean name="simple1" class="org.jboss.test.microcontainer.support.SimpleBeanImpl">
+      <annotation>@org.jboss.metadata.plugins.scope.ApplicationScope("testApp")</annotation>
+      <annotation>@org.jboss.metadata.plugins.scope.DeploymentScope("deployment1")</annotation>
+   </bean>
+
+   <bean name="simple2" class="org.jboss.test.microcontainer.support.SimpleBeanImpl">
+      <annotation>@org.jboss.metadata.plugins.scope.ApplicationScope("testApp")</annotation>
+      <annotation>@org.jboss.metadata.plugins.scope.DeploymentScope("deployment2")</annotation>
+   </bean>
+
+</deployment>

Modified: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/AspectMCAllTestSuite.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/AspectMCAllTestSuite.java	2007-02-26 09:54:57 UTC (rev 60899)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/AspectMCAllTestSuite.java	2007-02-26 09:59:42 UTC (rev 60900)
@@ -62,6 +62,7 @@
       suite.addTest(MetaDataTestCase.suite());
       suite.addTest(MixinTestCase.suite());
       suite.addTest(MultipleLifecycleTestCase.suite());
+      suite.addTest(ScopingAopTestCase.suite());
 
       return suite;
    }

Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/ScopingAopTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/ScopingAopTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/ScopingAopTestCase.java	2007-02-26 09:59:42 UTC (rev 60900)
@@ -0,0 +1,72 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.microcontainer.test;
+
+import junit.framework.Test;
+import org.jboss.aop.microcontainer.junit.AOPMicrocontainerTest;
+import org.jboss.aop.microcontainer.junit.AOPMicrocontainerTestDelegate;
+import org.jboss.aop.microcontainer.junit.ScopingAOPMicrocontainerTestDelegate;
+import org.jboss.test.AbstractTestDelegate;
+import org.jboss.test.microcontainer.support.SimpleBean;
+
+/**
+ * Test adding aspects to scoped beans.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ScopingAopTestCase extends AOPMicrocontainerTest
+{
+   public static Test suite()
+   {
+      return suite(ScopingAopTestCase.class);
+   }
+
+   public ScopingAopTestCase(String name)
+   {
+      super(name);
+   }
+
+   /**
+    * Get the test delegate
+    *
+    * @param clazz the test class
+    * @return the delegate
+    * @throws Exception for any error
+    */
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      String property = System.getProperty("jboss.mc.secure", "false");
+      boolean enableSecurity = Boolean.valueOf(property);
+      AOPMicrocontainerTestDelegate delegate = new ScopingAOPMicrocontainerTestDelegate(clazz);
+      delegate.enableSecurity = enableSecurity;
+      return delegate;
+   }
+
+   public void testScopingWithAop() throws Exception
+   {
+      SimpleBean simple1 = (SimpleBean)getBean("simple1");
+      assertNotNull(simple1);
+      SimpleBean simple2 = (SimpleBean)getBean("simple2");
+      assertNotNull(simple2);
+   }
+
+}




More information about the jboss-cvs-commits mailing list