[Jboss-cvs] JBossAS SVN: r56723 - in projects/microcontainer/trunk/deployers/src: main/org/jboss/deployers/plugins/deployer main/org/jboss/deployers/plugins/deployment main/org/jboss/deployers/plugins/structure/vfs main/org/jboss/deployers/plugins/structure/vfs/file main/org/jboss/deployers/plugins/structure/vfs/jar main/org/jboss/deployers/spi main/org/jboss/deployers/spi/deployer main/org/jboss/deployers/spi/deployment resources/tests/structure resources/tests/structure/file resources/tests/structure/file/directory resources/tests/structure/file/notknown resources/tests/structure/file/simple tests/org/jboss/test/deployers tests/org/jboss/test/deployers/deployer tests/org/jboss/test/deployers/deployer/support tests/org/jboss/test/deployers/deployer/test tests/org/jboss/test/deployers/structure tests/org/jboss/test/deployers/structure/file tests/org/jboss/test/deployers/structure/file/test tests/org/jboss/test/deployers/structure/jar/test tests/org/jboss/test/deployers/structu! re/main tests/org/jboss/test/deployers/structure/main/support tests/org/jboss/test/deployers/structure/main/test tests/org/jboss/test/deployers/structure/war/test

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Sep 11 07:52:48 EDT 2006


Author: adrian at jboss.org
Date: 2006-09-11 07:52:22 -0400 (Mon, 11 Sep 2006)
New Revision: 56723

Added:
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractSimpleDeployer.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/file/
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/file/FileStructure.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployment/
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployment/MainDeployer.java
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/file/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/file/directory/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/file/directory/empty
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/file/notknown/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/file/notknown/test-unknown.xml
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/file/notknown/unknown.xml
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/file/simple/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/file/simple/simple-service.xml
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/DeployerTestSuite.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/support/
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/support/TestSimpleDeployer.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/test/
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/test/DeployerOrderingUnitTestCase.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/test/DeployerProtocolUnitTestCase.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/test/DeployerWidthFirstUnitTestCase.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/test/MainDeployerDeployerUnitTestCase.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/file/
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/file/test/
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/file/test/FileStructureUnitTestCase.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/support/
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/support/TestStructureDeployer.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/support/TestStructureOrdering.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerFileStructureUnitTestCase.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerStructureOrderingUnitTestCase.java
Removed:
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployement/
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployment/MainDeployer.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/TestStructureDeployer.java
Modified:
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeployer.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/DeployerWrapper.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARStructure.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/Deployer.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/BaseDeployersTest.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/DeployersAllTestSuite.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/StructureTestSuite.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/jar/test/JARStructureUnitTestCase.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerJarStructureUnitTestCase.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerStructureUnitTestCase.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerWarStructureUnitTestCase.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/war/test/WARStructureUnitTestCase.java
Log:
[JBMICROCONT-5] - Basic deployer tests and introduction of standalone
xml file structure deployer for catching things like -service.xml

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeployer.java	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeployer.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -21,9 +21,9 @@
 */
 package org.jboss.deployers.plugins.deployer;
 
-import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.spi.deployer.Deployer;
 import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.logging.Logger;
 
 /**
  * AbstractDeployer.<p>
@@ -35,6 +35,9 @@
  */
 public abstract class AbstractDeployer implements Deployer
 {
+   /** The log */
+   protected Logger log = Logger.getLogger(this.getClass());
+   
    public boolean isRelevant(DeploymentUnit unit)
    {
       return true;
@@ -44,8 +47,4 @@
    {
       return Integer.MAX_VALUE;
    }
-
-   public abstract void deploy(DeploymentUnit unit) throws DeploymentException;
-
-   public abstract void undeploy(DeploymentUnit unit);
 }

Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractSimpleDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractSimpleDeployer.java	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractSimpleDeployer.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -0,0 +1,74 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.deployers.plugins.deployer;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+
+/**
+ * AbstractSimpleDeployer.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractSimpleDeployer extends AbstractDeployer
+{
+   public void prepareDeploy(DeploymentUnit unit) throws DeploymentException
+   {
+      // nothing
+   }
+
+   public void prepareUndeploy(DeploymentUnit unit)
+   {
+      undeploy(unit);
+   }
+
+   public void handoff(DeploymentUnit from, DeploymentUnit to) throws DeploymentException
+   {
+      // nothing
+   }
+
+   public void commitDeploy(DeploymentUnit unit) throws DeploymentException
+   {
+      deploy(unit);
+   }
+
+   public void commitUndeploy(DeploymentUnit unit)
+   {
+      // nothing
+   }
+
+   /**
+    * Deploy a deployment
+    * 
+    * @param unit the unit
+    * @throws DeploymentException for any error
+    */
+   public abstract void deploy(DeploymentUnit unit) throws DeploymentException; 
+
+   /**
+    * Undeploy a deployment
+    * 
+    * @param unit the unit
+    */
+   public abstract void undeploy(DeploymentUnit unit); 
+}

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/DeployerWrapper.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/DeployerWrapper.java	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/DeployerWrapper.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -31,6 +31,7 @@
  * 
  * To avoid any problems with error handling by the deployers.
  * 
+ * TODO change logging when full protocol is implemented
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @version $Revision: 1.1 $
  */
@@ -74,39 +75,102 @@
       }
    }
 
-   public void deploy(DeploymentUnit unit) throws DeploymentException
+   public void prepareDeploy(DeploymentUnit unit) throws DeploymentException
    {
       if (unit == null)
          throw new IllegalArgumentException("Null unit");
 
       try
       {
-         log.debug("Deploying: " + unit.getName());
-         deployer.deploy(unit);
-         log.debug("Deployed:  " + unit.getName());
+         log.debug("Preparing deployment: " + unit.getName());
+         deployer.prepareDeploy(unit);
+         log.debug("Prepared deployment:  " + unit.getName());
       }
       catch (Throwable t)
       {
-         log.error("Error during deploy: " + unit.getName(), t);
-         throw DeploymentException.rethrowAsDeploymentException("Error during deploy: " + unit.getName(), t);
+         log.error("Error during prepare deployment: " + unit.getName(), t);
+         throw DeploymentException.rethrowAsDeploymentException("Error during prepare deployment: " + unit.getName(), t);
       }
    }
 
-   public void undeploy(DeploymentUnit unit)
+   public void prepareUndeploy(DeploymentUnit unit)
    {
       if (unit == null)
          throw new IllegalArgumentException("Null unit");
+
       try
       {
+         // TODO log.debug("Prepare undeployment: " + unit.getName());
          log.debug("Undeploying: " + unit.getName());
-         deployer.undeploy(unit);
+         deployer.prepareUndeploy(unit);
+         // TODO log.debug("Prepared undeployment:  " + unit.getName());
          log.debug("Undeployed:  " + unit.getName());
       }
       catch (Throwable t)
       {
-         log.warn("Error during undeploy: " + unit.getName(), t);
+         // TODO log.warn("Error during prepare undeployment: " + unit.getName(), t);
+         log.warn("Error during undeployment: " + unit.getName(), t);
       }
    }
+
+   public void handoff(DeploymentUnit from, DeploymentUnit to) throws DeploymentException
+   {
+      if (from == null)
+         throw new IllegalArgumentException("Null from deployment");
+      if (to == null)
+         throw new IllegalArgumentException("Null to deployment");
+
+      try
+      {
+         log.debug("Handing off from=" + from.getName() + " to=" + to.getName());
+         deployer.handoff(from, to);
+         log.debug("Handed off from=" + from.getName() + " to=" + to.getName());
+      }
+      catch (Throwable t)
+      {
+         log.warn("Error during handoff from=" + from.getName() + " to=" + to.getName(), t);
+         throw DeploymentException.rethrowAsDeploymentException("Error during handoff from=" + from.getName() + " to=" + to.getName(), t);
+      }
+   }
+
+   public void commitDeploy(DeploymentUnit unit) throws DeploymentException
+   {
+      if (unit == null)
+         throw new IllegalArgumentException("Null unit");
+
+      try
+      {
+         // TODO log.debug("Commiting deployment: " + unit.getName());
+         log.debug("Deploying: " + unit.getName());
+         deployer.commitDeploy(unit);
+         // TODO log.debug("Commited deployment:  " + unit.getName());
+         log.debug("Deployed:  " + unit.getName());
+      }
+      catch (Throwable t)
+      {
+         // TODO log.error("Error during commit deploy: " + unit.getName(), t);
+         log.error("Error during deployment: " + unit.getName(), t);
+         // TODO throw DeploymentException.rethrowAsDeploymentException("Error during commit deployment: " + unit.getName(), t);
+         throw DeploymentException.rethrowAsDeploymentException("Error during deployment: " + unit.getName(), t);
+      }
+   }
+
+   public void commitUndeploy(DeploymentUnit unit)
+   {
+      if (unit == null)
+         throw new IllegalArgumentException("Null unit");
+
+      try
+      {
+         log.debug("Commiting undeployment: " + unit.getName());
+         deployer.commitUndeploy(unit);
+         log.debug("Commited undeployment:  " + unit.getName());
+      }
+      catch (Throwable t)
+      {
+         log.warn("Error during commit undeployment: " + unit.getName(), t);
+      }
+   }
    
    public int getRelativeOrder()
    {

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -43,9 +43,9 @@
 import org.jboss.deployers.plugins.deployer.DeployerWrapper;
 import org.jboss.deployers.plugins.structure.vfs.StructureDeployerWrapper;
 import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployement.MainDeployer;
 import org.jboss.deployers.spi.deployer.Deployer;
 import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.deployers.spi.deployment.MainDeployer;
 import org.jboss.deployers.spi.structure.DeploymentContext;
 import org.jboss.deployers.spi.structure.vfs.StructureDeployer;
 import org.jboss.logging.Logger;
@@ -53,6 +53,7 @@
 /**
  * MainDeployerImpl.
  * 
+ * TODO full deployer protocol
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @version $Revision: 1.1 $
  */
@@ -146,6 +147,40 @@
    }
    
    /**
+    * Get the deployers
+    * 
+    * @return the deployers
+    */
+   public synchronized Set<Deployer> getDeployers()
+   {
+      return new HashSet<Deployer>(deployers);
+   }
+   
+   /**
+    * Set the deployers
+    * 
+    * @param deployers the deployers
+    * @throws IllegalArgumentException for null deployers
+    */
+   public synchronized void setDeployers(Set<Deployer> deployers)
+   {
+      if (deployers == null)
+         throw new IllegalArgumentException("Null deployers");
+      
+      // Remove all the old deployers that are not in the new set
+      HashSet<Deployer> oldDeployers = new HashSet<Deployer>(this.deployers);
+      oldDeployers.removeAll(deployers);
+      for (Deployer deployer : oldDeployers)
+         removeDeployer(deployer);
+      
+      // Add all the new deployers that were not already present
+      HashSet<Deployer> newDeployers = new HashSet<Deployer>(deployers);
+      newDeployers.removeAll(this.deployers);
+      for (Deployer deployer : newDeployers)
+         addDeployer(deployer);
+   }
+   
+   /**
     * Add a deployer
     * 
     * @param deployer the deployer
@@ -280,7 +315,7 @@
             for (DeploymentContext context : undeployContexts)
             {
                DeploymentUnit unit = context.getDeploymentUnit();
-               deployer.undeploy(unit);
+               deployer.prepareUndeploy(unit);
             }
          }
          for (DeploymentContext context : undeployContexts)
@@ -299,7 +334,7 @@
                DeploymentUnit unit = context.getDeploymentUnit();
                try
                {
-                  deployer.deploy(unit);
+                  deployer.commitDeploy(unit);
                }
                catch (DeploymentException e)
                {
@@ -310,7 +345,7 @@
                   for (int j = i-1; j >= 0; --j)
                   {
                      Deployer other = theDeployers[j];
-                     other.undeploy(unit);
+                     other.prepareUndeploy(unit);
                   }
                }
             }

Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/file/FileStructure.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/file/FileStructure.java	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/file/FileStructure.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -0,0 +1,137 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.deployers.plugins.structure.vfs.file;
+
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
+
+import org.jboss.deployers.plugins.structure.vfs.AbstractStructureDeployer;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * WARStructure.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class FileStructure extends AbstractStructureDeployer
+{
+   /** The file suffixes */
+   private static Set<String> fileSuffixes = new CopyOnWriteArraySet<String>();
+
+   // Initialise known suffixes
+   static
+   {
+      fileSuffixes.add("-service.xml");
+      fileSuffixes.add("-beans.xml");
+      fileSuffixes.add("-ds.xml");
+   }
+
+   /**
+    * Add a file suffix
+    * 
+    * @param suffix the suffix
+    * @return true when added
+    * @throws IllegalArgumentException for a null suffix
+    */
+   public static boolean addFileSuffix(String suffix)
+   {
+      if (suffix == null)
+         throw new IllegalArgumentException("Null suffix");
+      return fileSuffixes.add(suffix);
+   }
+
+   /**
+    * Remove a file suffix
+    * 
+    * @param suffix the suffix
+    * @return true when removed
+    * @throws IllegalArgumentException for a null suffix
+    */
+   public static boolean removeFileSuffix(String suffix)
+   {
+      if (suffix == null)
+         throw new IllegalArgumentException("Null suffix");
+      return fileSuffixes.remove(suffix);
+   }
+   
+   /**
+    * Whether this is an archive
+    *
+    * @param name the name
+    * @return true when an archive
+    * @throws IllegalArgumentException for a null name
+    */
+   public static boolean isKnownFile(String name)
+   {
+      if (name == null)
+         throw new IllegalArgumentException("Null name");
+      
+      int index = name.lastIndexOf('-');
+      if (index == -1)
+         return false;
+      String suffix = name.substring(index);
+      return fileSuffixes.contains(suffix);
+   }
+
+   public boolean determineStructure(DeploymentContext context)
+   {
+      try
+      {
+         VirtualFile root = context.getRoot();
+         if (root.isFile())
+         {
+            // It must be top level
+            if (context.isTopLevel() == false)
+            {
+               if (isKnownFile(root.getName()) == false)
+               {
+                  log.trace("... no - it is not a top level file and not a known name");
+                  return false;
+               }
+               else
+               {
+                  log.trace("... ok - not a top level file but it is a known name");
+               }
+            }
+            else
+            {
+               log.trace("... ok - it is a top level file");
+            }
+
+            // There are no subdeployments for files
+            return true;
+         }
+         else
+         {
+            log.trace("... no - not a file.");
+            return false;
+         }
+      }
+      catch (Exception e)
+      {
+         log.warn("Error determining structure: " + context.getName(), e);
+         return false;
+      }
+   }
+}

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARStructure.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARStructure.java	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARStructure.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -38,6 +38,12 @@
  */
 public class JARStructure extends AbstractStructureDeployer
 {
+   @Override
+   public int getRelativeOrder()
+   {
+      return 10000;
+   }
+
    public boolean determineStructure(DeploymentContext context)
    {
       try

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/Deployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/Deployer.java	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/Deployer.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -44,21 +44,45 @@
    boolean isRelevant(DeploymentUnit unit);
    
    /**
-    * Deploy a deployment
+    * Prepare a deployment
     * 
     * @param unit the unit
     * @throws DeploymentException for any error
     */
-   void deploy(DeploymentUnit unit) throws DeploymentException;
+   void prepareDeploy(DeploymentUnit unit) throws DeploymentException;
 
    /**
-    * Undeploy a deployment
+    * Prepare an undeployment
     * 
     * @param unit the unit
     */
-   void undeploy(DeploymentUnit unit);
+   void prepareUndeploy(DeploymentUnit unit);
+   
+   /**
+    * Handoff a deployment
+    * 
+    * @param from the from deployment
+    * @param to the to deployment
+    * @throws DeploymentException for any error
+    */
+   void handoff(DeploymentUnit from, DeploymentUnit to) throws DeploymentException;
+   
+   /**
+    * Commit a deployment
+    * 
+    * @param unit the unit
+    * @throws DeploymentException for any error
+    */
+   void commitDeploy(DeploymentUnit unit) throws DeploymentException;
 
    /**
+    * Prepare an undeployment
+    * 
+    * @param unit the unit
+    */
+   void commitUndeploy(DeploymentUnit unit);
+
+   /**
     * Get the relative order
     * 
     * @return the relative order

Copied: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployment (from rev 56643, projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployement)

Deleted: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployment/MainDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployement/MainDeployer.java	2006-09-08 10:15:45 UTC (rev 56643)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployment/MainDeployer.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -1,73 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployers.spi.deployement;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.structure.DeploymentContext;
-
-/**
- * MainDeployer.<p>
- * 
- * The basic contract is to add and remove deployment
- * contexts then use process method to actually
- * bring the deployments to required state. 
- * 
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public interface MainDeployer
-{
-   /**
-    * Get a deployment context
-    * 
-    * @param name the name
-    * @return the context or null if not found
-    */
-   DeploymentContext getDeploymentContext(String name);
-   
-   /**
-    * Add a deployment context
-    * 
-    * @param context the deployment context
-    * @throws DeploymentException for any error
-    */
-   void addDeploymentContext(DeploymentContext context) throws DeploymentException;
-
-   /**
-    * Remove a deployment context
-    * 
-    * @param name the name of the context
-    * @return false when the context was previously unknown
-    * @throws DeploymentException for any error
-    */
-   boolean removeDeploymentContext(String name) throws DeploymentException;
-
-   /**
-    * Process the outstanding deployments
-    */
-   void process();
-   
-   /**
-    * Shutdown. Removes all the deployments.
-    */
-   void shutdown();
-}

Copied: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployment/MainDeployer.java (from rev 56721, projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployement/MainDeployer.java)
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployement/MainDeployer.java	2006-09-11 11:28:12 UTC (rev 56721)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployment/MainDeployer.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -0,0 +1,73 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.deployers.spi.deployment;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+
+/**
+ * MainDeployer.<p>
+ * 
+ * The basic contract is to add and remove deployment
+ * contexts then use process method to actually
+ * bring the deployments to required state. 
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface MainDeployer
+{
+   /**
+    * Get a deployment context
+    * 
+    * @param name the name
+    * @return the context or null if not found
+    */
+   DeploymentContext getDeploymentContext(String name);
+   
+   /**
+    * Add a deployment context
+    * 
+    * @param context the deployment context
+    * @throws DeploymentException for any error
+    */
+   void addDeploymentContext(DeploymentContext context) throws DeploymentException;
+
+   /**
+    * Remove a deployment context
+    * 
+    * @param name the name of the context
+    * @return false when the context was previously unknown
+    * @throws DeploymentException for any error
+    */
+   boolean removeDeploymentContext(String name) throws DeploymentException;
+
+   /**
+    * Process the outstanding deployments
+    */
+   void process();
+   
+   /**
+    * Shutdown. Removes all the deployments.
+    */
+   void shutdown();
+}

Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/file/directory/empty
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/file/directory/empty	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/file/directory/empty	2006-09-11 11:52:22 UTC (rev 56723)
@@ -0,0 +1 @@
+empty
\ No newline at end of file

Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/file/notknown/test-unknown.xml
===================================================================

Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/file/notknown/unknown.xml
===================================================================

Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/file/simple/simple-service.xml
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/file/simple/simple-service.xml	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/file/simple/simple-service.xml	2006-09-11 11:52:22 UTC (rev 56723)
@@ -0,0 +1 @@
+empty
\ No newline at end of file

Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/BaseDeployersTest.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/BaseDeployersTest.java	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/BaseDeployersTest.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -28,6 +28,7 @@
 
 import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
 import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.deployers.spi.structure.StructureDetermined;
 import org.jboss.deployers.spi.structure.vfs.StructureDeployer;
 import org.jboss.test.BaseTestCase;
 import org.jboss.util.NotImplementedException;
@@ -240,4 +241,17 @@
       VirtualFile file = getVirtualFile(root, path);
       return new AbstractDeploymentContext(file);
    }
+   
+   /**
+    * Create a simple predetermined deployment context
+    * 
+    * @param name the context name
+    * @return the context
+    */
+   protected DeploymentContext createSimpleDeployment(String name)
+   {
+      AbstractDeploymentContext context = new AbstractDeploymentContext(name);
+      context.setStructureDetermined(StructureDetermined.PREDETERMINED);
+      return context;
+   }
 }

Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/DeployersAllTestSuite.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/DeployersAllTestSuite.java	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/DeployersAllTestSuite.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -21,6 +21,7 @@
 */
 package org.jboss.test.deployers;
 
+import org.jboss.test.deployers.deployer.DeployerTestSuite;
 import org.jboss.test.deployers.structure.StructureTestSuite;
 
 import junit.framework.Test;
@@ -45,6 +46,7 @@
       TestSuite suite = new TestSuite("Deployers All Tests");
 
       suite.addTest(StructureTestSuite.suite());
+      suite.addTest(DeployerTestSuite.suite());
 
       return suite;
    }

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/DeployerTestSuite.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/DeployerTestSuite.java	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/DeployerTestSuite.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -0,0 +1,57 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.deployers.deployer;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.jboss.test.deployers.deployer.test.DeployerOrderingUnitTestCase;
+import org.jboss.test.deployers.deployer.test.DeployerProtocolUnitTestCase;
+import org.jboss.test.deployers.deployer.test.DeployerWidthFirstUnitTestCase;
+import org.jboss.test.deployers.deployer.test.MainDeployerDeployerUnitTestCase;
+
+/**
+ * Deployer Test Suite.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37459 $
+ */
+public class DeployerTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("Deployer Tests");
+
+      suite.addTest(DeployerProtocolUnitTestCase.suite());
+      suite.addTest(DeployerOrderingUnitTestCase.suite());
+      suite.addTest(DeployerWidthFirstUnitTestCase.suite());
+      suite.addTest(MainDeployerDeployerUnitTestCase.suite());
+
+      return suite;
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/support/TestSimpleDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/support/TestSimpleDeployer.java	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/support/TestSimpleDeployer.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -0,0 +1,117 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.deployers.deployer.support;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.deployers.plugins.deployer.AbstractSimpleDeployer;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+
+/**
+ * TestDeployerOrdering.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestSimpleDeployer extends AbstractSimpleDeployer
+{
+   private static int order = 0;
+
+   private int relativeOrder;
+   
+   private Map<DeploymentUnit, Integer> deployed = new HashMap<DeploymentUnit, Integer>();
+   private Map<DeploymentUnit, Integer> undeployed = new HashMap<DeploymentUnit, Integer>();
+
+   public static void reset()
+   {
+      order = 0;
+   }
+   
+   public TestSimpleDeployer()
+   {
+      this.relativeOrder = Integer.MAX_VALUE;
+   }
+   
+   public TestSimpleDeployer(int relativeOrder)
+   {
+      this.relativeOrder = relativeOrder;
+   }
+
+   public void clear()
+   {
+      deployed.clear();
+      undeployed.clear();
+   }
+   
+   public int getDeployOrder()
+   {
+      if (deployed.isEmpty())
+         return -1;
+      return Collections.max(deployed.values());
+   }
+
+   public int getUndeployOrder()
+   {
+      if (undeployed.isEmpty())
+         return -1;
+      return Collections.max(undeployed.values());
+   }
+   
+   public Set<DeploymentUnit> getDeployedUnits()
+   {
+      return deployed.keySet();
+   }
+
+   public Set<DeploymentUnit> getUndeployedUnits()
+   {
+      return undeployed.keySet();
+   }
+   
+   public Map<DeploymentUnit, Integer> getDeployed()
+   {
+      return deployed;
+   }
+
+   public Map<DeploymentUnit, Integer> getUndeployed()
+   {
+      return undeployed;
+   }
+   
+   public int getRelativeOrder()
+   {
+      return relativeOrder;
+   }
+
+   public void deploy(DeploymentUnit unit) throws DeploymentException
+   {
+      deployed.put(unit, ++order);
+   }
+
+   public void undeploy(DeploymentUnit unit)
+   {
+      undeployed.put(unit, ++order);
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/test/DeployerOrderingUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/test/DeployerOrderingUnitTestCase.java	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/test/DeployerOrderingUnitTestCase.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -0,0 +1,124 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.deployers.deployer.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.deployment.MainDeployerImpl;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.test.deployers.BaseDeployersTest;
+import org.jboss.test.deployers.deployer.support.TestSimpleDeployer;
+
+/**
+ * DeployerOrderingUnitTestCase.
+ * 
+ * TODO implement the full deployment protocol
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class DeployerOrderingUnitTestCase extends BaseDeployersTest
+{
+   public static Test suite()
+   {
+      return new TestSuite(DeployerOrderingUnitTestCase.class);
+   }
+   
+   public DeployerOrderingUnitTestCase(String name)
+   {
+      super(name);
+   }
+   
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      TestSimpleDeployer.reset();
+   }
+
+   public void testCorrectOrder() throws Exception
+   {
+      MainDeployerImpl main = new MainDeployerImpl();
+      TestSimpleDeployer deployer1 = new TestSimpleDeployer(1);
+      main.addDeployer(deployer1);
+      TestSimpleDeployer deployer2 = new TestSimpleDeployer(2);
+      main.addDeployer(deployer2);
+      
+      DeploymentContext context = createSimpleDeployment("correctOrder");
+      main.addDeploymentContext(context);
+      main.process();
+      
+      assertEquals(1, deployer1.getDeployOrder());
+      assertEquals(2, deployer2.getDeployOrder());
+      assertEquals(-1, deployer1.getUndeployOrder());
+      assertEquals(-1, deployer2.getUndeployOrder());
+
+      main.removeDeploymentContext(context.getName());
+      main.process();
+      
+      assertEquals(1, deployer1.getDeployOrder());
+      assertEquals(2, deployer2.getDeployOrder());
+      assertEquals(4, deployer1.getUndeployOrder());
+      assertEquals(3, deployer2.getUndeployOrder());
+
+      main.addDeploymentContext(context);
+      main.process();
+      
+      assertEquals(5, deployer1.getDeployOrder());
+      assertEquals(6, deployer2.getDeployOrder());
+      assertEquals(4, deployer1.getUndeployOrder());
+      assertEquals(3, deployer2.getUndeployOrder());
+   }
+   
+   public void testWrongOrder() throws Exception
+   {
+      MainDeployerImpl main = new MainDeployerImpl();
+      TestSimpleDeployer deployer2 = new TestSimpleDeployer(2);
+      main.addDeployer(deployer2);
+      TestSimpleDeployer deployer1 = new TestSimpleDeployer(1);
+      main.addDeployer(deployer1);
+      
+      DeploymentContext context = createSimpleDeployment("wrongOrder");
+      main.addDeploymentContext(context);
+      main.process();
+      
+      assertEquals(1, deployer1.getDeployOrder());
+      assertEquals(2, deployer2.getDeployOrder());
+      assertEquals(-1, deployer1.getUndeployOrder());
+      assertEquals(-1, deployer2.getUndeployOrder());
+
+      main.removeDeploymentContext(context.getName());
+      main.process();
+      
+      assertEquals(1, deployer1.getDeployOrder());
+      assertEquals(2, deployer2.getDeployOrder());
+      assertEquals(4, deployer1.getUndeployOrder());
+      assertEquals(3, deployer2.getUndeployOrder());
+
+      main.addDeploymentContext(context);
+      main.process();
+      
+      assertEquals(5, deployer1.getDeployOrder());
+      assertEquals(6, deployer2.getDeployOrder());
+      assertEquals(4, deployer1.getUndeployOrder());
+      assertEquals(3, deployer2.getUndeployOrder());
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/test/DeployerProtocolUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/test/DeployerProtocolUnitTestCase.java	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/test/DeployerProtocolUnitTestCase.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -0,0 +1,122 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.deployers.deployer.test;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.deployment.MainDeployerImpl;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.deployers.spi.deployment.MainDeployer;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.test.deployers.BaseDeployersTest;
+import org.jboss.test.deployers.deployer.support.TestSimpleDeployer;
+
+/**
+ * DeployerProtocolUnitTestCase.
+ * 
+ * TODO implement the full deployment protocol
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class DeployerProtocolUnitTestCase extends BaseDeployersTest
+{
+   private MainDeployer mainDeployer;
+   
+   private TestSimpleDeployer deployer = new TestSimpleDeployer();
+   
+   public static Test suite()
+   {
+      return new TestSuite(DeployerProtocolUnitTestCase.class);
+   }
+   
+   public DeployerProtocolUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testDeploy() throws Exception
+   {
+      MainDeployer main = getMainDeployer();
+      
+      DeploymentContext context = createSimpleDeployment("deploy");
+      main.addDeploymentContext(context);
+      main.process();
+      Set<DeploymentUnit> expected = new HashSet<DeploymentUnit>();
+      expected.add(context.getDeploymentUnit());
+      assertEquals(expected, deployer.getDeployedUnits());
+   }
+
+   public void testUndeploy() throws Exception
+   {
+      MainDeployer main = getMainDeployer();
+
+      DeploymentContext context = createSimpleDeployment("undeploy");
+      main.addDeploymentContext(context);
+      main.process();
+      Set<DeploymentUnit> expected = new HashSet<DeploymentUnit>();
+      expected.add(context.getDeploymentUnit());
+      assertEquals(expected, deployer.getDeployedUnits());
+      
+      main.removeDeploymentContext(context.getName());
+      main.process();
+      assertEquals(expected, deployer.getUndeployedUnits());
+   }
+
+   public void testRedeploy() throws Exception
+   {
+      MainDeployer main = getMainDeployer();
+
+      DeploymentContext context = createSimpleDeployment("redeploy");
+      main.addDeploymentContext(context);
+      main.process();
+      Set<DeploymentUnit> expected = new HashSet<DeploymentUnit>();
+      expected.add(context.getDeploymentUnit());
+      assertEquals(expected, deployer.getDeployedUnits());
+      
+      main.removeDeploymentContext(context.getName());
+      main.process();
+      assertEquals(expected, deployer.getUndeployedUnits());
+      
+      deployer.clear();
+      main.addDeploymentContext(context);
+      main.process();
+      expected.clear();
+      expected.add(context.getDeploymentUnit());
+      assertEquals(expected, deployer.getDeployedUnits());
+   }
+   
+   protected MainDeployer getMainDeployer()
+   {
+      if (mainDeployer != null)
+         return mainDeployer;
+      
+      MainDeployerImpl result = new MainDeployerImpl();
+      result.addDeployer(deployer);
+      
+      mainDeployer = result;
+      return result;
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/test/DeployerWidthFirstUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/test/DeployerWidthFirstUnitTestCase.java	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/test/DeployerWidthFirstUnitTestCase.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -0,0 +1,128 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.deployers.deployer.test;
+
+import java.util.Map;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.deployment.MainDeployerImpl;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.deployers.spi.deployment.MainDeployer;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.test.deployers.BaseDeployersTest;
+import org.jboss.test.deployers.deployer.support.TestSimpleDeployer;
+
+/**
+ * DeployerProtocolUnitTestCase.
+ * 
+ * TODO implement the full deployment protocol
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class DeployerWidthFirstUnitTestCase extends BaseDeployersTest
+{
+   private MainDeployer mainDeployer;
+   
+   private TestSimpleDeployer deployer1 = new TestSimpleDeployer(1);
+   private TestSimpleDeployer deployer2 = new TestSimpleDeployer(2);
+   
+   public static Test suite()
+   {
+      return new TestSuite(DeployerWidthFirstUnitTestCase.class);
+   }
+   
+   public DeployerWidthFirstUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testDeployWidthFirst() throws Exception
+   {
+      MainDeployer main = getMainDeployer();
+      
+      DeploymentContext context1 = createSimpleDeployment("deploy1");
+      main.addDeploymentContext(context1);
+      DeploymentContext context2 = createSimpleDeployment("deploy2");
+      main.addDeploymentContext(context2);
+      main.process();
+      
+      Map<DeploymentUnit, Integer> deployed1 = deployer1.getDeployed();
+      Map<DeploymentUnit, Integer> deployed2 = deployer2.getDeployed();
+      
+      int c1d1 = deployed1.get(context1.getDeploymentUnit());
+      int c1d2 = deployed2.get(context1.getDeploymentUnit());
+      int c2d1 = deployed1.get(context2.getDeploymentUnit());
+      int c2d2 = deployed2.get(context2.getDeploymentUnit());
+
+      assertFalse(c1d1 == -1);
+      assertFalse(c1d2 == -1);
+      assertFalse(c2d1 == -1);
+      assertFalse(c2d2 == -1);
+      
+      assertTrue("Deployer1 should be before Deployer2", c1d1 < c1d2 && c1d1 < c2d2 && c2d1 < c1d2 && c2d1 < c2d2);
+   }
+
+   public void testUndeployWidthFirst() throws Exception
+   {
+      MainDeployer main = getMainDeployer();
+      
+      DeploymentContext context1 = createSimpleDeployment("deploy1");
+      main.addDeploymentContext(context1);
+      DeploymentContext context2 = createSimpleDeployment("deploy2");
+      main.addDeploymentContext(context2);
+      main.process();
+      
+      main.removeDeploymentContext(context1.getName());
+      main.removeDeploymentContext(context2.getName());
+      main.process();
+      
+      Map<DeploymentUnit, Integer> undeployed1 = deployer1.getUndeployed();
+      Map<DeploymentUnit, Integer> undeployed2 = deployer2.getUndeployed();
+      
+      int c1d1 = undeployed1.get(context1.getDeploymentUnit());
+      int c1d2 = undeployed2.get(context1.getDeploymentUnit());
+      int c2d1 = undeployed1.get(context2.getDeploymentUnit());
+      int c2d2 = undeployed2.get(context2.getDeploymentUnit());
+      
+      assertFalse(c1d1 == -1);
+      assertFalse(c1d2 == -1);
+      assertFalse(c2d1 == -1);
+      assertFalse(c2d2 == -1);
+      
+      assertTrue("Deployer2 should be before Deployer1", c1d2 < c1d1 && c1d2 < c2d1 && c2d2 < c1d1 && c2d2 < c2d1);
+   }
+   
+   protected MainDeployer getMainDeployer()
+   {
+      if (mainDeployer != null)
+         return mainDeployer;
+      
+      MainDeployerImpl result = new MainDeployerImpl();
+      result.addDeployer(deployer1);
+      result.addDeployer(deployer2);
+      
+      mainDeployer = result;
+      return result;
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/test/MainDeployerDeployerUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/test/MainDeployerDeployerUnitTestCase.java	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/test/MainDeployerDeployerUnitTestCase.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -0,0 +1,221 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.deployers.deployer.test;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.deployment.MainDeployerImpl;
+import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
+import org.jboss.deployers.plugins.structure.vfs.jar.JARStructure;
+import org.jboss.deployers.spi.deployer.Deployer;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.deployers.spi.structure.StructureDetermined;
+import org.jboss.test.deployers.BaseDeployersTest;
+import org.jboss.test.deployers.deployer.support.TestSimpleDeployer;
+
+/**
+ * MainDeployerDeployerUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class MainDeployerDeployerUnitTestCase extends BaseDeployersTest
+{
+   public static Test suite()
+   {
+      return new TestSuite(MainDeployerDeployerUnitTestCase.class);
+   }
+   
+   public MainDeployerDeployerUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      enableTrace("org.jboss.deployers");
+   }
+   
+   public void testAddNullDeployer() throws Exception
+   {
+      MainDeployerImpl main = new MainDeployerImpl();
+      try
+      {
+         main.addDeployer(null);
+         fail("Should not be here!");
+      }
+      catch (AssertionFailedError e)
+      {
+         throw e;
+      }
+      catch (Throwable t)
+      {
+         checkThrowable(IllegalArgumentException.class, t);
+      }
+   }
+   
+   public void testAddDeployers() throws Exception
+   {
+      MainDeployerImpl main = new MainDeployerImpl();
+      assertEmpty(main.getDeployers());
+      
+      Deployer deployer = new TestSimpleDeployer();
+      HashSet<Deployer> expected = new HashSet<Deployer>();
+      expected.add(deployer);
+
+      main.addDeployer(deployer);
+      assertEquals(expected, main.getDeployers());
+      
+      deployer = new TestSimpleDeployer();
+      expected.add(deployer);
+
+      main.addDeployer(deployer);
+      assertEquals(expected, main.getDeployers());
+
+      // Duplicate
+      main.addDeployer(deployer);
+      assertEquals(expected, main.getDeployers());
+   }
+   
+   public void testRemoveNullDeployer() throws Exception
+   {
+      MainDeployerImpl main = new MainDeployerImpl();
+      try
+      {
+         main.removeDeployer(null);
+         fail("Should not be here!");
+      }
+      catch (AssertionFailedError e)
+      {
+         throw e;
+      }
+      catch (Throwable t)
+      {
+         checkThrowable(IllegalArgumentException.class, t);
+      }
+   }
+   
+   public void testRemoveDeployers() throws Exception
+   {
+      MainDeployerImpl main = new MainDeployerImpl();
+      assertEmpty(main.getDeployers());
+      
+      Deployer deployer1 = new TestSimpleDeployer();
+      Deployer deployer2 = new TestSimpleDeployer();
+      HashSet<Deployer> expected = new HashSet<Deployer>();
+      expected.add(deployer1);
+      expected.add(deployer2);
+      main.addDeployer(deployer1);
+      main.addDeployer(deployer2);
+      assertEquals(expected, main.getDeployers());
+      
+      Deployer notPresent = new TestSimpleDeployer();
+      main.removeDeployer(notPresent);
+      assertEquals(expected, main.getDeployers());
+
+      main.removeDeployer(deployer1);
+      expected.remove(deployer1);
+      assertEquals(expected, main.getDeployers());
+
+      main.removeDeployer(deployer2);
+      expected.remove(deployer2);
+      assertEquals(expected, main.getDeployers());
+   }
+   
+   public void testSetNullDeployers() throws Exception
+   {
+      MainDeployerImpl main = new MainDeployerImpl();
+      try
+      {
+         main.setDeployers(null);
+         fail("Should not be here!");
+      }
+      catch (AssertionFailedError e)
+      {
+         throw e;
+      }
+      catch (Throwable t)
+      {
+         checkThrowable(IllegalArgumentException.class, t);
+      }
+   }
+   
+   public void testSetDeployers() throws Exception
+   {
+      MainDeployerImpl main = new MainDeployerImpl();
+      assertEmpty(main.getDeployers());
+      
+      Deployer deployer1 = new TestSimpleDeployer();
+      Deployer deployer2 = new TestSimpleDeployer();
+      Set<Deployer> expected = new HashSet<Deployer>();
+      expected.add(deployer1);
+      expected.add(deployer2);
+      main.setDeployers(expected);
+      assertEquals(expected, main.getDeployers());
+      
+      expected = new HashSet<Deployer>();
+      expected.add(deployer1);
+      main.setDeployers(expected);
+      assertEquals(expected, main.getDeployers());
+      
+      expected = new HashSet<Deployer>();
+      expected.add(deployer1);
+      main.setDeployers(expected);
+      assertEquals(expected, main.getDeployers());
+      
+      expected = Collections.emptySet();
+      main.setDeployers(expected);
+      assertEquals(expected, main.getDeployers());
+   }
+   
+   public void testNoDeployers() throws Exception
+   {
+      MainDeployerImpl main = new MainDeployerImpl();
+      main.addStructureDeployer(new JARStructure());
+
+      DeploymentContext context = new AbstractDeploymentContext("predetermined");
+      context.setStructureDetermined(StructureDetermined.PREDETERMINED);
+      main.addDeploymentContext(context);
+      
+      try
+      {
+         main.process();
+         fail("Should not be here!");
+      }
+      catch (AssertionFailedError e)
+      {
+         throw e;
+      }
+      catch (Throwable t)
+      {
+         checkThrowable(IllegalStateException.class, t);
+      }
+   }
+}

Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/StructureTestSuite.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/StructureTestSuite.java	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/StructureTestSuite.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -25,8 +25,11 @@
 import junit.framework.TestSuite;
 import junit.textui.TestRunner;
 
+import org.jboss.test.deployers.structure.file.test.FileStructureUnitTestCase;
 import org.jboss.test.deployers.structure.jar.test.JARStructureUnitTestCase;
+import org.jboss.test.deployers.structure.main.test.MainDeployerFileStructureUnitTestCase;
 import org.jboss.test.deployers.structure.main.test.MainDeployerJarStructureUnitTestCase;
+import org.jboss.test.deployers.structure.main.test.MainDeployerStructureOrderingUnitTestCase;
 import org.jboss.test.deployers.structure.main.test.MainDeployerStructureUnitTestCase;
 import org.jboss.test.deployers.structure.main.test.MainDeployerWarStructureUnitTestCase;
 import org.jboss.test.deployers.structure.war.test.WARStructureUnitTestCase;
@@ -48,9 +51,12 @@
    {
       TestSuite suite = new TestSuite("Structure Tests");
 
+      suite.addTest(FileStructureUnitTestCase.suite());
       suite.addTest(JARStructureUnitTestCase.suite());
       suite.addTest(WARStructureUnitTestCase.suite());
       suite.addTest(MainDeployerStructureUnitTestCase.suite());
+      suite.addTest(MainDeployerStructureOrderingUnitTestCase.suite());
+      suite.addTest(MainDeployerFileStructureUnitTestCase.suite());
       suite.addTest(MainDeployerJarStructureUnitTestCase.suite());
       suite.addTest(MainDeployerWarStructureUnitTestCase.suite());
 

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/file/test/FileStructureUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/file/test/FileStructureUnitTestCase.java	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/file/test/FileStructureUnitTestCase.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -0,0 +1,105 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.deployers.structure.file.test;
+
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.structure.vfs.file.FileStructure;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.deployers.spi.structure.vfs.StructureDeployer;
+import org.jboss.test.deployers.BaseDeployersTest;
+
+/**
+ * FileStructureUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class FileStructureUnitTestCase extends BaseDeployersTest
+{
+   /** The file structure deployer */
+   private static final FileStructure structure = new FileStructure();
+   
+   public static Test suite()
+   {
+      return new TestSuite(FileStructureUnitTestCase.class);
+   }
+   
+   public FileStructureUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      enableTrace("org.jboss.deployers");
+   }
+
+   @Override
+   protected StructureDeployer getStrucutureDeployer()
+   {
+      return structure;
+   }
+
+   protected DeploymentContext assertValidContext(String root, String path) throws Exception
+   {
+      DeploymentContext context = createDeploymentContext(root, path);
+      assertTrue("Structure should be valid: " + context.getName(), determineStructure(context));
+      assertEmpty(context.getChildren());
+      return context;
+   }
+   
+   protected DeploymentContext assertNotValidContext(String root, String path, boolean isDirectory) throws Exception
+   {
+      DeploymentContext context = createDeploymentContext(root, path);
+      assertFalse("Structure should not be valid: " + context.getName(), determineStructure(context));
+      assertEmpty(context.getChildren());
+      return context;
+   }
+   
+   public void testSimple() throws Exception
+   {
+      assertValidContext("/structure/", "file/simple/simple-service.xml");
+   }
+   
+   public void testNotKnownButTopLevel() throws Exception
+   {
+      assertValidContext("/structure/", "file/notknown/test-unknown.xml");
+      assertValidContext("/structure/", "file/notknown/unknown.xml");
+   }
+   
+   public void testDirectory() throws Exception
+   {
+      assertNotValidContext("/structure/", "file/directory", true);
+   }
+   
+   protected void assertContexts(Map<String, Boolean> expected, Set<DeploymentContext> actual) throws Exception
+   {
+      assertCandidateContexts(expected, actual);
+   }
+}

Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/jar/test/JARStructureUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/jar/test/JARStructureUnitTestCase.java	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/jar/test/JARStructureUnitTestCase.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -79,7 +79,7 @@
       return getValidContext(root, path);
    }
    
-   protected DeploymentContext assertNotValidContext(String root, String path) throws Exception
+   protected DeploymentContext assertNotValidContext(String root, String path, boolean other) throws Exception
    {
       DeploymentContext context = createDeploymentContext(root, path);
       assertFalse("Structure should not be valid: " + context.getName(), determineStructure(context));
@@ -102,8 +102,8 @@
    
    public void testRootNotAnArchive() throws Exception
    {
-      assertNotValidContext("/structure/", "jar/notanarchive/NotAnArchive.jar");
-      assertNotValidContext("/structure/", "jar/notanarchive/NotAnArchive.zip");
+      assertNotValidContext("/structure/", "jar/notanarchive/NotAnArchive.jar", true);
+      assertNotValidContext("/structure/", "jar/notanarchive/NotAnArchive.zip", true);
    }
    
    public void testSubdeploymentNotAnArchive() throws Exception
@@ -179,6 +179,31 @@
       assertCandidatesValid(context);
    }
    
+   public void testSubdeploymentIsKnownFile() throws Exception
+   {
+      DeploymentContext context = getValidContext("/structure/file", "simple");
+      
+      // Test it got all the candidates
+      Map<String, Boolean> expected = new HashMap<String, Boolean>();
+      expected.put(getURL("/structure/file/simple/simple-service.xml"), true);
+      assertContexts(expected, context.getChildren());
+
+      assertCandidatesNotValid(context);
+   }
+   
+   public void testSubdeploymentIsUnknownFile() throws Exception
+   {
+      DeploymentContext context = getValidContext("/structure/file", "notknown");
+      
+      // Test it got all the candidates
+      Map<String, Boolean> expected = new HashMap<String, Boolean>();
+      expected.put(getURL("/structure/file/notknown/test-unknown.xml"), false);
+      expected.put(getURL("/structure/file/notknown/unknown.xml"), false);
+      assertContexts(expected, context.getChildren());
+
+      assertCandidatesNotValid(context);
+   }
+   
    protected void assertContexts(Map<String, Boolean> expected, Set<DeploymentContext> actual) throws Exception
    {
       assertCandidateContexts(expected, actual);

Copied: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/support/TestStructureDeployer.java (from rev 56647, projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/TestStructureDeployer.java)
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/TestStructureDeployer.java	2006-09-08 14:11:44 UTC (rev 56647)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/support/TestStructureDeployer.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -0,0 +1,58 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.deployers.structure.main.support;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.deployers.plugins.structure.vfs.AbstractStructureDeployer;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+
+/**
+ * TestStructureDeployer.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestStructureDeployer extends AbstractStructureDeployer
+{
+   /** The contexts with which we have been invoked */
+   private Set<DeploymentContext> invoked = new HashSet<DeploymentContext>();
+
+   /**
+    * Get the contexts with which we were invoked and clear it
+    * 
+    * @return the set of contexts
+    */
+   public Set<DeploymentContext> getInvoked()
+   {
+      HashSet<DeploymentContext> result = new HashSet<DeploymentContext>(invoked);
+      invoked.clear();
+      return result;
+   }
+   
+   public boolean determineStructure(DeploymentContext context)
+   {
+      invoked.add(context);
+      return true;
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/support/TestStructureOrdering.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/support/TestStructureOrdering.java	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/support/TestStructureOrdering.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -0,0 +1,66 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.deployers.structure.main.support;
+
+import org.jboss.deployers.plugins.structure.vfs.AbstractStructureDeployer;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+
+/**
+ * TestStructureOrdering.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestStructureOrdering extends AbstractStructureDeployer
+{
+   private static int order = 0;
+
+   private int relativeOrder;
+   
+   private int structureOrder = -1; 
+
+   public static void reset()
+   {
+      order = 0;
+   }
+   
+   public int getStructureOrder()
+   {
+      return structureOrder;
+   }
+   
+   public TestStructureOrdering(int relativeOrder)
+   {
+      this.relativeOrder = relativeOrder;
+   }
+   
+   public int getRelativeOrder()
+   {
+      return relativeOrder;
+   }
+
+   public boolean determineStructure(DeploymentContext context)
+   {
+      structureOrder = ++order;
+      return false;
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerFileStructureUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerFileStructureUnitTestCase.java	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerFileStructureUnitTestCase.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -0,0 +1,84 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.deployers.structure.main.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.deployment.MainDeployerImpl;
+import org.jboss.deployers.plugins.structure.vfs.file.FileStructure;
+import org.jboss.deployers.plugins.structure.vfs.jar.JARStructure;
+import org.jboss.deployers.plugins.structure.vfs.war.WARStructure;
+import org.jboss.deployers.spi.deployment.MainDeployer;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.deployers.spi.structure.DeploymentState;
+import org.jboss.test.deployers.structure.file.test.FileStructureUnitTestCase;
+
+/**
+ * MainDeployerStructureUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class MainDeployerFileStructureUnitTestCase extends FileStructureUnitTestCase
+{
+   public static Test suite()
+   {
+      return new TestSuite(MainDeployerFileStructureUnitTestCase.class);
+   }
+   
+   public MainDeployerFileStructureUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   protected DeploymentContext assertValidContext(String root, String path) throws Exception
+   {
+      DeploymentContext context = createDeploymentContext(root, path);
+      getMainDeployer().addDeploymentContext(context);
+      assertFalse("Structure should be valid: " + context.getName(), context.getState() == DeploymentState.ERROR);
+      assertEmpty(context.getChildren());
+      return context;
+   }
+
+   protected DeploymentContext assertNotValidContext(String root, String path, boolean other) throws Exception
+   {
+      // It might not be a valid file, but it could be another deployment
+      if (other)
+         return assertValidContext(root, path);
+
+      DeploymentContext context = createDeploymentContext(root, path);
+      getMainDeployer().addDeploymentContext(context);
+      assertTrue("Structure should not be valid: " + context.getName(), context.getState() == DeploymentState.ERROR);
+      assertEmpty(context.getChildren());
+      return context;
+   }
+
+   protected static MainDeployer getMainDeployer()
+   {
+      MainDeployerImpl main = new MainDeployerImpl();
+      main.addStructureDeployer(new FileStructure());
+      main.addStructureDeployer(new JARStructure());
+      main.addStructureDeployer(new WARStructure());
+      return main;
+   }
+}

Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerJarStructureUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerJarStructureUnitTestCase.java	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerJarStructureUnitTestCase.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -28,9 +28,10 @@
 import junit.framework.TestSuite;
 
 import org.jboss.deployers.plugins.deployment.MainDeployerImpl;
+import org.jboss.deployers.plugins.structure.vfs.file.FileStructure;
 import org.jboss.deployers.plugins.structure.vfs.jar.JARStructure;
 import org.jboss.deployers.plugins.structure.vfs.war.WARStructure;
-import org.jboss.deployers.spi.deployement.MainDeployer;
+import org.jboss.deployers.spi.deployment.MainDeployer;
 import org.jboss.deployers.spi.structure.DeploymentContext;
 import org.jboss.deployers.spi.structure.DeploymentState;
 import org.jboss.test.deployers.structure.jar.test.JARStructureUnitTestCase;
@@ -67,8 +68,11 @@
       return getValidContext(root, path);
    }
    
-   protected DeploymentContext assertNotValidContext(String root, String path) throws Exception
+   protected DeploymentContext assertNotValidContext(String root, String path, boolean other) throws Exception
    {
+      if (other)
+         return assertValidContext(root, path);
+      
       DeploymentContext context = createDeploymentContext(root, path);
       MainDeployer main = getMainDeployer();
       main.addDeploymentContext(context);
@@ -85,6 +89,7 @@
    protected static MainDeployer getMainDeployer()
    {
       MainDeployerImpl main = new MainDeployerImpl();
+      main.addStructureDeployer(new FileStructure());
       main.addStructureDeployer(new JARStructure());
       main.addStructureDeployer(new WARStructure());
       return main;

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerStructureOrderingUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerStructureOrderingUnitTestCase.java	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerStructureOrderingUnitTestCase.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -0,0 +1,85 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.deployers.structure.main.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.deployment.MainDeployerImpl;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.test.deployers.BaseDeployersTest;
+import org.jboss.test.deployers.structure.main.support.TestStructureOrdering;
+
+/**
+ * MainDeployerStructureOrderingUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class MainDeployerStructureOrderingUnitTestCase extends BaseDeployersTest
+{
+   public static Test suite()
+   {
+      return new TestSuite(MainDeployerStructureOrderingUnitTestCase.class);
+   }
+   
+   public MainDeployerStructureOrderingUnitTestCase(String name)
+   {
+      super(name);
+   }
+   
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      TestStructureOrdering.reset();
+   }
+
+   public void testCorrectOrder() throws Exception
+   {
+      MainDeployerImpl main = new MainDeployerImpl();
+      TestStructureOrdering deployer1 = new TestStructureOrdering(1);
+      main.addStructureDeployer(deployer1);
+      TestStructureOrdering deployer2 = new TestStructureOrdering(2);
+      main.addStructureDeployer(deployer2);
+      
+      DeploymentContext context = createDeploymentContext("/structure/", "jar/simple");
+      main.addDeploymentContext(context);
+      
+      assertEquals(1, deployer1.getStructureOrder());
+      assertEquals(2, deployer2.getStructureOrder());
+   }
+   
+   public void testWrongOrder() throws Exception
+   {
+      MainDeployerImpl main = new MainDeployerImpl();
+      TestStructureOrdering deployer2 = new TestStructureOrdering(2);
+      main.addStructureDeployer(deployer2);
+      TestStructureOrdering deployer1 = new TestStructureOrdering(1);
+      main.addStructureDeployer(deployer1);
+      
+      DeploymentContext context = createDeploymentContext("/structure/", "jar/simple");
+      main.addDeploymentContext(context);
+      
+      assertEquals(1, deployer1.getStructureOrder());
+      assertEquals(2, deployer2.getStructureOrder());
+   }
+}

Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerStructureUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerStructureUnitTestCase.java	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerStructureUnitTestCase.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -38,6 +38,7 @@
 import org.jboss.deployers.spi.structure.StructureDetermined;
 import org.jboss.deployers.spi.structure.vfs.StructureDeployer;
 import org.jboss.test.deployers.BaseDeployersTest;
+import org.jboss.test.deployers.structure.main.support.TestStructureDeployer;
 
 /**
  * MainDeployerStructureUnitTestCase.

Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerWarStructureUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerWarStructureUnitTestCase.java	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerWarStructureUnitTestCase.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -25,9 +25,10 @@
 import junit.framework.TestSuite;
 
 import org.jboss.deployers.plugins.deployment.MainDeployerImpl;
+import org.jboss.deployers.plugins.structure.vfs.file.FileStructure;
 import org.jboss.deployers.plugins.structure.vfs.jar.JARStructure;
 import org.jboss.deployers.plugins.structure.vfs.war.WARStructure;
-import org.jboss.deployers.spi.deployement.MainDeployer;
+import org.jboss.deployers.spi.deployment.MainDeployer;
 import org.jboss.deployers.spi.structure.DeploymentContext;
 import org.jboss.deployers.spi.structure.DeploymentState;
 import org.jboss.test.deployers.structure.war.test.WARStructureUnitTestCase;
@@ -75,6 +76,7 @@
    protected static MainDeployer getMainDeployer()
    {
       MainDeployerImpl main = new MainDeployerImpl();
+      main.addStructureDeployer(new FileStructure());
       main.addStructureDeployer(new JARStructure());
       main.addStructureDeployer(new WARStructure());
       return main;

Deleted: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/TestStructureDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/TestStructureDeployer.java	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/TestStructureDeployer.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -1,58 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.test.deployers.structure.main.test;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.jboss.deployers.plugins.structure.vfs.AbstractStructureDeployer;
-import org.jboss.deployers.spi.structure.DeploymentContext;
-
-/**
- * TestStructureDeployer.
- * 
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class TestStructureDeployer extends AbstractStructureDeployer
-{
-   /** The contexts with which we have been invoked */
-   private Set<DeploymentContext> invoked = new HashSet<DeploymentContext>();
-
-   /**
-    * Get the contexts with which we were invoked and clear it
-    * 
-    * @return the set of contexts
-    */
-   public Set<DeploymentContext> getInvoked()
-   {
-      HashSet<DeploymentContext> result = new HashSet<DeploymentContext>(invoked);
-      invoked.clear();
-      return result;
-   }
-   
-   public boolean determineStructure(DeploymentContext context)
-   {
-      invoked.add(context);
-      return true;
-   }
-}

Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/war/test/WARStructureUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/war/test/WARStructureUnitTestCase.java	2006-09-11 11:30:37 UTC (rev 56722)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/war/test/WARStructureUnitTestCase.java	2006-09-11 11:52:22 UTC (rev 56723)
@@ -71,7 +71,7 @@
       return context;
    }
 
-   protected DeploymentContext assertNotValidContext(String root, String path, boolean isValidJar) throws Exception
+   protected DeploymentContext assertNotValidContext(String root, String path, boolean other) throws Exception
    {
       DeploymentContext context = createDeploymentContext(root, path);
       assertFalse("Structure should not be valid: " + context.getName(), determineStructure(context));
@@ -86,7 +86,7 @@
    
    public void testNotAnArchive() throws Exception
    {
-      assertNotValidContext("/structure/", "war/notanarchive/notanarchive.war", false);
+      assertNotValidContext("/structure/", "war/notanarchive/notanarchive.war", true);
    }
    
    public void testWarDirectory() throws Exception




More information about the jboss-cvs-commits mailing list