[jboss-cvs] JBossAS SVN: r69981 - in projects/microcontainer/trunk: deployers-vfs/src/resources/tests and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Feb 20 12:56:21 EST 2008
Author: adrian at jboss.org
Date: 2008-02-20 12:56:21 -0500 (Wed, 20 Feb 2008)
New Revision: 69981
Added:
projects/microcontainer/trunk/deployers-vfs/src/resources/tests/bootstrap/
projects/microcontainer/trunk/deployers-vfs/src/resources/tests/bootstrap/bootstrap.xml
projects/microcontainer/trunk/deployers-vfs/src/resources/tests/bootstrap/test/
projects/microcontainer/trunk/deployers-vfs/src/resources/tests/bootstrap/test/META-INF/
projects/microcontainer/trunk/deployers-vfs/src/resources/tests/bootstrap/test/META-INF/test-beans.xml
projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/BootstrapDeployersTest.java
projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/BootstrapDeployersTestDelegate.java
projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/test/BootstrapDeployersSmokeTestUnitTestCase.java
Modified:
projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/classloading/AbstractTopLevelClassLoaderSystemDeployer.java
Log:
Make a start on writing tests in the way that JBossAS uses the deployers
Modified: projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/classloading/AbstractTopLevelClassLoaderSystemDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/classloading/AbstractTopLevelClassLoaderSystemDeployer.java 2008-02-20 17:53:53 UTC (rev 69980)
+++ projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/classloading/AbstractTopLevelClassLoaderSystemDeployer.java 2008-02-20 17:56:21 UTC (rev 69981)
@@ -38,7 +38,7 @@
* @author <a href="adrian at jboss.org">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public abstract class AbstractTopLevelClassLoaderSystemDeployer extends AbstractTopLevelClassLoaderDeployer
+public class AbstractTopLevelClassLoaderSystemDeployer extends AbstractTopLevelClassLoaderDeployer
{
/** The classloading */
private ClassLoading classLoading;
Added: projects/microcontainer/trunk/deployers-vfs/src/resources/tests/bootstrap/bootstrap.xml
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/resources/tests/bootstrap/bootstrap.xml (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs/src/resources/tests/bootstrap/bootstrap.xml 2008-02-20 17:56:21 UTC (rev 69981)
@@ -0,0 +1,111 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- The MainDeployer -->
+ <bean name="MainDeployer" class="org.jboss.deployers.plugins.main.MainDeployerImpl">
+ <property name="structuralDeployers"><inject bean="StructuralDeployers"/></property>
+ <property name="deployers"><inject bean="Deployers"/></property>
+ <property name="mgtDeploymentCreator"><inject bean="ManagedDeploymentCreator"/></property>
+ </bean>
+
+ <!-- The ManagedDeploymentCreator implementation -->
+ <bean name="ManagedDeploymentCreator" class="org.jboss.deployers.plugins.managed.DefaultManagedDeploymentCreator" />
+
+ <!-- The holder for deployers that determine structure -->
+ <bean name="StructuralDeployers" class="org.jboss.deployers.vfs.plugins.structure.VFSStructuralDeployersImpl">
+ <property name="structureBuilder">
+ <!-- The consolidator of the structure information -->
+ <bean name="StructureBuilder" class="org.jboss.deployers.vfs.plugins.structure.VFSStructureBuilder"/>
+ </property>
+ <!-- Accept any implementor of structure deployer -->
+ <incallback method="addDeployer"/>
+ <uncallback method="removeDeployer"/>
+ </bean>
+
+ <!-- The holder for deployers that do real deployment -->
+ <bean name="Deployers" class="org.jboss.deployers.plugins.deployers.DeployersImpl">
+ <constructor><parameter><inject bean="jboss.kernel:service=KernelController"/></parameter></constructor>
+ <!-- Accept any implementor of deployer -->
+ <incallback method="addDeployer"/>
+ <uncallback method="removeDeployer"/>
+ </bean>
+
+ <!-- A declared structure descriptor deployer -->
+ <bean name="DeclaredStructure" class="org.jboss.deployers.vfs.plugins.structure.explicit.DeclaredStructure"></bean>
+
+ <!-- JAR Structure -->
+ <bean name="JARStructure" class="org.jboss.deployers.vfs.plugins.structure.jar.JARStructure">
+ <!-- Unless specified the default list of suffixes is .zip, .ear, .jar, ,.rar, .war, .sar, .har, .aop -->
+ <constructor>
+ <parameter>
+ <set elementClass="java.lang.String">
+ <value>.zip</value>
+ <value>.ear</value>
+ <value>.jar</value>
+ <value>.rar</value>
+ <value>.war</value>
+ <value>.sar</value>
+ <value>.har</value>
+ <value>.aop</value>
+ <value>.deployer</value>
+ <value>.beans</value>
+ </set>
+ </parameter>
+ </constructor>
+ <property name="candidateStructureVisitorFactory">
+ <!-- Any file that is not an ordinary directory is a candidate -->
+ <bean name="JARStructureCandidates" class="org.jboss.deployers.vfs.spi.structure.helpers.DefaultCandidateStructureVisitorFactory">
+ <!-- A filter to exclude some obvious non-subdeployments -->
+ <property name="filter">
+ <bean name="JARFilter" class="org.jboss.virtual.plugins.vfs.helpers.SuffixesExcludeFilter">
+ <constructor><parameter>
+ <list elementClass="java.lang.String">
+ <!-- Exclude class files as subdeployments -->
+ <value>.class</value>
+ </list>
+ </parameter></constructor>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+
+ <!-- File Structure -->
+ <bean name="FileStructure" class="org.jboss.deployers.vfs.plugins.structure.file.FileStructure">
+ <!-- Unless specified the default list of suffixes is -service.xml, -beans.xml, -ds.xml, -aop.xml -->
+ <constructor>
+ <parameter>
+ <set elementClass="java.lang.String">
+ <value>-service.xml</value>
+ <value>-beans.xml</value>
+ <value>-ds.xml</value>
+ <value>-aop.xml</value>
+ </set>
+ </parameter>
+ </constructor>
+ </bean>
+
+ <!-- POJO Deployment -->
+ <bean name="BeanDeployer" class="org.jboss.deployers.vfs.deployer.kernel.BeanDeployer">
+ <property name="type">beans</property>
+ </bean>
+ <bean name="KernelDeploymentDeployer" class="org.jboss.deployers.vfs.deployer.kernel.KernelDeploymentDeployer">
+ <property name="type">beans</property>
+ </bean>
+ <bean name="BeanMetaDataDeployer" class="org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer">
+ <constructor><parameter><inject bean="jboss.kernel:service=Kernel"/></parameter></constructor>
+ <property name="type">beans</property>
+ </bean>
+
+ <!-- VFS ClassLoader -->
+ <!--bean name="ClassLoaderSystem" class="org.jboss.classloader.spi.ClassLoaderSystem">
+ <constructor factoryClass="org.jboss.classloader.spi.ClassLoaderSystem" factoryMethod="getInstance"/>
+ </bean>
+ <bean name="ClassLoading" class="org.jboss.classloading.spi.dependency.ClassLoading"/>
+ <bean name="ClassLoaderDescribeDeployer" class="org.jboss.deployers.vfs.plugins.classloader.VFSClassLoaderDescribeDeployer">
+ <property name="classLoading"><inject bean="ClassLoading"/></property>
+ </bean>
+ <bean name="ClassLoaderDeployer" class="org.jboss.deployers.plugins.classloading.AbstractTopLevelClassLoaderSystemDeployer">
+ <property name="classLoading"><inject bean="ClassLoading"/></property>
+ <property name="system"><inject bean="ClassLoaderSystem"/></property>
+ </bean-->
+</deployment>
Added: projects/microcontainer/trunk/deployers-vfs/src/resources/tests/bootstrap/test/META-INF/test-beans.xml
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/resources/tests/bootstrap/test/META-INF/test-beans.xml (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs/src/resources/tests/bootstrap/test/META-INF/test-beans.xml 2008-02-20 17:56:21 UTC (rev 69981)
@@ -0,0 +1,5 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Test" class="java.util.ArrayList"/>
+
+</deployment>
\ No newline at end of file
Added: projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/BootstrapDeployersTest.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/BootstrapDeployersTest.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/BootstrapDeployersTest.java 2008-02-20 17:56:21 UTC (rev 69981)
@@ -0,0 +1,100 @@
+/*
+* 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.deployers;
+
+import java.net.URL;
+import java.security.CodeSource;
+import java.security.ProtectionDomain;
+
+import org.jboss.deployers.client.spi.DeployerClient;
+import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.test.AbstractTestDelegate;
+import org.jboss.test.kernel.junit.MicrocontainerTest;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * BootstrapDeployersTest.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class BootstrapDeployersTest extends MicrocontainerTest
+{
+ public static AbstractTestDelegate getDelegate(Class<?> clazz) throws Exception
+ {
+ return new BootstrapDeployersTestDelegate(clazz);
+ }
+
+ public BootstrapDeployersTest(String name)
+ {
+ super(name);
+ }
+
+ protected DeployerClient getDeployerClient()
+ {
+ return getDelegate().getMainDeployer();
+ }
+
+ protected MainDeployerStructure getMainDeployerStructure()
+ {
+ return getDelegate().getMainDeployer();
+ }
+
+ protected String getRoot(Class<?> clazz)
+ {
+ ProtectionDomain pd = clazz.getProtectionDomain();
+ CodeSource cs = pd.getCodeSource();
+ URL location = cs.getLocation();
+ return location.toString();
+ }
+
+ protected BootstrapDeployersTestDelegate getDelegate()
+ {
+ return (BootstrapDeployersTestDelegate) super.getDelegate();
+ }
+
+ protected VFSDeployment createVFSDeployment(String root) throws Exception
+ {
+ URL resourceRoot = getClass().getResource(root);
+ if (resourceRoot == null)
+ throw new IllegalStateException("Resource not found: " + root);
+ VirtualFile rootFile = VFS.getRoot(resourceRoot);
+ return createVFSDeployment(rootFile);
+ }
+
+ protected VFSDeployment createVFSDeployment(VirtualFile root) throws Exception
+ {
+ VFSDeploymentFactory factory = VFSDeploymentFactory.getInstance();
+ return factory.createVFSDeployment(root);
+ }
+
+ protected VFSDeploymentUnit assertDeploy(String root) throws Exception
+ {
+ VFSDeployment deployment = createVFSDeployment(root);
+ getDeployerClient().deploy(deployment);
+ return (VFSDeploymentUnit) getMainDeployerStructure().getDeploymentUnit(deployment.getName(), true);
+ }
+}
Added: projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/BootstrapDeployersTestDelegate.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/BootstrapDeployersTestDelegate.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/BootstrapDeployersTestDelegate.java 2008-02-20 17:56:21 UTC (rev 69981)
@@ -0,0 +1,62 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, 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.deployers;
+
+import java.net.URL;
+
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.deployers.plugins.main.MainDeployerImpl;
+import org.jboss.test.kernel.junit.MicrocontainerTestDelegate;
+
+/**
+ * BootstrapDeployersTestDelegate.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BootstrapDeployersTestDelegate extends MicrocontainerTestDelegate
+{
+ private MainDeployerImpl mainDeployer;
+
+ public BootstrapDeployersTestDelegate(Class<?> clazz) throws Exception
+ {
+ super(clazz);
+ }
+
+ protected void deploy() throws Exception
+ {
+ String common = "/bootstrap/bootstrap.xml";
+ URL url = getClass().getResource(common);
+ if (url == null)
+ throw new IllegalStateException(common + " not found");
+ deploy(url);
+
+ super.deploy();
+ }
+
+ protected MainDeployerImpl getMainDeployer()
+ {
+ if (mainDeployer == null)
+ mainDeployer = getBean("MainDeployer", ControllerState.INSTALLED, MainDeployerImpl.class);
+ return mainDeployer;
+ }
+}
Added: projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/test/BootstrapDeployersSmokeTestUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/test/BootstrapDeployersSmokeTestUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/test/BootstrapDeployersSmokeTestUnitTestCase.java 2008-02-20 17:56:21 UTC (rev 69981)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.deployers.vfs.classloader.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.test.deployers.BootstrapDeployersTest;
+
+/**
+ * BootstrapDeployersSmokeTestUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BootstrapDeployersSmokeTestUnitTestCase extends BootstrapDeployersTest
+{
+ public static Test suite()
+ {
+ return suite(BootstrapDeployersSmokeTestUnitTestCase.class);
+ }
+
+ public BootstrapDeployersSmokeTestUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testDeployerClient() throws Exception
+ {
+ assertNotNull(getDeployerClient());
+ }
+
+ public void testMainDeployersStructure() throws Exception
+ {
+ assertNotNull(getMainDeployerStructure());
+ }
+
+ public void testDeployBeans() throws Exception
+ {
+ VFSDeploymentUnit unit = assertDeploy("/bootstrap/test");
+ List<DeploymentUnit> components = unit.getComponents();
+ assertNotNull(components);
+ assertEquals(1, components.size());
+ DeploymentUnit component = components.get(0);
+ assertEquals("Test", component.getName());
+
+ assertBean("Test", ArrayList.class);
+ }
+}
More information about the jboss-cvs-commits
mailing list