Search in sources :

Example 31 with ModelVersion

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

the class IDMSubsystem_1_0_TransformerUnitTestCase method testRejectionExpressions.

private void testRejectionExpressions(ModelTestControllerVersion controllerVersion, String picketLinkJBossAs7Version) throws Exception {
    ModelVersion oldVersion = ModelVersion.create(1, 0, 0);
    KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT);
    builder.createLegacyKernelServicesBuilder(null, controllerVersion, oldVersion).setExtensionClassName(IDMExtension.class.getName()).addMavenResourceURL("org.wildfly:wildfly-picketlink:" + controllerVersion.getMavenGavVersion()).addMavenResourceURL("org.picketlink.distribution:picketlink-jbas7:" + picketLinkJBossAs7Version).dontPersistXml();
    KernelServices mainServices = builder.build();
    KernelServices legacyServices = mainServices.getLegacyServices(oldVersion);
    Assert.assertNotNull(legacyServices);
    Assert.assertTrue(mainServices.isSuccessfulBoot());
    Assert.assertTrue(legacyServices.isSuccessfulBoot());
    ModelNode op = createOperation(ADD, ModelElement.PARTITION_MANAGER.getName(), "test.partition", ModelElement.IDENTITY_CONFIGURATION.getName(), "test.config", ModelElement.LDAP_STORE.getName(), "ldap-store");
    op.get(ModelElement.LDAP_STORE_ACTIVE_DIRECTORY.getName()).set(true);
    TransformedOperation transformedOperation = mainServices.transformOperation(oldVersion, op);
    Assert.assertTrue(transformedOperation.rejectOperation(null));
    op = createOperation(ADD, ModelElement.PARTITION_MANAGER.getName(), "test.partition", ModelElement.IDENTITY_CONFIGURATION.getName(), "test.config", ModelElement.LDAP_STORE.getName(), "ldap-store");
    op.get(ModelElement.LDAP_STORE_UNIQUE_ID_ATTRIBUTE_NAME.getName()).set("SOMEaTTRIBUTE");
    transformedOperation = mainServices.transformOperation(oldVersion, op);
    Assert.assertTrue(transformedOperation.rejectOperation(null));
}
Also used : TransformedOperation(org.jboss.as.controller.transform.OperationTransformer.TransformedOperation) 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)

Example 32 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 33 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 34 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 35 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)

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