use of org.jboss.as.subsystem.test.KernelServices 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);
}
use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.
the class ResourceAdaptersSubsystemTestCase method testRejectingTransformer300.
private void testRejectingTransformer300(String subsystemXml, ModelTestControllerVersion controllerVersion, ModelVersion modelVersion) throws Exception {
//Use the non-runtime version of the extension which will happen on the HC
KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT);
//.setSubsystemXmlResource(subsystemXml);
// Add legacy subsystems
builder.createLegacyKernelServicesBuilder(null, controllerVersion, modelVersion).addMavenResourceURL("org.jboss.as:jboss-as-connector:" + controllerVersion.getMavenGavVersion()).addMavenResourceURL("org.jboss.ironjacamar:ironjacamar-spec-api:1.1.4.Final").addMavenResourceURL("org.jboss.ironjacamar:ironjacamar-common-api:1.1.4.Final").setExtensionClassName("org.jboss.as.connector.subsystems.resourceadapters.ResourceAdaptersExtension").addOperationValidationResolve("add", PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, getMainSubsystemName()), PathElement.pathElement("resource-adapter", "*"), PathElement.pathElement("connection-definitions", "*"))).excludeFromParent(SingleClassFilter.createFilter(ConnectorLogger.class)).skipReverseControllerCheck();
KernelServices mainServices = builder.build();
org.junit.Assert.assertTrue(mainServices.isSuccessfulBoot());
KernelServices legacyServices = mainServices.getLegacyServices(modelVersion);
org.junit.Assert.assertTrue(legacyServices.isSuccessfulBoot());
org.junit.Assert.assertNotNull(legacyServices);
List<ModelNode> ops = builder.parseXmlResource(subsystemXml);
PathAddress subsystemAddress = PathAddress.pathAddress(ResourceAdaptersExtension.SUBSYSTEM_PATH);
ModelTestUtils.checkFailedTransformedBootOperations(mainServices, modelVersion, ops, new FailedOperationTransformationConfig().addFailedAttribute(subsystemAddress.append(PathElement.pathElement(RESOURCEADAPTER_NAME), ConnectionDefinitionResourceDefinition.PATH), FailedOperationTransformationConfig.REJECTED_RESOURCE));
}
use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.
the class ResourceAdaptersSubsystemTestCase method testRejectingTransformerElytronEnabled.
/**
* Tests transformation of model from current to passed one
*
* @throws Exception
*/
private void testRejectingTransformerElytronEnabled(String subsystemXml, ModelTestControllerVersion controllerVersion, ModelVersion modelVersion) throws Exception {
//Use the non-runtime version of the extension which will happen on the HC
KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT);
//.setSubsystemXmlResource(subsystemXml);
// Add legacy subsystems
builder.createLegacyKernelServicesBuilder(null, controllerVersion, modelVersion).addMavenResourceURL("org.jboss.as:jboss-as-connector:" + controllerVersion.getMavenGavVersion()).addMavenResourceURL("org.jboss.ironjacamar:ironjacamar-spec-api:1.1.4.Final").addMavenResourceURL("org.jboss.ironjacamar:ironjacamar-common-api:1.1.4.Final").setExtensionClassName("org.jboss.as.connector.subsystems.resourceadapters.ResourceAdaptersExtension").addOperationValidationResolve("add", PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, getMainSubsystemName()), PathElement.pathElement("resource-adapter", "*"), PathElement.pathElement("connection-definitions", "*"))).excludeFromParent(SingleClassFilter.createFilter(ConnectorLogger.class)).skipReverseControllerCheck();
KernelServices mainServices = builder.build();
org.junit.Assert.assertTrue(mainServices.isSuccessfulBoot());
KernelServices legacyServices = mainServices.getLegacyServices(modelVersion);
org.junit.Assert.assertTrue(legacyServices.isSuccessfulBoot());
org.junit.Assert.assertNotNull(legacyServices);
List<ModelNode> ops = builder.parseXmlResource(subsystemXml);
PathAddress subsystemAddress = PathAddress.pathAddress(ResourceAdaptersExtension.SUBSYSTEM_PATH);
ModelTestUtils.checkFailedTransformedBootOperations(mainServices, modelVersion, ops, new FailedOperationTransformationConfig().addFailedAttribute(subsystemAddress.append(PathElement.pathElement(RESOURCEADAPTER_NAME)), new FailedOperationTransformationConfig.AttributesPathAddressConfig(WM_SECURITY.getName(), WM_SECURITY_MAPPING_REQUIRED.getName(), WM_ELYTRON_SECURITY_DOMAIN.getName(), MODULE.getName(), STATISTICS_ENABLED.getName()) {
@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();
}
}).addFailedAttribute(subsystemAddress.append(PathElement.pathElement(RESOURCEADAPTER_NAME), ConnectionDefinitionResourceDefinition.PATH), FailedOperationTransformationConfig.ChainedConfig.createBuilder(Constants.CONNECTABLE, Constants.TRACKING).addConfig(new FailedOperationTransformationConfig.RejectExpressionsConfig(Constants.CONNECTABLE) {
@Override
protected boolean checkValue(String attrName, ModelNode attribute, boolean isWriteAttribute) {
if (super.checkValue(attrName, attribute, isWriteAttribute)) {
return true;
}
return attribute.asBoolean();
}
@Override
protected ModelNode correctValue(ModelNode toResolve, boolean isWriteAttribute) {
return new ModelNode(false);
}
}).addConfig(new FailedOperationTransformationConfig.AttributesPathAddressConfig(TRACKING.getName(), ELYTRON_ENABLED.getName(), AUTHENTICATION_CONTEXT.getName(), MCP.getName(), RECOVERY_ELYTRON_ENABLED.getName(), RECOVERY_AUTHENTICATION_CONTEXT.getName(), RECOVERY_CREDENTIAL_REFERENCE.getName()) {
@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();
}
}).build()));
}
use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.
the class EeLegacySubsystemTestCase method testSubsystem.
@Test
public void testSubsystem() throws Exception {
KernelServices services = standardSubsystemTest("subsystem_1_2.xml", false);
ModelNode model = services.readWholeModel();
ModelNode subsystem = model.require(SUBSYSTEM).require(EeExtension.SUBSYSTEM_NAME);
ModelNode globalModules = subsystem.require(GLOBAL_MODULES);
assertEquals("org.jboss.logging", globalModules.require(0).require(NAME).asString());
assertEquals("main", globalModules.require(0).require(SLOT).asString());
assertEquals("org.apache.log4j", globalModules.require(1).require(NAME).asString());
assertTrue(globalModules.require(1).require(ANNOTATIONS).asBoolean());
assertTrue(globalModules.require(1).require(META_INF).asBoolean());
assertFalse(globalModules.require(1).require(SERVICES).asBoolean());
assertFalse(subsystem.require(ANNOTATION_PROPERTY_REPLACEMENT).asBoolean());
assertTrue(subsystem.require(EAR_SUBDEPLOYMENTS_ISOLATED).asBoolean());
assertTrue(subsystem.require(JBOSS_DESCRIPTOR_PROPERTY_REPLACEMENT).asBoolean());
assertFalse(subsystem.require(SPEC_DESCRIPTOR_PROPERTY_REPLACEMENT).asBoolean());
}
use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.
the class EeOperationsTestCase method testManagedExecutorFailureOperations.
@Test
public void testManagedExecutorFailureOperations() throws Exception {
// Boot the container
final KernelServices kernelServices = createKernelServicesBuilder(createAdditionalInitialization()).setSubsystemXml(getSubsystemXml()).build();
// Default address
final ModelNode address = Operations.createAddress(ClientConstants.SUBSYSTEM, EeExtension.SUBSYSTEM_NAME, "managed-executor-service", "default");
// Create a composite operation that should fail; note that if the queue-length is undefined, 0 or Integer.MAX_VALUE the
// core-threads must be greater than 0
ModelNode op = Operations.createWriteAttributeOperation(address, "core-threads", 0);
ModelNode result = kernelServices.executeOperation(op);
Assert.assertFalse(Operations.isSuccessfulOutcome(result));
op = CompositeOperationBuilder.create().addStep(Operations.createWriteAttributeOperation(address, "queue-length", Integer.MAX_VALUE)).addStep(Operations.createWriteAttributeOperation(address, "core-threads", 0)).build().getOperation();
result = kernelServices.executeOperation(op);
Assert.assertFalse(Operations.isSuccessfulOutcome(result));
op = CompositeOperationBuilder.create().addStep(Operations.createWriteAttributeOperation(address, "queue-length", 0)).addStep(Operations.createWriteAttributeOperation(address, "core-threads", 0)).build().getOperation();
result = kernelServices.executeOperation(op);
Assert.assertFalse(Operations.isSuccessfulOutcome(result));
// The max-threads must be greater than or equal to the core-threads
op = CompositeOperationBuilder.create().addStep(Operations.createWriteAttributeOperation(address, "core-threads", 4)).addStep(Operations.createWriteAttributeOperation(address, "max-threads", 1)).build().getOperation();
result = kernelServices.executeOperation(op);
Assert.assertFalse(Operations.isSuccessfulOutcome(result));
// Test a failure at the runtime-stage
op = CompositeOperationBuilder.create().addStep(Operations.createWriteAttributeOperation(address, "queue-length", "${test.queue-length:10}")).addStep(Operations.createWriteAttributeOperation(address, "core-threads", "${test.core-threads:500}")).build().getOperation();
result = kernelServices.executeOperation(op);
Assert.assertFalse(Operations.isSuccessfulOutcome(result));
// The max-threads must be greater than or equal to the core-threads
final int calculatedMaxThreads = (ProcessorInfo.availableProcessors() * 2);
op = CompositeOperationBuilder.create().addStep(Operations.createWriteAttributeOperation(address, "core-threads", calculatedMaxThreads)).addStep(Operations.createWriteAttributeOperation(address, "max-threads", calculatedMaxThreads - 1)).build().getOperation();
result = kernelServices.executeOperation(op);
Assert.assertFalse(Operations.isSuccessfulOutcome(result));
}
Aggregations