Skip to content
Browse files

Better reject expression transformers tests for transactions

  • Loading branch information...
1 parent 2e69cda commit 6f025257f780d41d0bd02d7b701bbf77d55cd655 @kabir kabir committed with bstansberry Jan 8, 2013
View
4 ...er/src/main/java/org/jboss/as/controller/transform/RejectExpressionValuesTransformer.java
@@ -62,6 +62,10 @@ public RejectExpressionValuesTransformer(String... attributeNames) {
this (new HashSet<String>(Arrays.asList(attributeNames)));
}
+ public RejectExpressionValuesChainedTransformer getChainedTransformer() {
+ return chainedExpressionTransformer;
+ }
+
@SuppressWarnings("deprecation")
public RejectExpressionValuesTransformer(Set<String> allAttributeNames, Map<String, AttributeTransformationRequirementChecker> specialCheckers) {
chainedExpressionTransformer = new RejectExpressionValuesChainedTransformer(allAttributeNames, specialCheckers);
View
2 model-test/src/main/java/org/jboss/as/model/test/ModelTestUtils.java
@@ -396,7 +396,7 @@ public static void checkModelAgainstDefinition(final ModelNode model, Management
Assert.assertNotNull("Attribute " + name + " is not known", aa);
AttributeDefinition ad = aa.getAttributeDefinition();
if (!value.isDefined()) {
- Assert.assertTrue("Attribute is not allow null", ad.isAllowNull());
+ Assert.assertTrue("Attribute " + name + " does not allow null", ad.isAllowNull());
} else {
// Assert.assertEquals("Attribute '" + name + "' type mismatch", value.getType(), ad.getType()); //todo re-enable this check
}
View
2 subsystem-test/src/main/java/org/jboss/as/subsystem/test/KnownVersions.java
@@ -48,7 +48,7 @@
//Keep this list in alphabetical and subsystem version order
- //1.0.0 of configadmin belongs to AS 7.1.3 (inferred from the 1.2.0 core model version)
+ //1.0.0 of configadmin belongs to AS 7.1.3 (inferred from the 1.3.0 core model version)
addSubsystemVersion(map, "configadmin", "1.0.0", "1.3.0");
addSubsystemVersion(map, "jacorb", "1.1.0", "1.3.0");
addSubsystemVersion(map, "infinispan", "1.3.0", "1.3.0");
View
37 transactions/src/main/java/org/jboss/as/txn/subsystem/TransactionExtension.java
@@ -32,21 +32,24 @@
import org.jboss.as.controller.ExtensionContext;
import org.jboss.as.controller.ModelVersion;
import org.jboss.as.controller.OperationContext;
-import org.jboss.as.controller.OperationDefinition;
+import org.jboss.as.controller.OperationFailedException;
+import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PathElement;
-import org.jboss.as.controller.SimpleOperationDefinitionBuilder;
import org.jboss.as.controller.SubsystemRegistration;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver;
import org.jboss.as.controller.operations.common.GenericSubsystemDescribeHandler;
import org.jboss.as.controller.parsing.ExtensionParsingContext;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
+import org.jboss.as.controller.registry.Resource;
import org.jboss.as.controller.services.path.ResolvePathHandler;
import org.jboss.as.controller.transform.RejectExpressionValuesTransformer;
-import org.jboss.as.controller.transform.ResourceTransformer;
import org.jboss.as.controller.transform.TransformersSubRegistration;
+import org.jboss.as.controller.transform.chained.ChainedResourceTransformationContext;
+import org.jboss.as.controller.transform.chained.ChainedResourceTransformer;
+import org.jboss.as.controller.transform.chained.ChainedResourceTransformerEntry;
import org.jboss.as.txn.TransactionMessages;
-import org.jboss.dmr.ModelType;
+import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceRegistry;
@@ -130,7 +133,7 @@ public void initialize(ExtensionContext context) {
ManagementResourceRegistration logStoreChild = registration.registerSubModel(new LogStoreDefinition(resource));
if (registerRuntimeOnly) {
ManagementResourceRegistration transactionChild = logStoreChild.registerSubModel(new LogStoreTransactionDefinition(resource));
- ManagementResourceRegistration partecipantChild = transactionChild.registerSubModel(LogStoreTransactionParticipantDefinition.INSTANCE);
+ transactionChild.registerSubModel(LogStoreTransactionParticipantDefinition.INSTANCE);
}
subsystem.registerXMLElementWriter(TransactionSubsystem12Parser.INSTANCE);
@@ -161,15 +164,23 @@ private static void registerTransformers(final SubsystemRegistration subsystem)
// Transformations to the 1.1.0 Model:
final ModelVersion version110 = ModelVersion.create(1, 1, 0);
- // We need to reject all expressions, since they can't be resolved on the client
- // However, a slave running 1.1.0 has no way to tell us at registration that it has ignored a resource,
- // so we can't agressively fail on resource transformation
- final ResourceTransformer resourceTransformer = ResourceTransformer.DEFAULT;
- final RejectExpressionValuesTransformer operationTransformer =
+ final RejectExpressionValuesTransformer reject =
new RejectExpressionValuesTransformer(TransactionSubsystemRootResourceDefinition.attributes);
- final TransformersSubRegistration registration = subsystem.registerModelTransformers(version110, resourceTransformer);
- registration.registerOperationTransformer(ADD, operationTransformer);
- registration.registerOperationTransformer(WRITE_ATTRIBUTE_OPERATION, operationTransformer.getWriteAttributeTransformer());
+ final TransformersSubRegistration registration = subsystem.registerModelTransformers(version110, new ChainedResourceTransformer(
+ new ChainedResourceTransformerEntry() {
+ @Override
+ public void transformResource(ChainedResourceTransformationContext context, PathAddress address, Resource resource)
+ throws OperationFailedException {
+ ModelNode model = resource.getModel();
+ if (!model.hasDefined(TransactionSubsystemRootResourceDefinition.PROCESS_ID_UUID.getName())) {
+ model.get(TransactionSubsystemRootResourceDefinition.PROCESS_ID_UUID.getName()).set(false);
+ }
+ System.out.println(resource.getModel());
+ }
+ },
+ reject.getChainedTransformer()));
+ registration.registerOperationTransformer(ADD, reject);
+ registration.registerOperationTransformer(WRITE_ATTRIBUTE_OPERATION, reject.getWriteAttributeTransformer());
}
View
96 transactions/src/test/java/org/jboss/as/txn/TransactionSubsystemTestCase.java
@@ -21,20 +21,31 @@
*/
package org.jboss.as.txn;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.FAILED;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.NAME;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OUTCOME;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUCCESS;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.VALUE;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION;
+import static org.jboss.as.txn.subsystem.TransactionSubsystemRootResourceDefinition.BINDING;
+import static org.jboss.as.txn.subsystem.TransactionSubsystemRootResourceDefinition.DEFAULT_TIMEOUT;
+import static org.jboss.as.txn.subsystem.TransactionSubsystemRootResourceDefinition.ENABLE_STATISTICS;
+import static org.jboss.as.txn.subsystem.TransactionSubsystemRootResourceDefinition.ENABLE_TSM_STATUS;
+import static org.jboss.as.txn.subsystem.TransactionSubsystemRootResourceDefinition.NODE_IDENTIFIER;
+import static org.jboss.as.txn.subsystem.TransactionSubsystemRootResourceDefinition.OBJECT_STORE_PATH;
+import static org.jboss.as.txn.subsystem.TransactionSubsystemRootResourceDefinition.OBJECT_STORE_RELATIVE_TO;
+import static org.jboss.as.txn.subsystem.TransactionSubsystemRootResourceDefinition.PATH;
+import static org.jboss.as.txn.subsystem.TransactionSubsystemRootResourceDefinition.PROCESS_ID_SOCKET_BINDING;
+import static org.jboss.as.txn.subsystem.TransactionSubsystemRootResourceDefinition.PROCESS_ID_SOCKET_MAX_PORTS;
+import static org.jboss.as.txn.subsystem.TransactionSubsystemRootResourceDefinition.RECOVERY_LISTENER;
+import static org.jboss.as.txn.subsystem.TransactionSubsystemRootResourceDefinition.RELATIVE_TO;
+import static org.jboss.as.txn.subsystem.TransactionSubsystemRootResourceDefinition.STATUS_BINDING;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import java.io.IOException;
+import java.util.List;
import org.jboss.as.controller.ModelVersion;
-import org.jboss.as.controller.transform.OperationTransformer;
+import org.jboss.as.controller.PathAddress;
+import org.jboss.as.controller.PathElement;
+import org.jboss.as.model.test.FailedOperationTransformationConfig;
+import org.jboss.as.model.test.ModelTestUtils;
import org.jboss.as.subsystem.test.AbstractSubsystemBaseTest;
import org.jboss.as.subsystem.test.AdditionalInitialization;
import org.jboss.as.subsystem.test.KernelServices;
@@ -66,7 +77,7 @@ protected void compareXml(String configId, String original, String marshalled) t
@Test
public void testExpressions() throws Exception {
- standardSubsystemTest("expressions.xml");
+ standardSubsystemTest("full-expressions.xml");
}
@Test
@@ -75,13 +86,28 @@ public void testMinimalConfig() throws Exception {
}
@Test
- public void testSocketId() throws Exception {
- standardSubsystemTest("socket-id.xml");
+ public void testTransformers() throws Exception {
+ String subsystemXml = readResource("subsystem.xml");
+ ModelVersion modelVersion = ModelVersion.create(1, 1, 0);
+ //Use the non-runtime version of the extension which will happen on the HC
+ KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT)
+ .setSubsystemXml(subsystemXml);
+
+ // Add legacy subsystems
+ builder.createLegacyKernelServicesBuilder(null, modelVersion)
+ .addMavenResourceURL("org.jboss.as:jboss-as-transactions:7.1.2.Final");
+
+ KernelServices mainServices = builder.build();
+ KernelServices legacyServices = mainServices.getLegacyServices(modelVersion);
+ Assert.assertNotNull(legacyServices);
+
+ checkSubsystemModelTransformation(mainServices, modelVersion);
}
+
@Test
- public void testTransformers() throws Exception {
- String subsystemXml = readResource("subsystem.xml");
+ public void testTransformersFull() throws Exception {
+ String subsystemXml = readResource("full.xml");
ModelVersion modelVersion = ModelVersion.create(1, 1, 0);
//Use the non-runtime version of the extension which will happen on the HC
KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT)
@@ -97,19 +123,41 @@ public void testTransformers() throws Exception {
checkSubsystemModelTransformation(mainServices, modelVersion);
- final ModelNode operation = new ModelNode();
- operation.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
- operation.get(OP_ADDR).add(SUBSYSTEM, TransactionExtension.SUBSYSTEM_NAME);
- operation.get(NAME).set("status-socket-binding");
- operation.get(VALUE).set("${org.jboss.test:default-socket-binding}");
+ }
- final ModelNode mainResult = mainServices.executeOperation(operation);
- Assert.assertTrue(SUCCESS.equals(mainResult.get(OUTCOME).asString()));
+ @Test
+ public void testRejectTransformers() throws Exception {
+ KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization());
- final OperationTransformer.TransformedOperation op = mainServices.transformOperation(modelVersion, operation);
- ModelNode result = mainServices.executeOperation(modelVersion, op);
- Assert.assertEquals(FAILED, result.get(OUTCOME).asString());
+ // Add legacy subsystems
+ ModelVersion version_1_1 = ModelVersion.create(1, 1);
+ builder.createLegacyKernelServicesBuilder(createAdditionalInitialization(), version_1_1)
+ .addMavenResourceURL("org.jboss.as:jboss-as-transactions:7.1.2.Final");
+ KernelServices mainServices = builder.build();
+ assertTrue(mainServices.isSuccessfulBoot());
+ KernelServices legacyServices = mainServices.getLegacyServices(version_1_1);
+ assertNotNull(legacyServices);
+ assertTrue(legacyServices.isSuccessfulBoot());
+
+ List<ModelNode> ops = builder.parseXmlResource("full-expressions.xml");
+ ModelTestUtils.checkFailedTransformedBootOperations(mainServices, version_1_1, ops, new FailedOperationTransformationConfig()
+ .addFailedAttribute(PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, TransactionExtension.SUBSYSTEM_NAME)),
+ new FailedOperationTransformationConfig.RejectExpressionsConfig(
+ DEFAULT_TIMEOUT,
+ ENABLE_STATISTICS,
+ ENABLE_TSM_STATUS,
+ BINDING,
+ STATUS_BINDING,
+ RECOVERY_LISTENER,
+ NODE_IDENTIFIER,
+ PATH,
+ RELATIVE_TO,
+ PROCESS_ID_SOCKET_BINDING,
+ PROCESS_ID_SOCKET_MAX_PORTS,
+ OBJECT_STORE_PATH,
+ OBJECT_STORE_RELATIVE_TO
+ )));
}
}
View
8 ...esources/org/jboss/as/txn/expressions.xml → ...ces/org/jboss/as/txn/full-expressions.xml
@@ -1,14 +1,14 @@
<subsystem xmlns="urn:jboss:domain:transactions:1.2">
- <core-environment node-identifier="${test.node.identifier:1}" path="${test.path:var}" relative-to="jboss.server.data.dir">
+ <core-environment node-identifier="${test.node.identifier:1}" path="${test.path:var}" relative-to="${test.relto:jboss.server.data.dir}">
<process-id>
- <uuid/>
+ <socket socket-binding="${test.socket-binding:txn-socket-id}" socket-process-id-max-ports="${test.socket.process.id-max.ports:10}"/>
</process-id>
</core-environment>
- <recovery-environment socket-binding="txn-recovery-environment" status-socket-binding="txn-status-manager"
+ <recovery-environment socket-binding="${test.recovery.socket-binding:txn-recovery-environment" status-socket-binding="${test.recovery.status-socketbinding:txn-status-manager}"
recovery-listener="${test.recovery.listener:false}"/>
<coordinator-environment enable-statistics="${test.enable.statistics:true}" enable-tsm-status="${test.enable.tsm.status:true}"
default-timeout="${test.default.timeout:300}"/>
- <object-store path="${test.store.path:tx-object-store}" relative-to="jboss.server.data.dir"/>
+ <object-store path="${test.store.path:tx-object-store}" relative-to="${test.store.relative-to:jboss.server.data.dir}"/>
<jts/>
<use-hornetq-store/>
</subsystem>
View
14 transactions/src/test/resources/org/jboss/as/txn/full.xml
@@ -0,0 +1,14 @@
+<subsystem xmlns="urn:jboss:domain:transactions:1.2">
+ <core-environment node-identifier="1" path="var" relative-to="jboss.server.data.dir">
+ <process-id>
+ <socket socket-binding="txn-socket-id" socket-process-id-max-ports="10"/>
+ </process-id>
+ </core-environment>
+ <recovery-environment socket-binding="txn-recovery-environment" status-socket-binding="txn-status-manager"
+ recovery-listener="false"/>
+ <coordinator-environment enable-statistics="true" enable-tsm-status="true"
+ default-timeout="300"/>
+ <object-store path="tx-object-store" relative-to="jboss.server.data.dir"/>
+ <jts/>
+ <use-hornetq-store/>
+</subsystem>
View
14 transactions/src/test/resources/org/jboss/as/txn/socket-id.xml
@@ -1,14 +0,0 @@
-<subsystem xmlns="urn:jboss:domain:transactions:1.2">
- <core-environment node-identifier="${test.node.identifier:1}" path="${test.path:var}" relative-to="jboss.server.data.dir">
- <process-id>
- <socket socket-binding="txn-socket-id" socket-process-id-max-ports="${test.socket.process.id-max.ports:10}"/>
- </process-id>
- </core-environment>
- <recovery-environment socket-binding="txn-recovery-environment" status-socket-binding="txn-status-manager"
- recovery-listener="${test.recovery.listener:false}"/>
- <coordinator-environment enable-statistics="${test.enable.statistics:true}" enable-tsm-status="${test.enable.tsm.status:true}"
- default-timeout="${test.default.timeout:300}"/>
- <object-store path="${test.store.path:tx-object-store}" relative-to="jboss.server.data.dir"/>
- <jts/>
- <use-hornetq-store/>
-</subsystem>

0 comments on commit 6f02525

Please sign in to comment.
Something went wrong with that request. Please try again.