use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.
the class OperationSequencesTestCase method testProtocolStackAddRemoveSequenceWithParameters.
/**
* Tests the ability of the /subsystem=jgroups/stack=X:add() operation
* to correctly process the optional TRANSPORT and PROTOCOLS parameters.
*/
@Test
public void testProtocolStackAddRemoveSequenceWithParameters() throws Exception {
KernelServices services = buildKernelServices();
// add a protocol stack specifying TRANSPORT and PROTOCOLS parameters
ModelNode result = services.executeOperation(addStackOpWithParams);
Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
// check some random values
// remove the protocol stack
result = services.executeOperation(removeStackOp);
Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
// remove the protocol stack again
result = services.executeOperation(removeStackOp);
Assert.assertEquals(FAILED, result.get(OUTCOME).asString());
}
use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.
the class AbstractComplexSubsystemTestCase method getModel.
public ModelNode getModel(String resourceFileName, boolean checkMarshalledXML, String archiveName) throws Exception {
String xml = readResource(resourceFileName);
KernelServices services = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT).setSubsystemXml(xml).build();
ModelNode model = services.readWholeModel();
// Marshal the xml to see that it is the same as before
String marshalled = services.getPersistedSubsystemXml();
if (checkMarshalledXML)
Assert.assertEquals(normalizeXML(xml), normalizeXML(marshalled));
services = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT).setSubsystemXml(marshalled).build();
// Check that the model looks the same
ModelNode modelReloaded = services.readWholeModel();
compare(model, modelReloaded);
assertRemoveSubsystemResources(services);
return model;
}
use of org.jboss.as.subsystem.test.KernelServices 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.as.subsystem.test.KernelServices 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.as.subsystem.test.KernelServices in project wildfly by wildfly.
the class DatasourcesSubsystemTestCase method initialKernelServices.
private KernelServices initialKernelServices(KernelServicesBuilder builder, ModelTestControllerVersion controllerVersion, final ModelVersion modelVersion) throws Exception {
LegacyKernelServicesInitializer initializer = builder.createLegacyKernelServicesBuilder(null, controllerVersion, modelVersion);
String mavenGroupId = controllerVersion.getMavenGroupId();
String artifactId = "wildfly-connector";
if (controllerVersion.isEap() && controllerVersion.getMavenGavVersion().equals(controllerVersion.getCoreVersion())) {
// EAP 6
artifactId = "jboss-as-connector";
}
initializer.addMavenResourceURL(mavenGroupId + ":" + artifactId + ":" + controllerVersion.getMavenGavVersion());
initializer.addMavenResourceURL("org.jboss.ironjacamar:ironjacamar-spec-api:1.0.28.Final").addMavenResourceURL("org.jboss.ironjacamar:ironjacamar-common-api:1.0.28.Final").setExtensionClassName("org.jboss.as.connector.subsystems.datasources.DataSourcesExtension").excludeFromParent(SingleClassFilter.createFilter(ConnectorLogger.class));
KernelServices mainServices = builder.build();
Assert.assertTrue(mainServices.isSuccessfulBoot());
KernelServices legacyServices = mainServices.getLegacyServices(modelVersion);
Assert.assertTrue(legacyServices.isSuccessfulBoot());
Assert.assertNotNull(legacyServices);
return mainServices;
}
Aggregations