use of org.jboss.as.controller.descriptions.ModelDescriptionConstants.EXCLUDED_EXTENSIONS 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()));
}
}
}
}
Aggregations