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