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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Feb 1 18:42:21 EST 2007


Author: kabir.khan at jboss.com
Date: 2007-02-01 18:42:21 -0500 (Thu, 01 Feb 2007)
New Revision: 60170

Added:
   projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/DeployersInterceptedAspectManagerJMXTestCase.xml
   projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/DeployersLifecycleAspectManagerJMXTestCase.xml
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/AspectManagerBean.java
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/JBossServer.java
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/JMXKernel.java
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/DeployersInterceptedAspectManagerJMXTestCase.java
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/DeployersLifecycleAspectManagerJMXTestCase.java
Log:
Add some tests trying to reproduce the problems with aspects on deployers

Added: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/DeployersInterceptedAspectManagerJMXTestCase.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/DeployersInterceptedAspectManagerJMXTestCase.xml	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/DeployersInterceptedAspectManagerJMXTestCase.xml	2007-02-01 23:42:21 UTC (rev 60170)
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+   <bean name="ProfileService" class="java.lang.Object"/>
+   
+   <bean name="JBossServer" class="org.jboss.test.microcontainer.support.deployers.JBossServer"/>
+
+   <bean name="JMXKernel" class="org.jboss.test.microcontainer.support.deployers.JMXKernel">
+      <property name="kernel"><inject bean="jboss.kernel:service=Kernel"/></property>
+      <property name="serverImpl"><inject bean="JBossServer"/></property>
+   </bean>
+
+   <bean name="AspectManager" class="org.jboss.test.microcontainer.support.deployers.AspectManagerBean">
+      <constructor>
+         <parameter><![CDATA[
+	         <aop>
+				</aop>]]>
+	      </parameter>
+      </constructor>
+       <property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
+   </bean>
+
+   <beanfactory name="DeployersAdvice" class="org.jboss.test.microcontainer.support.deployers.DeployerAspects">
+   </beanfactory>
+
+   <bean name="DeployersAspect" class="org.jboss.aop.microcontainer.beans.Aspect">
+      <property name="advice"><inject bean="DeployersAdvice"/></property>
+      <property name="manager"><inject bean="AspectManager" property="aspectManager"/></property>
+   </bean>
+   
+   <bean name="DeployersBinding" class="org.jboss.aop.microcontainer.beans.AspectBinding">
+      <property name="pointcut">execution(* $instanceof{org.jboss.test.microcontainer.support.deployers.IDeployer}->$implements{org.jboss.test.microcontainer.support.deployers.IDeployer}(..))</property>
+      <property name="aspect"><inject bean="DeployersAspect" property="definition"/></property>
+      <property name="manager"><inject bean="AspectManager" property="aspectManager"/></property>
+   </bean>
+   
+   <bean name="MainDeployer" class="org.jboss.test.microcontainer.support.deployers.SampleMainDeployer">
+      <property name="deployers">
+         <list>
+            <bean name="SampleDeployer1" class="org.jboss.test.microcontainer.support.deployers.SampleDeployer">
+               <property name="type">aop</property>
+            </bean>
+            <bean name="SampleDeployer2" class="org.jboss.test.microcontainer.support.deployers.SampleDeployer">
+               <property name="type">beans</property>
+            </bean>
+         </list>
+      </property>
+   </bean>
+
+</deployment>

Added: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/DeployersLifecycleAspectManagerJMXTestCase.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/DeployersLifecycleAspectManagerJMXTestCase.xml	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/DeployersLifecycleAspectManagerJMXTestCase.xml	2007-02-01 23:42:21 UTC (rev 60170)
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+   <bean name="ProfileService" class="java.lang.Object"/>
+   
+   <bean name="JBossServer" class="org.jboss.test.microcontainer.support.deployers.JBossServer"/>
+
+   <bean name="JMXKernel" class="org.jboss.test.microcontainer.support.deployers.JMXKernel">
+      <property name="kernel"><inject bean="jboss.kernel:service=Kernel"/></property>
+      <property name="serverImpl"><inject bean="JBossServer"/></property>
+   </bean>
+
+   <bean name="AspectManager" class="org.jboss.test.microcontainer.support.deployers.AspectManagerBean">
+      <constructor>
+         <parameter><![CDATA[
+	         <aop>
+				</aop>]]>
+	      </parameter>
+      </constructor>
+       <property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
+   </bean>
+
+   <aop:lifecycle-configure xmlns:aop="urn:jboss:aop-beans:1.0"
+      name="Deployers"
+      class="org.jboss.test.microcontainer.support.deployers.DeployerAspects"
+      classes="org.jboss.test.microcontainer.support.deployers.IDeployer"
+      manager-bean="AspectManager"
+      manager-property="aspectManager"
+      pointcut="execution(* $instanceof{org.jboss.test.microcontainer.support.deployers.IDeployer}->$implements{org.jboss.test.microcontainer.support.deployers.IDeployer}(..))">
+   </aop:lifecycle-configure>
+
+   
+   <bean name="MainDeployer" class="org.jboss.test.microcontainer.support.deployers.SampleMainDeployer">
+      <property name="deployers">
+         <list>
+            <bean name="SampleDeployer1" class="org.jboss.test.microcontainer.support.deployers.SampleDeployer">
+               <property name="type">aop</property>
+            </bean>
+            <bean name="SampleDeployer2" class="org.jboss.test.microcontainer.support.deployers.SampleDeployer">
+               <property name="type">beans</property>
+            </bean>
+         </list>
+      </property>
+   </bean>
+
+</deployment>

Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/AspectManagerBean.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/AspectManagerBean.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/AspectManagerBean.java	2007-02-01 23:42:21 UTC (rev 60170)
@@ -0,0 +1,155 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.support.deployers;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.AspectXmlLoader;
+import org.w3c.dom.Document;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AspectManagerBean
+{
+   AspectMan delegate = new AspectMan();
+   MBeanServer server;
+   String bootstrapXml;
+   
+   public AspectManagerBean(String bootstrapXml)
+   {
+      this.bootstrapXml = bootstrapXml;
+      try
+      {
+         if (bootstrapXml != null)
+         {
+            InputStream in = new BufferedInputStream(new ByteArrayInputStream(bootstrapXml.getBytes()));
+            try
+            {
+               Document doc = AspectXmlLoader.loadDocument(new BufferedInputStream(in));
+               AspectXmlLoader loader = new AspectXmlLoader();
+               loader.setManager(getAspectManager());
+               loader.deployXML(doc, null);
+            }
+            finally
+            {
+               if (in != null)
+               {
+                  in.close();
+               }
+            }
+         }
+      }
+      catch (Exception e)
+      {
+         // AutoGenerated
+         throw new RuntimeException("Problem starting AspectManager", e);
+      }
+   }
+   
+   public void setMbeanServer(MBeanServer server)
+   {
+      this.server = server;
+   }
+
+   public MBeanServer getMbeanServer()
+   {
+      return server;
+   }
+   
+   public AspectManager getAspectManager()
+   {
+      return AspectManager.getTopLevelAspectManager();
+   }
+
+   /**
+    * @throws Exception
+    * @see org.jboss.system.ServiceMBeanSupport#start()
+    */
+   public void start() throws Exception
+   {
+      try
+      {
+         server.registerMBean(delegate, new ObjectName("jboss.aop:service=AspectManager"));
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException("Problem registering jboss.aop:service=AspectManager with JMXServer", e);
+      }
+   }
+
+   /**
+    * 
+    * @see org.jboss.system.ServiceMBeanSupport#destroy()
+    */
+   public void destroy()
+   {
+      if (this.server == null)
+      {
+         try
+         {
+            if (bootstrapXml != null)
+            {
+               InputStream in = new BufferedInputStream(new ByteArrayInputStream(bootstrapXml.getBytes()));
+               try
+               {
+                  Document doc = AspectXmlLoader.loadDocument(new BufferedInputStream(in));
+                  AspectXmlLoader loader = new AspectXmlLoader();
+                  loader.setManager(getAspectManager());
+                  loader.deployXML(doc, null);
+               }
+               finally
+               {
+                  if (in != null)
+                  {
+                     in.close();
+                  }
+               }
+            }
+            server.unregisterMBean(new ObjectName("jboss.aop:service=AspectManager"));
+         }
+         catch (Exception e)
+         {
+            throw new RuntimeException("Problem unregistering jboss.aop:service=AspectManager with JMXServer", e);
+         }
+      }
+   }
+   
+   public interface AspectManMBean
+   {
+      
+   }
+
+   public static class AspectMan implements AspectManMBean
+   {
+      
+   }
+   
+}

Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/JBossServer.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/JBossServer.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/JBossServer.java	2007-02-01 23:42:21 UTC (rev 60170)
@@ -0,0 +1,35 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.support.deployers;
+
+import javax.management.MBeanServer;
+
+import com.sun.management.jmx.MBeanServerImpl;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JBossServer
+{
+}

Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/JMXKernel.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/JMXKernel.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/JMXKernel.java	2007-02-01 23:42:21 UTC (rev 60170)
@@ -0,0 +1,61 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.support.deployers;
+
+import javax.management.MBeanServer;
+
+import org.jboss.kernel.Kernel;
+
+import com.sun.management.jmx.MBeanServerImpl;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JMXKernel
+{
+   Kernel kernel;
+   JBossServer serverImpl;
+   MBeanServer mbeanServer = new MBeanServerImpl();
+
+   public Kernel getKernel()
+   {
+      return kernel;
+   }
+
+   public void setKernel(Kernel kernel)
+   {
+      this.kernel = kernel;
+   }
+
+   public void setServerImpl(JBossServer serverImpl)
+   {
+      this.serverImpl = serverImpl;
+   }
+   
+   public MBeanServer getMbeanServer()
+   {
+      return mbeanServer;
+   }
+   
+}

Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/DeployersInterceptedAspectManagerJMXTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/DeployersInterceptedAspectManagerJMXTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/DeployersInterceptedAspectManagerJMXTestCase.java	2007-02-01 23:42:21 UTC (rev 60170)
@@ -0,0 +1,98 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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 java.util.HashSet;
+
+import javax.management.MBeanServer;
+
+import junit.framework.Test;
+
+import org.jboss.aop.microcontainer.junit.AOPMicrocontainerTest;
+import org.jboss.test.microcontainer.support.deployers.AspectManagerBean;
+import org.jboss.test.microcontainer.support.deployers.DeployerAspects;
+import org.jboss.test.microcontainer.support.deployers.IMainDeployer;
+import org.jboss.test.microcontainer.support.deployers.SampleDeployer;
+import org.jboss.test.microcontainer.support.deployers.IDeployer.IDeployerMethod;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class DeployersInterceptedAspectManagerJMXTestCase extends AOPMicrocontainerTest
+{
+   public static Test suite()
+   {
+      return suite(DeployersInterceptedAspectManagerJMXTestCase.class);
+   }
+   
+   public DeployersInterceptedAspectManagerJMXTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public void testBean() throws Exception
+   {
+      IMainDeployer md = (IMainDeployer) getBean("MainDeployer");
+      assertNotNull(md);
+
+      assertEquals("2 deployers", 2, md.getDeployers().size());
+
+      md.addDeployment("thing.xar");
+      md.process();
+
+      HashSet<IDeployerMethod> interceptedCalled = DeployerAspects.getCalled();
+      SampleDeployer d1 = (SampleDeployer) getBean("SampleDeployer1");
+      SampleDeployer d2 = (SampleDeployer) getBean("SampleDeployer2");
+      assertTrue("SampleDeployer1.prepareDeploy",
+            d1.getCalled().contains(IDeployerMethod.prepareDeploy));
+      assertTrue("SampleDeployer1.commitDeploy",
+            d1.getCalled().contains(IDeployerMethod.commitDeploy));
+      assertTrue("SampleDeployer2.prepareDeploy",
+            d2.getCalled().contains(IDeployerMethod.prepareDeploy));
+      assertTrue("SampleDeployer2.commitDeploy",
+            d2.getCalled().contains(IDeployerMethod.commitDeploy));
+
+      assertTrue("DeployerAspects.prepareDeploy",
+            interceptedCalled.contains(IDeployerMethod.prepareDeploy));
+      assertTrue("DeployerAspects.commitDeploy",
+            interceptedCalled.contains(IDeployerMethod.commitDeploy));
+
+      md.removeDeployment("thing.xar");
+      md.process();
+
+      assertTrue("SampleDeployer1.prepareUndeploy",
+            d1.getCalled().contains(IDeployerMethod.prepareUndeploy));
+      assertTrue("SampleDeployer1.commitUndeploy",
+            d1.getCalled().contains(IDeployerMethod.commitUndeploy));
+      assertTrue("SampleDeployer2.prepareUndeploy",
+            d2.getCalled().contains(IDeployerMethod.prepareUndeploy));
+      assertTrue("SampleDeployer2.commitUndeploy",
+            d2.getCalled().contains(IDeployerMethod.commitUndeploy));
+
+      assertTrue("DeployerAspects.prepareUndeploy",
+            interceptedCalled.contains(IDeployerMethod.prepareUndeploy));
+      assertTrue("DeployerAspects.commitUndeploy",
+            interceptedCalled.contains(IDeployerMethod.commitUndeploy));
+}
+}

Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/DeployersLifecycleAspectManagerJMXTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/DeployersLifecycleAspectManagerJMXTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/DeployersLifecycleAspectManagerJMXTestCase.java	2007-02-01 23:42:21 UTC (rev 60170)
@@ -0,0 +1,108 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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 java.util.HashSet;
+
+import javax.management.MBeanServer;
+
+import junit.framework.Test;
+
+import org.jboss.aop.microcontainer.junit.AOPMicrocontainerTest;
+import org.jboss.test.microcontainer.support.deployers.AspectManagerBean;
+import org.jboss.test.microcontainer.support.deployers.DeployerAspects;
+import org.jboss.test.microcontainer.support.deployers.IMainDeployer;
+import org.jboss.test.microcontainer.support.deployers.SampleDeployer;
+import org.jboss.test.microcontainer.support.deployers.IDeployer.IDeployerMethod;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class DeployersLifecycleAspectManagerJMXTestCase extends AOPMicrocontainerTest
+{
+   public static Test suite()
+   {
+      return suite(DeployersLifecycleAspectManagerJMXTestCase.class);
+   }
+   
+   public DeployersLifecycleAspectManagerJMXTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public void testBean() throws Exception
+   {
+//      //Make sure that the mbean server and aspect manager are installed properly
+//      MBeanServer server = (MBeanServer)getBean("MBeanServer");
+//      assertNotNull(server);
+//      AspectManagerBean am = (AspectManagerBean)getBean("AspectManager");
+//      assertNotNull(am);
+//      MBeanServer amServer = am.getMbeanServer();
+//      assertSame(server, amServer);
+//      assertEquals(server, amServer);
+      
+      //Now let's get on with the test
+      IMainDeployer md = (IMainDeployer) getBean("MainDeployer");
+      assertNotNull(md);
+
+      assertEquals("2 deployers", 2, md.getDeployers().size());
+
+      md.addDeployment("thing.xar");
+      md.process();
+
+      HashSet<IDeployerMethod> interceptedCalled = DeployerAspects.getCalled();
+      SampleDeployer d1 = (SampleDeployer) getBean("SampleDeployer1");
+      SampleDeployer d2 = (SampleDeployer) getBean("SampleDeployer2");
+      assertTrue("SampleDeployer1.prepareDeploy",
+            d1.getCalled().contains(IDeployerMethod.prepareDeploy));
+      assertTrue("SampleDeployer1.commitDeploy",
+            d1.getCalled().contains(IDeployerMethod.commitDeploy));
+      assertTrue("SampleDeployer2.prepareDeploy",
+            d2.getCalled().contains(IDeployerMethod.prepareDeploy));
+      assertTrue("SampleDeployer2.commitDeploy",
+            d2.getCalled().contains(IDeployerMethod.commitDeploy));
+
+      assertTrue("DeployerAspects.prepareDeploy",
+            interceptedCalled.contains(IDeployerMethod.prepareDeploy));
+      assertTrue("DeployerAspects.commitDeploy",
+            interceptedCalled.contains(IDeployerMethod.commitDeploy));
+
+      md.removeDeployment("thing.xar");
+      md.process();
+
+      assertTrue("SampleDeployer1.prepareUndeploy",
+            d1.getCalled().contains(IDeployerMethod.prepareUndeploy));
+      assertTrue("SampleDeployer1.commitUndeploy",
+            d1.getCalled().contains(IDeployerMethod.commitUndeploy));
+      assertTrue("SampleDeployer2.prepareUndeploy",
+            d2.getCalled().contains(IDeployerMethod.prepareUndeploy));
+      assertTrue("SampleDeployer2.commitUndeploy",
+            d2.getCalled().contains(IDeployerMethod.commitUndeploy));
+
+      assertTrue("DeployerAspects.prepareUndeploy",
+            interceptedCalled.contains(IDeployerMethod.prepareUndeploy));
+      assertTrue("DeployerAspects.commitUndeploy",
+            interceptedCalled.contains(IDeployerMethod.commitUndeploy));
+   }
+}




More information about the jboss-cvs-commits mailing list