[jboss-svn-commits] JBL Code SVN: r28753 - in labs/jbossesb/trunk/product: install and 9 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Aug 3 10:35:05 EDT 2009


Author: beve
Date: 2009-08-03 10:35:04 -0400 (Mon, 03 Aug 2009)
New Revision: 28753

Added:
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbConstants.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDirectoryStructure.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDirectoryStructureUnitTest.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/test_esb_archives/exploded-esb-archive-subdeployment.esb/
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/test_esb_archives/exploded-esb-archive-subdeployment.esb/META-INF/
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/test_esb_archives/exploded-esb-archive-subdeployment.esb/META-INF/deployment.xml
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/test_esb_archives/exploded-esb-archive-subdeployment.esb/META-INF/jboss-esb.xml
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/test_esb_archives/exploded-esb-archive-subdeployment.esb/request.xsd
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/test_esb_archives/exploded-esb-archive-subdeployment.esb/subdir/
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/test_esb_archives/exploded-esb-archive-subdeployment.esb/subdir/test.war/
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/test_esb_archives/exploded-esb-archive-subdeployment.esb/subdir/test.war/WEB-INF/
Modified:
   labs/jbossesb/trunk/product/install/esb-deployers-jboss-beans.xml
   labs/jbossesb/trunk/product/ivy.xml
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbConfigParser.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeployment.java
   labs/jbossesb/trunk/product/rosetta/tests/build.xml
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/util/VfsUtilUnitTest.java
Log:
Work for https://jira.jboss.org/jira/browse/JBESB-2655 "AS5 Deployer: Add StructureDeployer to support subdeployments in subdirectories and not only the root or the esb archive"


Modified: labs/jbossesb/trunk/product/install/esb-deployers-jboss-beans.xml
===================================================================
--- labs/jbossesb/trunk/product/install/esb-deployers-jboss-beans.xml	2009-08-03 14:11:46 UTC (rev 28752)
+++ labs/jbossesb/trunk/product/install/esb-deployers-jboss-beans.xml	2009-08-03 14:35:04 UTC (rev 28753)
@@ -3,6 +3,8 @@
 <!-- JBoss ESB 4.x + JBossAS5 integration -->
 
 <deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+	<bean name="EsbDirectoryStructure" class="org.jboss.soa.esb.listeners.deployers.mc.EsbDirectoryStructure"/>
 	
 	<bean name="EsbConfigParser" class="org.jboss.soa.esb.listeners.deployers.mc.EsbConfigParser">
 		<property name="esbDeploymentPrefix">jboss.esb:deployment=</property>

Modified: labs/jbossesb/trunk/product/ivy.xml
===================================================================
--- labs/jbossesb/trunk/product/ivy.xml	2009-08-03 14:11:46 UTC (rev 28752)
+++ labs/jbossesb/trunk/product/ivy.xml	2009-08-03 14:35:04 UTC (rev 28753)
@@ -107,40 +107,41 @@
         <dependency org="xmlunit" name="xmlunit" rev="1.2"/>
 
 		<!-- JBoss Microcontainer dependencies -->
-        <dependency org="org.jboss.deployers" name="jboss-deployers-vfs-spi" rev="2.0.5.GA">
+        <dependency org="org.jboss.deployers" name="jboss-deployers-vfs-spi" rev="2.0.7.GA">
             <exclude org="jboss" module="jboss-vfs"/>
         </dependency>
-        <dependency org="org.jboss.deployers" name="jboss-deployers-vfs" rev="2.0.5.GA"/>
-        <dependency org="org.jboss.deployers" name="jboss-deployers-spi" rev="2.0.5.GA"/>
-        <dependency org="org.jboss.deployers" name="jboss-deployers-core-spi" rev="2.0.5.GA"/>
-        <dependency org="org.jboss.deployers" name="jboss-deployers-core" rev="2.0.5.GA"/>
-        <dependency org="org.jboss.deployers" name="jboss-deployers-impl" rev="2.0.5.GA"/>
-        <dependency org="org.jboss.deployers" name="jboss-deployers-structure-spi" rev="2.0.5.GA"/>
-        <dependency org="org.jboss.deployers" name="jboss-deployers-client" rev="2.0.5.GA"/>
-        <dependency org="org.jboss.deployers" name="jboss-deployers-client-spi" rev="2.0.5.GA"/>
-        <dependency org="org.jboss.deployers" name="jboss-deployers-client-spi" rev="2.0.5.GA"/>
+        <dependency org="org.jboss.deployers" name="jboss-deployers-vfs" rev="2.0.7.GA"/>
+        <dependency org="org.jboss.deployers" name="jboss-deployers-spi" rev="2.0.7.GA"/>
+        <dependency org="org.jboss.deployers" name="jboss-deployers-core-spi" rev="2.0.7.GA"/>
+        <dependency org="org.jboss.deployers" name="jboss-deployers-core" rev="2.0.7.GA"/>
+        <dependency org="org.jboss.deployers" name="jboss-deployers-impl" rev="2.0.7.GA"/>
+        <dependency org="org.jboss.deployers" name="jboss-deployers-structure-spi" rev="2.0.7.GA"/>
+        <dependency org="org.jboss.deployers" name="jboss-deployers-client" rev="2.0.7.GA"/>
+        <dependency org="org.jboss.deployers" name="jboss-deployers-client-spi" rev="2.0.7.GA"/>
+        <dependency org="org.jboss.deployers" name="jboss-deployers-client-spi" rev="2.0.7.GA"/>
 
         <dependency org="org.jboss.microcontainer" name="jboss-dependency" rev="2.0.4.GA"/>
-        <dependency org="org.jboss.microcontainer" name="jboss-kernel" rev="2.0.4.GA"/>
+        <dependency org="org.jboss.microcontainer" name="jboss-kernel" rev="2.0.6.GA"/>
 
-        <dependency org="org.jboss.cl" name="jboss-classloader" rev="2.0.4.GA"/>
-        <dependency org="org.jboss.cl" name="jboss-classloading" rev="2.0.4.GA"/>
-        <dependency org="org.jboss.cl" name="jboss-classloading-vfs" rev="2.0.4.GA"/>
+        <dependency org="org.jboss.cl" name="jboss-classloader" rev="2.0.6.GA"/>
+        <dependency org="org.jboss.cl" name="jboss-classloading" rev="2.0.6.GA"/>
+        <dependency org="org.jboss.cl" name="jboss-classloading-vfs" rev="2.0.6.GA"/>
 
-        <dependency org="org.jboss.man" name="jboss-managed" rev="2.0.0.GA"/>
-        <dependency org="org.jboss.man"	name="jboss-metatype" rev="2.0.0.GA"/>
+        <dependency org="org.jboss.man" name="jboss-managed" rev="2.1.0.SP1"/>
+        <dependency org="org.jboss.man"	name="jboss-metatype" rev="2.1.0.SP1"/>
 
-        <dependency org="org.jboss.integration" name="jboss-classloading-spi" rev="5.0.3.GA"/>
-        <dependency org="org.jboss.integration" name="jboss-profileservice-spi" rev="5.0.3.GA"/>
+        <dependency org="org.jboss.integration" name="jboss-classloading-spi" rev="5.1.0.GA"/>
+        <dependency org="org.jboss.integration" name="jboss-profileservice-spi" rev="5.1.0.GA"/>
 
-        <dependency org="org.jboss" name="jboss-vfs" rev="2.1.0.GA"/>
-        <dependency org="org.jboss" name="jboss-common-core" rev="2.2.11.GA"/>
+        <dependency org="org.jboss" name="jboss-vfs" rev="2.1.2.GA"/>
+        <dependency org="org.jboss" name="jboss-common-core" rev="2.2.14.GA"/>
         <dependency org="org.jboss" name="jboss-mdr" rev="2.0.1.GA"/>
-        <dependency org="org.jboss"	name="jboss-reflect" rev="2.0.1.GA"/>
-        <dependency org="org.jboss"	name="jbossxb" rev="2.0.0.GA"/>
+        <dependency org="org.jboss"	name="jboss-reflect" rev="2.0.2.GA"/>
+        <dependency org="org.jboss"	name="jbossxb" rev="2.0.1.GA"/>
 
 
 		<!-- Note that jboss-metadata is still in beta -->
+        <!--dependency org="org.jboss"	name="jboss-metadata" rev="1.0.1.GA"/-->
         <dependency org="org.jboss"	name="jboss-metadata" rev="1.0.0.Beta6"/>
 
         <dependency org="org.jboss.jbossas"	name="jboss-as-bootstrap" rev="5.0.1.GA"/>
@@ -152,11 +153,13 @@
         <dependency org="org.jboss.jbossas"	name="jboss-as-system-jmx" rev="5.0.1.GA"/>
         <dependency org="org.jboss.jbossas"	name="jboss-as-webservices" rev="5.0.1.GA"/>
 
-        <dependency org="org.jboss.logging" name="jboss-logging-spi" rev="2.0.5.GA"/>
+        <dependency org="org.jboss.logging" name="jboss-logging-spi" rev="2.1.0.GA"/>
         <dependency org="org.jboss.javaee" name="jboss-ejb-api" rev="3.0.0.GA"/>
-        <dependency org="org.jboss.test" name="jboss-test" rev="1.1.3.GA"/>
+        <dependency org="org.jboss.test" name="jboss-test" rev="1.1.4.GA"/>
 
         <dependency org="javax.xml.bind" name="jaxb-api" rev="2.1"/>
 
+        <dependency org="org.jboss.security" name="jboss-security-spi" rev="2.1.0.20090318"/>
+
     </dependencies>
 </ivy-module>

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbConfigParser.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbConfigParser.java	2009-08-03 14:11:46 UTC (rev 28752)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbConfigParser.java	2009-08-03 14:35:04 UTC (rev 28753)
@@ -32,6 +32,8 @@
 
 import org.apache.log4j.Logger;
 import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer;
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
 import org.jboss.deployment.DeploymentException;
@@ -82,16 +84,6 @@
 public class EsbConfigParser extends AbstractVFSParsingDeployer<EsbMetaData>
 {
     /**
-     * The default suffix of JBossESB configuration files that should be picked up.
-     */
-    private static final String ESB_FILE_SUFFIX = "-esb.xml";
-
-    /**
-     * The default suffix of JBossESB archives that should be accepted.
-     */
-    private static final String ESB_ARCHIVE_SUFFIX = ".esb";
-    
-    /**
      * Name and path of the esb deployment.xml file.
      */
     private static final String ESB_DEPLOYMENT_XML = "META-INF/deployment.xml";
@@ -128,7 +120,7 @@
     private Logger log = Logger.getLogger(EsbConfigParser.class);
 
     /**
-     * Sole constructor that performas the following steps:
+     * Sole constructor that performs the following steps:
      * <lu>
      *  <li>Sets the output of this deployer to be {@link EsbMetaData}.</li>
      *  <li>Sets the suffix to {@link EsbConfigParser#ESB_FILE_SUFFIX}.</li>
@@ -139,8 +131,8 @@
     public EsbConfigParser()
     {
         super(EsbMetaData.class);
-        setSuffix(ESB_FILE_SUFFIX);
-        setJarExtension(ESB_ARCHIVE_SUFFIX);
+        setSuffix(EsbConstants.ESB_FILE_SUFFIX);
+        setJarExtension(EsbConstants.ESB_ARCHIVE_SUFFIX);
         setStage(DeploymentStages.PARSE);
     }
 
@@ -191,10 +183,13 @@
      */
     private String readEsbConfigFile(final VirtualFile file) throws DeploymentException, IOException
     {
-        if (file.getName().endsWith(ESB_FILE_SUFFIX))
+        if (file.getName().endsWith(EsbConstants.ESB_FILE_SUFFIX))
         {
             return JBossDeployerUtil.readEsbConfig(file.openStream());
         }
+        
+        VirtualFile child = file.getChild("META-INF");
+        log.info("META-INF : " + child);
 
         List<VirtualFile> esbConfigFiles;
         try
@@ -330,12 +325,12 @@
     String getDeploymentName(final VFSDeploymentUnit deploymentUnit)
     {
         final String simpleName = deploymentUnit.getSimpleName();
-        int idx = simpleName.indexOf(ESB_ARCHIVE_SUFFIX);
+        int idx = simpleName.indexOf(EsbConstants.ESB_ARCHIVE_SUFFIX);
         if (idx == -1)
         {
             return simpleName;
         }
-        return simpleName.substring(0, simpleName.indexOf(ESB_ARCHIVE_SUFFIX));
+        return simpleName.substring(0, simpleName.indexOf(EsbConstants.ESB_ARCHIVE_SUFFIX));
     }
 
     public void setActionArtifactsFile(final String actionArtifactsFile)
@@ -367,7 +362,7 @@
          */
         public boolean accepts(final VirtualFile file)
         {
-            return file.getName().endsWith(ESB_FILE_SUFFIX);
+            return file.getName().endsWith(EsbConstants.ESB_FILE_SUFFIX);
         }
     }
 

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbConstants.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbConstants.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbConstants.java	2009-08-03 14:35:04 UTC (rev 28753)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, 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.soa.esb.listeners.deployers.mc;
+
+/**
+ * Contstants for ESB Microecontainer Deployers.
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public final class EsbConstants
+{
+    /**
+     * The default suffix of JBossESB configuration files that should be picked up.
+     */
+    public static final String ESB_FILE_SUFFIX = "-esb.xml";
+    
+    /**
+     * The default suffix of JBossESB archives that should be accepted.
+     */
+    public static final String ESB_ARCHIVE_SUFFIX = ".esb";
+
+}

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeployment.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeployment.java	2009-08-03 14:11:46 UTC (rev 28752)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeployment.java	2009-08-03 14:35:04 UTC (rev 28753)
@@ -33,7 +33,7 @@
 import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleController;
 
 /**
- * EsbDeployment for Microcontainer. 
+ * EsbDeployment for the Microcontainer. 
  * <p/> 
  * 
  * Microcontainer will call the lifecycle methods:
@@ -106,7 +106,7 @@
 
     public void start() throws Exception
     {
-        log.info("Starting EBS Deployment '" + deploymentName + "'");
+        log.info("Starting ESB Deployment '" + deploymentName + "'");
         
         if (controller == null)
         {

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDirectoryStructure.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDirectoryStructure.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDirectoryStructure.java	2009-08-03 14:35:04 UTC (rev 28753)
@@ -0,0 +1,113 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, 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.soa.esb.listeners.deployers.mc;
+
+import java.util.List;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.structure.ContextInfo;
+import org.jboss.deployers.spi.structure.StructureMetaData;
+import org.jboss.deployers.vfs.plugins.structure.AbstractVFSStructureDeployer;
+import org.jboss.deployers.vfs.spi.structure.StructureContext;
+import org.jboss.deployers.vfs.spi.structure.VFSStructuralDeployers;
+import org.jboss.deployers.vfs.spi.structure.helpers.AbstractStructureDeployer;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * This StructureDeployer implmentation will recursively try to determine
+ * the structure of all files and directories in a .esb archive deployment.
+ * This class was added to support deployments in sub directories.
+ * <p/>
+ * 
+ * Dislaimer: Most of this code was copied from org.jboss.deployers.vfs.plugins.structure.dir.DirectoryStructure.
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class EsbDirectoryStructure extends AbstractVFSStructureDeployer
+{
+    public EsbDirectoryStructure()
+    {
+        setRelativeOrder(Integer.MAX_VALUE);
+    }
+
+    public boolean determineStructure(StructureContext context) throws DeploymentException
+    {
+        try
+        {
+            final VirtualFile file = context.getFile();
+            // jar structure should already handle top level dirs
+            if (context.isTopLevel() == false && isLeaf(file) == false && isMetadataPath(context) == false)
+            {
+                final List<VirtualFile> children = file.getChildren();
+                if (children != null && children.isEmpty() == false)
+                {
+                    VFSStructuralDeployers structuralDeployers = context.getDeployers();
+
+                    // get top
+                    while (context.getParentContext() != null)
+                        context = context.getParentContext();
+                    
+                    if (context.getName().endsWith(EsbConstants.ESB_ARCHIVE_SUFFIX))
+                    {
+	                    for (VirtualFile child : children)
+	                    {
+	                        structuralDeployers.determineStructure(child, context);
+	                    }
+                    }
+                }
+            }
+            return false;
+        } 
+        catch (final Exception e)
+        {
+            throw DeploymentException.rethrowAsDeploymentException("Error determining structure.", e);
+        }
+    }
+
+    /**
+     * Is the current context already part of metadata path.
+     * 
+     * @param context
+     *            the current structure context
+     * @return true if already part of parent's context metadata path
+     */
+    protected boolean isMetadataPath(final StructureContext context)
+    {
+        final StructureContext parentContext = context.getParentContext();
+        if (parentContext == null)
+            return false;
+
+        final StructureMetaData smd = parentContext.getMetaData();
+        final ContextInfo info = smd.getContext("");
+        final List<String> metadataPaths = info.getMetaDataPath();
+        if (metadataPaths != null && metadataPaths.isEmpty() == false)
+        {
+            final String relativePath = AbstractStructureDeployer.getRelativePath(context.getParent(), context.getFile());
+            for (String path : metadataPaths)
+                if (relativePath.equalsIgnoreCase(path))
+                    return true;
+        }
+
+        return false;
+    }
+
+}

Modified: labs/jbossesb/trunk/product/rosetta/tests/build.xml
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/build.xml	2009-08-03 14:11:46 UTC (rev 28752)
+++ labs/jbossesb/trunk/product/rosetta/tests/build.xml	2009-08-03 14:35:04 UTC (rev 28753)
@@ -118,6 +118,8 @@
         </copy>
 		<copy todir="${org.jboss.esb.tests.classes.dir}" >
             <fileset dir="${org.jboss.esb.module.tests.src.dir}" includes="**/*.xml" />
+            <fileset dir="${org.jboss.esb.module.tests.src.dir}" includes="**/*.war" />
+            <fileset dir="${org.jboss.esb.module.tests.src.dir}" includes="**/*.xsd" />
         </copy>
 		<copy file="${org.jboss.esb.root.dir}/etc/schemas/xml/jbossesb-1.0.1.xsd" todir="${org.jboss.esb.tests.classes.dir}"/>
 

Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDirectoryStructureUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDirectoryStructureUnitTest.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDirectoryStructureUnitTest.java	2009-08-03 14:35:04 UTC (rev 28753)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, 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.soa.esb.listeners.deployers.mc;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.net.URL;
+import java.util.List;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.jboss.deployers.structure.spi.DeploymentContext;
+import org.jboss.deployers.vfs.plugins.structure.VFSStructuralDeployersImpl;
+import org.jboss.deployers.vfs.plugins.structure.VFSStructureBuilder;
+import org.jboss.deployers.vfs.plugins.structure.jar.JARStructure;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
+import org.jboss.virtual.VirtualFile;
+import org.junit.Test;
+
+/**
+ * Unit test for {@link EsbStructure}.
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ * @since 4.7
+ *
+ */
+public class EsbDirectoryStructureUnitTest
+{
+    private URL dir = getClass().getResource("/org/jboss/soa/esb/listeners/deployers/mc/test_esb_archives");
+
+    @Test
+    public void explodedArchiveWithSubDir() throws Exception
+    {
+		VFSStructuralDeployersImpl structuralDeployers = createStructureDeployers(true);
+		
+        VirtualFile virtualFile = TestUtil.getVirtualFile(dir, "exploded-esb-archive-subdeployment.esb", getClass());
+		VFSDeployment deployment = VFSDeploymentFactory.getInstance().createVFSDeployment(virtualFile);
+		
+		VFSDeploymentContext context = (VFSDeploymentContext)structuralDeployers.determineStructure(deployment);
+		
+		assertTrue(context.isTopLevel());
+		assertNotNull(context.getMetaDataFile("jboss-esb.xml"));
+		assertNotNull(context.getFile("request.xsd"));
+		assertNotNull(context.getFile("subdir"));
+		assertNotNull(context.getFile("subdir/test.war"));
+		
+		List<DeploymentContext> children = context.getChildren();
+        assertEquals(1, children.size());
+        assertEquals("test.war", children.get(0).getSimpleName());
+    }
+    
+    @Test
+    public void explodedArchiveWithSubDirWithoutEsbDirectoryStructure() throws Exception
+    {
+        // Not adding EsbDirectoryStructure to the structure deployers.
+        VFSStructuralDeployersImpl structuralDeployers = createStructureDeployers(false);
+        
+        VirtualFile virtualFile = TestUtil.getVirtualFile(dir, "exploded-esb-archive-subdeployment.esb", getClass());
+        VFSDeployment deployment = VFSDeploymentFactory.getInstance().createVFSDeployment(virtualFile);
+        
+        VFSDeploymentContext context = (VFSDeploymentContext)structuralDeployers.determineStructure(deployment);
+        
+        assertTrue(context.isTopLevel());
+        assertNotNull(context.getMetaDataFile("jboss-esb.xml"));
+        assertNotNull(context.getFile("request.xsd"));
+        assertNotNull(context.getFile("subdir"));
+        assertNotNull(context.getFile("subdir/test.war"));
+        
+        List<DeploymentContext> children = context.getChildren();
+        assertEquals(0, children.size());
+    }
+    
+    private VFSStructuralDeployersImpl createStructureDeployers(boolean withEsbDirStructure)
+    {
+		final VFSStructuralDeployersImpl structuralDeployers = new VFSStructuralDeployersImpl();
+		VFSStructureBuilder builder = new VFSStructureBuilder();
+		
+		structuralDeployers.setStructureBuilder(builder);
+		structuralDeployers.addDeployer(new JARStructure());
+		if (withEsbDirStructure)
+			structuralDeployers.addDeployer(new EsbDirectoryStructure());
+		return structuralDeployers;
+    }
+    
+    public static junit.framework.Test suite()
+    {
+        return new JUnit4TestAdapter(EsbDirectoryStructureUnitTest.class);
+    }
+
+}

Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/test_esb_archives/exploded-esb-archive-subdeployment.esb/META-INF/deployment.xml
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/test_esb_archives/exploded-esb-archive-subdeployment.esb/META-INF/deployment.xml	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/test_esb_archives/exploded-esb-archive-subdeployment.esb/META-INF/deployment.xml	2009-08-03 14:35:04 UTC (rev 28753)
@@ -0,0 +1,5 @@
+<jbossesb-deployment>
+  <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_helloworld_Request_esb</depends>
+  <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_helloworld_Request_gw</depends>
+  <esb-depends>test2.war</esb-depends>
+</jbossesb-deployment>

Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/test_esb_archives/exploded-esb-archive-subdeployment.esb/META-INF/jboss-esb.xml
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/test_esb_archives/exploded-esb-archive-subdeployment.esb/META-INF/jboss-esb.xml	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/test_esb_archives/exploded-esb-archive-subdeployment.esb/META-INF/jboss-esb.xml	2009-08-03 14:35:04 UTC (rev 28753)
@@ -0,0 +1,50 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd" parameterReloadSecs="5">
+
+    <providers>
+          <jms-provider name="JBossMQ" connection-factory="ConnectionFactory">
+              <jms-bus busid="quickstartGwChannel">
+                  <jms-message-filter
+                      dest-type="QUEUE"
+                      dest-name="queue/quickstart_helloworld_Request_gw"
+                   />
+              </jms-bus>
+              <jms-bus busid="quickstartEsbChannel">
+                  <jms-message-filter
+                      dest-type="QUEUE"
+                      dest-name="queue/quickstart_helloworld_Request_esb"
+                  />
+              </jms-bus>
+
+          </jms-provider>
+      </providers>
+
+      <services>
+        <service
+            category="FirstServiceESB"
+            name="SimpleListener"
+            description="Hello World">
+            <listeners>
+                <jms-listener name="JMS-Gateway"
+                    busidref="quickstartGwChannel"
+                    is-gateway="true"
+                />
+                <jms-listener name="helloWorld"
+                              busidref="quickstartEsbChannel"
+                />
+            </listeners>
+            <actions mep="OneWay" webservice="true" inXsd="/org/jboss/soa/esb/listeners/deployers/mc/test_esb_archives/exploded-esb-archive.esb/request.xsd">
+                   <action name="action1"
+                    class="org.jboss.soa.esb.samples.quickstart.helloworld.MyJMSListenerAction"
+                    process="displayMessage"
+                    />
+                    <action name="action2" class="org.jboss.soa.esb.actions.SystemPrintln">
+                      <property name="printfull" value="false"/>
+                    </action>
+                    <!-- The next action is for Continuous Integration testing -->
+                    <action name="testStore" class="org.jboss.soa.esb.actions.TestMessageStore"/>
+            </actions>
+        </service>
+      </services>
+
+</jbossesb>

Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/test_esb_archives/exploded-esb-archive-subdeployment.esb/request.xsd
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/test_esb_archives/exploded-esb-archive-subdeployment.esb/request.xsd	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/test_esb_archives/exploded-esb-archive-subdeployment.esb/request.xsd	2009-08-03 14:35:04 UTC (rev 28753)
@@ -0,0 +1,8 @@
+<xs:schema version="1.0" targetNamespace="http://www.jboss.org/sayHi" xmlns:x1="http://www.jboss.org/sayHi"  xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+  <xs:element name="sayHi" type="x1:sayHi"/>
+  <xs:complexType name="sayHi">
+    <xs:sequence>
+      <xs:element name="arg0" type="xs:string" minOccurs="1"/>
+    </xs:sequence>
+  </xs:complexType>
+</xs:schema>

Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/util/VfsUtilUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/util/VfsUtilUnitTest.java	2009-08-03 14:11:46 UTC (rev 28752)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/util/VfsUtilUnitTest.java	2009-08-03 14:35:04 UTC (rev 28753)
@@ -2,17 +2,17 @@
  * JBoss, Home of Professional Open Source Copyright 2009, 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
@@ -26,13 +26,11 @@
 import java.io.File;
 import java.io.IOException;
 import java.net.MalformedURLException;
-import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.Arrays;
 import java.util.List;
 
-import org.jboss.virtual.MemoryFileFactory;
 import org.jboss.virtual.VFS;
 import org.jboss.virtual.VirtualFile;
 import org.junit.BeforeClass;
@@ -41,7 +39,7 @@
 /**
  * Unit test for {@link VfsUtil}.
  * <p/>
- * 
+ *
  * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
  */
 public class VfsUtilUnitTest
@@ -51,43 +49,43 @@
     {
         VFS.init();
     }
-    
+
     @Test
     public void createInMemoryFs() throws IOException
     {
         final URL rootUrl = new URL("vfsmemory", "VfsUtilUnitTest", "");
         final  VirtualFile root = VfsUtil.createInMemoryFs(rootUrl);
         assertNotNull(root);
-        
+
         final VirtualFile root2 = VfsUtil.createInMemoryFs(rootUrl);
         assertEquals(root, root2);
     }
-    
+
     @Test
     public void addFile() throws IOException
     {
         final URL rootUrl = new URL("vfsmemory", "VfsUtilUnitTest", "");
         final VirtualFile rootFs = VfsUtil.createInMemoryFs(rootUrl);
-        
+
         VfsUtil.addFile(rootUrl, "test.xml", "bajja".getBytes());
         final VirtualFile testFile = rootFs.getChild("test.xml");
         assertNotNull(testFile);
     }
-    
+
     @Test
     public void createUrl() throws MalformedURLException
     {
         URL rootUrl = VfsUtil.createInMemUrl("vsftest");
         assertEquals("vfsmemory://vsftest", rootUrl.toExternalForm());
     }
-    
+
     @Test
     public void createUrlPath() throws MalformedURLException
     {
         URL rootUrl = VfsUtil.createInMemUrl("vsftest", "WEB-INF");
         assertEquals("vfsmemory://vsftest/WEB-INF", rootUrl.toExternalForm());
     }
-    
+
     @Test
     public void createUrlPathUrl() throws IOException
     {
@@ -95,7 +93,7 @@
         URL pathUrl = VfsUtil.createInMemUrl(rootUrl, "WEB-INF/classes");
         assertEquals("vfsmemory://vsftest/WEB-INF/classes", pathUrl.toExternalForm());
     }
-    
+
     @Test
     public void addFilesInFromInMemFs() throws IOException, URISyntaxException
     {
@@ -103,16 +101,16 @@
         VfsUtil.createInMemoryFs(sourceUrl);
         VirtualFile file1 = VfsUtil.addFile(sourceUrl, "test", "dummy".getBytes());
         VirtualFile file2 = VfsUtil.addFile(sourceUrl, "test2", "dummy".getBytes());
-        
+
         URL destUrl = VfsUtil.createInMemUrl("vsftest2");
         VirtualFile destDir = VfsUtil.createInMemoryFs(destUrl);
-        
+
         VfsUtil.addFiles(Arrays.asList(file1, file2), destUrl, null);
-        
+
         assertNotNull(destDir.getChild("test"));
         assertNotNull(destDir.getChild("test2"));
     }
-    
+
     @Test
     public void addSchemasInFromInMemFs() throws IOException, URISyntaxException
     {
@@ -120,16 +118,16 @@
         VfsUtil.createInMemoryFs(sourceUrl);
         VirtualFile file1 = VfsUtil.addFile(sourceUrl, "/rootPath/somepath/types/test.xsd", "dummy".getBytes());
         VirtualFile file2 = VfsUtil.addFile(sourceUrl, "/rootPath/somepath/types/test2.xsd", "dummy".getBytes());
-        
+
         URL destUrl = VfsUtil.createInMemUrl("vsftest2");
         VirtualFile destDir = VfsUtil.createInMemoryFs(destUrl);
-        
+
         VfsUtil.addFiles(Arrays.asList(file1, file2), destUrl, "somepath", "WEB-INF/wsdl");
-        
+
         assertNotNull(destDir.getChild("WEB-INF/wsdl/types/test.xsd"));
         assertNotNull(destDir.getChild("WEB-INF/wsdl/types/test2.xsd"));
     }
-    
+
     @Test
     public void addFilesInFromFileFs() throws IOException, URISyntaxException
     {
@@ -142,21 +140,21 @@
             File tmpDir = new File(tmpFile.getParent());
             workDir = new File(tmpDir, "VfsTest");
             workDir.mkdir();
-            
+
             // Add two files to the working directory.
             File file1 = new File(workDir, "test1.txt");
             file1.createNewFile();
             File file2 = new File(workDir, "test2.txt");
             file2.createNewFile();
-            
+
             // Create a new virtual root using the workDir.
             VirtualFile root = VFS.createNewRoot(workDir.toURI());
             List<VirtualFile> files = root.getChildren();
             assertEquals(2, files.size());
-            
+
             URL destUrl = VfsUtil.createInMemUrl("vsftest2");
             VirtualFile destDir = VfsUtil.createInMemoryFs(destUrl);
-            
+
             VfsUtil.addFiles(files, destUrl, null);
             assertNotNull(destDir.getChild("test"));
             assertNotNull("test1.txt", destDir.getChild("test").getPathName());
@@ -176,7 +174,7 @@
             }
         }
     }
-    
+
     @Test
     public void subpath()
     {
@@ -187,13 +185,13 @@
         assertEquals(actualPath, VfsUtil.subpath(actualPath, null));
         assertEquals(actualPath, VfsUtil.subpath(actualPath, "dummy"));
     }
-    
+
     @Test
     public void subpathWithSuffix()
     {
         String actualPath = "Test.esb/types/custom-request-type.xsd";
         String expectedPath = "WEB-INF/wsdl/types/custom-request-type.xsd";
-        
+
         assertEquals(expectedPath, VfsUtil.subpath(actualPath, "Test.esb", "WEB-INF/wsdl"));
     }
 



More information about the jboss-svn-commits mailing list