Skip to content

Commit

Permalink
[plugin-web-app] Deprecate Internet Explorer profile (#4808)
Browse files Browse the repository at this point in the history
  • Loading branch information
valfirst authored Feb 9, 2024
1 parent 114684c commit 6ec59a2
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 6 deletions.
5 changes: 5 additions & 0 deletions docs/modules/plugins/partials/plugin-web-app-profiles.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ web.driver.firefox.command-line-arguments=--turbo
----

.^|`web/desktop/iexplore`
[WARNING]
====
Since Internet Explorer 11 https://blogs.windows.com/windowsexperience/2022/06/15/internet-explorer-11-has-retired-and-is-officially-out-of-support-what-you-need-to-know/[has retired and is officially out of support],
this profile is deprecated and will be removed in VIVIDUS 0.8.0.
====
|
[source, properties]
----
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2023 the original author or authors.
* Copyright 2019-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -66,6 +66,7 @@ public WebDriver getWebDriver(DesiredCapabilities desiredCapabilities, WebDriver
return new FirefoxDriver(options);
}
},
@Deprecated(since = "0.6.8", forRemoval = true)
IEXPLORE(false, true, Browser.IE, InternetExplorerDriverService.IE_DRIVER_EXE_PROPERTY, WebDriverManager::iedriver)
{
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
####################################################################
# Since Internet Explorer 11 has retired and is officially out of support:
# https://blogs.windows.com/windowsexperience/2022/06/15/internet-explorer-11-has-retired-and-is-officially-out-of-support-what-you-need-to-know/,
# this profile is deprecated and will be removed in VIVIDUS 0.8.0.
####################################################################

selenium.browser=iexplore
selenium.grid.capabilities.browserName=internet explorer
selenium.grid.capabilities.se\:ieOptions.iedriverVersion=3.141.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2023 the original author or authors.
* Copyright 2019-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,6 +32,8 @@

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.PropertyPlaceholderHelper;
import org.vividus.spring.SpelExpressionResolver;

Expand All @@ -56,6 +58,15 @@ public final class ConfigurationResolver
"org/vividus/util"
};

// This is the cheapest solution, it breaks low-coupling and other design principles. BUT the implementation of the
// solid solution requires much time and effort and the solution will become useless with removal of the deprecated
// profiles (in general deprecation of the profile is a very rare case). Summing up this is an acceptable trade-off.
private static final Set<String> DEPRECATED_PROFILES = Set.of(
"web/desktop/iexplore"
);

private static final Logger LOGGER = LoggerFactory.getLogger(ConfigurationResolver.class);

private static ConfigurationResolver instance;

private final Properties properties;
Expand Down Expand Up @@ -167,7 +178,11 @@ private static Multimap<String, String> assembleConfiguration(Properties configu
suites = propertyPlaceholderHelper.replacePlaceholders(suites, mergedProperties::getProperty);

Multimap<String, String> configuration = LinkedHashMultimap.create();
configuration.putAll("profile", asPaths(resolveSpel(profiles)));
List<String> parsedProfiles = asPaths(resolveSpel(profiles));
parsedProfiles.stream().filter(DEPRECATED_PROFILES::contains).forEach(profile ->
LOGGER.warn("`{}` profile is deprecated and will be removed in VIVIDUS 0.8.0", profile)
);
configuration.putAll("profile", parsedProfiles);
configuration.putAll("environment", asPaths(resolveSpel(environments)));
configuration.putAll("suite", asPaths(resolveSpel(suites)));
return configuration;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2023 the original author or authors.
* Copyright 2019-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,8 +16,10 @@

package org.vividus.configuration;

import static com.github.valfirst.slf4jtest.LoggingEvent.warn;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
Expand All @@ -33,10 +35,15 @@
import static org.mockito.Mockito.withSettings;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.function.Predicate;

import com.github.valfirst.slf4jtest.TestLogger;
import com.github.valfirst.slf4jtest.TestLoggerFactory;
import com.github.valfirst.slf4jtest.TestLoggerFactoryExtension;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junitpioneer.jupiter.ClearSystemProperty;
Expand All @@ -48,10 +55,11 @@
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.ResourcePatternResolver;

@ExtendWith(MockitoExtension.class)
@ExtendWith({ MockitoExtension.class, TestLoggerFactoryExtension.class })
class ConfigurationResolverTests
{
private static final String DESKTOP_CHROME = "desktop/chrome";
private static final String DEPRECATED_PROFILE = "web/desktop/iexplore";
private static final String CONFIGURATION = "configuration";
private static final String PROPERTY_1 = "property1";
private static final String PROPERTY_2 = "property2";
Expand All @@ -75,7 +83,7 @@ class ConfigurationResolverTests
private static final String ENVIRONMENTS = "environments";
private static final String SUITES = "suites";
private static final String UAT = "uat";
private static final String ACTIVE_PROFILES = "desktop/chrome,nosecurity";
private static final String ACTIVE_PROFILES = DEPRECATED_PROFILE + ",desktop/chrome,nosecurity";
private static final String HTTP_CLIENT_DEFAULT = "org/vividus/http/client";
private static final String UTIL_DEFAULT = "org/vividus/util";
private static final String PROFILE = "profile";
Expand All @@ -94,6 +102,8 @@ class ConfigurationResolverTests

@Mock private ResourcePatternResolver resourcePatternResolver;

private final TestLogger logger = TestLoggerFactory.getTestLogger(ConfigurationResolver.class);

@Test
@ClearSystemProperty(key = ENCRYPTOR_PASSWORD)
void shouldLoadProperties() throws IOException
Expand Down Expand Up @@ -152,6 +162,9 @@ void shouldLoadProperties() throws IOException
PROPERTY_6, DESKTOP_CHROME,
PROPERTY_7, DESKTOP_CHROME)));

when(mock.loadFromResourceTreeRecursively(true, PROFILE, DEPRECATED_PROFILE))
.thenReturn(new Properties());

when(mock.loadFromResourceTreeRecursively(true, ENVIRONMENT, UAT))
.thenReturn(toProperties(Map.of(PROPERTY_5, ENVIRONMENTS,
PROPERTY_6, ENVIRONMENTS)));
Expand Down Expand Up @@ -180,6 +193,7 @@ void shouldLoadProperties() throws IOException
argThat((ArgumentMatcher<Predicate<Resource>>) argument -> !argument.test(resource)), eq(EMPTY_STRING));
ordered.verify(propertiesLoader).loadFromResourceTreeRecursively(true, PROFILE, NOSECURITY);
ordered.verify(propertiesLoader).loadFromResourceTreeRecursively(true, PROFILE, DESKTOP_CHROME);
ordered.verify(propertiesLoader).loadFromResourceTreeRecursively(true, PROFILE, DEPRECATED_PROFILE);
ordered.verify(propertiesLoader).loadFromResourceTreeRecursively(true, ENVIRONMENT, UAT);
ordered.verify(propertiesLoader).loadFromResourceTreeRecursively(false, SUITE, EMPTY_STRING);
ordered.verify(deprecatedPropertiesHandler).replaceDeprecated(any(Properties.class));
Expand Down Expand Up @@ -207,6 +221,8 @@ void shouldLoadProperties() throws IOException
() -> assertEquals(EMPTY_STRING, properties.getProperty(CONFIGURATION_SUITES)),
() -> assertEquals(ACTIVE_PROFILES, properties.getProperty(CONFIGURATION_PROFILES)),
() -> assertEquals(UAT, properties.getProperty(CONFIGURATION_ENVIRONMENTS)));
assertThat(logger.getLoggingEvents(), is(List.of(
warn("`{}` profile is deprecated and will be removed in VIVIDUS 0.8.0", DEPRECATED_PROFILE))));
ConfigurationResolver.reset();
var ise = assertThrows(IllegalStateException.class, configurationResolver::getProperties);
assertEquals("ConfigurationResolver has not been initialized after the reset", ise.getMessage());
Expand Down

0 comments on commit 6ec59a2

Please sign in to comment.