[jboss-cvs] JBossAS SVN: r89967 - in projects/jboss-deployers/trunk: deployers-impl/src/test/java/org/jboss/test/deployers/deployer and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jun 8 10:26:16 EDT 2009
Author: adrian at jboss.org
Date: 2009-06-08 10:26:16 -0400 (Mon, 08 Jun 2009)
New Revision: 89967
Added:
projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/support/RequiredStageDeployer.java
projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/test/DeployerRequiredStageUnitTestCase.java
Modified:
projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/deployers/DeployersImpl.java
projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/DeployersDeployerTestSuite.java
projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/DeploymentContext.java
projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/DeploymentUnit.java
projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/AbstractDeploymentContext.java
projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/AbstractDeploymentUnit.java
projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/ComponentDeploymentContext.java
Log:
[JBDEPLOY-189] - Fix and test setRequiredStage()
Modified: projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/deployers/DeployersImpl.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/deployers/DeployersImpl.java 2009-06-08 14:25:51 UTC (rev 89966)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/deployers/DeployersImpl.java 2009-06-08 14:26:16 UTC (rev 89967)
@@ -636,6 +636,7 @@
checkShutdown();
+ context.setRequiredStage(stage);
ControllerState state = new ControllerState(stageName);
try
{
@@ -773,7 +774,7 @@
{
DeploymentControllerContext deploymentControllerContext = context.getTransientAttachments().getAttachment(ControllerContext.class.getName(), DeploymentControllerContext.class);
ControllerState current = deploymentControllerContext.getState();
- if (ControllerState.ERROR.equals(current) == false && states.isBeforeState(current, state))
+ if (ControllerState.ERROR.equals(current) == false && states.isBeforeState(current, state) && current.getStateString().equals(context.getRequiredStage().getName()) == false)
{
checkShutdown();
try
Modified: projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/DeployersDeployerTestSuite.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/DeployersDeployerTestSuite.java 2009-06-08 14:25:51 UTC (rev 89966)
+++ projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/DeployersDeployerTestSuite.java 2009-06-08 14:26:16 UTC (rev 89967)
@@ -31,6 +31,7 @@
import org.jboss.test.deployers.deployer.test.DeployerFlowUnitTestCase;
import org.jboss.test.deployers.deployer.test.DeployerOrderingUnitTestCase;
import org.jboss.test.deployers.deployer.test.DeployerProtocolUnitTestCase;
+import org.jboss.test.deployers.deployer.test.DeployerRequiredStageUnitTestCase;
import org.jboss.test.deployers.deployer.test.DeployerWidthFirstUnitTestCase;
import org.jboss.test.deployers.deployer.test.DeployersImplUnitTestCase;
import org.jboss.test.deployers.deployer.test.HeuristicAllOrNothingUnitTestCase;
@@ -65,6 +66,7 @@
suite.addTest(HeuristicAllOrNothingUnitTestCase.suite());
suite.addTest(HeuristicRussionDollUnitTestCase.suite());
suite.addTest(DeployerContextClassLoaderUnitTestCase.suite());
+ suite.addTest(DeployerRequiredStageUnitTestCase.suite());
return suite;
}
Added: projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/support/RequiredStageDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/support/RequiredStageDeployer.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/support/RequiredStageDeployer.java 2009-06-08 14:26:16 UTC (rev 89967)
@@ -0,0 +1,46 @@
+/*
+* 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 org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStage;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * RequiredStageDeployer.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class RequiredStageDeployer extends AbstractSimpleRealDeployer<DeploymentStage>
+{
+ public RequiredStageDeployer()
+ {
+ super(DeploymentStage.class);
+ }
+
+ public void deploy(DeploymentUnit unit, DeploymentStage deployment) throws DeploymentException
+ {
+ unit.setRequiredStage(deployment);
+ }
+}
Added: projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/test/DeployerRequiredStageUnitTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/test/DeployerRequiredStageUnitTestCase.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/test/DeployerRequiredStageUnitTestCase.java 2009-06-08 14:26:16 UTC (rev 89967)
@@ -0,0 +1,76 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.deployers.deployer.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.client.spi.DeployerClient;
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.spi.attachments.MutableAttachments;
+import org.jboss.deployers.spi.deployer.DeploymentStage;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.test.deployers.AbstractDeployerTest;
+import org.jboss.test.deployers.deployer.support.RequiredStageDeployer;
+
+/**
+ * DeployerRequiredStageUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class DeployerRequiredStageUnitTestCase extends AbstractDeployerTest
+{
+ public static Test suite()
+ {
+ return new TestSuite(DeployerRequiredStageUnitTestCase.class);
+ }
+
+ public DeployerRequiredStageUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testRequiredState() throws Exception
+ {
+ RequiredStageDeployer deployer = new RequiredStageDeployer();
+ deployer.setStage(DeploymentStages.POST_PARSE);
+ DeployerClient main = createMainDeployer(deployer);
+
+ String name = "simple";
+
+ Deployment deployment = createSimpleDeployment(name);
+ MutableAttachments attachments = (MutableAttachments) deployment.getPredeterminedManagedObjects();
+ attachments.addAttachment(DeploymentStage.class, DeploymentStages.DESCRIBE);
+ main.deploy(deployment);
+
+ DeploymentUnit unit = getDeploymentUnit(main, name);
+
+ assertEquals(DeploymentStages.DESCRIBE, unit.getRequiredStage());
+ assertEquals(DeploymentStages.DESCRIBE, main.getDeploymentStage(name));
+
+ main.change(name, DeploymentStages.INSTALLED);
+ assertEquals(DeploymentStages.INSTALLED, unit.getRequiredStage());
+ assertEquals(DeploymentStages.INSTALLED, main.getDeploymentStage(name));
+ }
+}
Modified: projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/DeploymentContext.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/DeploymentContext.java 2009-06-08 14:25:51 UTC (rev 89966)
+++ projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/DeploymentContext.java 2009-06-08 14:26:16 UTC (rev 89967)
@@ -348,6 +348,13 @@
Object getControllerContextName();
/**
+ * Get the required stage.
+ *
+ * @return the required stage
+ */
+ DeploymentStage getRequiredStage();
+
+ /**
* Set the required stage.
*
* @param stage the required stage
Modified: projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/DeploymentUnit.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/DeploymentUnit.java 2009-06-08 14:25:51 UTC (rev 89966)
+++ projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/DeploymentUnit.java 2009-06-08 14:26:16 UTC (rev 89967)
@@ -270,6 +270,13 @@
Object getControllerContextName();
/**
+ * Get the required stage.
+ *
+ * @return the required stage
+ */
+ DeploymentStage getRequiredStage();
+
+ /**
* Set the required stage.
*
* @param stage the required stage
Modified: projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/AbstractDeploymentContext.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/AbstractDeploymentContext.java 2009-06-08 14:25:51 UTC (rev 89966)
+++ projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/AbstractDeploymentContext.java 2009-06-08 14:26:16 UTC (rev 89967)
@@ -44,14 +44,14 @@
import org.jboss.classloading.spi.RealClassLoader;
import org.jboss.dependency.spi.ControllerContext;
import org.jboss.dependency.spi.DependencyInfo;
-import org.jboss.dependency.spi.ControllerState;
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.DeploymentStage;
import org.jboss.deployers.spi.attachments.Attachments;
import org.jboss.deployers.spi.attachments.MutableAttachments;
import org.jboss.deployers.spi.attachments.helpers.ManagedObjectsWithTransientAttachmentsImpl;
+import org.jboss.deployers.spi.deployer.DeploymentStage;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
import org.jboss.deployers.structure.spi.ClassLoaderFactory;
import org.jboss.deployers.structure.spi.DeploymentContext;
import org.jboss.deployers.structure.spi.DeploymentContextVisitor;
@@ -157,6 +157,9 @@
/** The transient attachements */
private transient TrackingMutableAttachments transientAttachments;
+ /** The required stage */
+ private DeploymentStage requiredStage = DeploymentStages.INSTALLED;
+
/**
* Get the scope builder for a deployment context
*
@@ -772,21 +775,22 @@
}
}
+ public DeploymentStage getRequiredStage()
+ {
+ DeploymentContext parent = getParent();
+ if (parent != null)
+ return parent.getRequiredStage();
+ else
+ return this.requiredStage;
+ }
+
public void setRequiredStage(DeploymentStage stage)
{
- ControllerContext controllerContext = getTransientAttachments().getAttachment(ControllerContext.class);
- if (controllerContext != null)
- {
- controllerContext.setRequiredState(new ControllerState(stage.getName()));
- }
+ DeploymentContext parent = getParent();
+ if (parent != null)
+ parent.setRequiredStage(stage);
else
- {
- DeploymentContext parent = getParent();
- if (parent == null)
- throw new IllegalStateException("Deployment ControllerContext has not been set");
-
- parent.setRequiredStage(stage);
- }
+ this.requiredStage = stage;
}
public DependencyInfo getDependencyInfo()
Modified: projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/AbstractDeploymentUnit.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/AbstractDeploymentUnit.java 2009-06-08 14:25:51 UTC (rev 89966)
+++ projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/AbstractDeploymentUnit.java 2009-06-08 14:26:16 UTC (rev 89967)
@@ -468,6 +468,11 @@
return getDeploymentContext().getControllerContextName();
}
+ public DeploymentStage getRequiredStage()
+ {
+ return getDeploymentContext().getRequiredStage();
+ }
+
public void setRequiredStage(DeploymentStage stage)
{
getDeploymentContext().setRequiredStage(stage);
Modified: projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/ComponentDeploymentContext.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/ComponentDeploymentContext.java 2009-06-08 14:25:51 UTC (rev 89966)
+++ projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/ComponentDeploymentContext.java 2009-06-08 14:26:16 UTC (rev 89967)
@@ -429,6 +429,11 @@
return parent.getControllerContextName();
}
+ public DeploymentStage getRequiredStage()
+ {
+ return parent.getRequiredStage();
+ }
+
public void setRequiredStage(DeploymentStage stage)
{
parent.setRequiredStage(stage);
More information about the jboss-cvs-commits
mailing list