[jboss-cvs] JBossAS SVN: r67326 - in projects/microcontainer/trunk/deployers-impl/src: main/org/jboss/deployers/plugins/main and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Nov 21 05:29:22 EST 2007
Author: alesj
Date: 2007-11-21 05:29:22 -0500 (Wed, 21 Nov 2007)
New Revision: 67326
Added:
projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/AddDeploymentRunnable.java
projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/AddProcessRemoveProcessRunnable.java
projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/DeployRunnable.java
projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/DeployShutdownTestRunnable.java
projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/DeployUndeployRunnable.java
projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/DeployerTestRunnable.java
projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/FailedDeployUndeployRunnable.java
projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/ShutdownRunnable.java
projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/TestDeployment.java
projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/UndeployRunnable.java
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/main/MainDeployerImpl.java
projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/AbstractDeployerTest.java
projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/test/DeployerSingleDeploymentTestCase.java
Log:
SingleDeployment thread tests.
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 2007-11-21 09:10:46 UTC (rev 67325)
+++ projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/deployers/DeployersImpl.java 2007-11-21 10:29:22 UTC (rev 67326)
@@ -63,6 +63,7 @@
* DeployersImpl.
*
* @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
* @version $Revision: 1.1 $
*/
public class DeployersImpl implements Deployers, ControllerContextActions
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-21 09:10:46 UTC (rev 67325)
+++ projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/main/MainDeployerImpl.java 2007-11-21 10:29:22 UTC (rev 67326)
@@ -50,43 +50,44 @@
/**
* MainDeployerImpl.
- *
+ *
* @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @author Scott.Stark at jboss.org
+ * @author <a href="scott.stark at jboss.org">Scott Stark</a>
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
* @version $Revision$
*/
public class MainDeployerImpl implements MainDeployer, MainDeployerStructure
{
/** The log */
private static final Logger log = Logger.getLogger(MainDeployerImpl.class);
-
+
/** Whether we are shutdown */
private AtomicBoolean shutdown = new AtomicBoolean(false);
-
+
/** The deployers */
private Deployers deployers;
-
+
/** The structural deployers */
private StructuralDeployers structuralDeployers;
/** The ManagedDeploymentCreator plugin */
private ManagedDeploymentCreator mgtDeploymentCreator = null;
-
+
/** The deployments by name */
private Map<String, DeploymentContext> topLevelDeployments = new ConcurrentHashMap<String, DeploymentContext>();
-
+
/** All deployments by name */
private Map<String, DeploymentContext> allDeployments = new ConcurrentHashMap<String, DeploymentContext>();
-
+
/** Deployments in error by name */
private Map<String, DeploymentContext> errorDeployments = new ConcurrentHashMap<String, DeploymentContext>();
-
+
/** Deployments missing deployers */
private Map<String, Deployment> missingDeployers = new ConcurrentHashMap<String, Deployment>();
/** The undeploy work */
private List<DeploymentContext> undeploy = new CopyOnWriteArrayList<DeploymentContext>();
-
+
/** The deploy work */
private List<DeploymentContext> deploy = new CopyOnWriteArrayList<DeploymentContext>();
@@ -95,7 +96,7 @@
/**
* Get the deployers
- *
+ *
* @return the deployers
*/
public synchronized Deployers getDeployers()
@@ -105,7 +106,7 @@
/**
* Set the deployers
- *
+ *
* @param deployers the deployers
* @throws IllegalArgumentException for null deployers
*/
@@ -115,10 +116,10 @@
throw new IllegalArgumentException("Null deployers");
this.deployers = deployers;
}
-
+
/**
* Get the structural deployers
- *
+ *
* @return the structural deployers
*/
public synchronized StructuralDeployers getStructuralDeployers()
@@ -128,7 +129,7 @@
/**
* Set the structural deployers
- *
+ *
* @param deployers the deployers
* @throws IllegalArgumentException for null deployers
*/
@@ -191,7 +192,7 @@
/**
* Get a top level deployment context by name
- *
+ *
* @param name the name
* @return the context
*/
@@ -247,7 +248,7 @@
{
if (deployment == null)
throw new DeploymentException("Null context");
-
+
lockRead();
try
{
@@ -326,7 +327,7 @@
public boolean removeDeployment(String name) throws DeploymentException
{
- return removeDeployment(name, true);
+ return removeDeployment(name, true);
}
/**
@@ -501,8 +502,8 @@
}
try
- {
- deployers.process(deployContexts, undeployContexts);
+ {
+ deployers.process(deployContexts, undeployContexts);
}
catch (RuntimeException e)
{
@@ -682,13 +683,13 @@
Map<String, ManagedObject> managedObjects = getManagedObjects(context);
parent.setData(managedObjects);
processManagedObjects(context, managedObjectsGraph, parent);
-
+
return managedObjectsGraph;
}
/**
- * Get the managed objects for a context
- *
+ * Get the managed objects for a context
+ *
* @param context the context
* @param graph the graph
* @param parent the parent node
@@ -710,7 +711,7 @@
/**
* Recursively process the DeploymentContext into ManagedDeployments.
- *
+ *
* @param context the context
* @param parent the parent
* @throws DeploymentException for any error
@@ -729,7 +730,7 @@
/**
* Determine the structure of a deployment
- *
+ *
* @param deployment the deployment
* @return the deployment context
* @throws DeploymentException for an error determining the deployment structure
@@ -745,7 +746,7 @@
}
throw new DeploymentException("No structural deployers.");
}
-
+
/**
* Add a context.
*
@@ -767,7 +768,7 @@
// Process the top level only
if (context.isTopLevel() && addToDeploy)
deploy.add(context);
-
+
// Add all the children
List<DeploymentContext> children = context.getChildren();
if (children != null)
@@ -776,7 +777,7 @@
addContext(child, addToDeploy);
}
}
-
+
/**
* Remove a context
*
@@ -797,7 +798,7 @@
// Process the top level only
if (context.isTopLevel() && addToUndeploy)
undeploy.add(context);
-
+
// Remove all the children
List<DeploymentContext> children = context.getChildren();
if (children != null)
Modified: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/AbstractDeployerTest.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/AbstractDeployerTest.java 2007-11-21 09:10:46 UTC (rev 67325)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/AbstractDeployerTest.java 2007-11-21 10:29:22 UTC (rev 67326)
@@ -185,11 +185,16 @@
protected Deployment createSimpleDeployment(String name)
{
- AbstractDeployment unit = new AbstractDeployment(name);
+ AbstractDeployment unit = createAbstractDeployment(name);
factory.addContext(unit, "");
return unit;
}
-
+
+ protected AbstractDeployment createAbstractDeployment(String name)
+ {
+ return new AbstractDeployment(name);
+ }
+
protected ContextInfo addChild(PredeterminedManagedObjectAttachments parent, String name)
{
return factory.addContext(parent, name);
Added: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/AddDeploymentRunnable.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/AddDeploymentRunnable.java (rev 0)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/AddDeploymentRunnable.java 2007-11-21 10:29:22 UTC (rev 67326)
@@ -0,0 +1,44 @@
+/*
+* 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.main.support;
+
+import java.util.Random;
+
+import org.jboss.deployers.client.spi.DeployerClient;
+import org.jboss.deployers.client.spi.Deployment;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AddDeploymentRunnable extends DeployShutdownTestRunnable
+{
+ public AddDeploymentRunnable(DeployerClient main, Deployment deployment)
+ {
+ super(main, deployment);
+ }
+
+ protected void internalRun() throws Throwable
+ {
+ Thread.sleep(new Random().nextInt(100));
+ main.addDeployment(deployment);
+ }
+}
Added: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/AddProcessRemoveProcessRunnable.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/AddProcessRemoveProcessRunnable.java (rev 0)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/AddProcessRemoveProcessRunnable.java 2007-11-21 10:29:22 UTC (rev 67326)
@@ -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.main.support;
+
+import org.jboss.deployers.client.spi.DeployerClient;
+import org.jboss.deployers.client.spi.Deployment;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AddProcessRemoveProcessRunnable extends DeployerTestRunnable
+{
+ public AddProcessRemoveProcessRunnable(DeployerClient main, Deployment deployment)
+ {
+ super(main, deployment);
+ }
+
+ protected void internalRun() throws Throwable
+ {
+ main.addDeployment(deployment);
+ main.process();
+ main.checkComplete(deployment);
+ Thread.sleep(100);
+ main.removeDeployment(deployment);
+ main.process();
+ }
+}
Added: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/DeployRunnable.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/DeployRunnable.java (rev 0)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/DeployRunnable.java 2007-11-21 10:29:22 UTC (rev 67326)
@@ -0,0 +1,44 @@
+/*
+* 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.main.support;
+
+import java.util.Random;
+
+import org.jboss.deployers.client.spi.DeployerClient;
+import org.jboss.deployers.client.spi.Deployment;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class DeployRunnable extends DeployShutdownTestRunnable
+{
+ public DeployRunnable(DeployerClient main, Deployment deployment)
+ {
+ super(main, deployment);
+ }
+
+ protected void internalRun() throws Throwable
+ {
+ Thread.sleep(new Random().nextInt(100));
+ main.deploy(deployment);
+ }
+}
Added: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/DeployShutdownTestRunnable.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/DeployShutdownTestRunnable.java (rev 0)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/DeployShutdownTestRunnable.java 2007-11-21 10:29:22 UTC (rev 67326)
@@ -0,0 +1,49 @@
+/*
+* 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.main.support;
+
+import java.util.Set;
+
+import org.jboss.deployers.client.spi.DeployerClient;
+import org.jboss.deployers.client.spi.Deployment;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class DeployShutdownTestRunnable extends DeployerTestRunnable
+{
+ protected DeployShutdownTestRunnable(DeployerClient main, Deployment deployment)
+ {
+ super(main, deployment);
+ }
+
+ public boolean isValid()
+ {
+ if (deployment instanceof TestDeployment == false)
+ throw new IllegalArgumentException("Deployment should be test deployment.");
+
+ TestDeployment testDeployment = (TestDeployment)deployment;
+ String name = testDeployment.getAvoidNameHitName();
+ Set<String> names = testDeployment.getNames();
+ return (super.isValid() ^ names.contains(name)) == false;
+ }
+}
Added: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/DeployUndeployRunnable.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/DeployUndeployRunnable.java (rev 0)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/DeployUndeployRunnable.java 2007-11-21 10:29:22 UTC (rev 67326)
@@ -0,0 +1,43 @@
+/*
+* 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.main.support;
+
+import org.jboss.deployers.client.spi.DeployerClient;
+import org.jboss.deployers.client.spi.Deployment;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class DeployUndeployRunnable extends DeployerTestRunnable
+{
+ public DeployUndeployRunnable(DeployerClient main, Deployment deployment)
+ {
+ super(main, deployment);
+ }
+
+ protected void internalRun() throws Throwable
+ {
+ main.deploy(deployment);
+ Thread.sleep(100);
+ main.undeploy(deployment);
+ }
+}
Added: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/DeployerTestRunnable.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/DeployerTestRunnable.java (rev 0)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/DeployerTestRunnable.java 2007-11-21 10:29:22 UTC (rev 67326)
@@ -0,0 +1,75 @@
+/*
+* 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.main.support;
+
+import org.jboss.deployers.client.spi.DeployerClient;
+import org.jboss.deployers.client.spi.Deployment;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class DeployerTestRunnable implements Runnable
+{
+ protected DeployerClient main;
+ protected Deployment deployment;
+ private Throwable problem;
+
+ protected DeployerTestRunnable(DeployerClient main, Deployment deployment)
+ {
+ this.main = main;
+ this.deployment = deployment;
+ }
+
+ public void run()
+ {
+ try
+ {
+ internalRun();
+ }
+ catch (Throwable t)
+ {
+ setProblem(t);
+ }
+ }
+
+ protected abstract void internalRun() throws Throwable;
+
+ public boolean isValid()
+ {
+ return (problem == null);
+ }
+
+ public Throwable getProblem()
+ {
+ return problem;
+ }
+
+ public void setProblem(Throwable problem)
+ {
+ this.problem = problem;
+ }
+
+ public String toString()
+ {
+ return getClass().getSimpleName() + ": " + deployment + "/" + problem;
+ }
+}
Added: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/FailedDeployUndeployRunnable.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/FailedDeployUndeployRunnable.java (rev 0)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/FailedDeployUndeployRunnable.java 2007-11-21 10:29:22 UTC (rev 67326)
@@ -0,0 +1,45 @@
+/*
+* 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.main.support;
+
+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.Deployer;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class FailedDeployUndeployRunnable extends DeployUndeployRunnable
+{
+ public FailedDeployUndeployRunnable(DeployerClient main, Deployment deployment, Deployer deployer)
+ {
+ super(main, deployment);
+ MutableAttachments mutable = (MutableAttachments) deployment.getPredeterminedManagedObjects();
+ mutable.addAttachment("fail", deployer);
+ }
+
+ public boolean isValid()
+ {
+ return super.isValid() == false;
+ }
+}
Added: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/ShutdownRunnable.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/ShutdownRunnable.java (rev 0)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/ShutdownRunnable.java 2007-11-21 10:29:22 UTC (rev 67326)
@@ -0,0 +1,45 @@
+/*
+* 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.main.support;
+
+import java.util.Random;
+
+import org.jboss.deployers.client.spi.DeployerClient;
+import org.jboss.deployers.client.spi.main.MainDeployer;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ShutdownRunnable extends DeployerTestRunnable
+{
+ public ShutdownRunnable(DeployerClient main)
+ {
+ super(main, null);
+ }
+
+ protected void internalRun() throws Throwable
+ {
+ Thread.sleep(new Random().nextInt(50));
+ MainDeployer mainDeployer = (MainDeployer)main;
+ mainDeployer.shutdown();
+ }
+}
Added: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/TestDeployment.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/TestDeployment.java (rev 0)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/TestDeployment.java 2007-11-21 10:29:22 UTC (rev 67326)
@@ -0,0 +1,69 @@
+/*
+* 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.main.support;
+
+import java.util.Set;
+
+import org.jboss.deployers.client.plugins.deployment.AbstractDeployment;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class TestDeployment extends AbstractDeployment
+{
+ private String avoidNameHitName;
+ private Set<String> names;
+
+ public TestDeployment()
+ {
+ }
+
+ public TestDeployment(String name)
+ {
+ super(name);
+ avoidNameHitName = name;
+ }
+
+ public TestDeployment(String name, Set<String> names)
+ {
+ this(name);
+ this.names = names;
+ }
+
+ public String getAvoidNameHitName()
+ {
+ return avoidNameHitName;
+ }
+
+ public String getName()
+ {
+ String name = super.getName();
+ if (names != null)
+ names.add(name);
+ return name;
+ }
+
+ public Set<String> getNames()
+ {
+ return names;
+ }
+}
Added: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/UndeployRunnable.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/UndeployRunnable.java (rev 0)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/UndeployRunnable.java 2007-11-21 10:29:22 UTC (rev 67326)
@@ -0,0 +1,44 @@
+/*
+* 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.main.support;
+
+import java.util.Random;
+
+import org.jboss.deployers.client.spi.DeployerClient;
+import org.jboss.deployers.client.spi.Deployment;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class UndeployRunnable extends DeployShutdownTestRunnable
+{
+ public UndeployRunnable(DeployerClient main, Deployment deployment)
+ {
+ super(main, deployment);
+ }
+
+ protected void internalRun() throws Throwable
+ {
+ Thread.sleep(new Random().nextInt(100));
+ main.undeploy(deployment);
+ }
+}
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-21 09:10:46 UTC (rev 67325)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/test/DeployerSingleDeploymentTestCase.java 2007-11-21 10:29:22 UTC (rev 67326)
@@ -23,13 +23,25 @@
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
+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.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.ShutdownRunnable;
+import org.jboss.test.deployers.main.support.TestDeployment;
+import org.jboss.test.deployers.main.support.UndeployRunnable;
/**
* Single deployment API test case.
@@ -198,11 +210,62 @@
public void testMultiThreads() throws Exception
{
- // todo
+ DeployerClient main = getMainDeployer();
+ int n = 30;
+ DeployerTestRunnable[] runnables = new DeployerTestRunnable[n];
+ for(int i = 0; i < n; i++)
+ {
+ if (i % 3 == 0)
+ runnables[i] = new DeployUndeployRunnable(main, createSimpleDeployment("deployundeploy" + i));
+ else if (i % 3 == 1)
+ runnables[i] = new AddProcessRemoveProcessRunnable(main, createSimpleDeployment("aprp" + i));
+ else
+ runnables[i] = new FailedDeployUndeployRunnable(main, createSimpleDeployment("failed" + i), deployer);
+ }
+ Thread[] threads = new Thread[n];
+ for(int i = 0; i < n; i++)
+ {
+ threads[i] = new Thread(runnables[i]);
+ threads[i].start();
+ }
+ for(int i = 0; i < n; i++)
+ {
+ threads[i].join();
+ assertTrue(runnables[i].toString(), runnables[i].isValid());
+ }
}
public void testMultiThreadsAndShutdown() throws Exception
{
- // todo
+ DeployerClient main = getMainDeployer();
+ int n = 30;
+ int shutdown = new Random().nextInt(n / 2);
+ log.info("Shutdown order: " + shutdown);
+ DeployerTestRunnable[] runnables = new DeployerTestRunnable[n];
+ Set<String> names = new HashSet<String>();
+ for(int i = 0; i < n; i++)
+ {
+ Deployment deployment = new TestDeployment("td" + i, names);
+ if (i == shutdown)
+ runnables[i] = new ShutdownRunnable(main);
+ else if (i % 3 == 0)
+ runnables[i] = new DeployRunnable(main, deployment);
+ else if (i % 3 == 1)
+ runnables[i] = new AddDeploymentRunnable(main, deployment);
+ else
+ runnables[i] = new UndeployRunnable(main, deployment);
+ }
+ Thread[] threads = new Thread[n];
+ for(int i = 0; i < n; i++)
+ {
+ threads[i] = new Thread(runnables[i]);
+ threads[i].start();
+ }
+ for(int i = 0; i < n; i++)
+ {
+ threads[i].join();
+ assertTrue(runnables[i].toString(), runnables[i].isValid());
+ }
+ log.info("Names: " + names.size() + " - " + names);
}
}
More information about the jboss-cvs-commits
mailing list