[jbosstools-commits] JBoss Tools SVN: r30552 - in workspace/adietish: org.jboss.ide.eclipse.as7.deployment.detyped and 4 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Wed Apr 13 09:03:46 EDT 2011


Author: adietish
Date: 2011-04-13 09:03:43 -0400 (Wed, 13 Apr 2011)
New Revision: 30552

Added:
   workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/jboss-marshalling-1.3.0.CR8.jar
   workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/jboss-threads-2.0.0.CR8-sources.jar
   workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/jboss-threads-2.0.0.CR8.jar
   workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/StandaloneDetypedOperationsIntegrationTest.java
Removed:
   workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/StandaloneDetypedOperations.java
Modified:
   workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/.classpath
   workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/META-INF/MANIFEST.MF
   workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/build.properties
   workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/StandaloneDetypedOperations.java
   workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/META-INF/MANIFEST.MF
   workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/StandaloneOperationsIntegrationTest.java
Log:


Deleted: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/StandaloneDetypedOperations.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/StandaloneDetypedOperations.java	2011-04-13 12:44:34 UTC (rev 30551)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/StandaloneDetypedOperations.java	2011-04-13 13:03:43 UTC (rev 30552)
@@ -1,143 +0,0 @@
-package org.jboss.ide.eclipse.as7.deployment;
-
-import static org.jboss.as.protocol.StreamUtils.safeClose;
-
-import java.io.File;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-import org.jboss.as.controller.client.ModelControllerClient;
-import org.jboss.as.controller.client.helpers.standalone.DeploymentPlanBuilder;
-import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentManager;
-
-public class StandaloneDetypedOperations {
-
-	public static final long DEFAULT_TIMEOUT = 15000;
-
-	private final List<IDeploymentPlanBuilderOperation> deployments = new ArrayList<IDeploymentPlanBuilderOperation>();
-	private final ModelControllerClient client;
-	private final ServerDeploymentManager manager;
-	private long timeout = DEFAULT_TIMEOUT;
-
-	public StandaloneDetypedOperations(String host, int port) throws UnknownHostException {
-		client = ModelControllerClient.Factory.create(host, port);
-		manager = ServerDeploymentManager.Factory.create(client);
-	}
-
-	public synchronized StandaloneDetypedOperations deploy(File file) {
-		deployments.add(new DeployOperation(file));
-		return this;
-	}
-
-	public synchronized StandaloneDetypedOperations deploy(String name, File file) {
-		deployments.add(new DeployOperation(name, file));
-		return this;
-	}
-
-	public synchronized StandaloneDetypedOperations undeploy(String name) {
-		deployments.add(new UndeployOperation(name));
-		return this;
-	}
-
-	public synchronized StandaloneDetypedOperations undeploy(File file) {
-		deployments.add(new UndeployOperation(file));
-		return this;
-	}
-
-	public synchronized void execute() throws DeployerException {
-		try {
-			DeploymentPlanBuilder builder = manager.newDeploymentPlan();
-			for (IDeploymentPlanBuilderOperation deployment : deployments) {
-				builder = deployment.addTo(builder);
-			}
-			manager.execute(builder.build()).get(timeout, TimeUnit.MILLISECONDS);
-		} catch (Exception e) {
-			throw new DeployerException(e);
-		}
-	}
-
-	public void setTimeout(long timeout) {
-		this.timeout = timeout;
-	}
-
-	public void dispose() {
-		safeClose(client);
-	}
-
-	private static class DeployOperation extends FileOperation {
-
-		private DeployOperation(File file) {
-			super(file);
-		}
-
-		private DeployOperation(String name, File file) {
-			super(name, file);
-		}
-
-		public synchronized DeploymentPlanBuilder addTo(DeploymentPlanBuilder builder) throws Exception {
-			String name = getName();
-			return builder.add(name, getFile()).deploy(name);
-		}		
-	}
-	
-	private static class UndeployOperation extends FileOperation {
-
-		private UndeployOperation(File file) {
-			super(file);
-		}
-
-		private UndeployOperation(String name) {
-			super(name, null);
-		}
-
-		public synchronized DeploymentPlanBuilder addTo(DeploymentPlanBuilder builder) throws Exception {
-			String name = getName();
-			return builder.undeploy(name).undeploy(name);
-		}
-	}
-	
-	private abstract static class FileOperation extends NamedOperation {
-
-		private File file;
-
-		private FileOperation(File file) {
-			this(null, file);
-		}
-
-		private FileOperation(String name, File file) {
-			super(name);
-			this.file = file;
-		}
-
-		protected File getFile() {
-			return file;
-		}
-
-		protected String getName() {
-			if (name != null) {
-				return name;
-			} else {
-				return file.getName();
-			}
-		}
-
-	}
-
-	private abstract static class NamedOperation implements IDeploymentPlanBuilderOperation {
-
-		protected String name;
-
-		private NamedOperation(String name) {
-			this.name = name;
-		}
-	}
-
-	private interface IDeploymentPlanBuilderOperation {
-
-		public DeploymentPlanBuilder addTo(DeploymentPlanBuilder builder) throws Exception;
-
-	}
-	
-}

Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/.classpath
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/.classpath	2011-04-13 12:44:34 UTC (rev 30551)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/.classpath	2011-04-13 13:03:43 UTC (rev 30552)
@@ -1,5 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
+	<classpathentry exported="true" kind="lib" path="jboss-marshalling-1.3.0.CR8.jar"/>
+	<classpathentry exported="true" kind="lib" path="jboss-threads-2.0.0.CR8.jar"/>
 	<classpathentry exported="true" kind="lib" path="jboss-dmr-1.0.0.Beta5.jar"/>
 	<classpathentry exported="true" kind="lib" path="jboss-as-controller-client-7.0.0.Beta3-SNAPSHOT.jar"/>
 	<classpathentry exported="true" kind="lib" path="jboss-as-protocol-7.0.0.Beta3-SNAPSHOT.jar"/>

Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/META-INF/MANIFEST.MF
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/META-INF/MANIFEST.MF	2011-04-13 12:44:34 UTC (rev 30551)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/META-INF/MANIFEST.MF	2011-04-13 13:03:43 UTC (rev 30552)
@@ -8,4 +8,7 @@
  jboss-as-cli-7.0.0.Beta3-SNAPSHOT.jar,
  jboss-as-protocol-7.0.0.Beta3-SNAPSHOT.jar,
  jboss-as-controller-client-7.0.0.Beta3-SNAPSHOT.jar,
- jboss-dmr-1.0.0.Beta5.jar
+ jboss-dmr-1.0.0.Beta5.jar,
+ jboss-threads-2.0.0.CR8.jar,
+ jboss-marshalling-1.3.0.CR8.jar
+Export-Package: org.jboss.ide.eclipse.as7.deployment.detyped

Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/build.properties
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/build.properties	2011-04-13 12:44:34 UTC (rev 30551)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/build.properties	2011-04-13 13:03:43 UTC (rev 30552)
@@ -5,4 +5,6 @@
                jboss-as-cli-7.0.0.Beta3-SNAPSHOT.jar,\
                jboss-as-protocol-7.0.0.Beta3-SNAPSHOT.jar,\
                jboss-as-controller-client-7.0.0.Beta3-SNAPSHOT.jar,\
-               jboss-dmr-1.0.0.Beta5.jar
+               jboss-dmr-1.0.0.Beta5.jar,\
+               jboss-threads-2.0.0.CR8.jar,\
+               jboss-marshalling-1.3.0.CR8.jar

Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/jboss-marshalling-1.3.0.CR8.jar
===================================================================
(Binary files differ)


Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/jboss-marshalling-1.3.0.CR8.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/jboss-threads-2.0.0.CR8-sources.jar
===================================================================
(Binary files differ)


Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/jboss-threads-2.0.0.CR8-sources.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/jboss-threads-2.0.0.CR8.jar
===================================================================
(Binary files differ)


Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/jboss-threads-2.0.0.CR8.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/StandaloneDetypedOperations.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/StandaloneDetypedOperations.java	2011-04-13 12:44:34 UTC (rev 30551)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/StandaloneDetypedOperations.java	2011-04-13 13:03:43 UTC (rev 30552)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ide.eclipse.as7.deployment.detyped;
 
 import java.io.File;
@@ -14,6 +35,9 @@
 import org.jboss.as.protocol.StreamUtils;
 import org.jboss.dmr.ModelNode;
 
+/**
+ * @author André Dietisheim
+ */
 public class StandaloneDetypedOperations {
 
 	private final List<IDeploymentOperation> deployments = new ArrayList<IDeploymentOperation>();

Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/META-INF/MANIFEST.MF
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/META-INF/MANIFEST.MF	2011-04-13 12:44:34 UTC (rev 30551)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/META-INF/MANIFEST.MF	2011-04-13 13:03:43 UTC (rev 30552)
@@ -6,6 +6,7 @@
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Require-Bundle: org.junit;bundle-version="[4.8.1,5.0.0)",
  org.eclipse.core.runtime;bundle-version="3.7.0",
- org.jboss.ide.eclipse.as7.deployment;bundle-version="0.0.1"
+ org.jboss.ide.eclipse.as7.deployment;bundle-version="0.0.1",
+ org.jboss.ide.eclipse.as7.deployment.detyped;bundle-version="1.0.0"
 Bundle-ClassPath: .,
  wars/

Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/StandaloneDetypedOperationsIntegrationTest.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/StandaloneDetypedOperationsIntegrationTest.java	                        (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/StandaloneDetypedOperationsIntegrationTest.java	2011-04-13 13:03:43 UTC (rev 30552)
@@ -0,0 +1,126 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ide.eclipse.as7.deployment.tests;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.net.HttpURLConnection;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.text.MessageFormat;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
+import org.jboss.ide.eclipse.as7.deployment.DeployerException;
+import org.jboss.ide.eclipse.as7.deployment.detyped.StandaloneDetypedOperations;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+
+/**
+ * @author André Dietisheim
+ */
+public class StandaloneDetypedOperationsIntegrationTest {
+
+	private static final String WAR_FOLDER = "/wars/";
+	private static final String BUNDLE_ID = "org.jboss.ide.eclipse.as7.deployment.tests";
+
+	private static final int WEBAPP_RESPONSE_TIMEOUT = 10 * 1024;
+
+	private static final String HOST = "localhost";
+	private static final int MGMT_PORT = 9999;
+	private static final int WEB_PORT = 8080;
+
+	@Test
+	public void canDeploy() throws Exception {
+		StandaloneDetypedOperations deployer = null;
+		File warFile = getWarFile("minimalistic.war");
+		try {
+			deployer = new StandaloneDetypedOperations(HOST, MGMT_PORT);
+			quietlyUndeploy(warFile, deployer);
+			deployer.deploy(warFile).execute();
+
+			String response = getServerResponse(new URL(
+					MessageFormat.format(
+							"http://{0}:{1}/{2}", HOST, String.valueOf(WEB_PORT), "minimalistic")));
+			assertTrue(response.indexOf("minimalistic") >= 0);
+
+		} finally {
+			quietlyUndeploy(warFile, deployer);
+		}
+	}
+
+	@Test(expected = DeployerException.class)
+	public void cannotDeployWarTwice() throws Exception {
+		StandaloneDetypedOperations deployer = null;
+		File warFile = getWarFile("minimalistic.war");
+		try {
+			deployer = new StandaloneDetypedOperations(HOST, MGMT_PORT);
+			deployer.deploy(warFile).execute();
+			deployer.deploy(warFile).execute();
+		} finally {
+			quietlyUndeploy(warFile, deployer);
+		}
+	}
+
+	private File getWarFile(String name) throws URISyntaxException, IOException {
+		Bundle bundle = Platform.getBundle(BUNDLE_ID);
+		URL entryUrl = bundle.getEntry(WAR_FOLDER + name);
+		return new File(FileLocator.resolve(entryUrl).toURI());
+	}
+
+	private String getServerResponse(URL url) throws IOException {
+		HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+		connection.setUseCaches(false);
+		connection.setDoInput(true);
+		connection.setAllowUserInteraction(false);
+		connection.setConnectTimeout(WEBAPP_RESPONSE_TIMEOUT);
+		connection.setInstanceFollowRedirects(true);
+		connection.setDoOutput(false);
+		BufferedInputStream in = new BufferedInputStream(connection.getInputStream());
+		return toString(in);
+	}
+
+	private String toString(InputStream in) throws IOException {
+		StringWriter writer = new StringWriter();
+		for (int data = -1; ((data = in.read()) != -1);) {
+			writer.write(data);
+		}
+		return writer.toString();
+	}
+
+	private void quietlyUndeploy(File file, StandaloneDetypedOperations deployer) {
+		try {
+			if (deployer != null) {
+				deployer.undeploy(file).execute();
+				deployer.dispose();
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+			// ignore
+		}
+	}
+}


Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/StandaloneDetypedOperationsIntegrationTest.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/StandaloneOperationsIntegrationTest.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/StandaloneOperationsIntegrationTest.java	2011-04-13 12:44:34 UTC (rev 30551)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/StandaloneOperationsIntegrationTest.java	2011-04-13 13:03:43 UTC (rev 30552)
@@ -42,8 +42,7 @@
 
 /**
  * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
+ * @author André Dietisheim
  */
 public class StandaloneOperationsIntegrationTest {
 



More information about the jbosstools-commits mailing list