use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.
the class OperationsTestCase method testAliases.
@Test
public void testAliases() throws Exception {
KernelServices services = this.createKernelServicesBuilder().setSubsystemXml(this.getSubsystemXml()).build();
PathAddress address = getCacheContainerAddress("minimal");
String alias = "alias0";
ModelNode operation = Operations.createListAddOperation(address, CacheContainerResourceDefinition.Attribute.ALIASES, alias);
ModelNode result = services.executeOperation(operation);
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertFalse(result.get(RESULT).isDefined());
operation = Operations.createListGetOperation(address, CacheContainerResourceDefinition.Attribute.ALIASES, 0);
result = services.executeOperation(operation);
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertEquals(new ModelNode(alias), result.get(RESULT));
operation = Operations.createListRemoveOperation(address, CacheContainerResourceDefinition.Attribute.ALIASES, 0);
result = services.executeOperation(operation);
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertFalse(result.get(RESULT).isDefined());
operation = Operations.createListGetOperation(address, CacheContainerResourceDefinition.Attribute.ALIASES, 0);
result = services.executeOperation(operation);
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertFalse(result.get(RESULT).isDefined());
// Validate that aliases can still be added/removed via legacy operations
operation = Util.createOperation("add-alias", address);
operation.get(ModelDescriptionConstants.NAME).set(alias);
result = services.executeOperation(operation);
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertFalse(result.get(RESULT).isDefined());
operation = Operations.createListGetOperation(address, CacheContainerResourceDefinition.Attribute.ALIASES, 0);
result = services.executeOperation(operation);
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
/* This currently fails due to WFCORE-626, requires wildfly-core-1.0.0.Beta4
Assert.assertEquals(new ModelNode(alias), result.get(RESULT));
*/
operation = Util.createOperation("remove-alias", address);
operation.get(ModelDescriptionConstants.NAME).set(alias);
result = services.executeOperation(operation);
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertFalse(result.get(RESULT).isDefined());
operation = Operations.createListGetOperation(address, CacheContainerResourceDefinition.Attribute.ALIASES, 0);
result = services.executeOperation(operation);
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertFalse(result.get(RESULT).isDefined());
}
use of org.jboss.as.subsystem.test.KernelServices 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.subsystem.test.KernelServices in project wildfly by wildfly.
the class OperationsTestCase method testLocalCacheReadWriteOperation.
/*
* Tests access to local cache attributes
*/
@Test
public void testLocalCacheReadWriteOperation() throws Exception {
// Parse and install the XML into the controller
String subsystemXml = getSubsystemXml();
KernelServices servicesA = this.createKernelServicesBuilder().setSubsystemXml(subsystemXml).build();
ModelNode readOperation = getCacheReadOperation("maximal", LocalCacheResourceDefinition.WILDCARD_PATH.getKey(), "local", CacheResourceDefinition.Attribute.STATISTICS_ENABLED);
// read the cache container batching attribute
ModelNode result = servicesA.executeOperation(readOperation);
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertTrue(result.get(RESULT).asBoolean());
ModelNode writeOperation = getCacheWriteOperation("maximal", LocalCacheResourceDefinition.WILDCARD_PATH.getKey(), "local", CacheResourceDefinition.Attribute.STATISTICS_ENABLED, "false");
// write the batching attribute
result = servicesA.executeOperation(writeOperation);
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
// re-read the batching attribute
result = servicesA.executeOperation(readOperation);
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertFalse(result.get(RESULT).asBoolean());
}
use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.
the class InfinispanSubsystemParsingTestCase method testInstallIntoController.
/**
* Test that the model created from the xml looks as expected
*/
@Test
public void testInstallIntoController() throws Exception {
// Parse the subsystem xml and install into the controller
KernelServices services = createKernelServicesBuilder().setSubsystemXml(getSubsystemXml()).build();
// Read the whole model and make sure it looks as expected
ModelNode model = services.readWholeModel();
Assert.assertTrue(model.get(InfinispanSubsystemResourceDefinition.PATH.getKey()).hasDefined(InfinispanSubsystemResourceDefinition.PATH.getValue()));
checkLegacyParserStatisticsTrue(model.get(InfinispanSubsystemResourceDefinition.PATH.getKeyValuePair()));
}
use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.
the class InfinispanTransformersTestCase method testTransformation.
@SuppressWarnings("deprecation")
private void testTransformation(final ModelTestControllerVersion controller) throws Exception {
final ModelVersion version = getModelVersion(controller).getVersion();
final String[] dependencies = getDependencies(controller);
KernelServices services = this.buildKernelServices(controller, version, dependencies);
// check that both versions of the legacy model are the same and valid
checkSubsystemModelTransformation(services, version, createModelFixer(version), false);
ModelNode transformed = services.readTransformedModel(version);
if (InfinispanModel.VERSION_3_0_0.requiresTransformation(version)) {
// Verify that mode=BATCH is translated to mode=NONE, batching=true
ModelNode cache = transformed.get(InfinispanSubsystemResourceDefinition.PATH.getKeyValuePair()).get(CacheContainerResourceDefinition.pathElement("maximal").getKeyValuePair()).get(LocalCacheResourceDefinition.pathElement("local").getKeyValuePair());
Assert.assertTrue(cache.hasDefined(CacheResourceDefinition.DeprecatedAttribute.BATCHING.getName()));
Assert.assertTrue(cache.get(CacheResourceDefinition.DeprecatedAttribute.BATCHING.getName()).asBoolean());
ModelNode transaction = cache.get(TransactionResourceDefinition.PATH.getKeyValuePair());
if (transaction.hasDefined(TransactionResourceDefinition.Attribute.MODE.getName())) {
Assert.assertEquals(TransactionMode.NONE.name(), transaction.get(TransactionResourceDefinition.Attribute.MODE.getName()).asString());
}
// Test properties operations
propertiesMapOperationsTest(services, version);
}
}
Aggregations