Search in sources :

Example 1 with SimpleAttribute

use of org.jboss.as.clustering.controller.SimpleAttribute in project wildfly by wildfly.

the class OperationsTestCase method testStoreProperties.

@SuppressWarnings("deprecation")
@Test
public void testStoreProperties() throws Exception {
    KernelServices services = this.createKernelServicesBuilder().setSubsystemXml(this.getSubsystemXml()).build();
    PathAddress address = getRemoteCacheStoreAddress("maximal", InvalidationCacheResourceDefinition.WILDCARD_PATH.getKey(), "invalid");
    String key = "infinispan.client.hotrod.ping_on_startup";
    String value = "true";
    ModelNode operation = Operations.createMapPutOperation(address, StoreResourceDefinition.Attribute.PROPERTIES, key, value);
    ModelNode result = services.executeOperation(operation);
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertFalse(result.get(RESULT).isDefined());
    operation = Operations.createMapGetOperation(address, StoreResourceDefinition.Attribute.PROPERTIES, key);
    result = services.executeOperation(operation);
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertEquals(value, result.get(RESULT).asString());
    operation = Operations.createMapRemoveOperation(address, StoreResourceDefinition.Attribute.PROPERTIES, key);
    result = services.executeOperation(operation);
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertFalse(result.get(RESULT).isDefined());
    operation = Operations.createMapGetOperation(address, StoreResourceDefinition.Attribute.PROPERTIES, key);
    result = services.executeOperation(operation);
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertFalse(result.get(RESULT).isDefined());
    // Validate that properties can still be added/removed/updated via child property resources
    PathAddress propertyAddress = address.append(StorePropertyResourceDefinition.pathElement(key));
    operation = Operations.createAddOperation(propertyAddress, Collections.<Attribute, ModelNode>singletonMap(new SimpleAttribute(StorePropertyResourceDefinition.VALUE), new ModelNode(value)));
    result = services.executeOperation(operation);
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertFalse(result.get(RESULT).isDefined());
    operation = Operations.createMapGetOperation(address, StoreResourceDefinition.Attribute.PROPERTIES, key);
    result = services.executeOperation(operation);
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertEquals(value, result.get(RESULT).asString());
    value = "false";
    operation = Operations.createWriteAttributeOperation(propertyAddress, new SimpleAttribute(StorePropertyResourceDefinition.VALUE), new ModelNode(value));
    result = services.executeOperation(operation);
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertFalse(result.get(RESULT).isDefined());
    operation = Operations.createMapGetOperation(address, StoreResourceDefinition.Attribute.PROPERTIES, key);
    result = services.executeOperation(operation);
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertEquals(value, result.get(RESULT).asString());
    operation = Operations.createReadAttributeOperation(propertyAddress, new SimpleAttribute(StorePropertyResourceDefinition.VALUE));
    result = services.executeOperation(operation);
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertEquals(value, result.get(RESULT).asString());
    operation = Util.createRemoveOperation(propertyAddress);
    result = services.executeOperation(operation);
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertFalse(result.get(RESULT).isDefined());
    operation = Operations.createMapGetOperation(address, StoreResourceDefinition.Attribute.PROPERTIES, key);
    result = services.executeOperation(operation);
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertFalse(result.get(RESULT).isDefined());
}
Also used : Attribute(org.jboss.as.clustering.controller.Attribute) SimpleAttribute(org.jboss.as.clustering.controller.SimpleAttribute) SimpleAttribute(org.jboss.as.clustering.controller.SimpleAttribute) PathAddress(org.jboss.as.controller.PathAddress) KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 2 with SimpleAttribute

use of org.jboss.as.clustering.controller.SimpleAttribute in project wildfly by wildfly.

the class PropertyResourceDefinition method buildTransformation.

static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
    ResourceTransformationDescriptionBuilder builder = parent.addChildResource(WILDCARD_PATH);
    if (JGroupsModel.VERSION_3_0_0.requiresTransformation(version)) {
        builder.setCustomResourceTransformer(new SimpleResourceTransformer(LEGACY_ADDRESS_TRANSFORMER));
        builder.addOperationTransformationOverride(ModelDescriptionConstants.ADD).setCustomOperationTransformer(new SimpleAddOperationTransformer(LEGACY_ADDRESS_TRANSFORMER).addAttributes(new SimpleAttribute(VALUE))).inheritResourceAttributeDefinitions();
        builder.addOperationTransformationOverride(ModelDescriptionConstants.REMOVE).setCustomOperationTransformer(new SimpleRemoveOperationTransformer(LEGACY_ADDRESS_TRANSFORMER));
        builder.addOperationTransformationOverride(ModelDescriptionConstants.READ_ATTRIBUTE_OPERATION).setCustomOperationTransformer(new SimpleReadAttributeOperationTransformer(LEGACY_ADDRESS_TRANSFORMER));
        builder.addOperationTransformationOverride(ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION).setCustomOperationTransformer(new SimpleWriteAttributeOperationTransformer(LEGACY_ADDRESS_TRANSFORMER));
        builder.addOperationTransformationOverride(ModelDescriptionConstants.UNDEFINE_ATTRIBUTE_OPERATION).setCustomOperationTransformer(new SimpleUndefineAttributeOperationTransformer(LEGACY_ADDRESS_TRANSFORMER));
        builder.addOperationTransformationOverride(ModelDescriptionConstants.DESCRIBE).setCustomOperationTransformer(new SimpleDescribeOperationTransformer(LEGACY_ADDRESS_TRANSFORMER));
    }
}
Also used : SimpleAddOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleAddOperationTransformer) SimpleRemoveOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleRemoveOperationTransformer) SimpleReadAttributeOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleReadAttributeOperationTransformer) SimpleWriteAttributeOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleWriteAttributeOperationTransformer) SimpleAttribute(org.jboss.as.clustering.controller.SimpleAttribute) SimpleUndefineAttributeOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleUndefineAttributeOperationTransformer) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) SimpleDescribeOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleDescribeOperationTransformer) SimpleResourceTransformer(org.jboss.as.clustering.controller.transform.SimpleResourceTransformer)

Aggregations

SimpleAttribute (org.jboss.as.clustering.controller.SimpleAttribute)2 Attribute (org.jboss.as.clustering.controller.Attribute)1 SimpleAddOperationTransformer (org.jboss.as.clustering.controller.transform.SimpleAddOperationTransformer)1 SimpleDescribeOperationTransformer (org.jboss.as.clustering.controller.transform.SimpleDescribeOperationTransformer)1 SimpleReadAttributeOperationTransformer (org.jboss.as.clustering.controller.transform.SimpleReadAttributeOperationTransformer)1 SimpleRemoveOperationTransformer (org.jboss.as.clustering.controller.transform.SimpleRemoveOperationTransformer)1 SimpleResourceTransformer (org.jboss.as.clustering.controller.transform.SimpleResourceTransformer)1 SimpleUndefineAttributeOperationTransformer (org.jboss.as.clustering.controller.transform.SimpleUndefineAttributeOperationTransformer)1 SimpleWriteAttributeOperationTransformer (org.jboss.as.clustering.controller.transform.SimpleWriteAttributeOperationTransformer)1 PathAddress (org.jboss.as.controller.PathAddress)1 ResourceTransformationDescriptionBuilder (org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder)1 KernelServices (org.jboss.as.subsystem.test.KernelServices)1 ModelNode (org.jboss.dmr.ModelNode)1 Test (org.junit.Test)1