Skip to content

Commit

Permalink
Add EAP6.2 transformers tests for connector subsystems
Browse files Browse the repository at this point in the history
  • Loading branch information
ctomc committed Jul 10, 2015
1 parent 3ac8e75 commit 38087b9
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 625 deletions.
Expand Up @@ -25,17 +25,13 @@
package org.jboss.as.connector.subsystems.datasources; package org.jboss.as.connector.subsystems.datasources;


import static org.jboss.as.connector.subsystems.datasources.Constants.CONNECTABLE; import static org.jboss.as.connector.subsystems.datasources.Constants.CONNECTABLE;
import static org.jboss.as.connector.subsystems.datasources.Constants.CONNECTION_LISTENER_CLASS;
import static org.jboss.as.connector.subsystems.datasources.Constants.CONNECTION_LISTENER_PROPERTIES;
import static org.jboss.as.connector.subsystems.datasources.Constants.DATASOURCE_ATTRIBUTE; import static org.jboss.as.connector.subsystems.datasources.Constants.DATASOURCE_ATTRIBUTE;
import static org.jboss.as.connector.subsystems.datasources.Constants.DATASOURCE_ATTRIBUTE_RELOAD_REQUIRED; import static org.jboss.as.connector.subsystems.datasources.Constants.DATASOURCE_ATTRIBUTE_RELOAD_REQUIRED;
import static org.jboss.as.connector.subsystems.datasources.Constants.DATASOURCE_DISABLE; import static org.jboss.as.connector.subsystems.datasources.Constants.DATASOURCE_DISABLE;
import static org.jboss.as.connector.subsystems.datasources.Constants.DATASOURCE_ENABLE; import static org.jboss.as.connector.subsystems.datasources.Constants.DATASOURCE_ENABLE;
import static org.jboss.as.connector.subsystems.datasources.Constants.DATASOURCE_PROPERTIES_ATTRIBUTES; import static org.jboss.as.connector.subsystems.datasources.Constants.DATASOURCE_PROPERTIES_ATTRIBUTES;
import static org.jboss.as.connector.subsystems.datasources.Constants.DATA_SOURCE; import static org.jboss.as.connector.subsystems.datasources.Constants.DATA_SOURCE;
import static org.jboss.as.connector.subsystems.datasources.Constants.DUMP_QUEUED_THREADS; import static org.jboss.as.connector.subsystems.datasources.Constants.DUMP_QUEUED_THREADS;
import static org.jboss.as.connector.subsystems.datasources.Constants.ENABLE_ADD_TRANSFORMER;
import static org.jboss.as.connector.subsystems.datasources.Constants.ENABLE_TRANSFORMER;
import static org.jboss.as.connector.subsystems.datasources.Constants.FLUSH_ALL_CONNECTION; import static org.jboss.as.connector.subsystems.datasources.Constants.FLUSH_ALL_CONNECTION;
import static org.jboss.as.connector.subsystems.datasources.Constants.FLUSH_GRACEFULLY_CONNECTION; import static org.jboss.as.connector.subsystems.datasources.Constants.FLUSH_GRACEFULLY_CONNECTION;
import static org.jboss.as.connector.subsystems.datasources.Constants.FLUSH_IDLE_CONNECTION; import static org.jboss.as.connector.subsystems.datasources.Constants.FLUSH_IDLE_CONNECTION;
Expand All @@ -60,7 +56,6 @@
import org.jboss.as.controller.access.constraint.ApplicationTypeConfig; import org.jboss.as.controller.access.constraint.ApplicationTypeConfig;
import org.jboss.as.controller.access.management.AccessConstraintDefinition; import org.jboss.as.controller.access.management.AccessConstraintDefinition;
import org.jboss.as.controller.access.management.ApplicationTypeAccessConstraintDefinition; import org.jboss.as.controller.access.management.ApplicationTypeAccessConstraintDefinition;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.transform.TransformationContext; import org.jboss.as.controller.transform.TransformationContext;
Expand Down Expand Up @@ -168,17 +163,9 @@ public List<AccessConstraintDefinition> getAccessConstraints() {
return accessConstraints; return accessConstraints;
} }


static void registerTransformers110(ResourceTransformationDescriptionBuilder parentBuilder) { static void registerTransformers120(ResourceTransformationDescriptionBuilder parentBuilder) {
ResourceTransformationDescriptionBuilder builder = parentBuilder.addChildResource(PATH_DATASOURCE) ResourceTransformationDescriptionBuilder builder = parentBuilder.addChildResource(PATH_DATASOURCE);
.getAttributeBuilder() builder.getAttributeBuilder()
.setDiscard(DiscardAttributeChecker.UNDEFINED,
org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_INCREMENTER_PROPERTIES, CONNECTION_LISTENER_CLASS,
CONNECTION_LISTENER_PROPERTIES,
org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_DECREMENTER_CLASS,
org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_INCREMENTER_CLASS,
org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_DECREMENTER_PROPERTIES,
org.jboss.as.connector.subsystems.common.pool.Constants.INITIAL_POOL_SIZE
)
.setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(new ModelNode(false)), CONNECTABLE) .setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(new ModelNode(false)), CONNECTABLE)
.setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(false, false, new ModelNode(true)), STATISTICS_ENABLED) .setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(false, false, new ModelNode(true)), STATISTICS_ENABLED)
.addRejectCheck(new RejectAttributeChecker.DefaultRejectAttributeChecker() { .addRejectCheck(new RejectAttributeChecker.DefaultRejectAttributeChecker() {
Expand All @@ -195,107 +182,20 @@ protected boolean rejectAttribute(PathAddress address, String attributeName, Mod
return !attributeValue.isDefined() || !attributeValue.asString().equals("true"); return !attributeValue.isDefined() || !attributeValue.asString().equals("true");
} }
}, STATISTICS_ENABLED) }, STATISTICS_ENABLED)
.addRejectCheck(RejectAttributeChecker.DEFINED, .setDiscard(new DiscardAttributeChecker.DefaultDiscardAttributeChecker() {
org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_INCREMENTER_PROPERTIES, CONNECTION_LISTENER_CLASS, @Override
CONNECTION_LISTENER_PROPERTIES, protected boolean isValueDiscardable(PathAddress address, String attributeName, ModelNode attributeValue, TransformationContext context) {
org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_DECREMENTER_CLASS, return attributeValue.equals(new ModelNode(false));
org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_INCREMENTER_CLASS, }
org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_DECREMENTER_PROPERTIES, }, TRACKING)
org.jboss.as.connector.subsystems.common.pool.Constants.INITIAL_POOL_SIZE, .addRejectCheck(RejectAttributeChecker.DEFINED, TRACKING).end()
CONNECTABLE, TRACKING
)
.addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, DATASOURCE_PROPERTIES_ATTRIBUTES)
/*These are nillable in the old model, but appear as not nillable in CompareModelUtils due to problems in the resource description
(leave the line commented out so no one else gets confused)
.addRejectCheck(RejectAttributeChecker.UNDEFINED, Constants.EXCEPTION_SORTER_PROPERTIES, Constants.REAUTHPLUGIN_PROPERTIES, Constants.STALE_CONNECTION_CHECKER_PROPERTIES, Constants.VALID_CONNECTION_CHECKER_PROPERTIES)*/
//Reject expressions for enabled, since if they are used we don't know their value for the operation transformer override
//Reject expressions for enabled, since if they are used we don't know their value for the operation transformer override
.setDiscard(DiscardAttributeChecker.UNDEFINED, TRACKING)
.addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, Constants.ENABLED)
.end()
.addOperationTransformationOverride(ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION)
.inheritResourceAttributeDefinitions()
.setCustomOperationTransformer(ENABLE_TRANSFORMER)
.end()
.addOperationTransformationOverride(ModelDescriptionConstants.UNDEFINE_ATTRIBUTE_OPERATION)
.inheritResourceAttributeDefinitions()
.setCustomOperationTransformer(ENABLE_TRANSFORMER)
.end()
.addOperationTransformationOverride(ModelDescriptionConstants.ADD)
.inheritResourceAttributeDefinitions()
.setCustomOperationTransformer(ENABLE_ADD_TRANSFORMER)
.end()
//We're rejecting operations when statistics-enabled=false, so let it through in the enable/disable ops which do not use that attribute
.addOperationTransformationOverride(DATASOURCE_ENABLE.getName())
.end()
.addOperationTransformationOverride(DATASOURCE_DISABLE.getName())
.end();

ConnectionPropertyDefinition.registerTransformers11x(builder);
}

static void registerTransformers111(ResourceTransformationDescriptionBuilder parentBuilder) {
ResourceTransformationDescriptionBuilder builder = parentBuilder.addChildResource(PATH_DATASOURCE);
builder.getAttributeBuilder()
.setDiscard(DiscardAttributeChecker.UNDEFINED,
org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_INCREMENTER_PROPERTIES, CONNECTION_LISTENER_CLASS,
CONNECTION_LISTENER_PROPERTIES,
org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_DECREMENTER_CLASS,
org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_INCREMENTER_CLASS,
org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_DECREMENTER_PROPERTIES,
org.jboss.as.connector.subsystems.common.pool.Constants.INITIAL_POOL_SIZE
)
.setDiscard(DiscardAttributeChecker.UNDEFINED, TRACKING)
.setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(new ModelNode(false)), CONNECTABLE)
.setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(false, false, new ModelNode(true)), STATISTICS_ENABLED)
.addRejectCheck(new RejectAttributeChecker.DefaultRejectAttributeChecker() {

@Override
public String getRejectionLogMessage(Map<String, ModelNode> attributes) {
return ConnectorLogger.ROOT_LOGGER.rejectAttributesMustBeTrue(attributes.keySet());
}

@Override
protected boolean rejectAttribute(PathAddress address, String attributeName, ModelNode attributeValue,
TransformationContext context) {
//This will not get called if it was discarded, so reject if it is undefined (default==false) or if defined and != 'true'
return !attributeValue.isDefined() || !attributeValue.asString().equals("true");
}
}, STATISTICS_ENABLED).addRejectCheck(RejectAttributeChecker.DEFINED,
org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_INCREMENTER_PROPERTIES, CONNECTION_LISTENER_CLASS,
CONNECTION_LISTENER_PROPERTIES,
org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_DECREMENTER_CLASS,
org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_INCREMENTER_CLASS,
org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_DECREMENTER_PROPERTIES,
org.jboss.as.connector.subsystems.common.pool.Constants.INITIAL_POOL_SIZE,
CONNECTABLE, TRACKING
)
//Reject expressions for enabled, since if they are used we don't know their value for the operation transformer override
//Although 'enabled' appears in the legacy model and the 'add' handler, the add does not actually set its value in the model
.addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, Constants.ENABLED)
.end()
.addOperationTransformationOverride(ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION)
.inheritResourceAttributeDefinitions()
.setCustomOperationTransformer(ENABLE_TRANSFORMER)
.end()
.addOperationTransformationOverride(ModelDescriptionConstants.UNDEFINE_ATTRIBUTE_OPERATION)
.inheritResourceAttributeDefinitions()
.setCustomOperationTransformer(ENABLE_TRANSFORMER)
.end()
.addOperationTransformationOverride(ModelDescriptionConstants.ADD)
.inheritResourceAttributeDefinitions()
.setCustomOperationTransformer(ENABLE_ADD_TRANSFORMER)
.end()
//We're rejecting operations when statistics-enabled=false, so let it through in the enable/disable ops which do not use that attribute //We're rejecting operations when statistics-enabled=false, so let it through in the enable/disable ops which do not use that attribute
.addOperationTransformationOverride(DATASOURCE_ENABLE.getName()) .addOperationTransformationOverride(DATASOURCE_ENABLE.getName())
.end() .end()
.addOperationTransformationOverride(DATASOURCE_DISABLE.getName()) .addOperationTransformationOverride(DATASOURCE_DISABLE.getName())
.end(); .end();

ConnectionPropertyDefinition.registerTransformers11x(builder);
} }



static void registerTransformers200(ResourceTransformationDescriptionBuilder parentBuilder) { static void registerTransformers200(ResourceTransformationDescriptionBuilder parentBuilder) {
ResourceTransformationDescriptionBuilder builder = parentBuilder.addChildResource(PATH_DATASOURCE); ResourceTransformationDescriptionBuilder builder = parentBuilder.addChildResource(PATH_DATASOURCE);
builder.getAttributeBuilder() builder.getAttributeBuilder()
Expand Down
Expand Up @@ -96,37 +96,28 @@ public void registerChildren(ManagementResourceRegistration resourceRegistration
} }


static void registerTransformers(SubsystemRegistration subsystem) { static void registerTransformers(SubsystemRegistration subsystem) {
TransformationDescription.Tools.register(get110TransformationDescription(), subsystem, ModelVersion.create(1, 1, 0)); TransformationDescription.Tools.register(get120TransformationDescription(), subsystem, ModelVersion.create(1, 2, 0)); //EAP 6.2.0
TransformationDescription.Tools.register(get111TransformationDescription(), subsystem, ModelVersion.create(1, 1, 1));
TransformationDescription.Tools.register(get200TransformationDescription(), subsystem, ModelVersion.create(2, 0, 0)); TransformationDescription.Tools.register(get200TransformationDescription(), subsystem, ModelVersion.create(2, 0, 0));
} }




static TransformationDescription get200TransformationDescription() { static TransformationDescription get120TransformationDescription() {


ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createSubsystemInstance(); ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createSubsystemInstance();
//No change //No change
//JdbcDriverDefinition.registerTransformers110(builder); //JdbcDriverDefinition.registerTransformers110(builder);
DataSourceDefinition.registerTransformers200(builder); DataSourceDefinition.registerTransformers120(builder);
XaDataSourceDefinition.registerTransformers200(builder); XaDataSourceDefinition.registerTransformers120(builder);
return builder.build(); return builder.build();
} }


static TransformationDescription get110TransformationDescription() { static TransformationDescription get200TransformationDescription() {

ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createSubsystemInstance();
JdbcDriverDefinition.registerTransformers110(builder);
DataSourceDefinition.registerTransformers110(builder);
XaDataSourceDefinition.registerTransformers110(builder);
return builder.build();
}

static TransformationDescription get111TransformationDescription() {


ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createSubsystemInstance(); ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createSubsystemInstance();
JdbcDriverDefinition.registerTransformers111(builder); //No change
DataSourceDefinition.registerTransformers111(builder); //JdbcDriverDefinition.registerTransformers110(builder);
XaDataSourceDefinition.registerTransformers111(builder); DataSourceDefinition.registerTransformers200(builder);
XaDataSourceDefinition.registerTransformers200(builder);
return builder.build(); return builder.build();
} }


Expand Down

0 comments on commit 38087b9

Please sign in to comment.