Author: asoldano
Date: 2014-10-01 06:51:22 -0400 (Wed, 01 Oct 2014)
New Revision: 18958
Modified:
container/wildfly81/branches/jbossws-wildfly810/tests-integration/src/main/java/org/jboss/as/webservices/deployer/RemoteDeployer.java
Log:
[JBWS-3835] Add mechanism for restarting target container while running JBossWS tests
Modified:
container/wildfly81/branches/jbossws-wildfly810/tests-integration/src/main/java/org/jboss/as/webservices/deployer/RemoteDeployer.java
===================================================================
---
container/wildfly81/branches/jbossws-wildfly810/tests-integration/src/main/java/org/jboss/as/webservices/deployer/RemoteDeployer.java 2014-10-01
10:50:21 UTC (rev 18957)
+++
container/wildfly81/branches/jbossws-wildfly810/tests-integration/src/main/java/org/jboss/as/webservices/deployer/RemoteDeployer.java 2014-10-01
10:51:22 UTC (rev 18958)
@@ -71,9 +71,11 @@
import static
org.jboss.as.controller.descriptions.ModelDescriptionConstants.RELEASE_VERSION;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REMOVE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REQUIRED;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RESTART;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RESULT;
import static
org.jboss.as.controller.descriptions.ModelDescriptionConstants.ROLLBACK_ON_RUNTIME_FAILURE;
import static
org.jboss.as.controller.descriptions.ModelDescriptionConstants.SERVER_IDENTITY;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SHUTDOWN;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SSL;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.STEPS;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM;
@@ -417,6 +419,15 @@
}
@Override
+ public void restart() throws Exception {
+ ModelNode op = new ModelNode();
+ op.get("operation").set(SHUTDOWN);
+ op.get(RESTART).set("true");
+ applyUpdate(op);
+ waitForServerToRestart(TIMEOUT);
+ }
+
+ @Override
public String setSystemProperty(String propName, String propValue) throws Exception
{
if (propName == null || propName.trim().length() == 0) {
throw new IllegalArgumentException("Empty system property name
specified!");
@@ -520,6 +531,36 @@
return op;
}
+ private void waitForServerToRestart(int timeout) throws Exception {
+ Thread.sleep(1000);
+ long start = System.currentTimeMillis();
+ long now;
+ do {
+ final ModelControllerClient client = newModelControllerClient(timeout / 10);
+ ModelNode operation = new ModelNode();
+ operation.get(OP_ADDR).setEmptyList();
+ operation.get(OP).set(READ_ATTRIBUTE_OPERATION);
+ operation.get(NAME).set("server-state");
+ try {
+ ModelNode result = client.execute(operation);
+ boolean normal =
"running".equals(result.get(RESULT).asString());
+ if (normal) {
+ return;
+ }
+ } catch (Exception e) {
+ //NOOP
+ } finally {
+ client.close();
+ }
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ }
+ now = System.currentTimeMillis();
+ } while (now - start < timeout);
+ throw new Exception("Server did not restart!");
+ }
+
private static String getSystemProperty(final String name, final String defaultValue)
{
PrivilegedAction<String> action = new PrivilegedAction<String>() {
public String run() {
@@ -530,9 +571,13 @@
}
private static ModelControllerClient newModelControllerClient() throws Exception {
- return ModelControllerClient.Factory.create(protocol, address.getHostAddress(),
port, callbackHandler, null, TIMEOUT);
+ return newModelControllerClient(TIMEOUT);
}
+ private static ModelControllerClient newModelControllerClient(int timeout) throws
Exception {
+ return ModelControllerClient.Factory.create(protocol, address.getHostAddress(),
port, callbackHandler, null, timeout);
+ }
+
private static ServerDeploymentManager newDeploymentManager(ModelControllerClient
client) throws Exception {
return ServerDeploymentManager.Factory.create(client);
}
Show replies by date