use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.
the class Ejb3TransformersTestCase method testTransformation.
/**
* Tests transformation of model from current version into specified version
* The xml used should parse on legacy servers without rejections.
*
* @param model
* @param controller
* @param mavenResourceURLs
* @throws Exception
*/
private void testTransformation(ModelVersion model, ModelTestControllerVersion controller, String... mavenResourceURLs) throws Exception {
// create builder for current subsystem version
KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT).setSubsystemXmlResource("subsystem-ejb3-transform.xml");
// initialize the legacy services and add required jars
builder.createLegacyKernelServicesBuilder(null, controller, model).addMavenResourceURL(mavenResourceURLs).skipReverseControllerCheck();
KernelServices services = builder.build();
Assert.assertTrue(services.isSuccessfulBoot());
Assert.assertTrue(services.getLegacyServices(model).isSuccessfulBoot());
// check that both versions of the legacy model are the same and valid
checkSubsystemModelTransformation(services, model, null);
}
use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.
the class SubsystemOperationsTestCase method testRemoveThreadPool.
@Test
public void testRemoveThreadPool() throws Exception {
final KernelServices kernelServices = boot(getSubsystemXml("/minimal-subsystem.xml"));
final ModelNode address = createAddress(BatchSubsystemDefinition.THREAD_POOL_PATH);
// Remove the thread pool
final ModelNode removeOp = SubsystemOperations.createRemoveOperation(address);
executeOperation(kernelServices, removeOp);
// Reboot with a default thread pool
String marshalledXml = kernelServices.getPersistedSubsystemXml();
try {
boot(marshalledXml);
Assert.fail("Should be missing <thread-pool/>");
} catch (XMLStreamException ignore) {
}
// Add back a thread-pool, must be named batch
final ModelNode addOp = SubsystemOperations.createAddOperation(address);
addOp.get("max-threads").set(10);
final ModelNode keepAlive = addOp.get("keepalive-time");
keepAlive.get("time").set(100L);
keepAlive.get("unit").set(TimeUnit.MILLISECONDS.toString());
executeOperation(kernelServices, addOp);
// Get the serialized output and boot
marshalledXml = kernelServices.getPersistedSubsystemXml();
try {
final KernelServices k = boot(marshalledXml);
Assert.assertTrue(k.isSuccessfulBoot());
} catch (XMLStreamException e) {
final StringWriter writer = new StringWriter();
e.printStackTrace(new PrintWriter(writer));
Assert.fail("Failed to parse XML; " + writer.toString());
}
// Remove and add in a composite operation
final Operation compositeOp = CompositeOperationBuilder.create().addStep(removeOp).addStep(addOp).build();
executeOperation(kernelServices, compositeOp);
// Get the serialized output and boot
marshalledXml = kernelServices.getPersistedSubsystemXml();
try {
final KernelServices k = boot(marshalledXml);
Assert.assertTrue(k.isSuccessfulBoot());
} catch (XMLStreamException e) {
final StringWriter writer = new StringWriter();
e.printStackTrace(new PrintWriter(writer));
Assert.fail("Failed to parse XML; " + writer.toString());
}
}
use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.
the class SubsystemOperationsTestCase method testFailure.
@Test
public void testFailure() throws Exception {
final KernelServices kernelServices = boot();
// Add another named job-repository
ModelNode op = SubsystemOperations.createAddOperation(createAddress(JobRepositoryDefinition.NAME, "foo"));
ModelNode result = kernelServices.executeOperation(op);
Assert.assertFalse(SubsystemOperations.isSuccessfulOutcome(result));
// Add another named thread-pool
op = SubsystemOperations.createAddOperation(createAddress(BatchConstants.THREAD_POOL, "foo"));
result = kernelServices.executeOperation(op);
Assert.assertFalse(SubsystemOperations.isSuccessfulOutcome(result));
}
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();
}
}));
}
Aggregations