User: starksm
Date: 01/07/08 18:06:06
Modified: src/main/org/jboss/test/util Tag: Branch_2_4 Deploy.java
Log:
Merge latest changes from main to the 2.4 branch
Revision Changes Path
No revision
No revision
1.1.2.1 +109 -14 jbosstest/src/main/org/jboss/test/util/Deploy.java
Index: Deploy.java
===================================================================
RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/util/Deploy.java,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1
--- Deploy.java 2001/04/18 22:16:40 1.1
+++ Deploy.java 2001/07/09 01:06:06 1.1.2.1
@@ -1,28 +1,123 @@
+/*
+ * JBoss, the OpenSource EJB server
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
package org.jboss.test.util;
+
+import java.util.Map;
+import java.util.Hashtable;
-/** A utility class for deploying the a named ejb jar.
+import junit.framework.TestCase;
-@author [EMAIL PROTECTED]
-@version $Revision: 1.1 $
-*/
+/**
+ * A utility class for deploying jar files.
+ *
+ * @author [EMAIL PROTECTED]
+ * @author <a href="mailto:[EMAIL PROTECTED]">Jason Dillon</a>
+ * @version $Revision: 1.1.2.1 $
+ */
public class Deploy
{
- public static boolean deployed;
+ /** A map of jarname -> Boolean deployment status. */
+ private static Map deployed = new Hashtable();
- /** Deploy the security ejb jar one time
+ /**
+ * Check if a jar is deployed.
*/
- public static void deploy(String jarName) throws Exception
+ private static boolean isDeployed(final String jarName) {
+ Boolean bool = (Boolean)deployed.get(jarName);
+ if (bool == null)
+ return false;
+ return bool.booleanValue();
+ }
+
+ /**
+ * Mark a jar as deployed or undeployed.
+ */
+ private static void setDeployed(final String jarName, final boolean flag)
{
- String noDeploy = System.getProperty("no-deploy");
- if( noDeploy != null || deployed )
- return;
+ deployed.put(jarName, new Boolean(flag));
+ }
+ /** Return the deployment directory to use. */
+ private static String getDeployFilename(final String filename) {
String deployDir = System.getProperty("jbosstest.deploy.dir");
- if( deployDir == null )
+ if (deployDir == null) {
deployDir = "../deploy";
+ }
+ return deployDir + "/" + filename;
+ }
+
+ /**
+ * Deploy the security ejb jar one time.
+ */
+ public static void deploy(final String jarName) throws Exception
+ {
+ String noDeploy = System.getProperty("no-deploy");
+ if (noDeploy != null || isDeployed(jarName)) {
+ return;
+ }
- System.out.println("Deploying: "+ jarName);
- new org.jboss.jmx.client.Deployer().deploy(deployDir+'/' + jarName);
- deployed = true;
+ String filename = getDeployFilename(jarName);
+ System.out.print("Deploying: "+ jarName + "...");
+ new org.jboss.jmx.client.Deployer().deploy(filename);
+ setDeployed(jarName, true);
+ System.out.println("Done");
}
+
+ /**
+ * Undeploy an archive from a the remote JBoss server.
+ */
+ public static void undeploy(final String jarName) throws Exception
+ {
+ String noUndeploy = System.getProperty("no-undeploy");
+ if (noUndeploy != null || !isDeployed(jarName)) {
+ return;
+ }
+
+ String filename = getDeployFilename(jarName);
+ System.out.print("Undeploying: "+ jarName + "...");
+ new org.jboss.jmx.client.Deployer().undeploy(filename);
+ setDeployed(jarName, false);
+ System.out.println("Done");
+ }
+
+ /**
+ * A psuedo test case, which provides hooks to deploy.
+ */
+ public static class Deployer
+ extends TestCase
+ {
+ String jarName;
+
+ public Deployer(final String jarName) {
+ super("deploy");
+ this.jarName = jarName;
+ }
+
+ public void deploy() throws Exception {
+ Deploy.deploy(this.jarName);
+ }
+ }
+
+ /**
+ * A psuedo test case, which provides hooks to undeploy.
+ */
+ public static class Undeployer
+ extends TestCase
+ {
+ String jarName;
+
+ public Undeployer(final String jarName) {
+ super("undeploy");
+ this.jarName = jarName;
+ }
+
+ public void undeploy() throws Exception {
+ Deploy.undeploy(this.jarName);
+ }
+ }
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development