Java Code Examples for org.jboss.as.subsystem.test.KernelServices#getLegacyServices()

The following examples show how to use org.jboss.as.subsystem.test.KernelServices#getLegacyServices() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoggingSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void testEap7Transformer(final ModelTestControllerVersion controllerVersion, final ModelVersion legacyModelVersion, final String subsystemXml, final ModelFixer... modelFixers) throws Exception {
    final KernelServicesBuilder builder = createKernelServicesBuilder(LoggingTestEnvironment.getManagementInstance())
            .setSubsystemXml(subsystemXml);

    // Create the legacy kernel
    builder.createLegacyKernelServicesBuilder(LoggingTestEnvironment.getManagementInstance(), controllerVersion, legacyModelVersion)
            .addMavenResourceURL(controllerVersion.getCoreMavenGroupId() + ":wildfly-logging:" + controllerVersion.getCoreVersion())
            .dontPersistXml()
            .addSingleChildFirstClass(LoggingTestEnvironment.class)
            .configureReverseControllerCheck(LoggingTestEnvironment.getManagementInstance(), null);

    KernelServices mainServices = builder.build();
    Assert.assertTrue(mainServices.isSuccessfulBoot());
    KernelServices legacyServices = mainServices.getLegacyServices(legacyModelVersion);
    Assert.assertTrue(legacyServices.isSuccessfulBoot());
    Assert.assertNotNull(legacyServices);
    checkSubsystemModelTransformation(mainServices, legacyModelVersion, new ChainedModelFixer(modelFixers));
}
 
Example 2
Source File: LoggingSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void testEapTransformer(final ModelTestControllerVersion controllerVersion, final ModelVersion legacyModelVersion, final String subsystemXml, final ModelFixer... modelFixers) throws Exception {

        final KernelServicesBuilder builder = createKernelServicesBuilder(LoggingTestEnvironment.getManagementInstance())
                .setSubsystemXml(subsystemXml);

        // Create the legacy kernel
        builder.createLegacyKernelServicesBuilder(LoggingTestEnvironment.getManagementInstance(), controllerVersion, legacyModelVersion)
                .addMavenResourceURL("org.jboss.as:jboss-as-logging:" + controllerVersion.getMavenGavVersion())
                .dontPersistXml()
                .addSingleChildFirstClass(LoggingTestEnvironment.class)
                .configureReverseControllerCheck(LoggingTestEnvironment.getManagementInstance(), null);

        KernelServices mainServices = builder.build();
        Assert.assertTrue(mainServices.isSuccessfulBoot());
        KernelServices legacyServices = mainServices.getLegacyServices(legacyModelVersion);
        Assert.assertTrue(legacyServices.isSuccessfulBoot());
        Assert.assertNotNull(legacyServices);
        checkSubsystemModelTransformation(mainServices, legacyModelVersion, new ChainedModelFixer(modelFixers));
    }
 
Example 3
Source File: LoggingSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void testEapFailedTransformers(final ModelTestControllerVersion controllerVersion, final ModelVersion legacyModelVersion, final String subsystemXml, final FailedOperationTransformationConfig config) throws Exception {
    final KernelServicesBuilder builder = createKernelServicesBuilder(LoggingTestEnvironment.getManagementInstance());

    // Create the legacy kernel
    builder.createLegacyKernelServicesBuilder(LoggingTestEnvironment.getManagementInstance(), controllerVersion, legacyModelVersion)
            .addMavenResourceURL("org.jboss.as:jboss-as-logging:" + controllerVersion.getMavenGavVersion())
            .dontPersistXml()
            .addSingleChildFirstClass(LoggingTestEnvironment.class)
            .configureReverseControllerCheck(LoggingTestEnvironment.getManagementInstance(), null);


    KernelServices mainServices = builder.build();
    KernelServices legacyServices = mainServices.getLegacyServices(legacyModelVersion);

    Assert.assertNotNull(legacyServices);
    Assert.assertTrue("main services did not boot", mainServices.isSuccessfulBoot());
    Assert.assertTrue(legacyServices.isSuccessfulBoot());

    final List<ModelNode> ops = builder.parseXml(subsystemXml);
    ModelTestUtils.checkFailedTransformedBootOperations(mainServices, legacyModelVersion, ops, config);
}
 
Example 4
Source File: LoggingSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void testEap7FailedTransformers(final ModelTestControllerVersion controllerVersion, final ModelVersion legacyModelVersion, final String subsystemXml, final FailedOperationTransformationConfig config) throws Exception {
    final KernelServicesBuilder builder = createKernelServicesBuilder(LoggingTestEnvironment.getManagementInstance());

    // Create the legacy kernel
    builder.createLegacyKernelServicesBuilder(LoggingTestEnvironment.getManagementInstance(), controllerVersion, legacyModelVersion)
            .addMavenResourceURL(controllerVersion.getCoreMavenGroupId() + ":wildfly-logging:" + controllerVersion.getCoreVersion())
            .dontPersistXml()
            .addSingleChildFirstClass(LoggingTestEnvironment.class)
            .configureReverseControllerCheck(LoggingTestEnvironment.getManagementInstance(), null);


    KernelServices mainServices = builder.build();
    KernelServices legacyServices = mainServices.getLegacyServices(legacyModelVersion);

    Assert.assertNotNull(legacyServices);
    Assert.assertTrue("main services did not boot", mainServices.isSuccessfulBoot());
    Assert.assertTrue(legacyServices.isSuccessfulBoot());

    final List<ModelNode> ops = builder.parseXml(subsystemXml);
    ModelTestUtils.checkFailedTransformedBootOperations(mainServices, legacyModelVersion, ops, config);
}
 
Example 5
Source File: RemotingSubsystemTransformersTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testTransformersEAP640() throws Exception {
    KernelServicesBuilder builder = createKernelServicesBuilder(DEFAULT_ADDITIONAL_INITIALIZATION)
            .setSubsystemXmlResource("remoting-transformers.xml");

    ModelTestControllerVersion controllerVersion = ModelTestControllerVersion.EAP_6_4_0;
    ModelVersion oldVersion = controllerVersion.getSubsystemModelVersion(getMainSubsystemName());

    // Add legacy subsystems
    builder.createLegacyKernelServicesBuilder(null, controllerVersion)
            .addMavenResourceURL("org.jboss.as:jboss-as-remoting:" + controllerVersion.getMavenGavVersion())
            .skipReverseControllerCheck();
    //.configureReverseControllerCheck(createAdditionalInitialization(), null);
    KernelServices mainServices = builder.build();
    assertTrue(mainServices.isSuccessfulBoot());
    KernelServices legacyServices = mainServices.getLegacyServices(oldVersion);
    assertNotNull(legacyServices);
    assertTrue(legacyServices.isSuccessfulBoot());

    checkSubsystemModelTransformation(mainServices, oldVersion, null, false);
    checkRejectOutboundConnectionProtocolNotRemote(mainServices, oldVersion, CommonAttributes.REMOTE_OUTBOUND_CONNECTION, "remote-conn1");
    checkRejectHttpConnector(mainServices, oldVersion);
    checkRejectEndpointConfiguration(mainServices, oldVersion);
}
 
Example 6
Source File: RemotingSubsystemTransformersTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testTransformersEAP700() throws Exception {
    KernelServicesBuilder builder = createKernelServicesBuilder(DEFAULT_ADDITIONAL_INITIALIZATION)
            .setSubsystemXmlResource("remoting-with-expressions-and-good-legacy-protocol.xml");
    ModelTestControllerVersion controllerVersion = ModelTestControllerVersion.EAP_7_0_0;

    ModelVersion oldVersion = controllerVersion.getSubsystemModelVersion(getMainSubsystemName());
    // Add legacy subsystems
    builder.createLegacyKernelServicesBuilder(DEFAULT_ADDITIONAL_INITIALIZATION, controllerVersion)
            .addMavenResourceURL("org.wildfly.core:wildfly-remoting:" + controllerVersion.getCoreVersion())
            .configureReverseControllerCheck(DEFAULT_ADDITIONAL_INITIALIZATION, null);
    KernelServices mainServices = builder.build();
    assertTrue(mainServices.isSuccessfulBoot());
    KernelServices legacyServices = mainServices.getLegacyServices(oldVersion);
    assertNotNull(legacyServices);
    assertTrue(legacyServices.isSuccessfulBoot());

    checkSubsystemModelTransformation(mainServices, oldVersion, null, false);
}
 
Example 7
Source File: SecurityManagerSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void testTransformers(ModelTestControllerVersion controllerVersion) throws Exception {

        KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT);
        ModelVersion version = ModelVersion.create(2, 0, 0);
        builder.createLegacyKernelServicesBuilder(AdditionalInitialization.MANAGEMENT, controllerVersion, version)
                .addMavenResourceURL("org.jboss.eap:wildfly-security-manager:" + controllerVersion.getMavenGavVersion());

        KernelServices mainServices = builder.build();
        assertTrue(mainServices.isSuccessfulBoot());
        KernelServices legacyServices = mainServices.getLegacyServices(version);
        assertNotNull(legacyServices);
        assertTrue(legacyServices.isSuccessfulBoot());

        PathAddress subsystemAddress = PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, getMainSubsystemName()));
        ModelTestUtils.checkFailedTransformedBootOperations(mainServices, version,
                builder.parseXmlResource("security-manager-reject.xml"),
                new FailedOperationTransformationConfig()
                        .addFailedAttribute(PathAddress.pathAddress(subsystemAddress, PathElement.pathElement(Constants.DEPLOYMENT_PERMISSIONS)),
                                new FailedOperationTransformationConfig.NewAttributesConfig(Constants.MAXIMUM_PERMISSIONS)));
    }
 
Example 8
Source File: TransformerSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void testTransformers(ModelTestControllerVersion controllerVersion) throws Exception {
    ModelVersion oldVersion = ModelVersion.create(1, 0, 0);
    KernelServicesBuilder builder = createKernelServicesBuilder(null)
            .setSubsystemXml(getSubsystemXml());
    builder.createLegacyKernelServicesBuilder(null, controllerVersion, oldVersion)
            .setExtensionClassName(VersionedExtension1.class.getName())
            .addSimpleResourceURL(LEGACY_ARCHIVE.toString())
            .skipReverseControllerCheck();
    KernelServices mainServices = builder.build();
    KernelServices legacyServices = mainServices.getLegacyServices(oldVersion);
    Assert.assertNotNull(legacyServices);


    ModelNode mainModel = mainServices.readWholeModel();
    ModelNode mainSubsystem = mainModel.get(SUBSYSTEM, "test-subsystem");
    Assert.assertEquals(3, mainSubsystem.keys().size());
    Assert.assertEquals("This is only a test", mainSubsystem.get("test-attribute").asString());
    Assert.assertTrue(mainSubsystem.hasDefined("new-element"));
    Assert.assertTrue(mainSubsystem.get("new-element").hasDefined("test"));
    Assert.assertTrue(mainSubsystem.hasDefined("renamed"));
    Assert.assertTrue(mainSubsystem.get("renamed").hasDefined("element"));

    ModelNode legacyModel = legacyServices.readWholeModel();
    ModelNode legacySubsystem = legacyModel.get(SUBSYSTEM, "test-subsystem");
    Assert.assertEquals(2, legacySubsystem.keys().size());
    Assert.assertEquals("This is only a test", legacySubsystem.get("test-attribute").asString());
    Assert.assertTrue(legacySubsystem.hasDefined("element"));
    Assert.assertTrue(legacySubsystem.get("element").hasDefined("renamed"));

    checkSubsystemModelTransformation(mainServices, oldVersion);

    PathAddress subsystemAddress = PathAddress.pathAddress(SUBSYSTEM, "test-subsystem");
    ModelNode writeAttribute = Util.getWriteAttributeOperation(subsystemAddress, "test-attribute", "do reject");
    OperationTransformer.TransformedOperation op = mainServices.executeInMainAndGetTheTransformedOperation(writeAttribute, oldVersion);
    Assert.assertFalse(op.rejectOperation(success()));

    //The model now has the 'magic' old value which gets put into the transformer attachment, which the reject transformer
    //will reject
    writeAttribute = Util.getWriteAttributeOperation(subsystemAddress, "test-attribute", "something else");
    op = mainServices.executeInMainAndGetTheTransformedOperation(writeAttribute, oldVersion);
    Assert.assertTrue(op.rejectOperation(success()));
    legacyServices.shutdown();
    mainServices.shutdown();
}
 
Example 9
Source File: TransformerAttachmentAndInspectModelSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Test
public void testTransformers() throws Exception {
    ModelVersion oldVersion = ModelVersion.create(1, 0, 0);
    KernelServicesBuilder builder = createKernelServicesBuilder(null)
            .setSubsystemXml(getSubsystemXml());
    builder.createLegacyKernelServicesBuilder(null, ModelTestControllerVersion.MASTER, oldVersion)
            .setExtensionClassName(OldExtension.class.getName())
            .addSimpleResourceURL("target/legacy-archive.jar")
            .dontPersistXml()//don't test xml persistence as woodstox parser for legacy test will break it
            .skipReverseControllerCheck();
    KernelServices mainServices = builder.build();
    KernelServices legacyServices = mainServices.getLegacyServices(oldVersion);
    Assert.assertNotNull(legacyServices);


    ModelNode mainModel = mainServices.readWholeModel();
    ModelNode legacyModel = legacyServices.readWholeModel();
    checkModels(mainModel, legacyModel, "Hello", "one", "A", "two", "B");

    //Check the resource transformation results in the same model as the one from the add ops
    Assert.assertEquals(legacyModel.get(SUBSYSTEM, "test-subsystem"), mainServices.readTransformedModel(oldVersion).get(SUBSYSTEM, "test-subsystem"));

    //Remove, change, and add things back to the normal state
    final PathAddress subsystemAddress = PathAddress.pathAddress(SUBSYSTEM, "test-subsystem");

    ModelNode write1 = getMapRemoveOperation(subsystemAddress, "properties", "one");
    transformAndExecuteInLegacyController(mainServices, oldVersion, write1);
    checkModels(mainServices.readWholeModel(), legacyServices.readWholeModel(), "Hello", "two", "B");

    ModelNode write2 = getMapPutOperation(subsystemAddress, "properties", "two", "b");
    transformAndExecuteInLegacyController(mainServices, oldVersion, write2);
    checkModels(mainServices.readWholeModel(), legacyServices.readWholeModel(), "Hello", "two", "b");

    ModelNode write3 = getMapRemoveOperation(subsystemAddress, "properties", "two");
    transformAndExecuteInLegacyController(mainServices, oldVersion, write3);
    checkModels(mainServices.readWholeModel(), legacyServices.readWholeModel(), "Hello");

    ModelNode write4 = getMapPutOperation(subsystemAddress, "properties", "one", "A");
    transformAndExecuteInLegacyController(mainServices, oldVersion, write4);
    checkModels(mainServices.readWholeModel(), legacyServices.readWholeModel(), "Hello", "one", "A");

    ModelNode write5 = getMapPutOperation(subsystemAddress, "properties", "two", "B");
    transformAndExecuteInLegacyController(mainServices, oldVersion, write5);
    checkModels(mainServices.readWholeModel(), legacyServices.readWholeModel(), "Hello", "one", "A", "two", "B");

    //Now try to do the same with a composite
    ModelNode composite = Util.createEmptyOperation(COMPOSITE, PathAddress.EMPTY_ADDRESS);
    composite.get(STEPS).add(write1);
    composite.get(STEPS).add(write2);
    composite.get(STEPS).add(write3);
    transformAndExecuteInLegacyController(mainServices, oldVersion, composite);
    checkModels(mainServices.readWholeModel(), legacyServices.readWholeModel(), "Hello");

    composite = Util.createEmptyOperation(COMPOSITE, PathAddress.EMPTY_ADDRESS);
    composite.get(STEPS).add(write4);
    composite.get(STEPS).add(write5);
    transformAndExecuteInLegacyController(mainServices, oldVersion, composite);
    checkModels(mainServices.readWholeModel(), legacyServices.readWholeModel(), "Hello", "one", "A", "two", "B");
    legacyServices.shutdown();
    mainServices.shutdown();
}