/**
* Test for AS7-3643
*/
@Test
public void testCanFindServerRestartRequiredAfterChangingSocketBindingPortOffset() throws Exception {
final DomainClient masterClient = domainMasterLifecycleUtil.getDomainClient();
ModelNode read = new ModelNode();
read.get(OP).set(READ_ATTRIBUTE_OPERATION);
read.get(OP_ADDR).add(HOST, "master").add(SERVER_CONFIG, "main-one");
read.get(NAME).set("socket-binding-port-offset");
ModelNode result = validateResponse(masterClient.execute(read));
int original = result.isDefined() ? result.asInt() : 0;
//The bug causing AS7-3643 caused execution of this op to fail
ModelNode write = new ModelNode();
write.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
write.get(OP_ADDR).add(HOST, "master").add(SERVER_CONFIG, "main-one");
write.get(NAME).set("socket-binding-port-offset");
write.get(VALUE).set(original + 1);
ModelNode response = masterClient.execute(write);
validateResponse(response);
final String mainServerGroup = "main-server-group";
Assert.assertEquals(SUCCESS, response.get(SERVER_GROUPS, mainServerGroup, "main-one", RESPONSE, OUTCOME).asString());
ModelNode headers = response.get(SERVER_GROUPS, mainServerGroup, "main-one", RESPONSE, RESPONSE_HEADERS);
Assert.assertEquals(RESTART_REQUIRED, headers.get(PROCESS_STATE).asString());
Assert.assertTrue(RESTART_REQUIRED, headers.get(OPERATION_REQUIRES_RESTART).asBoolean());
//Now just set back to the original
write.get(VALUE).set(original);
validateResponse(masterClient.execute(write));
}