[jboss-cvs] JBossAS SVN: r70109 - 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
Tue Feb 26 10:05:44 EST 2008


Author: adrian at jboss.org
Date: 2008-02-26 10:05:43 -0500 (Tue, 26 Feb 2008)
New Revision: 70109

Modified:
   projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/deployers/DeployersImpl.java
   projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/test/DeployerChangeStageTestCase.java
Log:
Add a test for change in deployment state throwing an error

Modified: projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/deployers/DeployersImpl.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/deployers/DeployersImpl.java	2008-02-26 14:53:58 UTC (rev 70108)
+++ projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/deployers/DeployersImpl.java	2008-02-26 15:05:43 UTC (rev 70109)
@@ -408,8 +408,10 @@
       {
          context.setState(DeploymentState.ERROR);
          context.setProblem(t);
-         throw DeploymentException.rethrowAsDeploymentException("Error changing to stage " + stage + " for " + context.getName(), t);
       }
+      Throwable problem = context.getProblem();
+      if (problem != null)
+         throw DeploymentException.rethrowAsDeploymentException("Error changing to stage " + stage + " for " + context.getName(), problem);
    }
    
    public void process(List<DeploymentContext> deploy, List<DeploymentContext> undeploy)

Modified: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/test/DeployerChangeStageTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/test/DeployerChangeStageTestCase.java	2008-02-26 14:53:58 UTC (rev 70108)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/test/DeployerChangeStageTestCase.java	2008-02-26 15:05:43 UTC (rev 70109)
@@ -29,7 +29,9 @@
 import org.jboss.deployers.client.spi.DeployerClient;
 import org.jboss.deployers.client.spi.Deployment;
 import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.DeploymentState;
 import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.structure.spi.DeploymentContext;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 
 /**
@@ -86,6 +88,7 @@
       try
       {
          main.change(single.getName(), DeploymentStages.REAL);
+         fail("Should not be here");
       }
       catch (Throwable t)
       {
@@ -100,4 +103,34 @@
       main.change(single.getName(), DeploymentStages.REAL);
       assertEquals(expected, deployer.getDeployedUnits());
    }
+
+   public void testChangeStageFail() throws Throwable
+   {
+      DeployerClient main = getMainDeployer();
+
+      Deployment single = createSimpleDeployment("single");
+      main.deploy(single);
+      List<String> expected = new ArrayList<String>();
+      expected.add(single.getName());
+      assertEquals(expected, deployer.getDeployedUnits());
+
+      main.change(single.getName(), DeploymentStages.CLASSLOADER);
+      DeploymentUnit unit = assertDeploymentUnit(main, single.getName());
+      DeploymentContext context = assertDeploymentContext(main, single.getName());
+      unit.addAttachment("fail", deployer);
+      
+      deployer.clear();
+      try
+      {
+         main.change(single.getName(), DeploymentStages.REAL);
+         fail("Should not be here");
+      }
+      catch (Throwable t)
+      {
+         checkThrowable(DeploymentException.class, t);
+      }
+      assertEquals(expected, deployer.getFailed());
+      assertEquals(DeploymentState.ERROR, context.getState());
+      checkThrowable(DeploymentException.class, context.getProblem());
+   }
 }




More information about the jboss-cvs-commits mailing list