protected ModelNode testWrite(
     final ModelNode address, final String attribute, final ModelNode value) throws IOException {
   final CompositeOperationBuilder builder = CompositeOperationBuilder.create();
   builder.addStep(Operations.createWriteAttributeOperation(address, attribute, value));
   // Create the read operation
   builder.addStep(Operations.createReadAttributeOperation(address, attribute));
   final ModelNode result = executeOperation(builder.build());
   assertEquals(value, Operations.readResult(Operations.readResult(result).get("step-2")));
   return result;
 }
 private boolean addCompositeResource(
     final String profileName,
     final ModelControllerClient client,
     final Resource resource,
     final String parentAddress,
     final CompositeOperationBuilder compositeOp,
     final boolean checkExistence)
     throws IOException {
   final String inputAddress;
   if (parentAddress == null) {
     inputAddress = resource.getAddress();
   } else if (parentAddress.equals(resource.getAddress())) {
     inputAddress = resource.getAddress();
   } else if (resource.getAddress() == null) {
     inputAddress = parentAddress;
   } else {
     inputAddress = String.format("%s,%s", parentAddress, resource.getAddress());
   }
   // The address cannot be null
   if (inputAddress == null) {
     throw new RuntimeException("You must specify the address to deploy the resource to.");
   }
   final ModelNode address = parseAddress(profileName, inputAddress);
   if (checkExistence) {
     final boolean exists = resourceExists(address, client);
     if (resource.isAddIfAbsent() && exists) {
       return false;
     }
     if (exists && force) {
       reportFailure(client.execute(ServerOperations.createRemoveOperation(address, true)));
     } else if (exists && !force) {
       throw new RuntimeException(String.format("Resource %s already exists.", address));
     }
   }
   compositeOp.addStep(buildAddOperation(address, resource.getProperties()));
   if (resource.getResources() != null) {
     final String resourceAddress = resource.getAddress();
     final String addr;
     if (parentAddress != null && resourceAddress != null) {
       addr = parentAddress + "," + resourceAddress;
     } else if (parentAddress != null) {
       addr = parentAddress;
     } else if (resourceAddress != null) {
       addr = resourceAddress;
     } else {
       addr = null;
     }
     for (Resource r : resource.getResources()) {
       addCompositeResource(profileName, client, r, addr, compositeOp, false);
     }
   }
   return true;
 }
 protected ModelNode testUndefine(
     final ModelNode address, final String attribute, final boolean expectFailure)
     throws IOException {
   final CompositeOperationBuilder builder = CompositeOperationBuilder.create();
   builder.addStep(Operations.createUndefineAttributeOperation(address, attribute));
   // Create the read operation
   final ModelNode readOp = Operations.createReadAttributeOperation(address, attribute);
   readOp.get("include-defaults").set(false);
   builder.addStep(readOp);
   final ModelNode result = client.getControllerClient().execute(builder.build());
   if (expectFailure) {
     assertFalse(
         "Undefining attribute " + attribute + " should have failed.",
         Operations.isSuccessfulOutcome(result));
   } else {
     if (!Operations.isSuccessfulOutcome(result)) {
       Assert.fail(Operations.getFailureDescription(result).toString());
     }
     assertFalse(
         "Attribute '" + attribute + "' was not undefined.",
         Operations.readResult(Operations.readResult(result).get("step-2")).isDefined());
   }
   return result;
 }