Search in sources :

Example 11 with ModelVersion

use of org.jboss.as.controller.ModelVersion in project wildfly by wildfly.

the class SubsystemTransformerTestCase method testTransformersEAP700.

@Test
public void testTransformersEAP700() throws Exception {
    final KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()).setSubsystemXmlResource("/default-subsystem_1_0.xml");
    final ModelVersion legacyVersion = ModelVersion.create(1, 1, 0);
    final ModelTestControllerVersion controllerVersion = ModelTestControllerVersion.EAP_7_0_0;
    // Add legacy subsystems
    builder.createLegacyKernelServicesBuilder(createAdditionalInitialization(), controllerVersion, legacyVersion).addMavenResourceURL(controllerVersion.getMavenGroupId() + ":wildfly-batch-jberet:" + controllerVersion.getMavenGavVersion()).addMavenResourceURL(controllerVersion.getCoreMavenGroupId() + ":wildfly-threads:" + controllerVersion.getCoreVersion());
    final KernelServices mainServices = builder.build();
    assertTrue(mainServices.isSuccessfulBoot());
    final KernelServices legacyServices = mainServices.getLegacyServices(legacyVersion);
    assertNotNull(legacyServices);
    assertTrue(legacyServices.isSuccessfulBoot());
    checkSubsystemModelTransformation(mainServices, legacyVersion, null, false);
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelTestControllerVersion(org.jboss.as.model.test.ModelTestControllerVersion) ModelVersion(org.jboss.as.controller.ModelVersion) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder) Test(org.junit.Test)

Example 12 with ModelVersion

use of org.jboss.as.controller.ModelVersion in project wildfly by wildfly.

the class InfinispanTransformersTestCase method testTransformation.

@SuppressWarnings("deprecation")
private void testTransformation(final ModelTestControllerVersion controller) throws Exception {
    final ModelVersion version = getModelVersion(controller).getVersion();
    final String[] dependencies = getDependencies(controller);
    KernelServices services = this.buildKernelServices(controller, version, dependencies);
    // check that both versions of the legacy model are the same and valid
    checkSubsystemModelTransformation(services, version, createModelFixer(version), false);
    ModelNode transformed = services.readTransformedModel(version);
    if (InfinispanModel.VERSION_3_0_0.requiresTransformation(version)) {
        // Verify that mode=BATCH is translated to mode=NONE, batching=true
        ModelNode cache = transformed.get(InfinispanSubsystemResourceDefinition.PATH.getKeyValuePair()).get(CacheContainerResourceDefinition.pathElement("maximal").getKeyValuePair()).get(LocalCacheResourceDefinition.pathElement("local").getKeyValuePair());
        Assert.assertTrue(cache.hasDefined(CacheResourceDefinition.DeprecatedAttribute.BATCHING.getName()));
        Assert.assertTrue(cache.get(CacheResourceDefinition.DeprecatedAttribute.BATCHING.getName()).asBoolean());
        ModelNode transaction = cache.get(TransactionResourceDefinition.PATH.getKeyValuePair());
        if (transaction.hasDefined(TransactionResourceDefinition.Attribute.MODE.getName())) {
            Assert.assertEquals(TransactionMode.NONE.name(), transaction.get(TransactionResourceDefinition.Attribute.MODE.getName()).asString());
        }
        // Test properties operations
        propertiesMapOperationsTest(services, version);
    }
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelVersion(org.jboss.as.controller.ModelVersion) ModelNode(org.jboss.dmr.ModelNode)

Example 13 with ModelVersion

use of org.jboss.as.controller.ModelVersion in project wildfly by wildfly.

the class WebSubsystemTestCase method testTransformation_1_3_0.

private void testTransformation_1_3_0(ModelTestControllerVersion controllerVersion) throws Exception {
    ModelVersion modelVersion = ModelVersion.create(1, 3, 0);
    String subsystemXml = readResource("subsystem-1.3.0.xml");
    KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()).setSubsystemXml(subsystemXml);
    builder.createLegacyKernelServicesBuilder(null, controllerVersion, modelVersion).addMavenResourceURL("org.jboss.as:jboss-as-web:" + controllerVersion.getMavenGavVersion()).setExtensionClassName("org.jboss.as.web.WebExtension").configureReverseControllerCheck(createAdditionalInitialization(), null);
    KernelServices mainServices = builder.build();
    KernelServices legacyServices = mainServices.getLegacyServices(modelVersion);
    Assert.assertTrue(mainServices.isSuccessfulBoot());
    Assert.assertTrue(legacyServices.isSuccessfulBoot());
    checkSubsystemModelTransformation(mainServices, modelVersion, new ModelFixer.CumulativeModelFixer(SSLConfigurationNameFixer.INSTANCE, AccessLogPrefixFixer_1_2_0.INSTANCE));
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelVersion(org.jboss.as.controller.ModelVersion) ModelFixer(org.jboss.as.model.test.ModelFixer) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder)

Example 14 with ModelVersion

use of org.jboss.as.controller.ModelVersion in project wildfly by wildfly.

the class ModClusterTransformersTestCase method testRejections.

private void testRejections(ModelTestControllerVersion controllerVersion) throws Exception {
    String[] dependencies = getDependencies(controllerVersion);
    String subsystemXml = readResource("subsystem-reject.xml");
    ModClusterModel model = getModelVersion(controllerVersion);
    ModelVersion modelVersion = model.getVersion();
    String extensionClassName = (model.getVersion().getMajor() == 1) ? "org.jboss.as.modcluster.ModClusterExtension" : "org.wildfly.extension.mod_cluster.ModClusterExtension";
    KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization());
    builder.createLegacyKernelServicesBuilder(null, controllerVersion, modelVersion).addMavenResourceURL(dependencies).setExtensionClassName(extensionClassName);
    KernelServices mainServices = builder.build();
    KernelServices legacyServices = mainServices.getLegacyServices(modelVersion);
    Assert.assertNotNull(legacyServices);
    Assert.assertTrue(mainServices.isSuccessfulBoot());
    Assert.assertTrue(legacyServices.isSuccessfulBoot());
    ModelTestUtils.checkFailedTransformedBootOperations(mainServices, modelVersion, parse(subsystemXml), createFailedOperationConfig(modelVersion));
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelVersion(org.jboss.as.controller.ModelVersion) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder)

Example 15 with ModelVersion

use of org.jboss.as.controller.ModelVersion in project wildfly by wildfly.

the class SecurityDomainModelv30UnitTestCase method testTransformers.

private void testTransformers(ModelTestControllerVersion controllerVersion) throws Exception {
    KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization());
    ModelVersion version = ModelVersion.create(1, 3, 0);
    final String mavenGavVersion = controllerVersion.getMavenGavVersion();
    final String artifactId;
    if (controllerVersion.isEap() && mavenGavVersion.equals(controllerVersion.getCoreVersion())) {
        /* EAP 6 */
        artifactId = "jboss-as-security";
    } else {
        artifactId = "wildfly-security";
    }
    builder.createLegacyKernelServicesBuilder(AdditionalInitialization.MANAGEMENT, controllerVersion, version).addMavenResourceURL(controllerVersion.getMavenGroupId() + ":" + artifactId + ":" + mavenGavVersion);
    KernelServices mainServices = builder.build();
    assertTrue(mainServices.isSuccessfulBoot());
    KernelServices legacyServices = mainServices.getLegacyServices(version);
    assertNotNull(legacyServices);
    assertTrue(legacyServices.isSuccessfulBoot());
    // any elytron-related resources in the model should get rejected as those are not supported in model version 1.3.0.
    PathAddress subsystemAddress = PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, getMainSubsystemName()));
    ModelTestUtils.checkFailedTransformedBootOperations(mainServices, version, builder.parseXmlResource("securitysubsystemv30.xml"), new FailedOperationTransformationConfig().addFailedAttribute(PathAddress.pathAddress(subsystemAddress, PathElement.pathElement(Constants.ELYTRON_REALM)), FailedOperationTransformationConfig.REJECTED_RESOURCE).addFailedAttribute(PathAddress.pathAddress(subsystemAddress, PathElement.pathElement(Constants.ELYTRON_KEY_STORE)), FailedOperationTransformationConfig.REJECTED_RESOURCE).addFailedAttribute(PathAddress.pathAddress(subsystemAddress, PathElement.pathElement(Constants.ELYTRON_TRUST_STORE)), FailedOperationTransformationConfig.REJECTED_RESOURCE).addFailedAttribute(PathAddress.pathAddress(subsystemAddress, PathElement.pathElement(Constants.ELYTRON_KEY_MANAGER)), FailedOperationTransformationConfig.REJECTED_RESOURCE).addFailedAttribute(PathAddress.pathAddress(subsystemAddress, PathElement.pathElement(Constants.ELYTRON_TRUST_MANAGER)), FailedOperationTransformationConfig.REJECTED_RESOURCE).addFailedAttribute(PathAddress.pathAddress(subsystemAddress, PathElement.pathElement(Constants.SECURITY_DOMAIN, "domain-with-custom-audit-provider"), SecurityExtension.PATH_AUDIT_CLASSIC, PathElement.pathElement(Constants.PROVIDER_MODULE, "org.myorg.security.MyCustomLogAuditProvider")), new FailedOperationTransformationConfig.NewAttributesConfig(Constants.MODULE)).addFailedAttribute(PathAddress.pathAddress(subsystemAddress, PathElement.pathElement(Constants.SECURITY_MANAGEMENT)), new FailedOperationTransformationConfig.NewAttributesConfig(Constants.INITIALIZE_JACC)));
}
Also used : FailedOperationTransformationConfig(org.jboss.as.model.test.FailedOperationTransformationConfig) PathAddress(org.jboss.as.controller.PathAddress) KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelVersion(org.jboss.as.controller.ModelVersion) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder)

Aggregations

ModelVersion (org.jboss.as.controller.ModelVersion)37 KernelServices (org.jboss.as.subsystem.test.KernelServices)30 KernelServicesBuilder (org.jboss.as.subsystem.test.KernelServicesBuilder)28 ModelNode (org.jboss.dmr.ModelNode)18 FailedOperationTransformationConfig (org.jboss.as.model.test.FailedOperationTransformationConfig)10 ResourceTransformationDescriptionBuilder (org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder)7 PathAddress (org.jboss.as.controller.PathAddress)6 ChainedTransformationDescriptionBuilder (org.jboss.as.controller.transform.description.ChainedTransformationDescriptionBuilder)5 ModelTestControllerVersion (org.jboss.as.model.test.ModelTestControllerVersion)5 Test (org.junit.Test)4 ModelFixer (org.jboss.as.model.test.ModelFixer)3 NewAttributesConfig (org.jboss.as.model.test.FailedOperationTransformationConfig.NewAttributesConfig)2 AbstractSubsystemBaseTest (org.jboss.as.subsystem.test.AbstractSubsystemBaseTest)2 Map (java.util.Map)1 JGroupsSubsystemInitialization (org.jboss.as.clustering.jgroups.subsystem.JGroupsSubsystemInitialization)1 AdditionalInitialization (org.jboss.as.clustering.subsystem.AdditionalInitialization)1 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)1 TransformedOperation (org.jboss.as.controller.transform.OperationTransformer.TransformedOperation)1 TransformationContext (org.jboss.as.controller.transform.TransformationContext)1 AttributeConverter (org.jboss.as.controller.transform.description.AttributeConverter)1