Search in sources :

Example 16 with ModelVersion

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

the class DatasourcesSubsystemTestCase method testTransformerEAP7FullConfiguration.

/**
     * Tests transformation of model from latest version which works well in EAP 7.0.0 without setting up FailedOperationTransformationConfig.
     *
     * @throws Exception
     */
private void testTransformerEAP7FullConfiguration(String subsystemXml) throws Exception {
    ModelTestControllerVersion eap7ControllerVersion = ModelTestControllerVersion.EAP_7_0_0;
    ModelVersion eap7ModelVersion = ModelVersion.create(4, 0, 0);
    KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT);
    KernelServices mainServices = initialKernelServices(builder, eap7ControllerVersion, eap7ModelVersion);
    List<ModelNode> ops = builder.parseXmlResource(subsystemXml);
    ModelTestUtils.checkFailedTransformedBootOperations(mainServices, eap7ModelVersion, ops, FailedOperationTransformationConfig.NO_FAILURES);
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelTestControllerVersion(org.jboss.as.model.test.ModelTestControllerVersion) ModelVersion(org.jboss.as.controller.ModelVersion) ModelNode(org.jboss.dmr.ModelNode) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder)

Example 17 with ModelVersion

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

the class DatasourcesSubsystemTestCase method testTransformerEAP7Rejection.

/**
     * Tests transformation of model from latest version which needs to be rejected in EAP 7.0.0
     *
     * @throws Exception
     */
private void testTransformerEAP7Rejection(String subsystemXml) throws Exception {
    //Use the non-runtime version of the extension which will happen on the HC
    ModelTestControllerVersion eap7ControllerVersion = ModelTestControllerVersion.EAP_7_0_0;
    ModelVersion eap7ModelVersion = ModelVersion.create(4, 0, 0);
    KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT);
    KernelServices mainServices = initialKernelServices(builder, eap7ControllerVersion, eap7ModelVersion);
    List<ModelNode> ops = builder.parseXmlResource(subsystemXml);
    PathAddress subsystemAddress = PathAddress.pathAddress(DataSourcesSubsystemRootDefinition.PATH_SUBSYSTEM);
    ModelTestUtils.checkFailedTransformedBootOperations(mainServices, eap7ModelVersion, ops, new FailedOperationTransformationConfig().addFailedAttribute(subsystemAddress.append(DataSourceDefinition.PATH_DATASOURCE), new RejectUndefinedAttribute(Constants.CONNECTION_URL.getName())));
}
Also used : FailedOperationTransformationConfig(org.jboss.as.model.test.FailedOperationTransformationConfig) PathAddress(org.jboss.as.controller.PathAddress) KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelTestControllerVersion(org.jboss.as.model.test.ModelTestControllerVersion) ModelVersion(org.jboss.as.controller.ModelVersion) ModelNode(org.jboss.dmr.ModelNode) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder)

Example 18 with ModelVersion

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

the class NamingExtension method registerTransformers.

private void registerTransformers(SubsystemRegistration subsystem) {
    final ModelVersion v2_0_0 = ModelVersion.create(2, 0, 0);
    ChainedTransformationDescriptionBuilder chainedBuilder = TransformationDescriptionBuilder.Factory.createChainedSubystemInstance(subsystem.getSubsystemVersion());
    ResourceTransformationDescriptionBuilder builder_2_0 = chainedBuilder.createBuilder(subsystem.getSubsystemVersion(), v2_0_0);
    NamingBindingResourceDefinition.INSTANCE.registerTransformers_2_0(builder_2_0);
    chainedBuilder.buildAndRegister(subsystem, new ModelVersion[] { v2_0_0 });
}
Also used : ChainedTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ChainedTransformationDescriptionBuilder) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) ModelVersion(org.jboss.as.controller.ModelVersion)

Example 19 with ModelVersion

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

the class ModClusterTransformersTestCase method testTransformation.

private void testTransformation(ModelTestControllerVersion controllerVersion) throws Exception {
    String[] dependencies = getDependencies(controllerVersion);
    String subsystemXml = readResource("subsystem-transform.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()).setSubsystemXml(subsystemXml);
    builder.createLegacyKernelServicesBuilder(null, controllerVersion, modelVersion).addMavenResourceURL(dependencies).setExtensionClassName(extensionClassName).skipReverseControllerCheck();
    KernelServices mainServices = builder.build();
    KernelServices legacyServices = mainServices.getLegacyServices(modelVersion);
    Assert.assertNotNull(legacyServices);
    Assert.assertTrue(mainServices.isSuccessfulBoot());
    Assert.assertTrue(legacyServices.isSuccessfulBoot());
    checkSubsystemModelTransformation(mainServices, modelVersion, null, false);
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelVersion(org.jboss.as.controller.ModelVersion) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder)

Example 20 with ModelVersion

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

the class InfinispanTransformersTestCase method testRejections.

private void testRejections(final ModelTestControllerVersion controller) throws Exception {
    final ModelVersion version = getModelVersion(controller).getVersion();
    final String[] dependencies = getDependencies(controller);
    // create builder for current subsystem version
    KernelServicesBuilder builder = this.createKernelServicesBuilder();
    // initialize the legacy services
    builder.createLegacyKernelServicesBuilder(createAdditionalInitialization(), controller, version).addSingleChildFirstClass(InfinispanSubsystemInitialization.class).addSingleChildFirstClass(JGroupsSubsystemInitialization.class).addSingleChildFirstClass(org.jboss.as.clustering.subsystem.AdditionalInitialization.class).addMavenResourceURL(dependencies).dontPersistXml();
    KernelServices services = builder.build();
    KernelServices legacyServices = services.getLegacyServices(version);
    Assert.assertNotNull(legacyServices);
    Assert.assertTrue("main services did not boot", services.isSuccessfulBoot());
    Assert.assertTrue(legacyServices.isSuccessfulBoot());
    // test failed operations involving backups
    List<ModelNode> xmlOps = builder.parseXmlResource("infinispan-transformer-reject.xml");
    ModelTestUtils.checkFailedTransformedBootOperations(services, version, xmlOps, createFailedOperationConfig(version));
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelVersion(org.jboss.as.controller.ModelVersion) ModelNode(org.jboss.dmr.ModelNode) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder) JGroupsSubsystemInitialization(org.jboss.as.clustering.jgroups.subsystem.JGroupsSubsystemInitialization)

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