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;
}
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());
}
}
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);
}
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);
}
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());
}
Aggregations