[jbosstools-commits] JBoss Tools SVN: r30802 - trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Sat Apr 23 07:48:01 EDT 2011
Author: adietish
Date: 2011-04-23 07:48:01 -0400 (Sat, 23 Apr 2011)
New Revision: 30802
Added:
trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/AS7ManagerIntegrationTest.java
trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/AS7ManagerTestUtils.java
Removed:
trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/JBossManagementTestUtils.java
Modified:
trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/DetypedDeployerIntegrationTest.java
trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/JBossManagementIntegrationTest.java
Log:
[JBIDE-8690] corrected tests
Added: trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/AS7ManagerIntegrationTest.java
===================================================================
--- trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/AS7ManagerIntegrationTest.java (rev 0)
+++ trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/AS7ManagerIntegrationTest.java 2011-04-23 11:48:01 UTC (rev 30802)
@@ -0,0 +1,167 @@
+/*
+ * 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.as.management.as7.tests;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.UnknownHostException;
+import java.util.concurrent.ExecutionException;
+
+import org.jboss.ide.eclipse.as.core.server.internal.v7.JBoss7DeploymentState;
+import org.jboss.ide.eclipse.as.core.server.internal.v7.JBoss7ManangementException;
+import org.jboss.ide.eclipse.as.management.as7.deployment.AS7Manager;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ *
+ * @author André Dietisheim
+ */
+public class AS7ManagerIntegrationTest {
+
+ private AS7Manager manager;
+
+ @Before
+ public void setUp() throws UnknownHostException {
+ this.manager = new AS7Manager(AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.MGMT_PORT);
+ }
+
+ @After
+ public void tearDown() {
+ manager.dispose();
+ }
+
+ @Ignore
+ @Test
+ public void canDeploy() throws Exception {
+ File warFile = AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.MINIMALISTIC_WAR);
+ try {
+ AS7ManagerTestUtils.waitUntilFinished(manager.deploy(warFile));
+
+ String response = AS7ManagerTestUtils.waitForRespose(
+ "minimalistic", AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.WEB_PORT);
+ assertTrue(response != null
+ && response.indexOf("minimalistic") >= 0);
+ } finally {
+ AS7ManagerTestUtils.quietlyUndeploy(warFile, manager);
+ }
+ }
+
+ @Ignore
+ @Test
+ public void deployedWarIsResponding() throws Exception {
+ File warFile = AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.MINIMALISTIC_WAR);
+ try {
+ AS7ManagerTestUtils.waitUntilFinished(manager.deploy(warFile));
+
+ String response = AS7ManagerTestUtils.waitForRespose(
+ "minimalistic", AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.WEB_PORT);
+ assertTrue(response != null
+ && response.indexOf("minimalistic") >= 0);
+
+ } finally {
+ AS7ManagerTestUtils.quietlyUndeploy(warFile, manager);
+ }
+ }
+
+ @Ignore
+ @Test(expected = JBoss7ManangementException.class)
+ public void cannotDeployWarTwice() throws Exception {
+ File warFile = AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.MINIMALISTIC_WAR);
+ try {
+ AS7ManagerTestUtils.waitUntilFinished(manager.deploy(warFile));
+ AS7ManagerTestUtils.waitUntilFinished(manager.deploy(warFile));
+ } finally {
+ AS7ManagerTestUtils.quietlyUndeploy(warFile, manager);
+ }
+ }
+
+ @Ignore
+ @Test(expected = JBoss7ManangementException.class)
+ public void cannotUndeployNondeployed() throws JBoss7ManangementException, InterruptedException, ExecutionException {
+ AS7ManagerTestUtils.waitUntilFinished(manager.undeploy("inexistant"));
+ }
+
+ @Ignore
+ @Test
+ public void canReplaceWar() throws Exception {
+ File warFile = AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.MINIMALISTIC_WAR);
+ File warFile2 = AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.GWT_HELLOWORLD_WAR);
+ String name = warFile.getName();
+ try {
+ AS7ManagerTestUtils.waitUntilFinished(manager.deploy(name, warFile));
+ AS7ManagerTestUtils.waitUntilFinished(manager.replace(name, warFile2));
+ String response = AS7ManagerTestUtils.waitForRespose(
+ "minimalistic", AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.WEB_PORT);
+ assertTrue(response != null
+ && response.indexOf("GWT") >= 0);
+ } finally {
+ AS7ManagerTestUtils.quietlyUndeploy(name, manager);
+ }
+ }
+
+ @Test
+ public void getEnabledStateIfDeploymentIsDeployed() throws URISyntaxException, IOException, JBoss7ManangementException {
+ String deploymentName = "testDeployment";
+ File warFile = AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.MINIMALISTIC_WAR);
+ try {
+ AS7ManagerTestUtils.waitUntilFinished(manager.deploy(deploymentName, warFile));
+ JBoss7DeploymentState state = manager.getDeploymentState(deploymentName);
+ assertNotNull(state);
+ assertThat(state, equalTo(JBoss7DeploymentState.STARTED));
+ } finally {
+ AS7ManagerTestUtils.quietlyUndeploy(deploymentName, manager);
+ }
+ }
+
+ @Test
+ public void getDisabledStateIfDeploymentIsOnlyAdded() throws URISyntaxException, IOException, JBoss7ManangementException {
+ String deploymentName = "testDeployment";
+ File warFile = AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.MINIMALISTIC_WAR);
+ try {
+ AS7ManagerTestUtils.waitUntilFinished(manager.add(deploymentName, warFile));
+ JBoss7DeploymentState state = manager.getDeploymentState(deploymentName);
+ assertNotNull(state);
+ assertThat(state, equalTo(JBoss7DeploymentState.STOPPED));
+ } finally {
+ AS7ManagerTestUtils.quietlyRemove(deploymentName, manager);
+ }
+ }
+
+ @Test(expected = JBoss7ManangementException.class)
+ public void getErrorIfDeploymentIsNotDeployed() throws URISyntaxException, IOException, JBoss7ManangementException {
+ String deploymentName = "testDeployment";
+ try {
+ manager.getDeploymentState(deploymentName);
+ } finally {
+ AS7ManagerTestUtils.quietlyUndeploy(deploymentName, manager);
+ }
+ }
+}
Property changes on: trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/AS7ManagerIntegrationTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Copied: trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/AS7ManagerTestUtils.java (from rev 30773, trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/JBossManagementTestUtils.java)
===================================================================
--- trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/AS7ManagerTestUtils.java (rev 0)
+++ trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/AS7ManagerTestUtils.java 2011-04-23 11:48:01 UTC (rev 30802)
@@ -0,0 +1,141 @@
+/*
+ * 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.as.management.as7.tests;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+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 org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
+import org.jboss.ide.eclipse.as.core.server.internal.v7.JBoss7ManangementException;
+import org.jboss.ide.eclipse.as.core.server.internal.v7.IJBoss7DeploymentResult;
+import org.jboss.ide.eclipse.as.management.as7.deployment.AS7Manager;
+import org.osgi.framework.Bundle;
+
+/**
+ * @author André Dietisheim
+ */
+public class AS7ManagerTestUtils {
+
+ public static final String GWT_HELLOWORLD_WAR = "gwt-helloworld.war";
+ public static final String MINIMALISTIC_WAR = "minimalistic.war";
+
+ public static final String HOST = "localhost";
+ public static final int MGMT_PORT = 9999;
+ public static final int WEB_PORT = 8080;
+
+ private static final String WAR_FOLDER = "/wars/";
+ private static final String BUNDLE_ID = "org.jboss.ide.eclipse.as.management.as7.tests";
+
+ private static final int RESPONSE_TIMEOUT = 10 * 1024;
+ private static final long WAIT_TIMEOUT = 10 * 1024;
+
+ public static 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());
+ }
+
+ public static String waitForRespose(String name, String host, int port) throws IOException {
+ waitForResponseCode(200, name, host, port);
+ return getResponse(name, host, port);
+ }
+
+ public static void quietlyUndeploy(File file, AS7Manager manager) {
+ quietlyUndeploy(file.getName(), manager);
+ }
+
+ public static void quietlyUndeploy(String name, AS7Manager manager) {
+ try {
+ // DetypedDeployer.undeploy(name, AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.MGMT_PORT);
+ waitUntilFinished(manager.undeploy(name));
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ public static void quietlyRemove(String name, AS7Manager manager) {
+ try {
+ //DetypedDeployer.remove(name, AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.MGMT_PORT);
+ waitUntilFinished(manager.remove(name));
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ public static void waitUntilFinished(IJBoss7DeploymentResult result) throws JBoss7ManangementException {
+ result.getStatus(); // wait for operation to finish
+ }
+
+
+ public static String getResponse(String name, String host, int port) throws IOException {
+ URL url = new URL("http://" + host + ":" + port + "/" + name);
+ HttpURLConnection connection = connect(url);
+ return toString(new BufferedInputStream(connection.getInputStream()));
+ }
+
+ public static HttpURLConnection waitForResponseCode(int code, String name, String host, int port)
+ throws IOException {
+ URL url = new URL("http://" + host + ":" + port + "/" + name);
+ long until = System.currentTimeMillis() + WAIT_TIMEOUT;
+ while (System.currentTimeMillis() < until) {
+ HttpURLConnection connection = connect(url);
+ try {
+ if (connection.getResponseCode() == code) {
+ return connection;
+ }
+ } catch (FileNotFoundException e) {
+ if (code == 404) {
+ return connection;
+ }
+ throw e;
+ }
+ }
+ throw new RuntimeException("wait on url " + url + " for response code " + code + " timed out.");
+ }
+
+ private static HttpURLConnection connect(URL url) throws IOException {
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setUseCaches(false);
+ connection.setDoInput(true);
+ connection.setAllowUserInteraction(false);
+ connection.setConnectTimeout(RESPONSE_TIMEOUT);
+ connection.setInstanceFollowRedirects(true);
+ connection.setDoOutput(false);
+ return connection;
+ }
+
+ public static String toString(InputStream in) throws IOException {
+ StringWriter writer = new StringWriter();
+ for (int data = -1; ((data = in.read()) != -1);) {
+ writer.write(data);
+ }
+ return writer.toString();
+ }
+}
Property changes on: trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/AS7ManagerTestUtils.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/DetypedDeployerIntegrationTest.java
===================================================================
--- trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/DetypedDeployerIntegrationTest.java 2011-04-23 05:50:30 UTC (rev 30801)
+++ trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/DetypedDeployerIntegrationTest.java 2011-04-23 11:48:01 UTC (rev 30802)
@@ -40,11 +40,11 @@
@Test
public void canDeploy() throws Exception {
- File warFile = JBossManagementTestUtils.getWarFile(JBossManagementTestUtils.MINIMALISTIC_WAR);
+ File warFile = AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.MINIMALISTIC_WAR);
try {
- DetypedDeployer.deploy(warFile, JBossManagementTestUtils.HOST, JBossManagementTestUtils.MGMT_PORT);
+ DetypedDeployer.deploy(warFile, AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.MGMT_PORT);
- String response = JBossManagementTestUtils.waitForRespose("minimalistic", JBossManagementTestUtils.HOST, JBossManagementTestUtils.WEB_PORT);
+ String response = AS7ManagerTestUtils.waitForRespose("minimalistic", AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.WEB_PORT);
assertTrue(response.indexOf("minimalistic") >= 0);
} finally {
@@ -54,10 +54,10 @@
@Test(expected = JBoss7ManangementException.class)
public void cannotDeployWarTwice() throws Exception {
- File warFile = JBossManagementTestUtils.getWarFile(JBossManagementTestUtils.MINIMALISTIC_WAR);
+ File warFile = AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.MINIMALISTIC_WAR);
try {
- DetypedDeployer.deploy(warFile, JBossManagementTestUtils.HOST, JBossManagementTestUtils.MGMT_PORT);
- DetypedDeployer.deploy(warFile, JBossManagementTestUtils.HOST, JBossManagementTestUtils.MGMT_PORT);
+ DetypedDeployer.deploy(warFile, AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.MGMT_PORT);
+ DetypedDeployer.deploy(warFile, AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.MGMT_PORT);
} finally {
quietlyUndeploy(warFile);
}
@@ -65,14 +65,14 @@
@Test
public void canReplaceWar() throws Exception {
- File warFile = JBossManagementTestUtils.getWarFile(JBossManagementTestUtils.MINIMALISTIC_WAR);
- File warFile2 = JBossManagementTestUtils.getWarFile(JBossManagementTestUtils.GWT_HELLOWORLD_WAR);
+ File warFile = AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.MINIMALISTIC_WAR);
+ File warFile2 = AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.GWT_HELLOWORLD_WAR);
String name = warFile.getName();
try {
- DetypedDeployer.deploy(name, warFile, JBossManagementTestUtils.HOST, JBossManagementTestUtils.MGMT_PORT);
- DetypedDeployer.replace(name, warFile2, JBossManagementTestUtils.HOST, JBossManagementTestUtils.MGMT_PORT);
- String response = JBossManagementTestUtils.waitForRespose(
- "minimalistic", JBossManagementTestUtils.HOST, JBossManagementTestUtils.WEB_PORT);
+ DetypedDeployer.deploy(name, warFile, AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.MGMT_PORT);
+ DetypedDeployer.replace(name, warFile2, AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.MGMT_PORT);
+ String response = AS7ManagerTestUtils.waitForRespose(
+ "minimalistic", AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.WEB_PORT);
assertTrue(response.indexOf("GWT") >= 0);
} finally {
quietlyUndeploy(warFile);
@@ -81,19 +81,19 @@
@Test(expected = JBoss7ManangementException.class)
public void cannotUndeployNondeployed() throws JBoss7ManangementException {
- DetypedDeployer.undeploy("inexistant", JBossManagementTestUtils.HOST, JBossManagementTestUtils.MGMT_PORT);
+ DetypedDeployer.undeploy("inexistant", AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.MGMT_PORT);
}
@Test
public void canQueryDeploymentdeployedState() throws Exception {
- File warFile = JBossManagementTestUtils.getWarFile(JBossManagementTestUtils.MINIMALISTIC_WAR);
- File warFile2 = JBossManagementTestUtils.getWarFile(JBossManagementTestUtils.GWT_HELLOWORLD_WAR);
+ File warFile = AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.MINIMALISTIC_WAR);
+ File warFile2 = AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.GWT_HELLOWORLD_WAR);
try {
- DetypedDeployer.deploy(warFile, JBossManagementTestUtils.HOST, JBossManagementTestUtils.MGMT_PORT);
- DetypedDeployer.deploy(warFile2, JBossManagementTestUtils.HOST, JBossManagementTestUtils.MGMT_PORT);
- List<String> deployments = DetypedDeployer.getDeployments(JBossManagementTestUtils.HOST, JBossManagementTestUtils.MGMT_PORT);
+ DetypedDeployer.deploy(warFile, AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.MGMT_PORT);
+ DetypedDeployer.deploy(warFile2, AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.MGMT_PORT);
+ List<String> deployments = DetypedDeployer.getDeployments(AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.MGMT_PORT);
assertThat(deployments.size(), is(2));
- assertThat(deployments, hasItems(JBossManagementTestUtils.MINIMALISTIC_WAR, JBossManagementTestUtils.GWT_HELLOWORLD_WAR));
+ assertThat(deployments, hasItems(AS7ManagerTestUtils.MINIMALISTIC_WAR, AS7ManagerTestUtils.GWT_HELLOWORLD_WAR));
} finally {
quietlyUndeploy(warFile);
quietlyUndeploy(warFile2);
@@ -102,7 +102,7 @@
private void quietlyUndeploy(File file) {
try {
- DetypedDeployer.undeploy(file.getName(), JBossManagementTestUtils.HOST, JBossManagementTestUtils.MGMT_PORT);
+ DetypedDeployer.undeploy(file.getName(), AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.MGMT_PORT);
} catch (Exception e) {
e.printStackTrace();
// ignore
Modified: trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/JBossManagementIntegrationTest.java
===================================================================
--- trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/JBossManagementIntegrationTest.java 2011-04-23 05:50:30 UTC (rev 30801)
+++ trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/JBossManagementIntegrationTest.java 2011-04-23 11:48:01 UTC (rev 30802)
@@ -50,7 +50,7 @@
@Before
public void setUp() throws UnknownHostException {
- this.manager = new AS7Manager(JBossManagementTestUtils.HOST, JBossManagementTestUtils.MGMT_PORT);
+ this.manager = new AS7Manager(AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.MGMT_PORT);
}
@After
@@ -61,97 +61,97 @@
@Ignore
@Test
public void canDeploy() throws Exception {
- File warFile = JBossManagementTestUtils.getWarFile(JBossManagementTestUtils.MINIMALISTIC_WAR);
+ File warFile = AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.MINIMALISTIC_WAR);
try {
- JBossManagementTestUtils.waitUntilFinished(manager.deploy(warFile));
+ AS7ManagerTestUtils.waitUntilFinished(manager.deploy(warFile));
- String response = JBossManagementTestUtils.waitForRespose(
- "minimalistic", JBossManagementTestUtils.HOST, JBossManagementTestUtils.WEB_PORT);
+ String response = AS7ManagerTestUtils.waitForRespose(
+ "minimalistic", AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.WEB_PORT);
assertTrue(response != null
&& response.indexOf("minimalistic") >= 0);
} finally {
- JBossManagementTestUtils.quietlyUndeploy(warFile, manager);
+ AS7ManagerTestUtils.quietlyUndeploy(warFile, manager);
}
}
@Ignore
@Test
public void deployedWarIsResponding() throws Exception {
- File warFile = JBossManagementTestUtils.getWarFile(JBossManagementTestUtils.MINIMALISTIC_WAR);
+ File warFile = AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.MINIMALISTIC_WAR);
try {
- JBossManagementTestUtils.waitUntilFinished(manager.deploy(warFile));
+ AS7ManagerTestUtils.waitUntilFinished(manager.deploy(warFile));
- String response = JBossManagementTestUtils.waitForRespose(
- "minimalistic", JBossManagementTestUtils.HOST, JBossManagementTestUtils.WEB_PORT);
+ String response = AS7ManagerTestUtils.waitForRespose(
+ "minimalistic", AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.WEB_PORT);
assertTrue(response != null
&& response.indexOf("minimalistic") >= 0);
} finally {
- JBossManagementTestUtils.quietlyUndeploy(warFile, manager);
+ AS7ManagerTestUtils.quietlyUndeploy(warFile, manager);
}
}
@Ignore
@Test(expected = JBoss7ManangementException.class)
public void cannotDeployWarTwice() throws Exception {
- File warFile = JBossManagementTestUtils.getWarFile(JBossManagementTestUtils.MINIMALISTIC_WAR);
+ File warFile = AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.MINIMALISTIC_WAR);
try {
- JBossManagementTestUtils.waitUntilFinished(manager.deploy(warFile));
- JBossManagementTestUtils.waitUntilFinished(manager.deploy(warFile));
+ AS7ManagerTestUtils.waitUntilFinished(manager.deploy(warFile));
+ AS7ManagerTestUtils.waitUntilFinished(manager.deploy(warFile));
} finally {
- JBossManagementTestUtils.quietlyUndeploy(warFile, manager);
+ AS7ManagerTestUtils.quietlyUndeploy(warFile, manager);
}
}
@Ignore
@Test(expected = JBoss7ManangementException.class)
public void cannotUndeployNondeployed() throws JBoss7ManangementException, InterruptedException, ExecutionException {
- JBossManagementTestUtils.waitUntilFinished(manager.undeploy("inexistant"));
+ AS7ManagerTestUtils.waitUntilFinished(manager.undeploy("inexistant"));
}
@Ignore
@Test
public void canReplaceWar() throws Exception {
- File warFile = JBossManagementTestUtils.getWarFile(JBossManagementTestUtils.MINIMALISTIC_WAR);
- File warFile2 = JBossManagementTestUtils.getWarFile(JBossManagementTestUtils.GWT_HELLOWORLD_WAR);
+ File warFile = AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.MINIMALISTIC_WAR);
+ File warFile2 = AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.GWT_HELLOWORLD_WAR);
String name = warFile.getName();
try {
- JBossManagementTestUtils.waitUntilFinished(manager.deploy(name, warFile));
- JBossManagementTestUtils.waitUntilFinished(manager.replace(name, warFile2));
- String response = JBossManagementTestUtils.waitForRespose(
- "minimalistic", JBossManagementTestUtils.HOST, JBossManagementTestUtils.WEB_PORT);
+ AS7ManagerTestUtils.waitUntilFinished(manager.deploy(name, warFile));
+ AS7ManagerTestUtils.waitUntilFinished(manager.replace(name, warFile2));
+ String response = AS7ManagerTestUtils.waitForRespose(
+ "minimalistic", AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.WEB_PORT);
assertTrue(response != null
&& response.indexOf("GWT") >= 0);
} finally {
- JBossManagementTestUtils.quietlyUndeploy(name, manager);
+ AS7ManagerTestUtils.quietlyUndeploy(name, manager);
}
}
@Test
public void getEnabledStateIfDeploymentIsDeployed() throws URISyntaxException, IOException, JBoss7ManangementException {
String deploymentName = "testDeployment";
- File warFile = JBossManagementTestUtils.getWarFile(JBossManagementTestUtils.MINIMALISTIC_WAR);
+ File warFile = AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.MINIMALISTIC_WAR);
try {
- JBossManagementTestUtils.waitUntilFinished(manager.deploy(deploymentName, warFile));
+ AS7ManagerTestUtils.waitUntilFinished(manager.deploy(deploymentName, warFile));
JBoss7DeploymentState state = manager.getDeploymentState(deploymentName);
assertNotNull(state);
assertThat(state, equalTo(JBoss7DeploymentState.STARTED));
} finally {
- JBossManagementTestUtils.quietlyUndeploy(deploymentName, manager);
+ AS7ManagerTestUtils.quietlyUndeploy(deploymentName, manager);
}
}
@Test
public void getDisabledStateIfDeploymentIsOnlyAdded() throws URISyntaxException, IOException, JBoss7ManangementException {
String deploymentName = "testDeployment";
- File warFile = JBossManagementTestUtils.getWarFile(JBossManagementTestUtils.MINIMALISTIC_WAR);
+ File warFile = AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.MINIMALISTIC_WAR);
try {
- JBossManagementTestUtils.waitUntilFinished(manager.add(deploymentName, warFile));
+ AS7ManagerTestUtils.waitUntilFinished(manager.add(deploymentName, warFile));
JBoss7DeploymentState state = manager.getDeploymentState(deploymentName);
assertNotNull(state);
assertThat(state, equalTo(JBoss7DeploymentState.STOPPED));
} finally {
- JBossManagementTestUtils.quietlyRemove(deploymentName, manager);
+ AS7ManagerTestUtils.quietlyRemove(deploymentName, manager);
}
}
@@ -161,7 +161,7 @@
try {
manager.getDeploymentState(deploymentName);
} finally {
- JBossManagementTestUtils.quietlyUndeploy(deploymentName, manager);
+ AS7ManagerTestUtils.quietlyUndeploy(deploymentName, manager);
}
}
}
Deleted: trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/JBossManagementTestUtils.java
===================================================================
--- trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/JBossManagementTestUtils.java 2011-04-23 05:50:30 UTC (rev 30801)
+++ trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/JBossManagementTestUtils.java 2011-04-23 11:48:01 UTC (rev 30802)
@@ -1,141 +0,0 @@
-/*
- * 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.as.management.as7.tests;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-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 org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Platform;
-import org.jboss.ide.eclipse.as.core.server.internal.v7.JBoss7ManangementException;
-import org.jboss.ide.eclipse.as.core.server.internal.v7.IJBoss7DeploymentResult;
-import org.jboss.ide.eclipse.as.management.as7.deployment.AS7Manager;
-import org.osgi.framework.Bundle;
-
-/**
- * @author André Dietisheim
- */
-public class JBossManagementTestUtils {
-
- public static final String GWT_HELLOWORLD_WAR = "gwt-helloworld.war";
- public static final String MINIMALISTIC_WAR = "minimalistic.war";
-
- public static final String HOST = "localhost";
- public static final int MGMT_PORT = 9999;
- public static final int WEB_PORT = 8080;
-
- private static final String WAR_FOLDER = "/wars/";
- private static final String BUNDLE_ID = "org.jboss.ide.eclipse.as.management.as7.tests";
-
- private static final int RESPONSE_TIMEOUT = 10 * 1024;
- private static final long WAIT_TIMEOUT = 10 * 1024;
-
- public static 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());
- }
-
- public static String waitForRespose(String name, String host, int port) throws IOException {
- waitForResponseCode(200, name, host, port);
- return getResponse(name, host, port);
- }
-
- public static void quietlyUndeploy(File file, AS7Manager manager) {
- quietlyUndeploy(file.getName(), manager);
- }
-
- public static void quietlyUndeploy(String name, AS7Manager manager) {
- try {
- // DetypedDeployer.undeploy(name, JBossManagementTestUtils.HOST, JBossManagementTestUtils.MGMT_PORT);
- waitUntilFinished(manager.undeploy(name));
- } catch (Exception e) {
- // ignore
- }
- }
-
- public static void quietlyRemove(String name, AS7Manager manager) {
- try {
- //DetypedDeployer.remove(name, JBossManagementTestUtils.HOST, JBossManagementTestUtils.MGMT_PORT);
- waitUntilFinished(manager.remove(name));
- } catch (Exception e) {
- // ignore
- }
- }
-
- public static void waitUntilFinished(IJBoss7DeploymentResult result) throws JBoss7ManangementException {
- result.getStatus(); // wait for operation to finish
- }
-
-
- public static String getResponse(String name, String host, int port) throws IOException {
- URL url = new URL("http://" + host + ":" + port + "/" + name);
- HttpURLConnection connection = connect(url);
- return toString(new BufferedInputStream(connection.getInputStream()));
- }
-
- public static HttpURLConnection waitForResponseCode(int code, String name, String host, int port)
- throws IOException {
- URL url = new URL("http://" + host + ":" + port + "/" + name);
- long until = System.currentTimeMillis() + WAIT_TIMEOUT;
- while (System.currentTimeMillis() < until) {
- HttpURLConnection connection = connect(url);
- try {
- if (connection.getResponseCode() == code) {
- return connection;
- }
- } catch (FileNotFoundException e) {
- if (code == 404) {
- return connection;
- }
- throw e;
- }
- }
- throw new RuntimeException("wait on url " + url + " for response code " + code + " timed out.");
- }
-
- private static HttpURLConnection connect(URL url) throws IOException {
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setUseCaches(false);
- connection.setDoInput(true);
- connection.setAllowUserInteraction(false);
- connection.setConnectTimeout(RESPONSE_TIMEOUT);
- connection.setInstanceFollowRedirects(true);
- connection.setDoOutput(false);
- return connection;
- }
-
- public static String toString(InputStream in) throws IOException {
- StringWriter writer = new StringWriter();
- for (int data = -1; ((data = in.read()) != -1);) {
- writer.write(data);
- }
- return writer.toString();
- }
-}
More information about the jbosstools-commits
mailing list