Search in sources :

Example 26 with Property

use of org.jboss.dmr.Property in project wildfly by wildfly.

the class ResourceAdapterSubsystemParser method writeConDef.

private void writeConDef(XMLExtendedStreamWriter streamWriter, ModelNode conDef, final String poolName, final boolean isXa) throws XMLStreamException {
    streamWriter.writeStartElement(Activation.Tag.CONNECTION_DEFINITION.getLocalName());
    CLASS_NAME.marshallAsAttribute(conDef, streamWriter);
    JNDINAME.marshallAsAttribute(conDef, streamWriter);
    ENABLED.marshallAsAttribute(conDef, streamWriter);
    CONNECTABLE.marshallAsAttribute(conDef, streamWriter);
    TRACKING.marshallAsAttribute(conDef, streamWriter);
    USE_JAVA_CONTEXT.marshallAsAttribute(conDef, streamWriter);
    streamWriter.writeAttribute("pool-name", poolName);
    USE_CCM.marshallAsAttribute(conDef, streamWriter);
    SHARABLE.marshallAsAttribute(conDef, streamWriter);
    ENLISTMENT.marshallAsAttribute(conDef, streamWriter);
    MCP.marshallAsAttribute(conDef, streamWriter);
    ENLISTMENT_TRACE.marshallAsAttribute(conDef, streamWriter);
    writeNewConfigProperties(streamWriter, conDef);
    boolean poolRequired = INITIAL_POOL_SIZE.isMarshallable(conDef) || MAX_POOL_SIZE.isMarshallable(conDef) || MIN_POOL_SIZE.isMarshallable(conDef) || POOL_USE_STRICT_MIN.isMarshallable(conDef) || POOL_PREFILL.isMarshallable(conDef) || POOL_FAIR.isMarshallable(conDef) || POOL_FLUSH_STRATEGY.isMarshallable(conDef);
    final boolean capacityRequired = CAPACITY_INCREMENTER_CLASS.isMarshallable(conDef) || CAPACITY_INCREMENTER_PROPERTIES.isMarshallable(conDef) || CAPACITY_DECREMENTER_CLASS.isMarshallable(conDef) || CAPACITY_DECREMENTER_PROPERTIES.isMarshallable(conDef);
    poolRequired = poolRequired || capacityRequired;
    if (poolRequired) {
        if (isXa) {
            streamWriter.writeStartElement(ConnectionDefinition.Tag.XA_POOL.getLocalName());
            MIN_POOL_SIZE.marshallAsElement(conDef, streamWriter);
            INITIAL_POOL_SIZE.marshallAsElement(conDef, streamWriter);
            MAX_POOL_SIZE.marshallAsElement(conDef, streamWriter);
            POOL_PREFILL.marshallAsElement(conDef, streamWriter);
            POOL_FAIR.marshallAsElement(conDef, streamWriter);
            POOL_USE_STRICT_MIN.marshallAsElement(conDef, streamWriter);
            POOL_FLUSH_STRATEGY.marshallAsElement(conDef, streamWriter);
            SAME_RM_OVERRIDE.marshallAsElement(conDef, streamWriter);
            if (conDef.hasDefined(INTERLEAVING.getName()) && conDef.get(INTERLEAVING.getName()).getType().equals(ModelType.BOOLEAN) && conDef.get(INTERLEAVING.getName()).asBoolean()) {
                streamWriter.writeEmptyElement(INTERLEAVING.getXmlName());
            } else {
                INTERLEAVING.marshallAsElement(conDef, streamWriter);
            }
            if (conDef.hasDefined(NOTXSEPARATEPOOL.getName()) && conDef.get(NOTXSEPARATEPOOL.getName()).getType().equals(ModelType.BOOLEAN) && conDef.get(NOTXSEPARATEPOOL.getName()).asBoolean()) {
                streamWriter.writeEmptyElement(NOTXSEPARATEPOOL.getXmlName());
            } else {
                NOTXSEPARATEPOOL.marshallAsElement(conDef, streamWriter);
            }
            PAD_XID.marshallAsElement(conDef, streamWriter);
            WRAP_XA_RESOURCE.marshallAsElement(conDef, streamWriter);
        } else {
            streamWriter.writeStartElement(ConnectionDefinition.Tag.POOL.getLocalName());
            MIN_POOL_SIZE.marshallAsElement(conDef, streamWriter);
            INITIAL_POOL_SIZE.marshallAsElement(conDef, streamWriter);
            MAX_POOL_SIZE.marshallAsElement(conDef, streamWriter);
            POOL_PREFILL.marshallAsElement(conDef, streamWriter);
            POOL_USE_STRICT_MIN.marshallAsElement(conDef, streamWriter);
            POOL_FLUSH_STRATEGY.marshallAsElement(conDef, streamWriter);
        }
        if (capacityRequired) {
            streamWriter.writeStartElement(Pool.Tag.CAPACITY.getLocalName());
            if (conDef.hasDefined(CAPACITY_INCREMENTER_CLASS.getName())) {
                streamWriter.writeStartElement(Capacity.Tag.INCREMENTER.getLocalName());
                CAPACITY_INCREMENTER_CLASS.marshallAsAttribute(conDef, streamWriter);
                CAPACITY_INCREMENTER_PROPERTIES.marshallAsElement(conDef, streamWriter);
                streamWriter.writeEndElement();
            }
            if (conDef.hasDefined(CAPACITY_DECREMENTER_CLASS.getName())) {
                streamWriter.writeStartElement(Capacity.Tag.DECREMENTER.getLocalName());
                CAPACITY_DECREMENTER_CLASS.marshallAsAttribute(conDef, streamWriter);
                CAPACITY_DECREMENTER_PROPERTIES.marshallAsElement(conDef, streamWriter);
                streamWriter.writeEndElement();
            }
            streamWriter.writeEndElement();
        }
        streamWriter.writeEndElement();
    }
    if (conDef.hasDefined(APPLICATION.getName()) || conDef.hasDefined(SECURITY_DOMAIN.getName()) || conDef.hasDefined(SECURITY_DOMAIN_AND_APPLICATION.getName()) || conDef.hasDefined(ELYTRON_ENABLED.getName())) {
        streamWriter.writeStartElement(ConnectionDefinition.Tag.SECURITY.getLocalName());
        if (conDef.hasDefined(APPLICATION.getName()) && conDef.get(APPLICATION.getName()).getType().equals(ModelType.BOOLEAN) && conDef.get(APPLICATION.getName()).asBoolean()) {
            streamWriter.writeEmptyElement(APPLICATION.getXmlName());
        } else {
            APPLICATION.marshallAsElement(conDef, streamWriter);
        }
        SECURITY_DOMAIN.marshallAsElement(conDef, streamWriter);
        SECURITY_DOMAIN_AND_APPLICATION.marshallAsElement(conDef, streamWriter);
        ELYTRON_ENABLED.marshallAsElement(conDef, streamWriter);
        AUTHENTICATION_CONTEXT.marshallAsElement(conDef, streamWriter);
        AUTHENTICATION_CONTEXT_AND_APPLICATION.marshallAsElement(conDef, streamWriter);
        streamWriter.writeEndElement();
    }
    if (conDef.hasDefined(BLOCKING_TIMEOUT_WAIT_MILLIS.getName()) || conDef.hasDefined(IDLETIMEOUTMINUTES.getName()) || conDef.hasDefined(ALLOCATION_RETRY.getName()) || conDef.hasDefined(ALLOCATION_RETRY_WAIT_MILLIS.getName()) || conDef.hasDefined(XA_RESOURCE_TIMEOUT.getName())) {
        streamWriter.writeStartElement(ConnectionDefinition.Tag.TIMEOUT.getLocalName());
        BLOCKING_TIMEOUT_WAIT_MILLIS.marshallAsElement(conDef, streamWriter);
        IDLETIMEOUTMINUTES.marshallAsElement(conDef, streamWriter);
        ALLOCATION_RETRY.marshallAsElement(conDef, streamWriter);
        ALLOCATION_RETRY_WAIT_MILLIS.marshallAsElement(conDef, streamWriter);
        XA_RESOURCE_TIMEOUT.marshallAsElement(conDef, streamWriter);
        streamWriter.writeEndElement();
    }
    if (conDef.hasDefined(BACKGROUNDVALIDATION.getName()) || conDef.hasDefined(BACKGROUNDVALIDATIONMILLIS.getName()) || conDef.hasDefined(USE_FAST_FAIL.getName()) || conDef.hasDefined(VALIDATE_ON_MATCH.getName())) {
        streamWriter.writeStartElement(ConnectionDefinition.Tag.VALIDATION.getLocalName());
        BACKGROUNDVALIDATION.marshallAsElement(conDef, streamWriter);
        BACKGROUNDVALIDATIONMILLIS.marshallAsElement(conDef, streamWriter);
        USE_FAST_FAIL.marshallAsElement(conDef, streamWriter);
        VALIDATE_ON_MATCH.marshallAsElement(conDef, streamWriter);
        streamWriter.writeEndElement();
    }
    if (conDef.hasDefined(RECOVERY_USERNAME.getName()) || conDef.hasDefined(RECOVERY_PASSWORD.getName()) || conDef.hasDefined(RECOVERY_SECURITY_DOMAIN.getName()) || conDef.hasDefined(RECOVERLUGIN_CLASSNAME.getName()) || conDef.hasDefined(RECOVERLUGIN_PROPERTIES.getName()) || conDef.hasDefined(NO_RECOVERY.getName()) || conDef.hasDefined(ELYTRON_ENABLED.getName())) {
        streamWriter.writeStartElement(ConnectionDefinition.Tag.RECOVERY.getLocalName());
        NO_RECOVERY.marshallAsAttribute(conDef, streamWriter);
        if (conDef.hasDefined(RECOVERY_USERNAME.getName()) || conDef.hasDefined(RECOVERY_PASSWORD.getName()) || conDef.hasDefined(RECOVERY_CREDENTIAL_REFERENCE.getName()) || conDef.hasDefined(RECOVERY_SECURITY_DOMAIN.getName()) || conDef.hasDefined(RECOVERY_ELYTRON_ENABLED.getName())) {
            streamWriter.writeStartElement(Recovery.Tag.RECOVER_CREDENTIAL.getLocalName());
            RECOVERY_USERNAME.marshallAsElement(conDef, streamWriter);
            RECOVERY_PASSWORD.marshallAsElement(conDef, streamWriter);
            RECOVERY_CREDENTIAL_REFERENCE.marshallAsElement(conDef, streamWriter);
            RECOVERY_SECURITY_DOMAIN.marshallAsElement(conDef, streamWriter);
            RECOVERY_ELYTRON_ENABLED.marshallAsElement(conDef, streamWriter);
            RECOVERY_AUTHENTICATION_CONTEXT.marshallAsElement(conDef, streamWriter);
            streamWriter.writeEndElement();
        }
        if (conDef.hasDefined(RECOVERLUGIN_CLASSNAME.getName()) || conDef.hasDefined(RECOVERLUGIN_PROPERTIES.getName())) {
            streamWriter.writeStartElement(Recovery.Tag.RECOVER_PLUGIN.getLocalName());
            RECOVERLUGIN_CLASSNAME.marshallAsAttribute(conDef, streamWriter);
            if (conDef.hasDefined(RECOVERLUGIN_PROPERTIES.getName())) {
                for (Property property : conDef.get(RECOVERLUGIN_PROPERTIES.getName()).asPropertyList()) {
                    writeProperty(streamWriter, conDef, property.getName(), property.getValue().asString(), org.jboss.jca.common.api.metadata.common.Extension.Tag.CONFIG_PROPERTY.getLocalName());
                }
            }
            streamWriter.writeEndElement();
        }
        streamWriter.writeEndElement();
    }
    streamWriter.writeEndElement();
}
Also used : Property(org.jboss.dmr.Property)

Example 27 with Property

use of org.jboss.dmr.Property in project wildfly by wildfly.

the class ResourceAdapterSubsystemParser method writeRaElement.

private void writeRaElement(XMLExtendedStreamWriter streamWriter, ModelNode ra, final String name) throws XMLStreamException {
    streamWriter.writeStartElement(Activations.Tag.RESOURCE_ADAPTER.getLocalName());
    streamWriter.writeAttribute(ResourceAdapterParser.Attribute.ID.getLocalName(), name);
    STATISTICS_ENABLED.marshallAsAttribute(ra, streamWriter);
    ARCHIVE.marshallAsElement(ra, streamWriter);
    MODULE.marshallAsElement(ra, streamWriter);
    BOOTSTRAP_CONTEXT.marshallAsElement(ra, streamWriter);
    if (ra.hasDefined(BEANVALIDATION_GROUPS.getName())) {
        streamWriter.writeStartElement(Activation.Tag.BEAN_VALIDATION_GROUPS.getLocalName());
        for (ModelNode bvg : ra.get(BEANVALIDATION_GROUPS.getName()).asList()) {
            streamWriter.writeStartElement(BEANVALIDATION_GROUPS.getXmlName());
            streamWriter.writeCharacters(bvg.asString());
            streamWriter.writeEndElement();
        }
        streamWriter.writeEndElement();
    }
    TRANSACTION_SUPPORT.marshallAsElement(ra, streamWriter);
    writeNewConfigProperties(streamWriter, ra);
    TransactionSupportEnum transactionSupport = ra.hasDefined(TRANSACTION_SUPPORT.getName()) ? TransactionSupportEnum.valueOf(ra.get(TRANSACTION_SUPPORT.getName()).resolve().asString()) : null;
    boolean isXa = false;
    if (transactionSupport == TransactionSupportEnum.XATransaction) {
        isXa = true;
    }
    if (ra.hasDefined(WM_SECURITY.getName()) && ra.get(WM_SECURITY.getName()).asBoolean()) {
        streamWriter.writeStartElement(Activation.Tag.WORKMANAGER.getLocalName());
        streamWriter.writeStartElement(WorkManager.Tag.SECURITY.getLocalName());
        WM_SECURITY_MAPPING_REQUIRED.marshallAsElement(ra, streamWriter);
        WM_SECURITY_DOMAIN.marshallAsElement(ra, streamWriter);
        WM_ELYTRON_SECURITY_DOMAIN.marshallAsElement(ra, streamWriter);
        WM_SECURITY_DEFAULT_PRINCIPAL.marshallAsElement(ra, streamWriter);
        if (ra.hasDefined(WM_SECURITY_DEFAULT_GROUPS.getName())) {
            streamWriter.writeStartElement(WM_SECURITY_DEFAULT_GROUPS.getXmlName());
            for (ModelNode group : ra.get(WM_SECURITY_DEFAULT_GROUPS.getName()).asList()) {
                streamWriter.writeStartElement(WM_SECURITY_DEFAULT_GROUP.getXmlName());
                streamWriter.writeCharacters(group.asString());
                streamWriter.writeEndElement();
            }
            streamWriter.writeEndElement();
        }
        if (ra.hasDefined(WM_SECURITY_MAPPING_USERS.getName()) || ra.hasDefined(WM_SECURITY_MAPPING_GROUPS.getName())) {
            streamWriter.writeStartElement(WorkManagerSecurity.Tag.MAPPINGS.getLocalName());
            if (ra.hasDefined(WM_SECURITY_MAPPING_USERS.getName())) {
                streamWriter.writeStartElement(WorkManagerSecurity.Tag.USERS.getLocalName());
                for (ModelNode node : ra.get(WM_SECURITY_MAPPING_USERS.getName()).asList()) {
                    streamWriter.writeStartElement(WorkManagerSecurity.Tag.MAP.getLocalName());
                    WM_SECURITY_MAPPING_FROM.marshallAsAttribute(node, streamWriter);
                    WM_SECURITY_MAPPING_TO.marshallAsAttribute(node, streamWriter);
                    streamWriter.writeEndElement();
                }
                streamWriter.writeEndElement();
            }
            if (ra.hasDefined(WM_SECURITY_MAPPING_GROUPS.getName())) {
                streamWriter.writeStartElement(WorkManagerSecurity.Tag.GROUPS.getLocalName());
                for (ModelNode node : ra.get(WM_SECURITY_MAPPING_GROUPS.getName()).asList()) {
                    streamWriter.writeStartElement(WorkManagerSecurity.Tag.MAP.getLocalName());
                    WM_SECURITY_MAPPING_FROM.marshallAsAttribute(node, streamWriter);
                    WM_SECURITY_MAPPING_TO.marshallAsAttribute(node, streamWriter);
                    streamWriter.writeEndElement();
                }
                streamWriter.writeEndElement();
            }
            streamWriter.writeEndElement();
        }
        streamWriter.writeEndElement();
        streamWriter.writeEndElement();
    }
    if (ra.hasDefined(CONNECTIONDEFINITIONS_NAME)) {
        streamWriter.writeStartElement(Activation.Tag.CONNECTION_DEFINITIONS.getLocalName());
        for (Property conDef : ra.get(CONNECTIONDEFINITIONS_NAME).asPropertyList()) {
            writeConDef(streamWriter, conDef.getValue(), conDef.getName(), isXa);
        }
        streamWriter.writeEndElement();
    }
    if (ra.hasDefined(ADMIN_OBJECTS_NAME)) {
        streamWriter.writeStartElement(Activation.Tag.ADMIN_OBJECTS.getLocalName());
        for (Property adminObject : ra.get(ADMIN_OBJECTS_NAME).asPropertyList()) {
            writeAdminObject(streamWriter, adminObject.getValue(), adminObject.getName());
        }
        streamWriter.writeEndElement();
    }
    streamWriter.writeEndElement();
}
Also used : TransactionSupportEnum(org.jboss.jca.common.api.metadata.common.TransactionSupportEnum) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 28 with Property

use of org.jboss.dmr.Property in project wildfly by wildfly.

the class ReadEnvironmentVariablesTestCase method getEnvironmentVariables.

private Map<String, String> getEnvironmentVariables(DomainClient client, String host, String server, String socketBindingGroup) throws Exception {
    ModelNode op = new ModelNode();
    op.get(OP).set(READ_RESOURCE_OPERATION);
    op.get(OP_ADDR).add(HOST, host).add(SERVER, server).add(SOCKET_BINDING_GROUP, socketBindingGroup).add(SOCKET_BINDING, "http");
    op.get(INCLUDE_RUNTIME).set(true);
    ModelNode socketBinding = validateResponse(client.execute(op));
    URL url = new URL("http", TestSuiteEnvironment.formatPossibleIpv6Address(socketBinding.get("bound-address").asString()), socketBinding.get("bound-port").asInt(), "/env-test/env");
    HttpGet get = new HttpGet(url.toURI());
    HttpClient httpClient = HttpClients.createDefault();
    HttpResponse response = httpClient.execute(get);
    ModelNode env = ModelNode.fromJSONStream(response.getEntity().getContent());
    Map<String, String> environment = new HashMap<String, String>();
    for (Property property : env.asPropertyList()) {
        environment.put(property.getName(), property.getValue().asProperty().getName());
    }
    return environment;
}
Also used : HashMap(java.util.HashMap) HttpGet(org.apache.http.client.methods.HttpGet) HttpClient(org.apache.http.client.HttpClient) HttpResponse(org.apache.http.HttpResponse) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property) URL(java.net.URL)

Example 29 with Property

use of org.jboss.dmr.Property in project wildfly by wildfly.

the class JcaDistributedWorkManagerWriteHandler method applyUpdateToRuntime.

@Override
protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<JcaSubsystemConfiguration> jcaSubsystemConfigurationHandbackHolder) throws OperationFailedException {
    final ModelNode address = operation.require(OP_ADDR);
    final String name = PathAddress.pathAddress(address).getLastElement().getValue();
    Object wm = context.getServiceRegistry(true).getService(ConnectorServices.WORKMANAGER_SERVICE.append(name)).getValue();
    if (wm == null || !(wm instanceof NamedDistributedWorkManager)) {
        throw ConnectorLogger.ROOT_LOGGER.failedToFindDistributedWorkManager(name);
    }
    NamedDistributedWorkManager namedDistributedWorkManager = (NamedDistributedWorkManager) wm;
    Injection injector = new Injection();
    if (attributeName.equals(JcaDistributedWorkManagerDefinition.DWmParameters.POLICY.getAttribute().getName())) {
        switch(JcaDistributedWorkManagerDefinition.PolicyValue.valueOf(resolvedValue.asString())) {
            case NEVER:
                {
                    namedDistributedWorkManager.setPolicy(new Never());
                    break;
                }
            case ALWAYS:
                {
                    namedDistributedWorkManager.setPolicy(new Always());
                    break;
                }
            case WATERMARK:
                {
                    namedDistributedWorkManager.setPolicy(new WaterMark());
                    break;
                }
            default:
                {
                    throw ROOT_LOGGER.unsupportedPolicy(resolvedValue.asString());
                }
        }
    } else if (attributeName.equals(JcaDistributedWorkManagerDefinition.DWmParameters.SELECTOR.getAttribute().getName())) {
        switch(JcaDistributedWorkManagerDefinition.SelectorValue.valueOf(resolvedValue.asString())) {
            case FIRST_AVAILABLE:
                {
                    namedDistributedWorkManager.setSelector(new FirstAvailable());
                    break;
                }
            case MAX_FREE_THREADS:
                {
                    namedDistributedWorkManager.setSelector(new MaxFreeThreads());
                    break;
                }
            case PING_TIME:
                {
                    namedDistributedWorkManager.setSelector(new PingTime());
                    break;
                }
            default:
                {
                    throw ROOT_LOGGER.unsupportedSelector(resolvedValue.asString());
                }
        }
    } else if (attributeName.equals(JcaDistributedWorkManagerDefinition.DWmParameters.POLICY_OPTIONS.getAttribute().getName()) && namedDistributedWorkManager.getPolicy() != null) {
        for (Property property : resolvedValue.asPropertyList()) {
            try {
                injector.inject(namedDistributedWorkManager.getPolicy(), property.getName(), property.getValue().asString());
            } catch (Exception e) {
                ROOT_LOGGER.unsupportedPolicyOption(property.getName());
            }
        }
    } else if (attributeName.equals(JcaDistributedWorkManagerDefinition.DWmParameters.SELECTOR_OPTIONS.getAttribute().getName())) {
        for (Property property : resolvedValue.asPropertyList()) {
            try {
                injector.inject(namedDistributedWorkManager.getSelector(), property.getName(), property.getValue().asString());
            } catch (Exception e) {
                ROOT_LOGGER.unsupportedSelectorOption(property.getName());
            }
        }
    }
    return false;
}
Also used : Injection(org.jboss.as.connector.util.Injection) PingTime(org.jboss.jca.core.workmanager.selector.PingTime) FirstAvailable(org.jboss.jca.core.workmanager.selector.FirstAvailable) WaterMark(org.jboss.jca.core.workmanager.policy.WaterMark) OperationFailedException(org.jboss.as.controller.OperationFailedException) NamedDistributedWorkManager(org.jboss.as.connector.services.workmanager.NamedDistributedWorkManager) MaxFreeThreads(org.jboss.jca.core.workmanager.selector.MaxFreeThreads) Never(org.jboss.jca.core.workmanager.policy.Never) Always(org.jboss.jca.core.workmanager.policy.Always) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 30 with Property

use of org.jboss.dmr.Property in project wildfly by wildfly.

the class HostExcludesTestCase method testHostExcludes.

@Test
public void testHostExcludes() throws IOException, MgmtOperationException {
    Set<String> availableExtensions = retrieveAvailableExtensions();
    ModelNode op = Util.getEmptyOperation(READ_CHILDREN_RESOURCES_OPERATION, null);
    op.get(CHILD_TYPE).set(EXTENSION);
    ModelNode result = DomainTestUtils.executeForResult(op, masterClient);
    Set<String> currentExtensions = new HashSet<>();
    for (Property prop : result.asPropertyList()) {
        currentExtensions.add(prop.getName());
    }
    // Check we are able to retrieve at minimum all the extensions defined for the current server
    if (!availableExtensions.containsAll(currentExtensions)) {
        currentExtensions.removeAll(availableExtensions);
        fail(String.format("The following extensions defined in domain.xml cannot be retrieved by this test %s . " + "It could lead in a false negative test result, check HostExcludesTestCase.retrieveAvailableExtensions method", currentExtensions));
    }
    // Check that the list of all available extensions is in the ExtensionConf.CURRENT configuration
    Set<String> current = ExtensionConf.forName(MAJOR).getExtensions(isEeGalleonPack);
    if (!current.equals(availableExtensions)) {
        Set<String> extensionsAdded = diff.apply(current, availableExtensions);
        Set<String> extensionsRemoved = diff.apply(availableExtensions, current);
        fail(String.format("The following extensions %s have been removed on the current release. Remove them on ExtensionConf.CURRENT object defined in this test. " + "The following extensions %s have been added on the current release. Add them to ExtensionConf.CURRENT object defined in this test.", extensionsAdded, extensionsRemoved));
    }
    // not included in this test.
    if (ExtensionConf.CURRENT.isModified()) {
        op = Util.getReadAttributeOperation(null, "product-version");
        result = DomainTestUtils.executeForResult(op, masterClient);
        if (!result.asString().startsWith(ExtensionConf.CURRENT.getName())) {
            fail(String.format("The ExtensionConf.CURRENT has extensions added or removed but it no longer points to the current release. " + "Modify this test adding new ExtensionConf enums for each previous releases undefined in this test by using the list of extensions added or removed on ExtensionConf.CURRENT." + "Then remove all the extensions from ExtensionConf.CURRENT enum and correct the MAJOR number accordingly to point out to the current release."));
        }
    }
    op = Util.getEmptyOperation(READ_CHILDREN_RESOURCES_OPERATION, null);
    op.get(CHILD_TYPE).set(HOST_EXCLUDE);
    result = DomainTestUtils.executeForResult(op, masterClient);
    Set<String> processedExclusionsIds = new HashSet<>();
    for (Property prop : result.asPropertyList()) {
        String name = prop.getName();
        List<String> excludedExtensions = prop.getValue().get(EXCLUDED_EXTENSIONS).asListOrEmpty().stream().map(p -> p.asString()).collect(Collectors.toList());
        // check duplicated extensions
        Assert.assertTrue(String.format("There are duplicated extensions declared for %s host-exclude", name), excludedExtensions.size() == new HashSet<>(excludedExtensions).size());
        // check we have defined the current host-exclude configuration in the test
        ExtensionConf confPrevRelease = ExtensionConf.forName(name);
        Assert.assertNotNull(String.format("This host-exclude name is not defined in this test: %s", name), confPrevRelease);
        // check that available extensions - excluded extensions = expected extensions in a previous release - removed
        Set<String> expectedExtensions = ExtensionConf.forName(name).getExtensions(isEeGalleonPack);
        expectedExtensions.removeAll(ExtensionConf.forName(MAJOR).getRemovedExtensions());
        Set<String> extensionsUnderTest = new HashSet<>(availableExtensions);
        extensionsUnderTest.removeAll(excludedExtensions);
        if (expectedExtensions.size() > extensionsUnderTest.size()) {
            expectedExtensions.removeAll(extensionsUnderTest);
            fail(String.format("These extensions are expected to be available after applying the %s host-exclude configuration to the extensions supplied by this server release: %s", name, expectedExtensions));
        }
        if (extensionsUnderTest.size() != expectedExtensions.size()) {
            extensionsUnderTest.removeAll(expectedExtensions);
            fail(String.format("These extensions are missing on the %s host-exclude: %s", name, extensionsUnderTest));
        }
        processedExclusionsIds.add(name);
    }
    // Verifies all the exclusions Id added as configurations for this test are defined as host exclusions in the current server release
    for (ExtensionConf extensionConf : ExtensionConf.values()) {
        if (extensionConf != ExtensionConf.CURRENT && !processedExclusionsIds.contains(extensionConf.getName())) {
            Set<String> extensions = extensionConf.getExtensions(isEeGalleonPack);
            extensions.removeAll(ExtensionConf.forName(MAJOR).getRemovedExtensions());
            if (!extensions.equals(availableExtensions)) {
                fail(String.format("The %s exclusion id is not defined as host exclusion for the current release.", extensionConf.getName()));
            }
        }
    }
}
Also used : Arrays(java.util.Arrays) BeforeClass(org.junit.BeforeClass) BiFunction(java.util.function.BiFunction) Logger(org.jboss.logging.Logger) HashMap(java.util.HashMap) DomainTestUtils(org.jboss.as.test.integration.domain.management.util.DomainTestUtils) Resource(org.jboss.modules.Resource) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) HOST_EXCLUDE(org.jboss.as.controller.descriptions.ModelDescriptionConstants.HOST_EXCLUDE) DirectoryStream(java.nio.file.DirectoryStream) ModuleLoadException(org.jboss.modules.ModuleLoadException) Util(org.jboss.as.controller.operations.common.Util) Map(java.util.Map) Property(org.jboss.dmr.Property) DomainLifecycleUtil(org.jboss.as.test.integration.domain.management.util.DomainLifecycleUtil) MgmtOperationException(org.jboss.as.test.integration.management.util.MgmtOperationException) Assert.fail(org.junit.Assert.fail) Path(java.nio.file.Path) CHILD_TYPE(org.jboss.as.controller.descriptions.ModelDescriptionConstants.CHILD_TYPE) WildFlyManagedConfiguration(org.jboss.as.test.integration.domain.management.util.WildFlyManagedConfiguration) AfterClass(org.junit.AfterClass) Iterator(java.util.Iterator) Files(java.nio.file.Files) EXCLUDED_EXTENSIONS(org.jboss.as.controller.descriptions.ModelDescriptionConstants.EXCLUDED_EXTENSIONS) Set(java.util.Set) IOException(java.io.IOException) Test(org.junit.Test) LocalModuleLoader(org.jboss.modules.LocalModuleLoader) EXTENSION(org.jboss.as.controller.descriptions.ModelDescriptionConstants.EXTENSION) Collectors(java.util.stream.Collectors) File(java.io.File) DomainClient(org.jboss.as.controller.client.helpers.domain.DomainClient) READ_CHILDREN_RESOURCES_OPERATION(org.jboss.as.controller.descriptions.ModelDescriptionConstants.READ_CHILDREN_RESOURCES_OPERATION) List(java.util.List) Module(org.jboss.modules.Module) Paths(java.nio.file.Paths) ModelNode(org.jboss.dmr.ModelNode) Assert(org.junit.Assert) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

Property (org.jboss.dmr.Property)203 ModelNode (org.jboss.dmr.ModelNode)163 HashMap (java.util.HashMap)22 Test (org.junit.Test)19 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)16 SimpleAttributeDefinition (org.jboss.as.controller.SimpleAttributeDefinition)16 PathAddress (org.jboss.as.controller.PathAddress)12 ArrayList (java.util.ArrayList)11 Map (java.util.Map)11 ValueExpression (org.jboss.dmr.ValueExpression)10 ModelType (org.jboss.dmr.ModelType)9 OperationFailedException (org.jboss.as.controller.OperationFailedException)8 HashSet (java.util.HashSet)7 ArrayDeque (java.util.ArrayDeque)6 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)6 Properties (java.util.Properties)5 LinkedHashMap (java.util.LinkedHashMap)4 LoginModuleControlFlag (javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag)4 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)4 HttpResponse (org.apache.http.HttpResponse)3