Search in sources :

Example 31 with ModelNode

use of org.jboss.dmr.ModelNode in project wildfly by wildfly.

the class PropertiesTestUtil method success.

public static ModelNode success() {
    final ModelNode result = new ModelNode();
    result.get(OUTCOME).set(SUCCESS);
    result.get(RESULT);
    return result;
}
Also used : ModelNode(org.jboss.dmr.ModelNode)

Example 32 with ModelNode

use of org.jboss.dmr.ModelNode in project wildfly by wildfly.

the class PropertiesTestUtil method checkLegacyChildResourceModel.

public static void checkLegacyChildResourceModel(ModelNode model, String... properties) {
    Assert.assertEquals(0, properties.length % 2);
    ModelNode props = model.get("property");
    Assert.assertEquals(properties.length / 2, props.isDefined() ? props.keys().size() : 0);
    for (int i = 0; i < properties.length; i += 2) {
        ModelNode property = props.get(properties[i]);
        Assert.assertTrue(property.isDefined());
        Assert.assertEquals(1, property.keys().size());
        Assert.assertEquals(properties[i + 1], property.get("value").asString());
    }
}
Also used : ModelNode(org.jboss.dmr.ModelNode)

Example 33 with ModelNode

use of org.jboss.dmr.ModelNode in project wildfly by wildfly.

the class PropertiesTestUtil method checkMapModels.

public static void checkMapModels(KernelServices services, ModelVersion version, PathAddress address, String... properties) throws Exception {
    final ModelNode readResource = Util.createEmptyOperation(READ_RESOURCE_OPERATION, address);
    readResource.get(RECURSIVE).set(true);
    readResource.get(INCLUDE_DEFAULTS).set(false);
    ModelNode mainModel = services.executeForResult(readResource.clone());
    checkMainMapModel(mainModel, properties);
    final ModelNode legacyModel;
    if (address.getLastElement().getKey().equals("transport")) {
        //TODO get rid of this once the PathAddress transformer works properly
        //Temporary workaround
        readResource.get(OP_ADDR).set(address.subAddress(0, address.size() - 1).append("transport", "TRANSPORT").toModelNode());
        legacyModel = services.getLegacyServices(version).executeForResult(readResource);
    } else {
        legacyModel = ModelTestUtils.checkResultAndGetContents(services.executeOperation(version, services.transformOperation(version, readResource.clone())));
    }
    checkLegacyChildResourceModel(legacyModel, properties);
}
Also used : ModelNode(org.jboss.dmr.ModelNode)

Example 34 with ModelNode

use of org.jboss.dmr.ModelNode in project wildfly by wildfly.

the class PropertiesTestUtil method checkMapResults.

public static void checkMapResults(KernelServices services, ModelNode expected, ModelVersion version, ModelNode operation) throws Exception {
    ModelNode main = ModelTestUtils.checkOutcome(services.executeOperation(operation.clone())).get(ModelDescriptionConstants.RESULT);
    ModelNode legacyResult = services.executeOperation(version, services.transformOperation(version, operation.clone()));
    ModelNode legacy;
    if (expected.isDefined()) {
        legacy = ModelTestUtils.checkOutcome(legacyResult).get(ModelDescriptionConstants.RESULT);
    } else {
        ModelTestUtils.checkFailed(legacyResult);
        legacy = new ModelNode();
    }
    Assert.assertEquals(main, legacy);
    Assert.assertEquals(expected, legacy);
}
Also used : ModelNode(org.jboss.dmr.ModelNode)

Example 35 with ModelNode

use of org.jboss.dmr.ModelNode in project wildfly by wildfly.

the class OperationsTestCase method testTransportReadWriteOperation.

/**
     * Tests access to transport attributes
     */
@Test
public void testTransportReadWriteOperation() throws Exception {
    KernelServices services = this.buildKernelServices();
    // read the transport rack attribute
    ModelNode result = services.executeOperation(getTransportReadOperation("maximal", "TCP", TransportResourceDefinition.Attribute.RACK));
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertEquals("rack1", result.get(RESULT).resolve().asString());
    // write the rack attribute
    result = services.executeOperation(getTransportWriteOperation("maximal", "TCP", TransportResourceDefinition.Attribute.RACK, "new-rack"));
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    // re-read the rack attribute
    result = services.executeOperation(getTransportReadOperation("maximal", "TCP", TransportResourceDefinition.Attribute.RACK));
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertEquals("new-rack", result.get(RESULT).asString());
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Aggregations

ModelNode (org.jboss.dmr.ModelNode)1634 PathAddress (org.jboss.as.controller.PathAddress)351 Test (org.junit.Test)344 KernelServices (org.jboss.as.subsystem.test.KernelServices)102 Property (org.jboss.dmr.Property)92 OperationFailedException (org.jboss.as.controller.OperationFailedException)89 OperationContext (org.jboss.as.controller.OperationContext)68 ParseUtils.unexpectedElement (org.jboss.as.controller.parsing.ParseUtils.unexpectedElement)68 ArrayList (java.util.ArrayList)58 Resource (org.jboss.as.controller.registry.Resource)54 PathElement (org.jboss.as.controller.PathElement)53 ParseUtils.unexpectedAttribute (org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute)52 ParseUtils.requireNoNamespaceAttribute (org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute)50 IOException (java.io.IOException)49 ServiceName (org.jboss.msc.service.ServiceName)49 ResourceTransformationDescriptionBuilder (org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder)47 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)44 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)42 OperationBuilder (org.jboss.as.controller.client.OperationBuilder)42 Map (java.util.Map)38