Author: adietish
Date: 2011-11-10 05:50:03 -0500 (Thu, 10 Nov 2011)
New Revision: 36271
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/internal/management/as7/AS7Manager.java
trunk/as/tests/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/internal/management/as7/tests/AS7ManagerIntegrationTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/internal/management/as7/tests/utils/AS7ManagerTestUtils.java
Log:
[JBIDE-9239] started implementing AS7Manager#addDeploymentDir
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/internal/management/as7/AS7Manager.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/internal/management/as7/AS7Manager.java 2011-11-10
08:44:44 UTC (rev 36270)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/internal/management/as7/AS7Manager.java 2011-11-10
10:50:03 UTC (rev 36271)
@@ -31,7 +31,6 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.concurrent.CancellationException;
import java.util.concurrent.Future;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -144,9 +143,9 @@
* @throws JBoss7ManangerException
*/
public JBoss7DeploymentState getDeploymentStateSafe(String name) throws
JBoss7ManangerException {
- if( !getDeploymentNames().contains(name))
+ if( hasDeployment(name)) {
return JBoss7DeploymentState.NOT_FOUND;
-
+ }
return getDeploymentState(name);
}
@@ -182,6 +181,11 @@
}
}
+ public void addDeploymentDirectory(String path) {
+
+ }
+
+
/**
* Shuts the server down.
*
@@ -277,19 +281,18 @@
return op;
}
- private Set<String> getDeploymentNames() throws CancellationException {
+ public boolean hasDeployment(String name) throws JBoss7ManangerException {
+ return getDeploymentNames().contains(name);
+ }
+
+ private Set<String> getDeploymentNames() throws JBoss7ManangerException {
final ModelNode op = getEmptyOperation(READ_CHILDREN_NAMES_OPERATION, new
ModelNode());
op.get(CHILD_TYPE).set(DEPLOYMENT);
- ModelNode response;
- try {
- response = client.execute(op);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- final ModelNode result = response.get(RESULT);
- final Set<String> deploymentNames = new HashSet<String>();
+ ModelNode response = execute(op);
+ ModelNode result = response.get(RESULT);
+ Set<String> deploymentNames = new HashSet<String>();
if (result.isDefined()) {
- final List<ModelNode> deploymentNodes = result.asList();
+ final List<ModelNode> deploymentNodes = result.asList();
for (ModelNode node : deploymentNodes) {
deploymentNames.add(node.asString());
}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/internal/management/as7/tests/AS7ManagerIntegrationTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/internal/management/as7/tests/AS7ManagerIntegrationTest.java 2011-11-10
08:44:44 UTC (rev 36270)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/internal/management/as7/tests/AS7ManagerIntegrationTest.java 2011-11-10
10:50:03 UTC (rev 36271)
@@ -43,10 +43,10 @@
@Before
public void setUp() throws IOException {
- assertTrue("There is no server at " + AS7ManagerTestUtils.HOST +
+ assertTrue("There is no server at " + AS7ManagerTestUtils.LOCALHOST +
" that listens on port " + AS7Manager.MGMT_PORT,
- AS7ManagerTestUtils.isListening(AS7ManagerTestUtils.HOST, AS7Manager.MGMT_PORT));
- this.manager = new AS7Manager(AS7ManagerTestUtils.HOST, AS7Manager.MGMT_PORT);
+ AS7ManagerTestUtils.isListening(AS7ManagerTestUtils.LOCALHOST,
AS7Manager.MGMT_PORT));
+ this.manager = new AS7Manager(AS7ManagerTestUtils.LOCALHOST, AS7Manager.MGMT_PORT);
}
@After
@@ -62,7 +62,7 @@
AS7ManagerTestUtils.waitUntilFinished(manager.deploy(warFile));
String response = AS7ManagerTestUtils.waitForRespose(
- "minimalistic", AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.WEB_PORT);
+ "minimalistic", AS7ManagerTestUtils.LOCALHOST,
AS7ManagerTestUtils.WEB_PORT);
assertTrue(response != null
&& response.indexOf("minimalistic") >= 0);
} finally {
@@ -78,7 +78,7 @@
AS7ManagerTestUtils.waitUntilFinished(manager.deploy(warFile));
String response = AS7ManagerTestUtils.waitForRespose(
- "minimalistic", AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.WEB_PORT);
+ "minimalistic", AS7ManagerTestUtils.LOCALHOST,
AS7ManagerTestUtils.WEB_PORT);
assertTrue(response != null
&& response.indexOf("minimalistic") >= 0);
@@ -115,7 +115,7 @@
AS7ManagerTestUtils.waitUntilFinished(manager.deploy(name, warFile));
AS7ManagerTestUtils.waitUntilFinished(manager.replace(name, warFile2));
String response = AS7ManagerTestUtils.waitForRespose(
- "minimalistic", AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.WEB_PORT);
+ "minimalistic", AS7ManagerTestUtils.LOCALHOST,
AS7ManagerTestUtils.WEB_PORT);
assertTrue(response != null
&& response.indexOf("GWT") >= 0);
} finally {
@@ -162,7 +162,23 @@
}
}
+ @Ignore
@Test
+ public void canAddDeploymentDirectory() throws URISyntaxException, IOException,
JBoss7ManangerException {
+ String deploymentName = getRandomDeploymentName();
+ File warFile = AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.MINIMALISTIC_WAR);
+ try {
+ assertFalse(manager.hasDeployment(deploymentName));
+ File deploymentDir = new File(System.getProperty("java.io.tmpdir"),
"as7dir");
+ manager.addDeploymentDirectory(deploymentDir.getAbsolutePath());
+
+ AS7ManagerTestUtils.waitForResponseCode(200, deploymentName,
AS7ManagerTestUtils.LOCALHOST, AS7ManagerTestUtils.WEB_PORT);
+ } finally {
+ AS7ManagerTestUtils.quietlyRemove(deploymentName, manager);
+ }
+ }
+
+ @Test
public void canGetServerState() throws JBoss7ManangerException {
assertEquals(JBoss7ServerState.RUNNING, manager.getServerState());
}
@@ -171,8 +187,10 @@
public void canStopServer() throws JBoss7ManangerException, UnknownHostException,
IOException {
manager.stopServer();
assertFalse(
- AS7ManagerTestUtils.isListening(AS7ManagerTestUtils.HOST, AS7Manager.MGMT_PORT));
+ AS7ManagerTestUtils.isListening(AS7ManagerTestUtils.LOCALHOST,
AS7Manager.MGMT_PORT));
}
-
+ private String getRandomDeploymentName() {
+ return String.valueOf(System.currentTimeMillis());
+ }
}
\ No newline at end of file
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/internal/management/as7/tests/utils/AS7ManagerTestUtils.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/internal/management/as7/tests/utils/AS7ManagerTestUtils.java 2011-11-10
08:44:44 UTC (rev 36270)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/internal/management/as7/tests/utils/AS7ManagerTestUtils.java 2011-11-10
10:50:03 UTC (rev 36271)
@@ -38,7 +38,7 @@
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 String LOCALHOST = "localhost";
public static final int WEB_PORT = 8080;
private static final String WAR_FOLDER = "/wars/";
@@ -68,7 +68,7 @@
public static void quietlyUndeploy(String name, AS7Manager manager) {
try {
- // DetypedDeployer.undeploy(name, AS7ManagerTestUtils.HOST,
+ // DetypedDeployer.undeploy(name, AS7ManagerTestUtils.LOCALHOST,
// AS7ManagerTestUtils.MGMT_PORT);
waitUntilFinished(manager.undeploy(name));
} catch (Exception e) {
@@ -78,7 +78,7 @@
public static void quietlyRemove(String name, AS7Manager manager) {
try {
- // DetypedDeployer.remove(name, AS7ManagerTestUtils.HOST,
+ // DetypedDeployer.remove(name, AS7ManagerTestUtils.LOCALHOST,
// AS7ManagerTestUtils.MGMT_PORT);
waitUntilFinished(manager.remove(name));
} catch (Exception e) {