ModelNode op = createOpNode(null, "reload");
op.get(ADMIN_ONLY).set(true);
ModelNode result = executeOperation(op);
// wait until the server is admin-only mode
RetryTaskExecutor rte = new RetryTaskExecutor();
rte.retryTask(new Callable<ModelNode>() {
public ModelNode call() throws Exception {
ModelNode rop = createOpNode(null, READ_ATTRIBUTE_OPERATION);
rop.get(NAME).set("running-mode");
ModelNode mode = executeOperation(rop);
if (! mode.asString().equals("ADMIN_ONLY")) throw new Exception ("Wrong mode.");
return mode;
}
});
// check that the server is unreachable
Assert.assertFalse("Could not connect to created connector.",WebUtil.testHttpURL(new URL(
"http", url.getHost(), url.getPort(), "/").toString()));
// update the model in admin-only mode - add a web connector
op = createOpNode("socket-binding-group=standard-sockets/socket-binding=test-binding", ADD);
op.get("interface").set("public");
op.get("port").set(TEST_PORT);
result = executeOperation(op);
op = createOpNode("subsystem=web/connector=test", ADD);
op.get("socket-binding").set("test-binding");
op.get("protocol").set("HTTP/1.1");
op.get("scheme").set("http");
result = executeOperation(op);
// restart the server back to normal mode
op = createOpNode(null, "reload");
op.get(ADMIN_ONLY).set(false);
result = executeOperation(op);
// wait until the server is in normal mode
rte = new RetryTaskExecutor();
rte.retryTask(new Callable<ModelNode>() {
public ModelNode call() throws Exception {
ModelNode rop = createOpNode(null, READ_ATTRIBUTE_OPERATION);
rop.get(NAME).set("running-mode");
ModelNode mode = executeOperation(rop);
if (! mode.asString().equals("NORMAL")) throw new Exception ("Wrong mode.");