use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class ComplexResourceAdaptersSubsystemTestCase method testResourceAdapters.
@Test
public void testResourceAdapters() throws Exception {
ModelNode model = getModel("ra.xml", "some.rar");
if (model == null)
return;
// Check model..
Properties params = ParseUtils.raCommonProperties();
ModelNode raCommonModel = model.get("subsystem", "resource-adapters", "resource-adapter", "myRA");
ParseUtils.checkModelParams(raCommonModel, params);
Assert.assertEquals(raCommonModel.asString(), "A", raCommonModel.get("config-properties", "Property", "value").asString());
Assert.assertEquals(raCommonModel.get("beanvalidationgroups").asString(), raCommonModel.get("beanvalidationgroups").asString(), "[\"Class0\",\"Class00\"]");
params = ParseUtils.raAdminProperties();
ModelNode raAdminModel = raCommonModel.get("admin-objects", "Pool2");
ParseUtils.checkModelParams(raAdminModel, params);
Assert.assertEquals(raAdminModel.asString(), "D", raAdminModel.get("config-properties", "Property", "value").asString());
params = ParseUtils.raConnectionProperties();
ModelNode raConnModel = raCommonModel.get("connection-definitions", "Pool1");
ParseUtils.checkModelParams(raConnModel, params);
Assert.assertEquals(raConnModel.asString(), "B", raConnModel.get("config-properties", "Property", "value").asString());
Assert.assertEquals(raConnModel.asString(), "C", raConnModel.get("recovery-plugin-properties", "Property").asString());
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class ResourceAdapterSubsystemParser method writeRaElement.
private void writeRaElement(XMLExtendedStreamWriter streamWriter, ModelNode ra, final String name) throws XMLStreamException {
streamWriter.writeStartElement(Activations.Tag.RESOURCE_ADAPTER.getLocalName());
streamWriter.writeAttribute(ResourceAdapterParser.Attribute.ID.getLocalName(), name);
STATISTICS_ENABLED.marshallAsAttribute(ra, streamWriter);
ARCHIVE.marshallAsElement(ra, streamWriter);
MODULE.marshallAsElement(ra, streamWriter);
BOOTSTRAP_CONTEXT.marshallAsElement(ra, streamWriter);
if (ra.hasDefined(BEANVALIDATION_GROUPS.getName())) {
streamWriter.writeStartElement(Activation.Tag.BEAN_VALIDATION_GROUPS.getLocalName());
for (ModelNode bvg : ra.get(BEANVALIDATION_GROUPS.getName()).asList()) {
streamWriter.writeStartElement(BEANVALIDATION_GROUPS.getXmlName());
streamWriter.writeCharacters(bvg.asString());
streamWriter.writeEndElement();
}
streamWriter.writeEndElement();
}
TRANSACTION_SUPPORT.marshallAsElement(ra, streamWriter);
writeNewConfigProperties(streamWriter, ra);
TransactionSupportEnum transactionSupport = ra.hasDefined(TRANSACTION_SUPPORT.getName()) ? TransactionSupportEnum.valueOf(ra.get(TRANSACTION_SUPPORT.getName()).asString()) : null;
boolean isXa = false;
if (transactionSupport == TransactionSupportEnum.XATransaction) {
isXa = true;
}
if (ra.hasDefined(WM_SECURITY.getName()) && ra.get(WM_SECURITY.getName()).asBoolean()) {
streamWriter.writeStartElement(Activation.Tag.WORKMANAGER.getLocalName());
streamWriter.writeStartElement(WorkManager.Tag.SECURITY.getLocalName());
WM_SECURITY_MAPPING_REQUIRED.marshallAsElement(ra, streamWriter);
WM_SECURITY_DOMAIN.marshallAsElement(ra, streamWriter);
WM_ELYTRON_SECURITY_DOMAIN.marshallAsElement(ra, streamWriter);
WM_SECURITY_DEFAULT_PRINCIPAL.marshallAsElement(ra, streamWriter);
if (ra.hasDefined(WM_SECURITY_DEFAULT_GROUPS.getName())) {
streamWriter.writeStartElement(WM_SECURITY_DEFAULT_GROUPS.getXmlName());
for (ModelNode group : ra.get(WM_SECURITY_DEFAULT_GROUPS.getName()).asList()) {
streamWriter.writeStartElement(WM_SECURITY_DEFAULT_GROUP.getXmlName());
streamWriter.writeCharacters(group.asString());
streamWriter.writeEndElement();
}
streamWriter.writeEndElement();
}
if (ra.hasDefined(WM_SECURITY_MAPPING_USERS.getName()) || ra.hasDefined(WM_SECURITY_MAPPING_GROUPS.getName())) {
streamWriter.writeStartElement(WorkManagerSecurity.Tag.MAPPINGS.getLocalName());
if (ra.hasDefined(WM_SECURITY_MAPPING_USERS.getName())) {
streamWriter.writeStartElement(WorkManagerSecurity.Tag.USERS.getLocalName());
for (ModelNode node : ra.get(WM_SECURITY_MAPPING_USERS.getName()).asList()) {
streamWriter.writeStartElement(WorkManagerSecurity.Tag.MAP.getLocalName());
WM_SECURITY_MAPPING_FROM.marshallAsAttribute(node, streamWriter);
WM_SECURITY_MAPPING_TO.marshallAsAttribute(node, streamWriter);
streamWriter.writeEndElement();
}
streamWriter.writeEndElement();
}
if (ra.hasDefined(WM_SECURITY_MAPPING_GROUPS.getName())) {
streamWriter.writeStartElement(WorkManagerSecurity.Tag.GROUPS.getLocalName());
for (ModelNode node : ra.get(WM_SECURITY_MAPPING_GROUPS.getName()).asList()) {
streamWriter.writeStartElement(WorkManagerSecurity.Tag.MAP.getLocalName());
WM_SECURITY_MAPPING_FROM.marshallAsAttribute(node, streamWriter);
WM_SECURITY_MAPPING_TO.marshallAsAttribute(node, streamWriter);
streamWriter.writeEndElement();
}
streamWriter.writeEndElement();
}
streamWriter.writeEndElement();
}
streamWriter.writeEndElement();
streamWriter.writeEndElement();
}
if (ra.hasDefined(CONNECTIONDEFINITIONS_NAME)) {
streamWriter.writeStartElement(Activation.Tag.CONNECTION_DEFINITIONS.getLocalName());
for (Property conDef : ra.get(CONNECTIONDEFINITIONS_NAME).asPropertyList()) {
writeConDef(streamWriter, conDef.getValue(), conDef.getName(), isXa);
}
streamWriter.writeEndElement();
}
if (ra.hasDefined(ADMIN_OBJECTS_NAME)) {
streamWriter.writeStartElement(Activation.Tag.ADMIN_OBJECTS.getLocalName());
for (Property adminObject : ra.get(ADMIN_OBJECTS_NAME).asPropertyList()) {
writeAdminObject(streamWriter, adminObject.getValue(), adminObject.getName());
}
streamWriter.writeEndElement();
}
streamWriter.writeEndElement();
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class DatasourcesSubsystemTestCase method testTransformer.
/**
* Tests transformation of model from latest version into one passed into modelVersion parameter.
*
* @throws Exception
*/
private void testTransformer(String subsystemXml, ModelTestControllerVersion controllerVersion, final ModelVersion modelVersion) throws Exception {
//Use the non-runtime version of the extension which will happen on the HC
KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT);
KernelServices mainServices = initialKernelServices(builder, controllerVersion, modelVersion);
List<ModelNode> ops = builder.parseXmlResource(subsystemXml);
PathAddress subsystemAddress = PathAddress.pathAddress(DataSourcesSubsystemRootDefinition.PATH_SUBSYSTEM);
ModelTestUtils.checkFailedTransformedBootOperations(mainServices, modelVersion, ops, new FailedOperationTransformationConfig().addFailedAttribute(subsystemAddress.append(DataSourceDefinition.PATH_DATASOURCE), new FailedOperationTransformationConfig.NewAttributesConfig(TRACKING)).addFailedAttribute(subsystemAddress.append(XaDataSourceDefinition.PATH_XA_DATASOURCE), new FailedOperationTransformationConfig.NewAttributesConfig(TRACKING)));
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class DatasourcesSubsystemTestCase method testTransformerElytronEnabled.
/**
* Tests transformation of model from latest version into one passed into modelVersion parameter.
*
* @throws Exception
*/
private void testTransformerElytronEnabled(String subsystemXml, ModelTestControllerVersion controllerVersion, final ModelVersion modelVersion) throws Exception {
//Use the non-runtime version of the extension which will happen on the HC
KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization());
KernelServices mainServices = initialKernelServices(builder, controllerVersion, modelVersion);
List<ModelNode> ops = builder.parseXmlResource(subsystemXml);
PathAddress subsystemAddress = PathAddress.pathAddress(DataSourcesSubsystemRootDefinition.PATH_SUBSYSTEM);
ModelTestUtils.checkFailedTransformedBootOperations(mainServices, modelVersion, ops, new FailedOperationTransformationConfig().addFailedAttribute(subsystemAddress.append(DataSourceDefinition.PATH_DATASOURCE), new FailedOperationTransformationConfig.NewAttributesConfig(TRACKING, ELYTRON_ENABLED, AUTHENTICATION_CONTEXT, CREDENTIAL_REFERENCE)).addFailedAttribute(subsystemAddress.append(XaDataSourceDefinition.PATH_XA_DATASOURCE), new FailedOperationTransformationConfig.NewAttributesConfig(TRACKING, ELYTRON_ENABLED, AUTHENTICATION_CONTEXT, RECOVERY_ELYTRON_ENABLED, RECOVERY_AUTHENTICATION_CONTEXT, CREDENTIAL_REFERENCE, RECOVERY_CREDENTIAL_REFERENCE) {
@Override
protected boolean isAttributeWritable(String attributeName) {
return false;
}
@Override
protected boolean checkValue(String attrName, ModelNode attribute, boolean isWriteAttribute) {
if (attribute.isDefined()) {
return true;
} else {
return false;
}
}
@Override
protected ModelNode correctValue(ModelNode toResolve, boolean isWriteAttribute) {
return new ModelNode();
}
}));
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class JcaSubsystemTestCase method testTransformerWF.
/**
* Tests transformation of model from 1.2.0 version into 1.1.0 version.
*
* @throws Exception
*/
private void testTransformerWF(ModelTestControllerVersion controllerVersion, ModelVersion modelVersion, String xmlResourceName) throws Exception {
// create builder for current subsystem version
KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()).setSubsystemXmlResource(xmlResourceName);
// create builder for legacy subsystem version
builder.createLegacyKernelServicesBuilder(null, controllerVersion, modelVersion).addMavenResourceURL("org.wildfly:wildfly-connector:" + controllerVersion.getMavenGavVersion()).addMavenResourceURL("org.wildfly:wildfly-threads:" + controllerVersion.getMavenGavVersion()).setExtensionClassName("org.jboss.as.connector.subsystems.jca.JcaExtension").excludeFromParent(SingleClassFilter.createFilter(ConnectorLogger.class)).configureReverseControllerCheck(AdditionalInitialization.MANAGEMENT, new ModelFixer() {
@Override
public ModelNode fixModel(ModelNode modelNode) {
//These two are true in the original model but get removed by the transformers, so they default to false. Set them to true
//modelNode.get(Constants.TRACER, Constants.TRACER). add(new ModelNode(Constants.TRACER));
//.add(Constants.TRACER);
modelNode.get(Constants.TRACER, Constants.TRACER, TracerDefinition.TracerParameters.TRACER_ENABLED.getAttribute().getName()).set(true);
return modelNode;
}
});
KernelServices mainServices = builder.build();
KernelServices legacyServices = mainServices.getLegacyServices(modelVersion);
Assert.assertNotNull(legacyServices);
assertTrue("main services did not boot", mainServices.isSuccessfulBoot());
assertTrue(legacyServices.isSuccessfulBoot());
checkSubsystemModelTransformation(mainServices, modelVersion);
}
Aggregations