Skip to content

Commit

Permalink
Merge branch 'trunk' into renovate/com.github.javaparser-javaparser-c…
Browse files Browse the repository at this point in the history
…ore-3.x
  • Loading branch information
pujagani authored Dec 23, 2024
2 parents adf16e6 + cc5ca35 commit 4f80d0d
Show file tree
Hide file tree
Showing 29 changed files with 89 additions and 46 deletions.
6 changes: 4 additions & 2 deletions java/src/org/openqa/selenium/Architecture.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.openqa.selenium;

import java.util.Locale;

/**
* Represents the known architectures used in WebDriver. It attempts to smooth over some of Java's
* rough edges when dealing with microprocessor architectures by, for instance, allowing you to
Expand Down Expand Up @@ -98,7 +100,7 @@ public int getDataModel() {

@Override
public String toString() {
return name().toLowerCase();
return name().toLowerCase(Locale.ENGLISH);
}

/**
Expand All @@ -121,7 +123,7 @@ public static Architecture getCurrent() {
*/
public static Architecture extractFromSysProperty(String arch) {
if (arch != null) {
arch = arch.toLowerCase();
arch = arch.toLowerCase(Locale.ENGLISH);
}

// Some architectures are basically the same even though they have different names. ia32, x86,
Expand Down
5 changes: 3 additions & 2 deletions java/src/org/openqa/selenium/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.openqa.selenium;

import java.util.Arrays;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -414,7 +415,7 @@ public static Platform extractFromSysProperty(String osName) {
* @return the most likely platform based on given operating system name and version
*/
public static Platform extractFromSysProperty(String osName, String osVersion) {
osName = osName.toLowerCase();
osName = osName.toLowerCase(Locale.ENGLISH);
// os.name for android is linux
if ("dalvik".equalsIgnoreCase(System.getProperty("java.vm.name"))) {
return Platform.ANDROID;
Expand All @@ -434,7 +435,7 @@ public static Platform extractFromSysProperty(String osName, String osVersion) {
if ("".equals(matcher)) {
continue;
}
matcher = matcher.toLowerCase();
matcher = matcher.toLowerCase(Locale.ENGLISH);
if (os.isExactMatch(osName, matcher)) {
return os;
}
Expand Down
6 changes: 4 additions & 2 deletions java/src/org/openqa/selenium/Proxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
Expand Down Expand Up @@ -93,7 +94,8 @@ public Proxy() {
public Proxy(Map<String, ?> raw) {
Map<String, Consumer<Object>> setters = new HashMap<>();
setters.put(
PROXY_TYPE, value -> setProxyType(ProxyType.valueOf(((String) value).toUpperCase())));
PROXY_TYPE,
value -> setProxyType(ProxyType.valueOf(((String) value).toUpperCase(Locale.ENGLISH))));
setters.put(FTP_PROXY, value -> setFtpProxy((String) value));
setters.put(HTTP_PROXY, value -> setHttpProxy((String) value));
setters.put(
Expand Down Expand Up @@ -448,7 +450,7 @@ public String toString() {
case DIRECT:
case MANUAL:
case SYSTEM:
builder.append(getProxyType().toString().toLowerCase());
builder.append(getProxyType().toString().toLowerCase(Locale.ENGLISH));
break;

case PAC:
Expand Down
3 changes: 2 additions & 1 deletion java/src/org/openqa/selenium/chrome/ChromeDriverService.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.WebDriverException;
Expand Down Expand Up @@ -300,7 +301,7 @@ protected List<String> createArgs() {
}

if (logLevel != null) {
args.add(String.format("--log-level=%s", logLevel.toString().toUpperCase()));
args.add(String.format("--log-level=%s", logLevel.toString().toUpperCase(Locale.ENGLISH)));
}
if (allowedListIps != null) {
args.add(String.format("--allowed-ips=%s", allowedListIps));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.openqa.selenium.chromium;

import java.util.Locale;
import java.util.Map;
import java.util.logging.Level;

Expand Down Expand Up @@ -46,7 +47,7 @@ public enum ChromiumDriverLogLevel {

@Override
public String toString() {
return super.toString().toLowerCase();
return super.toString().toLowerCase(Locale.ENGLISH);
}

public static ChromiumDriverLogLevel fromString(String text) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import static org.openqa.selenium.remote.http.Contents.utf8String;

import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import org.openqa.selenium.WebDriver;
Expand Down Expand Up @@ -105,7 +106,7 @@ public void close() {
protected HttpMethod convertFromCdpHttpMethod(String method) {
Require.nonNull("HTTP Method", method);
try {
return HttpMethod.valueOf(method.toUpperCase());
return HttpMethod.valueOf(method.toUpperCase(Locale.ENGLISH));
} catch (IllegalArgumentException e) {
// Spam in a reasonable value
return HttpMethod.GET;
Expand Down
3 changes: 2 additions & 1 deletion java/src/org/openqa/selenium/devtools/idealized/Network.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Base64;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CancellationException;
Expand Down Expand Up @@ -300,7 +301,7 @@ protected Optional<Credentials> getAuthCredentials(URI uri) {
protected HttpMethod convertFromCdpHttpMethod(String method) {
Require.nonNull("HTTP Method", method);
try {
return HttpMethod.valueOf(method.toUpperCase());
return HttpMethod.valueOf(method.toUpperCase(Locale.ENGLISH));
} catch (IllegalArgumentException e) {
// Spam in a reasonable value
return HttpMethod.GET;
Expand Down
3 changes: 2 additions & 1 deletion java/src/org/openqa/selenium/edge/EdgeDriverService.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.WebDriverException;
Expand Down Expand Up @@ -294,7 +295,7 @@ protected List<String> createArgs() {
}

if (logLevel != null) {
args.add(String.format("--log-level=%s", logLevel.toString().toUpperCase()));
args.add(String.format("--log-level=%s", logLevel.toString().toUpperCase(Locale.ENGLISH)));
}
if (Boolean.TRUE.equals(silent)) {
args.add("--silent");
Expand Down
3 changes: 2 additions & 1 deletion java/src/org/openqa/selenium/firefox/FirefoxBinary.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -72,7 +73,7 @@ public String toString() {
* @return the Channel enum value matching the parameter
*/
public static Channel fromString(String name) {
final String lcName = name.toLowerCase();
final String lcName = name.toLowerCase(Locale.ENGLISH);
return stream(Channel.values())
.filter(ch -> ch.name.equals(lcName))
.findFirst()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.openqa.selenium.firefox;

import java.util.Collections;
import java.util.Locale;
import java.util.Map;
import java.util.logging.Level;

Expand Down Expand Up @@ -47,7 +48,7 @@ public enum FirefoxDriverLogLevel {

@Override
public String toString() {
return super.toString().toLowerCase();
return super.toString().toLowerCase(Locale.ENGLISH);
}

public static FirefoxDriverLogLevel fromString(String text) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.Optional;
import java.util.ServiceLoader;
Expand Down Expand Up @@ -194,7 +195,7 @@ public int hashCode() {
}

public String getType(Type type) {
String className = deriveClass(type).getSimpleName().toLowerCase();
String className = deriveClass(type).getSimpleName().toLowerCase(Locale.ENGLISH);

return isCollection(type) ? "list of " + className + "s" : className;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import com.google.common.annotations.VisibleForTesting;
import java.util.Comparator;
import java.util.Locale;
import java.util.Set;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.grid.config.Config;
Expand Down Expand Up @@ -67,7 +68,7 @@ public Set<SlotId> selectSlot(
@VisibleForTesting
long getNumberOfSupportedBrowsers(NodeStatus nodeStatus) {
return nodeStatus.getSlots().stream()
.map(slot -> slot.getStereotype().getBrowserName().toLowerCase())
.map(slot -> slot.getStereotype().getBrowserName().toLowerCase(Locale.ENGLISH))
.distinct()
.count();
}
Expand Down
20 changes: 14 additions & 6 deletions java/src/org/openqa/selenium/grid/node/config/NodeOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.ServiceLoader;
Expand Down Expand Up @@ -582,16 +583,21 @@ private void addSpecificDrivers(

Optional<Map.Entry<WebDriverInfo, Collection<SessionFactory>>> first =
allDrivers.entrySet().stream()
.filter(entry -> drivers.contains(entry.getKey().getDisplayName().toLowerCase()))
.filter(
entry ->
drivers.contains(entry.getKey().getDisplayName().toLowerCase(Locale.ENGLISH)))
.findFirst();

if (first.isEmpty()) {
throw new ConfigException("No drivers were found for %s", drivers.toString());
}

allDrivers.entrySet().stream()
.filter(entry -> drivers.contains(entry.getKey().getDisplayName().toLowerCase()))
.sorted(Comparator.comparing(entry -> entry.getKey().getDisplayName().toLowerCase()))
.filter(
entry -> drivers.contains(entry.getKey().getDisplayName().toLowerCase(Locale.ENGLISH)))
.sorted(
Comparator.comparing(
entry -> entry.getKey().getDisplayName().toLowerCase(Locale.ENGLISH)))
.peek(this::report)
.forEach(
entry -> {
Expand All @@ -614,7 +620,8 @@ private Map<WebDriverInfo, Collection<SessionFactory>> discoverDrivers(
List<WebDriverInfo> driversSM =
StreamSupport.stream(ServiceLoader.load(WebDriverInfo.class).spliterator(), false)
.filter(WebDriverInfo::isAvailable)
.sorted(Comparator.comparing(info -> info.getDisplayName().toLowerCase()))
.sorted(
Comparator.comparing(info -> info.getDisplayName().toLowerCase(Locale.ENGLISH)))
.collect(Collectors.toList());
infos.addAll(driversSM);
} else {
Expand All @@ -625,7 +632,8 @@ private Map<WebDriverInfo, Collection<SessionFactory>> discoverDrivers(
List<WebDriverInfo> localDrivers =
StreamSupport.stream(ServiceLoader.load(WebDriverInfo.class).spliterator(), false)
.filter(WebDriverInfo::isPresent)
.sorted(Comparator.comparing(info -> info.getDisplayName().toLowerCase()))
.sorted(
Comparator.comparing(info -> info.getDisplayName().toLowerCase(Locale.ENGLISH)))
.collect(Collectors.toList());
infos.addAll(localDrivers);
}
Expand Down Expand Up @@ -708,7 +716,7 @@ public Optional<WebDriver> createDriver(Capabilities capabilities)
private int getDriverMaxSessions(WebDriverInfo info, int desiredMaxSessions) {
// Safari and Safari Technology Preview
if (info.getMaximumSimultaneousSessions() == 1
&& SINGLE_SESSION_DRIVERS.contains(info.getDisplayName().toLowerCase())) {
&& SINGLE_SESSION_DRIVERS.contains(info.getDisplayName().toLowerCase(Locale.ENGLISH))) {
return info.getMaximumSimultaneousSessions();
}
boolean overrideMaxSessions =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
Expand Down Expand Up @@ -56,7 +57,7 @@ public Capabilities apply(Capabilities capabilities) {
.setCapability(SE_NO_VNC_PORT, slotStereotype.getCapability(SE_NO_VNC_PORT));
}

String browserName = capabilities.getBrowserName().toLowerCase();
String browserName = capabilities.getBrowserName().toLowerCase(Locale.ENGLISH);

if ("internet explorer".equalsIgnoreCase(browserName)) {
return new ImmutableCapabilities(removeUnknownExtensionsForIE(capabilities));
Expand All @@ -83,7 +84,7 @@ public Capabilities apply(Capabilities capabilities) {
Map<String, Object> toReturn = new HashMap<>(slotStereotype.merge(capabilities).asMap());

// Merge browser specific stereotype and capabilities options
switch (browserName.toLowerCase()) {
switch (browserName.toLowerCase(Locale.ENGLISH)) {
case "chrome":
case "microsoftedge":
case "msedge":
Expand Down
3 changes: 2 additions & 1 deletion java/src/org/openqa/selenium/grid/node/k8s/OneShotNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.net.URISyntaxException;
import java.time.Duration;
import java.time.Instant;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.ServiceLoader;
Expand Down Expand Up @@ -157,7 +158,7 @@ public static Node create(Config config) {
.filter(
info ->
driverName
.map(name -> name.equals(info.getDisplayName().toLowerCase()))
.map(name -> name.equals(info.getDisplayName().toLowerCase(Locale.ENGLISH)))
.orElse(true))
.findFirst()
.orElseThrow(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.time.Duration;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.logging.Logger;
Expand Down Expand Up @@ -122,7 +123,7 @@ public String getServiceProtocolVersion() {

private String normalizeProtocolVersion(String protocolVersion) {
// Support input in the form of "http/1.1" or "HTTP/1.1"
return protocolVersion.toUpperCase().replaceAll("/", "_").replaceAll("\\.", "_");
return protocolVersion.toUpperCase(Locale.ENGLISH).replaceAll("/", "_").replaceAll("\\.", "_");
}

// Method being used in SessionSlot
Expand Down
3 changes: 2 additions & 1 deletion java/src/org/openqa/selenium/grid/web/ResourceHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import java.io.UncheckedIOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Locale;
import java.util.Optional;
import java.util.stream.Collectors;
import org.openqa.selenium.internal.Require;
Expand Down Expand Up @@ -134,7 +135,7 @@ private String mediaType(String uri) {
String extension = (index == -1 || uri.length() == index) ? "" : uri.substring(index + 1);

MediaType type;
switch (extension.toLowerCase()) {
switch (extension.toLowerCase(Locale.ENGLISH)) {
case "appcache":
type = CACHE_MANIFEST_UTF_8;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import com.google.common.collect.ImmutableSet;
import java.io.UncheckedIOException;
import java.util.Locale;
import java.util.logging.Logger;
import org.openqa.selenium.internal.Require;
import org.openqa.selenium.remote.http.HttpClient;
Expand Down Expand Up @@ -78,7 +79,7 @@ public HttpResponse execute(HttpRequest req) throws UncheckedIOException {

req.forEachHeader(
(name, value) -> {
if (IGNORED_REQ_HEADERS.contains(name.toLowerCase())) {
if (IGNORED_REQ_HEADERS.contains(name.toLowerCase(Locale.ENGLISH))) {
return;
}
toUpstream.addHeader(name, value);
Expand Down
Loading

0 comments on commit 4f80d0d

Please sign in to comment.