[jboss-cvs] JBossAS SVN: r67379 - in projects/microcontainer/trunk/deployers-impl/src: tests/org/jboss/test/deployers/main/test and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Nov 22 07:12:37 EST 2007


Author: alesj
Date: 2007-11-22 07:12:37 -0500 (Thu, 22 Nov 2007)
New Revision: 67379

Modified:
   projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/main/MainDeployerImpl.java
   projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/test/DeployerSingleDeploymentTestCase.java
Log:
Test fail deploy on structure.

Modified: projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/main/MainDeployerImpl.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/main/MainDeployerImpl.java	2007-11-22 11:58:58 UTC (rev 67378)
+++ projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/main/MainDeployerImpl.java	2007-11-22 12:12:37 UTC (rev 67379)
@@ -391,7 +391,7 @@
                DeploymentContext[] deployedContexts = new DeploymentContext[i];
                System.arraycopy(contexts, 0, deployedContexts, 0, i);
                deployers.process(null, Arrays.asList(deployedContexts));
-               throw DeploymentException.rethrowAsDeploymentException("Unable to deploy deployments.", t);
+               throw DeploymentException.rethrowAsDeploymentException("Unable to deploy deployments, cause: " + deployments[i], t);
             }
          }
          try

Modified: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/test/DeployerSingleDeploymentTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/test/DeployerSingleDeploymentTestCase.java	2007-11-22 11:58:58 UTC (rev 67378)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/test/DeployerSingleDeploymentTestCase.java	2007-11-22 12:12:37 UTC (rev 67379)
@@ -25,24 +25,30 @@
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Random;
 import java.util.Set;
-import java.util.Random;
 
 import junit.framework.Test;
 import org.jboss.deployers.client.spi.DeployerClient;
 import org.jboss.deployers.client.spi.Deployment;
 import org.jboss.deployers.client.spi.main.MainDeployer;
 import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.structure.StructureMetaDataFactory;
+import org.jboss.deployers.structure.spi.DeploymentContext;
+import org.jboss.deployers.structure.spi.StructuralDeployers;
+import org.jboss.deployers.structure.spi.StructureBuilder;
+import org.jboss.deployers.structure.spi.helpers.AbstractStructureBuilder;
+import org.jboss.deployers.plugins.main.MainDeployerImpl;
 import org.jboss.test.deployers.main.support.AddDeploymentRunnable;
 import org.jboss.test.deployers.main.support.AddProcessRemoveProcessRunnable;
 import org.jboss.test.deployers.main.support.DeployRunnable;
 import org.jboss.test.deployers.main.support.DeployUndeployRunnable;
 import org.jboss.test.deployers.main.support.DeployerTestRunnable;
 import org.jboss.test.deployers.main.support.FailedDeployUndeployRunnable;
+import org.jboss.test.deployers.main.support.ProcessRunnable;
 import org.jboss.test.deployers.main.support.ShutdownRunnable;
 import org.jboss.test.deployers.main.support.TestDeployment;
 import org.jboss.test.deployers.main.support.UndeployRunnable;
-import org.jboss.test.deployers.main.support.ProcessRunnable;
 
 /**
  * Single deployment API test case.
@@ -61,6 +67,47 @@
       return suite(DeployerSingleDeploymentTestCase.class);
    }
 
+   protected void checkFailedDeployOnStructure(DeployerClient mainDeployer, final int failed, int size) throws Throwable
+   {
+      final StructureBuilder builder = new AbstractStructureBuilder();
+      StructuralDeployers structuralDeployers = new StructuralDeployers()
+      {
+         public DeploymentContext determineStructure(Deployment deployment) throws DeploymentException
+         {
+            String name = deployment.getName();
+            if (name.endsWith("deployment" + failed))
+               throw new RuntimeException(String.valueOf(failed));
+            return builder.populateContext(deployment, StructureMetaDataFactory.createStructureMetaData());
+         }
+      };
+      ((MainDeployerImpl)mainDeployer).setStructuralDeployers(structuralDeployers);
+      
+      Deployment[] deployments = new Deployment[size];
+      for(int i = 0; i < size; i++)
+         deployments[i] = createSimpleDeployment("deployment" + i);
+      try
+      {
+         mainDeployer.deploy(deployments);
+         fail("Should not be here.");
+      }
+      catch (DeploymentException e)
+      {
+         Throwable cause = e.getCause();
+         assertNotNull(cause);
+         String msg = cause.getMessage();
+         assertEquals(failed, Integer.parseInt(msg));
+      }
+      deployer.clear();
+   }
+
+   public void testFailedDeployOnStructure() throws Throwable
+   {
+      DeployerClient main = getMainDeployer();
+      checkFailedDeployOnStructure(main, 0, 3);
+      checkFailedDeployOnStructure(main, 1, 3);
+      checkFailedDeployOnStructure(main, 2, 3);
+   }
+
    protected void checkFailedDeploy(DeployerClient mainDeployer, int failed, int size) throws Throwable
    {
       Deployment[] deployments = new Deployment[size];




More information about the jboss-cvs-commits mailing list