Author: adietish
Date: 2011-04-14 08:34:04 -0400 (Thu, 14 Apr 2011)
New Revision: 30570
Modified:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/MinimalisticDeployerIntegrationTest.java
Log:
Modified:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java
===================================================================
---
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java 2011-04-14
12:28:48 UTC (rev 30569)
+++
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java 2011-04-14
12:34:04 UTC (rev 30570)
@@ -40,9 +40,10 @@
*/
public class MinimalisticStandaloneDeployer {
- public static void undeploy(String name, String host, int port) throws
CancellationException, IOException {
- ModelControllerClient client = ModelControllerClient.Factory.create(host, port);
+ public static void undeploy(String name, String host, int port) throws DeployerException
{
+ ModelControllerClient client = null;
try {
+ client = ModelControllerClient.Factory.create(host, port);
// undeploy
ModelNode request = new ModelNode();
request.get("operation").set("undeploy");
@@ -54,14 +55,17 @@
request.get("operation").set("remove");
request.get("address").add("deployment", name);
result = client.execute(request);
+ } catch(Exception e) {
+ throw new DeployerException(e);
} finally {
StreamUtils.safeClose(client);
}
}
- public static void deploy(File file, String host, int port) throws
CancellationException, IOException {
- ModelControllerClient client = ModelControllerClient.Factory.create(host, port);
+ public static void deploy(File file, String host, int port) throws DeployerException {
+ ModelControllerClient client = null;
try {
+ client = ModelControllerClient.Factory.create(host, port);
String name = file.getName();
ModelNode request = new ModelNode();
@@ -75,6 +79,8 @@
ModelNode result = client.execute(operation.build());
throwOnFailure(result);
+ } catch(Exception e) {
+ throw new DeployerException(e);
} finally {
StreamUtils.safeClose(client);
}
@@ -94,9 +100,9 @@
return Util.getDeployments(client);
}
- private static void throwOnFailure(ModelNode result) {
+ private static void throwOnFailure(ModelNode result) throws DeployerException {
if (!Util.isSuccess(result)) {
- throw new RuntimeException(Util.getFailureDescription(result));
+ throw new DeployerException(Util.getFailureDescription(result));
}
}
Modified:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/MinimalisticDeployerIntegrationTest.java
===================================================================
---
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/MinimalisticDeployerIntegrationTest.java 2011-04-14
12:28:48 UTC (rev 30569)
+++
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/MinimalisticDeployerIntegrationTest.java 2011-04-14
12:34:04 UTC (rev 30570)
@@ -40,7 +40,6 @@
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
import org.jboss.ide.eclipse.as7.deployment.detyped.MinimalisticStandaloneDeployer;
-import org.jboss.ide.eclipse.as7.deployment.internal.StandaloneTypedOperations;
import org.junit.Test;
import org.osgi.framework.Bundle;
@@ -50,6 +49,8 @@
*/
public class MinimalisticDeployerIntegrationTest {
+ private static final String GWT_HELLOWORLD_WAR = "gwt-helloworld.war";
+ private static final String MINIMALISTIC_WAR = "minimalistic.war";
private static final String WAR_FOLDER = "/wars/";
private static final String BUNDLE_ID =
"org.jboss.ide.eclipse.as7.deployment.tests";
@@ -61,7 +62,7 @@
@Test
public void canDeploy() throws Exception {
- File warFile = getWarFile("minimalistic.war");
+ File warFile = getWarFile(MINIMALISTIC_WAR);
try {
MinimalisticStandaloneDeployer.deploy(warFile, HOST, MGMT_PORT);
@@ -77,7 +78,7 @@
@Test(expected = Exception.class)
public void cannotDeployWarTwice() throws Exception {
- File warFile = getWarFile("minimalistic.war");
+ File warFile = getWarFile(MINIMALISTIC_WAR);
try {
MinimalisticStandaloneDeployer.deploy(warFile, HOST, MGMT_PORT);
MinimalisticStandaloneDeployer.deploy(warFile, HOST, MGMT_PORT);
@@ -88,15 +89,14 @@
@Test
public void canQueryDeploymentdeployedState() throws Exception {
- StandaloneTypedOperations deployer = null;
- File warFile = getWarFile("minimalistic.war");
- File warFile2 = getWarFile("gwt-helloworld.war");
+ File warFile = getWarFile(MINIMALISTIC_WAR);
+ File warFile2 = getWarFile(GWT_HELLOWORLD_WAR);
try {
MinimalisticStandaloneDeployer.deploy(warFile, HOST, MGMT_PORT);
MinimalisticStandaloneDeployer.deploy(warFile2, HOST, MGMT_PORT);
List<String> deployments = MinimalisticStandaloneDeployer.getDeployments(HOST,
MGMT_PORT);
assertThat(deployments.size(), is(2));
- assertThat(deployments, hasItems( "minimalistic.war",
"gwt-helloworld.war"));
+ assertThat(deployments, hasItems( MINIMALISTIC_WAR, GWT_HELLOWORLD_WAR));
} finally {
quietlyUndeploy(warFile);
}