Search in sources :

Example 1 with ModelFixer

use of org.jboss.as.model.test.ModelFixer in project wildfly by wildfly.

the class JacORBTransformersTestCase method testTransformers.

private void testTransformers(ModelTestControllerVersion controllerVersion, ModelVersion modelVersion) throws Exception {
    KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.ADMIN_ONLY_HC).setSubsystemXmlResource("subsystem-transform.xml");
    // Add legacy subsystems
    builder.createLegacyKernelServicesBuilder(AdditionalInitialization.ADMIN_ONLY_HC, controllerVersion, modelVersion).addMavenResourceURL("org.jboss.as:jboss-as-jacorb:" + controllerVersion.getMavenGavVersion()).configureReverseControllerCheck(AdditionalInitialization.ADMIN_ONLY_HC, null);
    KernelServices mainServices = builder.build();
    KernelServices legacyServices = mainServices.getLegacyServices(modelVersion);
    Assert.assertTrue(mainServices.isSuccessfulBoot());
    Assert.assertTrue(legacyServices.isSuccessfulBoot());
    checkSubsystemModelTransformation(mainServices, modelVersion, new ModelFixer() {

        @Override
        public ModelNode fixModel(ModelNode modelNode) {
            //modelNode.get(JacORBSubsystemDefinitions.PERSISTENT_SERVER_ID.getName()).set(JacORBSubsystemDefinitions.PERSISTENT_SERVER_ID.getDefaultValue());
            modelNode.get(JacORBSubsystemDefinitions.INTEROP_CHUNK_RMI_VALUETYPES.getName()).set(JacORBSubsystemDefinitions.INTEROP_CHUNK_RMI_VALUETYPES.getDefaultValue());
            return modelNode;
        }
    });
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelFixer(org.jboss.as.model.test.ModelFixer) ModelNode(org.jboss.dmr.ModelNode) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder)

Example 2 with ModelFixer

use of org.jboss.as.model.test.ModelFixer in project wildfly by wildfly.

the class TransactionSubsystemTestCase method testTransformersFull.

private void testTransformersFull(ModelTestControllerVersion controllerVersion, ModelVersion modelVersion) throws Exception {
    String subsystemXml = readResource("full-expressions-transform.xml");
    //Use the non-runtime version of the extension which will happen on the HC
    KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT).setSubsystemXml(subsystemXml);
    // Add legacy subsystems
    builder.createLegacyKernelServicesBuilder(null, controllerVersion, modelVersion).addMavenResourceURL("org.jboss.as:jboss-as-transactions:" + controllerVersion.getMavenGavVersion()).addSingleChildFirstClass(RemoveProcessUUIDOperationFixer.class).configureReverseControllerCheck(AdditionalInitialization.MANAGEMENT, ADD_REMOVED_HORNETQ_STORE_ENABLE_ASYNC_IO, RemoveProcessUUIDOperationFixer.INSTANCE).excludeFromParent(SingleClassFilter.createFilter(TransactionLogger.class));
    KernelServices mainServices = builder.build();
    KernelServices legacyServices = mainServices.getLegacyServices(modelVersion);
    Assert.assertTrue(mainServices.isSuccessfulBoot());
    Assert.assertTrue(legacyServices.isSuccessfulBoot());
    checkSubsystemModelTransformation(mainServices, modelVersion, new ModelFixer() {

        @Override
        public ModelNode fixModel(ModelNode modelNode) {
            modelNode.remove("path");
            modelNode.remove("relative-to");
            //only needs to be removed for 6.2
            modelNode.get("process-id-uuid").set(false);
            return modelNode;
        }
    });
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelFixer(org.jboss.as.model.test.ModelFixer) ModelNode(org.jboss.dmr.ModelNode) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder) TransactionLogger(org.jboss.as.txn.logging.TransactionLogger)

Example 3 with ModelFixer

use of org.jboss.as.model.test.ModelFixer 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);
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelFixer(org.jboss.as.model.test.ModelFixer) ModelNode(org.jboss.dmr.ModelNode) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder)

Example 4 with ModelFixer

use of org.jboss.as.model.test.ModelFixer in project wildfly by wildfly.

the class ResourceAdaptersSubsystemTestCase method testTransformer.

/**
     * Tests transformation of model from current to passed one
     *
     * @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).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").excludeFromParent(SingleClassFilter.createFilter(ConnectorLogger.class)).configureReverseControllerCheck(null, new ModelFixer() {

        @Override
        public ModelNode fixModel(ModelNode modelNode) {
            //Replace the value used in the xml
            if (modelNode.get(Constants.RESOURCEADAPTER_NAME).hasDefined("myRA")) {
                if (modelNode.get(Constants.RESOURCEADAPTER_NAME).get("myRA").get(Constants.CONNECTIONDEFINITIONS_NAME).get("poolName").get(Constants.ENLISTMENT.getName()).isDefined()) {
                    modelNode.get(Constants.RESOURCEADAPTER_NAME).get("myRA").get(Constants.CONNECTIONDEFINITIONS_NAME).get("poolName").get(Constants.ENLISTMENT.getName()).set(false);
                }
                if (modelNode.get(Constants.RESOURCEADAPTER_NAME).get("myRA").get(Constants.CONNECTIONDEFINITIONS_NAME).get("poolName").get(Constants.SHARABLE.getName()).isDefined()) {
                    modelNode.get(Constants.RESOURCEADAPTER_NAME).get("myRA").get(Constants.CONNECTIONDEFINITIONS_NAME).get("poolName").get(Constants.SHARABLE.getName()).set(false);
                }
            }
            return modelNode;
        }
    });
    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);
    checkSubsystemModelTransformation(mainServices, modelVersion, null, false);
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelFixer(org.jboss.as.model.test.ModelFixer) ModelNode(org.jboss.dmr.ModelNode) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder)

Example 5 with ModelFixer

use of org.jboss.as.model.test.ModelFixer in project wildfly by wildfly.

the class EeSubsystemTestCase method testTransformersDiscardsImpliedValues1_0_0.

private void testTransformersDiscardsImpliedValues1_0_0(ModelTestControllerVersion controllerVersion) throws Exception {
    String subsystemXml = readResource("subsystem-transformers-discard.xml");
    ModelVersion modelVersion = ModelVersion.create(1, 0, 0);
    //Use the non-runtime version of the extension which will happen on the HC
    KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT).setSubsystemXml(subsystemXml);
    // Add legacy subsystems
    builder.createLegacyKernelServicesBuilder(null, controllerVersion, modelVersion).addMavenResourceURL("org.jboss.as:jboss-as-ee:" + controllerVersion.getMavenGavVersion()).configureReverseControllerCheck(AdditionalInitialization.MANAGEMENT, new ModelFixer() {

        // The regular model will have the new attributes because they are in the xml,
        // but the reverse controller model will not because transformation strips them
        @Override
        public ModelNode fixModel(ModelNode modelNode) {
            for (ModelNode node : modelNode.get(GLOBAL_MODULES).asList()) {
                if ("org.apache.log4j".equals(node.get(NAME).asString())) {
                    if (!node.has(ANNOTATIONS)) {
                        node.get(ANNOTATIONS).set(false);
                    }
                    if (!node.has(META_INF)) {
                        node.get(META_INF).set(false);
                    }
                    if (!node.has(SERVICES)) {
                        node.get(SERVICES).set(true);
                    }
                }
            }
            return modelNode;
        }
    });
    KernelServices mainServices = builder.build();
    KernelServices legacyServices = mainServices.getLegacyServices(modelVersion);
    Assert.assertTrue(mainServices.isSuccessfulBoot());
    Assert.assertTrue(legacyServices.isSuccessfulBoot());
    ModelNode globalModules = mainServices.readTransformedModel(modelVersion).get(ModelDescriptionConstants.SUBSYSTEM, "ee").get(GlobalModulesDefinition.GLOBAL_MODULES);
    for (ModelNode node : globalModules.asList()) {
        if (node.hasDefined(ANNOTATIONS) || node.hasDefined(SERVICES) || node.hasDefined(META_INF)) {
            Assert.fail(node + " -- attributes not discarded");
        }
    }
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelVersion(org.jboss.as.controller.ModelVersion) ModelFixer(org.jboss.as.model.test.ModelFixer) ModelNode(org.jboss.dmr.ModelNode) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder)

Aggregations

ModelFixer (org.jboss.as.model.test.ModelFixer)5 KernelServices (org.jboss.as.subsystem.test.KernelServices)5 KernelServicesBuilder (org.jboss.as.subsystem.test.KernelServicesBuilder)5 ModelNode (org.jboss.dmr.ModelNode)5 ModelVersion (org.jboss.as.controller.ModelVersion)1 TransactionLogger (org.jboss.as.txn.logging.TransactionLogger)1