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 void processResources(final ModelControllerClient client, final Resource... resources)
      throws IOException {
    for (Resource resource : resources) {
      if (isDomainServer()) {
        // Profiles are required when adding resources in domain mode
        final List<String> profiles = domain.getProfiles();
        if (profiles.isEmpty()) {
          throw new IllegalStateException("Cannot add resources when no profiles were defined.");
        }
        for (String profile : profiles) {
          final CompositeOperationBuilder compositeOperationBuilder =
              CompositeOperationBuilder.create();
          if (addCompositeResource(
              profile, client, resource, address, compositeOperationBuilder, true)) {
            if (resource.hasBeforeAddCommands()) {
              resource.getBeforeAdd().execute(client);
            }
            // Execute the add resource operation
            reportFailure(client.execute(compositeOperationBuilder.build()));

            if (resource.hasAfterAddCommands()) {
              resource.getAfterAdd().execute(client);
            }
          }
        }
      } else {
        final CompositeOperationBuilder compositeOperationBuilder =
            CompositeOperationBuilder.create();
        if (addCompositeResource(
            null, client, resource, address, compositeOperationBuilder, true)) {
          if (resource.hasBeforeAddCommands()) {
            resource.getBeforeAdd().execute(client);
          }
          // Execute the add resource operation
          reportFailure(client.execute(compositeOperationBuilder.build()));

          if (resource.hasAfterAddCommands()) {
            resource.getAfterAdd().execute(client);
          }
        }
      }
    }
  }
 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;
 }