[jboss-cvs] JBossAS SVN: r60089 - in projects/microcontainer/trunk/aop-mc-int/src: tests/org/jboss/test/microcontainer/support and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Jan 28 17:42:03 EST 2007
Author: scott.stark at jboss.org
Date: 2007-01-28 17:42:02 -0500 (Sun, 28 Jan 2007)
New Revision: 60089
Added:
projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/DeployersInterceptedTestCase.xml
projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/DeployersLifecycleTestCase.xml
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/DeployerAspects.java
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/IDeployer.java
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/IMainDeployer.java
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/MainDeployerAspects.java
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/SampleDeployer.java
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/SampleMainDeployer.java
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/DeployersInterceptedTestCase.java
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/DeployersLifecycleTestCase.java
Log:
Add tests of MainDeployer/Deployer type of aspects
Added: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/DeployersInterceptedTestCase.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/DeployersInterceptedTestCase.xml (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/DeployersInterceptedTestCase.xml 2007-01-28 22:42:02 UTC (rev 60089)
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Repository" class="org.jboss.metadata.plugins.repository.basic.BasicMetaDataRepository"/>
+
+ <bean name="AspectManager" class="org.jboss.aop.AspectManager">
+ <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
+ </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>
+ </bean>
+
+ <bean name="DeployersBinding" class="org.jboss.aop.microcontainer.beans.AspectBinding">
+ <!-- This fails to match anything
+ -->
+ <property name="pointcut">execution(* $instanceof{org.jboss.test.microcontainer.support.deployers.IDeployer}->$implements(org.jboss.test.microcontainer.support.deployers.IDeployer))</property>
+ <!-- This matches the prepareDeploy method
+ <property name="pointcut">execution(* $instanceof{org.jboss.test.microcontainer.support.deployers.IDeployer}->prepareDeploy(..))</property>
+ -->
+ <!-- This matches all IDeployer methods
+ <property name="pointcut">execution(* $instanceof{org.jboss.test.microcontainer.support.deployers.IDeployer}->*(..))</property>
+ -->
+ <property name="aspect"><inject bean="DeployersAspect" property="definition"/></property>
+ <property name="manager"><inject bean="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>
Property changes on: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/DeployersInterceptedTestCase.xml
___________________________________________________________________
Name: svn:keywords
+ Id,Revision
Name: svn:eol-style
+ native
Added: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/DeployersLifecycleTestCase.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/DeployersLifecycleTestCase.xml (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/DeployersLifecycleTestCase.xml 2007-01-28 22:42:02 UTC (rev 60089)
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Repository" class="org.jboss.metadata.plugins.repository.basic.BasicMetaDataRepository"/>
+
+ <bean name="AspectManager" class="org.jboss.aop.AspectManager">
+ <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
+ </bean>
+
+ <aop:lifecycle-configure xmlns:aop="urn:jboss:aop-beans:1.0"
+ name="DeployerAspects"
+ class="org.jboss.test.microcontainer.support.deployers.DeployerAspects"
+ classes="org.jboss.test.microcontainer.support.deployers.IDeployer"
+ manager-bean="AspectManager"
+ pointcut="execution(* $instanceof{org.jboss.test.microcontainer.support.deployers.IDeployer}->*(..))">
+ </aop:lifecycle-configure>
+ <aop:lifecycle-configure xmlns:aop="urn:jboss:aop-beans:1.0"
+ name="MainDeployerAspects"
+ class="org.jboss.test.microcontainer.support.deployers.MainDeployerAspects"
+ classes="org.jboss.test.microcontainer.support.deployers.IMainDeployer"
+ manager-bean="AspectManager"
+ pointcut="execution(* $instanceof{org.jboss.test.microcontainer.support.deployers.IMainDeployer}->*(..))">
+ </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>
Property changes on: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/DeployersLifecycleTestCase.xml
___________________________________________________________________
Name: svn:keywords
+ Id,Revision
Name: svn:eol-style
+ native
Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/DeployerAspects.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/DeployerAspects.java (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/DeployerAspects.java 2007-01-28 22:42:02 UTC (rev 60089)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.support.deployers;
+
+import java.util.HashSet;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.logging.Logger;
+import org.jboss.test.microcontainer.support.deployers.IDeployer.IDeployerMethod;
+
+/**
+ * IDeployer aspects
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class DeployerAspects
+{
+ private static Logger log = Logger.getLogger(DeployerAspects.class);
+ private static HashSet<IDeployerMethod> called = new HashSet<IDeployerMethod>();
+ private static DeployerAspects instance;
+
+ public static HashSet<IDeployerMethod> getCalled()
+ {
+ return called;
+ }
+ public static synchronized DeployerAspects getInstance()
+ {
+ if( instance == null )
+ instance = new DeployerAspects();
+ return instance;
+ }
+
+ public DeployerAspects()
+ {
+ log.debug("ctor");
+ instance = this;
+ }
+
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ log.debug(invocation);
+ MethodInvocation mi = (MethodInvocation) invocation;
+ String methodName = mi.getActualMethod().getName();
+ Object value = null;
+ if( methodName.equals("prepareDeploy") )
+ value = prepareDeploy(mi);
+ else if( methodName.equals("commitDeploy") )
+ value = commitDeploy(mi);
+ else if( methodName.equals("prepareUndeploy") )
+ value = prepareUndeploy(mi);
+ else if( methodName.equals("commitUndeploy") )
+ value = commitUndeploy(mi);
+ else
+ value = invocation.invokeNext();
+ return value;
+ }
+
+ public Object prepareDeploy(MethodInvocation invocation)
+ throws Throwable
+ {
+ Object target = invocation.getTargetObject();
+ log.debug("prepareDeploy, target="+target);
+ called.add(IDeployerMethod.prepareDeploy);
+ return invocation.invokeNext();
+ }
+ public Object commitDeploy(MethodInvocation invocation)
+ throws Throwable
+ {
+ Object target = invocation.getTargetObject();
+ Object value = invocation.invokeNext();
+ log.debug("commitDeploy, target="+target);
+ called.add(IDeployerMethod.commitDeploy);
+ return value;
+ }
+
+ public Object prepareUndeploy(MethodInvocation invocation)
+ throws Throwable
+ {
+ Object target = invocation.getTargetObject();
+ log.debug("prepareUndeploy, target="+target);
+ called.add(IDeployerMethod.prepareUndeploy);
+ return invocation.invokeNext();
+ }
+ public Object commitUndeploy(MethodInvocation invocation)
+ throws Throwable
+ {
+ Object target = invocation.getTargetObject();
+ Object value = invocation.invokeNext();
+ log.debug("commitUndeploy, target="+target);
+ called.add(IDeployerMethod.commitUndeploy);
+ return value;
+ }
+}
Property changes on: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/DeployerAspects.java
___________________________________________________________________
Name: svn:keywords
+ Id,Revision
Name: svn:eol-style
+ native
Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/IDeployer.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/IDeployer.java (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/IDeployer.java 2007-01-28 22:42:02 UTC (rev 60089)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.support.deployers;
+
+/**
+ * Test deployer interface
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface IDeployer
+{
+ public enum IDeployerMethod {
+ prepareDeploy,
+ prepareUndeploy,
+ commitDeploy,
+ commitUndeploy
+ }
+
+ void prepareDeploy(String unit) throws Exception;
+ void prepareUndeploy(String unit);
+ void commitDeploy(String unit) throws Exception;
+ void commitUndeploy(String unit);
+}
Property changes on: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/IDeployer.java
___________________________________________________________________
Name: svn:keywords
+ Id,Revision
Name: svn:eol-style
+ native
Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/IMainDeployer.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/IMainDeployer.java (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/IMainDeployer.java 2007-01-28 22:42:02 UTC (rev 60089)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.support.deployers;
+
+import java.util.List;
+
+/**
+ * Test main deployer interface
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface IMainDeployer
+{
+ public List<IDeployer> getDeployers();
+ public void addDeployer(IDeployer deployer);
+ public void removeDeployer(IDeployer deployer);
+ public void addDeployment(String unit);
+ public void removeDeployment(String unit);
+ public void process() throws Exception;
+}
Property changes on: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/IMainDeployer.java
___________________________________________________________________
Name: svn:keywords
+ Id,Revision
Name: svn:eol-style
+ native
Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/MainDeployerAspects.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/MainDeployerAspects.java (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/MainDeployerAspects.java 2007-01-28 22:42:02 UTC (rev 60089)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.support.deployers;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.logging.Logger;
+
+/**
+ * IMainDeployer aspects.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class MainDeployerAspects
+{
+ private static Logger log = Logger.getLogger(MainDeployerAspects.class);
+ private static boolean processCalled;
+
+ public static boolean isProcessCalled()
+ {
+ return processCalled;
+ }
+
+ public static void setProcessCalled(boolean processCalled)
+ {
+ MainDeployerAspects.processCalled = processCalled;
+ }
+
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ log.debug(invocation);
+ MethodInvocation mi = (MethodInvocation) invocation;
+ String methodName = mi.getActualMethod().getName();
+ Object value = null;
+ if( methodName.equals("process") )
+ value = process(mi);
+ else
+ value = invocation.invokeNext();
+ return value;
+
+ }
+
+ public Object process(MethodInvocation invocation)
+ throws Throwable
+ {
+ Object target = invocation.getTargetObject();
+ Object[] args = invocation.getArguments();
+ log.debug("process, target="+target);
+ processCalled = true;
+ return invocation.invokeNext();
+ }
+
+}
Property changes on: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/MainDeployerAspects.java
___________________________________________________________________
Name: svn:keywords
+ Id,Revision
Name: svn:eol-style
+ native
Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/SampleDeployer.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/SampleDeployer.java (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/SampleDeployer.java 2007-01-28 22:42:02 UTC (rev 60089)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.support.deployers;
+
+import java.util.HashSet;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Sample IDeployer.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class SampleDeployer implements IDeployer
+{
+ private static Logger log = Logger.getLogger(SampleDeployer.class);
+ private HashSet<IDeployerMethod> called = new HashSet<IDeployerMethod>();
+ private String type;
+
+ public SampleDeployer()
+ {
+ log.debug("ctor");
+ }
+
+ public HashSet<IDeployerMethod> getCalled()
+ {
+ return called;
+ }
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public void setType(String type)
+ {
+ this.type = type;
+ }
+
+ public void commitDeploy(String unit) throws Exception
+ {
+ called.add(IDeployerMethod.commitDeploy);
+ }
+
+ public void commitUndeploy(String unit)
+ {
+ called.add(IDeployerMethod.commitUndeploy);
+ }
+
+ public void prepareDeploy(String unit) throws Exception
+ {
+ called.add(IDeployerMethod.prepareDeploy);
+ }
+
+ public void prepareUndeploy(String unit)
+ {
+ called.add(IDeployerMethod.prepareUndeploy);
+ }
+
+}
Property changes on: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/SampleDeployer.java
___________________________________________________________________
Name: svn:keywords
+ Id,Revision
Name: svn:eol-style
+ native
Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/SampleMainDeployer.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/SampleMainDeployer.java (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/SampleMainDeployer.java 2007-01-28 22:42:02 UTC (rev 60089)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.support.deployers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Sample IMainDeployer
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class SampleMainDeployer implements IMainDeployer
+{
+ private static Logger log = Logger.getLogger(SampleMainDeployer.class);
+ private ArrayList<IDeployer> deployers = new ArrayList<IDeployer>();
+ private ArrayList<String> added = new ArrayList<String>();
+ private ArrayList<String> removed = new ArrayList<String>();
+
+ public List<IDeployer> getDeployers()
+ {
+ return new ArrayList<IDeployer>(deployers);
+ }
+ public void setDeployers(List<IDeployer> list)
+ {
+ this.deployers.clear();
+ this.deployers.addAll(list);
+ log.debug("setDeployers, size="+deployers.size());
+ }
+ public void addDeployer(IDeployer deployer)
+ {
+ deployers.add(deployer);
+ }
+ public void removeDeployer(IDeployer deployer)
+ {
+ deployers.remove(deployer);
+ }
+
+ public void addDeployment(String unit)
+ {
+ added.add(unit);
+ }
+ public void removeDeployment(String unit)
+ {
+ added.remove(unit);
+ removed.add(unit);
+ }
+
+ public void process() throws Exception
+ {
+ for(IDeployer d : deployers)
+ {
+ for(String unit : removed)
+ {
+ d.prepareUndeploy(unit);
+ d.commitUndeploy(unit);
+ }
+ }
+
+ for(IDeployer d : deployers)
+ {
+ for(String unit : added)
+ {
+ d.prepareDeploy(unit);
+ d.commitDeploy(unit);
+ }
+ }
+ }
+
+}
Property changes on: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/deployers/SampleMainDeployer.java
___________________________________________________________________
Name: svn:keywords
+ Id,Revision
Name: svn:eol-style
+ native
Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/DeployersInterceptedTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/DeployersInterceptedTestCase.java (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/DeployersInterceptedTestCase.java 2007-01-28 22:42:02 UTC (rev 60089)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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 java.util.HashSet;
+
+import junit.framework.Test;
+
+import org.jboss.aop.microcontainer.junit.AOPMicrocontainerTest;
+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;
+
+/**
+ * Tests of deployer/main deployer type of aspects.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class DeployersInterceptedTestCase extends AOPMicrocontainerTest
+{
+ public static Test suite()
+ {
+ return suite(DeployersInterceptedTestCase.class);
+ }
+
+ public DeployersInterceptedTestCase(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));
+ }
+}
Property changes on: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/DeployersInterceptedTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id,Revision
Name: svn:eol-style
+ native
Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/DeployersLifecycleTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/DeployersLifecycleTestCase.java (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/DeployersLifecycleTestCase.java 2007-01-28 22:42:02 UTC (rev 60089)
@@ -0,0 +1,102 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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 java.util.HashSet;
+
+import junit.framework.Test;
+
+import org.jboss.aop.microcontainer.junit.AOPMicrocontainerTest;
+import org.jboss.test.microcontainer.support.deployers.DeployerAspects;
+import org.jboss.test.microcontainer.support.deployers.IMainDeployer;
+import org.jboss.test.microcontainer.support.deployers.MainDeployerAspects;
+import org.jboss.test.microcontainer.support.deployers.SampleDeployer;
+import org.jboss.test.microcontainer.support.deployers.IDeployer.IDeployerMethod;
+
+/**
+ * Tests of deployer/main deployer type of aspects.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class DeployersLifecycleTestCase extends AOPMicrocontainerTest
+{
+ public static Test suite()
+ {
+ return suite(DeployersLifecycleTestCase.class);
+ }
+
+ public DeployersLifecycleTestCase(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();
+
+ assertTrue("MainDeployerAspects.process", MainDeployerAspects.isProcessCalled());
+
+ 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));
+
+ MainDeployerAspects.setProcessCalled(false);
+ md.removeDeployment("thing.xar");
+ md.process();
+ assertTrue("MainDeployerAspects.process", MainDeployerAspects.isProcessCalled());
+
+ 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));
+
+ }
+}
Property changes on: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/DeployersLifecycleTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id,Revision
Name: svn:eol-style
+ native
More information about the jboss-cvs-commits
mailing list