performWsdlUriSchemeAttributeTest(true);
}
private void performWsdlUriSchemeAttributeTest(boolean checkUpdateWithDeployedEndpoint) throws Exception {
Assert.assertTrue(containerController.isStarted(DEFAULT_JBOSSAS));
ManagementClient managementClient = new ManagementClient(TestSuiteEnvironment.getModelControllerClient(),
TestSuiteEnvironment.getServerAddress(), TestSuiteEnvironment.getServerPort(), "http-remoting");
ModelControllerClient client = managementClient.getControllerClient();
String initialWsdlUriScheme = null;
try {
//save initial wsdl-uri-schema value to restore later
initialWsdlUriScheme = getAttribute("wsdl-uri-scheme", client, false);
//set wsdl-uri-scheme value to https
ModelNode op = createOpNode("subsystem=webservices/", WRITE_ATTRIBUTE_OPERATION);
op.get(NAME).set("wsdl-uri-scheme");
op.get(VALUE).set("https");
applyUpdate(client, op, false);
deployer.deploy(DEP_1);
//check if it works for the deployed endpoint url
checkWSDLUriScheme(client, DEP_1 + ".war", "https");
deployer.undeploy(DEP_1);
//set wsdl-uri-scheme value to http
ModelNode op2 = createOpNode("subsystem=webservices/", WRITE_ATTRIBUTE_OPERATION);
op2.get(NAME).set("wsdl-uri-scheme");
op2.get(VALUE).set("http");
applyUpdate(client, op2, false);
deployer.deploy(DEP_1);
//check if the uri scheme of soap address is modified to http
checkWSDLUriScheme(client, DEP_1 + ".war", "http");
if (checkUpdateWithDeployedEndpoint) {
//set wsdl-uri-schema value to http
ModelNode opB = createOpNode("subsystem=webservices/", WRITE_ATTRIBUTE_OPERATION);
opB.get(NAME).set("wsdl-uri-scheme");
opB.get(VALUE).set("https");
applyUpdate(client, opB, true);
//check this doesn't apply to endpointed which are deployed before this change
checkWSDLUriScheme(client, DEP_1 + ".war", "http");
deployer.undeploy(DEP_1);
deployer.deploy(DEP_1);
//check this will take effect to redeployed endpoint
checkWSDLUriScheme(client, DEP_1 + ".war", "http");
}
} finally {
try {
deployer.undeploy(DEP_1);
} catch (Throwable t) {
//ignore
}
try {
//restore the value of wsdl-uri-scheme attribute
ModelNode op = null;
if ("undefined".equals(initialWsdlUriScheme)) {
op = createOpNode("subsystem=webservices/", UNDEFINE_ATTRIBUTE_OPERATION);
op.get(NAME).set("wsdl-uri-scheme");
} else {
op = createOpNode("subsystem=webservices/", WRITE_ATTRIBUTE_OPERATION);
op.get(NAME).set("wsdl-uri-scheme");
op.get(VALUE).set(initialWsdlUriScheme);
}
applyUpdate(client, op, checkUpdateWithDeployedEndpoint);
} finally {
managementClient.close();
}
}
}