DomainTestSuite.stopSupport();
}
@Test
public void testSystemPropertyManagement() throws IOException {
DomainClient masterClient = domainMasterLifecycleUtil.getDomainClient();
DomainClient slaveClient = domainSlaveLifecycleUtil.getDomainClient();
ModelNode response = masterClient.execute(getReadChildrenNamesOperation(MAIN_RUNNING_SERVER_ADDRESS, SYSTEM_PROPERTY));
ModelNode returnVal = validateResponse(response);
int origPropCount = returnVal.asInt();
ModelNode request = getSystemPropertyAddOperation(ROOT_PROP_ADDRESS, "domain", Boolean.FALSE);
response = masterClient.execute(request);
validateResponse(response);
// TODO validate response structure
response = masterClient.execute(getReadChildrenNamesOperation(MAIN_RUNNING_SERVER_ADDRESS, SYSTEM_PROPERTY));
returnVal = validateResponse(response);
Assert.assertEquals(origPropCount + 1, returnVal.asList().size());
response = masterClient.execute(getReadChildrenNamesOperation(OTHER_RUNNING_SERVER_ADDRESS, SYSTEM_PROPERTY));
returnVal = validateResponse(response);
Assert.assertEquals(origPropCount + 1, returnVal.asList().size());
response = masterClient.execute(getReadAttributeOperation(MAIN_RUNNING_SERVER_PROP_ADDRESS, VALUE));
returnVal = validateResponse(response);
Assert.assertEquals("domain", returnVal.asString());
response = masterClient.execute(getReadAttributeOperation(OTHER_RUNNING_SERVER_PROP_ADDRESS, VALUE));
returnVal = validateResponse(response);
Assert.assertEquals("domain", returnVal.asString());
// Override at server-group
request = getSystemPropertyAddOperation(SERVER_GROUP_PROP_ADDRESS, "group", Boolean.FALSE);
response = masterClient.execute(request);
validateResponse(response);
response = masterClient.execute(getReadAttributeOperation(MAIN_RUNNING_SERVER_PROP_ADDRESS, VALUE));
returnVal = validateResponse(response);
Assert.assertEquals("domain", returnVal.asString());
response = masterClient.execute(getReadAttributeOperation(OTHER_RUNNING_SERVER_PROP_ADDRESS, VALUE));
returnVal = validateResponse(response);
Assert.assertEquals("group", returnVal.asString());
// Change the domain level value, confirm it does not replace override
request = getWriteAttributeOperation(ROOT_PROP_ADDRESS, "domain2");
response = masterClient.execute(request);
validateResponse(response);
response = masterClient.execute(getReadAttributeOperation(MAIN_RUNNING_SERVER_PROP_ADDRESS, VALUE));
returnVal = validateResponse(response);
Assert.assertEquals("domain2", returnVal.asString());
response = masterClient.execute(getReadAttributeOperation(OTHER_RUNNING_SERVER_PROP_ADDRESS, VALUE));
returnVal = validateResponse(response);
Assert.assertEquals("group", returnVal.asString());
// Override at the host level
request = getSystemPropertyAddOperation(HOST_PROP_ADDRESS, "host", Boolean.FALSE);
response = masterClient.execute(request);
validateResponse(response);
response = masterClient.execute(getReadAttributeOperation(MAIN_RUNNING_SERVER_PROP_ADDRESS, VALUE));
returnVal = validateResponse(response);
Assert.assertEquals("domain2", returnVal.asString());
response = masterClient.execute(getReadAttributeOperation(OTHER_RUNNING_SERVER_PROP_ADDRESS, VALUE));
returnVal = validateResponse(response);
Assert.assertEquals("host", returnVal.asString());
// Change the domain level value, confirm it does not replace override
request = getWriteAttributeOperation(ROOT_PROP_ADDRESS, "domain3");
response = masterClient.execute(request);
validateResponse(response);
response = masterClient.execute(getReadAttributeOperation(MAIN_RUNNING_SERVER_PROP_ADDRESS, VALUE));
returnVal = validateResponse(response);
Assert.assertEquals("domain3", returnVal.asString());
response = masterClient.execute(getReadAttributeOperation(OTHER_RUNNING_SERVER_PROP_ADDRESS, VALUE));
returnVal = validateResponse(response);
Assert.assertEquals("host", returnVal.asString());
// Change the server group level value, confirm it does not replace override
request = getWriteAttributeOperation(SERVER_GROUP_PROP_ADDRESS, "group2");
response = masterClient.execute(request);
validateResponse(response);
response = masterClient.execute(getReadAttributeOperation(MAIN_RUNNING_SERVER_PROP_ADDRESS, VALUE));
returnVal = validateResponse(response);
Assert.assertEquals("domain3", returnVal.asString());
response = masterClient.execute(getReadAttributeOperation(OTHER_RUNNING_SERVER_PROP_ADDRESS, VALUE));
returnVal = validateResponse(response);
Assert.assertEquals("host", returnVal.asString());
// Override at the server level
request = getSystemPropertyAddOperation(SERVER_PROP_ADDRESS, "server", Boolean.FALSE);
response = masterClient.execute(request);
validateResponse(response);
response = masterClient.execute(getReadAttributeOperation(MAIN_RUNNING_SERVER_PROP_ADDRESS, VALUE));
returnVal = validateResponse(response);
Assert.assertEquals("domain3", returnVal.asString());
response = masterClient.execute(getReadAttributeOperation(OTHER_RUNNING_SERVER_PROP_ADDRESS, VALUE));
returnVal = validateResponse(response);
Assert.assertEquals("server", returnVal.asString());
// Change the server group level value, confirm it does not replace override
request = getWriteAttributeOperation(HOST_PROP_ADDRESS, "host2");
response = masterClient.execute(request);
validateResponse(response);
response = masterClient.execute(getReadAttributeOperation(MAIN_RUNNING_SERVER_PROP_ADDRESS, VALUE));
returnVal = validateResponse(response);
Assert.assertEquals("domain3", returnVal.asString());
response = masterClient.execute(getReadAttributeOperation(OTHER_RUNNING_SERVER_PROP_ADDRESS, VALUE));
returnVal = validateResponse(response);
Assert.assertEquals("server", returnVal.asString());
// Modify the server level value
request = getWriteAttributeOperation(SERVER_PROP_ADDRESS, "server1");
response = slaveClient.execute(request); // Start using the slave client
validateResponse(response);
response = masterClient.execute(getReadAttributeOperation(MAIN_RUNNING_SERVER_PROP_ADDRESS, VALUE));
returnVal = validateResponse(response);
Assert.assertEquals("domain3", returnVal.asString());
response = slaveClient.execute(getReadAttributeOperation(OTHER_RUNNING_SERVER_PROP_ADDRESS, VALUE));
returnVal = validateResponse(response);
Assert.assertEquals("server1", returnVal.asString());
// Remove from top down
request = getEmptyOperation(REMOVE, ROOT_PROP_ADDRESS);
response = masterClient.execute(request);
validateResponse(response);
response = masterClient.execute(getReadChildrenNamesOperation(MAIN_RUNNING_SERVER_ADDRESS, SYSTEM_PROPERTY));
returnVal = validateResponse(response);
Assert.assertEquals(origPropCount, returnVal.asList().size());
response = slaveClient.execute(getReadAttributeOperation(OTHER_RUNNING_SERVER_PROP_ADDRESS, VALUE));
returnVal = validateResponse(response);
Assert.assertEquals("server1", returnVal.asString());
request = getEmptyOperation(REMOVE, SERVER_GROUP_PROP_ADDRESS);
response = masterClient.execute(request);
validateResponse(response);
response = masterClient.execute(getReadChildrenNamesOperation(MAIN_RUNNING_SERVER_ADDRESS, SYSTEM_PROPERTY));
returnVal = validateResponse(response);
Assert.assertEquals(origPropCount, returnVal.asList().size());
response = slaveClient.execute(getReadAttributeOperation(OTHER_RUNNING_SERVER_PROP_ADDRESS, VALUE));
returnVal = validateResponse(response);
Assert.assertEquals("server1", returnVal.asString());
request = getEmptyOperation(REMOVE, HOST_PROP_ADDRESS);
response = masterClient.execute(request);
validateResponse(response);
response = masterClient.execute(getReadChildrenNamesOperation(MAIN_RUNNING_SERVER_ADDRESS, SYSTEM_PROPERTY));
returnVal = validateResponse(response);
Assert.assertEquals(origPropCount, returnVal.asList().size());
response = slaveClient.execute(getReadAttributeOperation(OTHER_RUNNING_SERVER_PROP_ADDRESS, VALUE));
returnVal = validateResponse(response);
Assert.assertEquals("server1", returnVal.asString());
request = getEmptyOperation(REMOVE, SERVER_PROP_ADDRESS);
response = masterClient.execute(request);
validateResponse(response);
response = masterClient.execute(getReadChildrenNamesOperation(MAIN_RUNNING_SERVER_ADDRESS, SYSTEM_PROPERTY));
returnVal = validateResponse(response);
Assert.assertEquals(origPropCount, returnVal.asList().size());
response = slaveClient.execute(getReadChildrenNamesOperation(OTHER_RUNNING_SERVER_ADDRESS, SYSTEM_PROPERTY));
returnVal = validateResponse(response);
Assert.assertEquals(origPropCount, returnVal.asList().size());
}