Skip to content

Commit 4b35528

Browse files
committed
Run format script
1 parent 22d946a commit 4b35528

File tree

3 files changed

+72
-70
lines changed

3 files changed

+72
-70
lines changed

java/src/org/openqa/selenium/manager/SeleniumManager.java

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,9 @@
1616
// under the License.
1717
package org.openqa.selenium.manager;
1818

19-
import org.openqa.selenium.Beta;
20-
import org.openqa.selenium.Capabilities;
21-
import org.openqa.selenium.Platform;
22-
import org.openqa.selenium.Proxy;
23-
import org.openqa.selenium.WebDriverException;
24-
import org.openqa.selenium.json.Json;
25-
import org.openqa.selenium.json.JsonException;
26-
import org.openqa.selenium.manager.SeleniumManagerOutput.Result;
27-
import org.openqa.selenium.os.CommandLine;
19+
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
20+
import static org.openqa.selenium.Platform.MAC;
21+
import static org.openqa.selenium.Platform.WINDOWS;
2822

2923
import java.io.IOException;
3024
import java.io.InputStream;
@@ -39,10 +33,15 @@
3933
import java.util.Map;
4034
import java.util.logging.Level;
4135
import java.util.logging.Logger;
42-
43-
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
44-
import static org.openqa.selenium.Platform.MAC;
45-
import static org.openqa.selenium.Platform.WINDOWS;
36+
import org.openqa.selenium.Beta;
37+
import org.openqa.selenium.Capabilities;
38+
import org.openqa.selenium.Platform;
39+
import org.openqa.selenium.Proxy;
40+
import org.openqa.selenium.WebDriverException;
41+
import org.openqa.selenium.json.Json;
42+
import org.openqa.selenium.json.JsonException;
43+
import org.openqa.selenium.manager.SeleniumManagerOutput.Result;
44+
import org.openqa.selenium.os.CommandLine;
4645

4746
/**
4847
* This implementation is still in beta, and may change.
@@ -112,10 +111,11 @@ private static Result runCommand(Path binary, List<String> arguments) {
112111
String output;
113112
int code;
114113
try {
115-
CommandLine command = new CommandLine(binary.toAbsolutePath().toString(), arguments.toArray(new String[0]));
114+
CommandLine command =
115+
new CommandLine(binary.toAbsolutePath().toString(), arguments.toArray(new String[0]));
116116
command.copyOutputTo(System.err);
117117
command.executeAsync();
118-
command.waitFor(10000); // A generous timeout
118+
command.waitFor(10000); // A generous timeout
119119
if (command.isRunning()) {
120120
LOG.warning("Selenium Manager did not exit");
121121
}
@@ -146,17 +146,11 @@ private static Result runCommand(Path binary, List<String> arguments) {
146146
}
147147
if (code != 0) {
148148
throw new WebDriverException(
149-
"Command failed with code: "
150-
+ code
151-
+ ", executed: "
152-
+ arguments
153-
+ "\n"
154-
+ dump,
149+
"Command failed with code: " + code + ", executed: " + arguments + "\n" + dump,
155150
failedToParse);
156151
} else if (failedToParse != null || jsonOutput == null) {
157152
throw new WebDriverException(
158-
"Failed to parse json output, executed: " + arguments + "\n" + dump,
159-
failedToParse);
153+
"Failed to parse json output, executed: " + arguments + "\n" + dump, failedToParse);
160154
}
161155
return jsonOutput.result;
162156
}
@@ -198,27 +192,32 @@ private synchronized Path getBinary() {
198192
}
199193

200194
private void deleteOnExit(Path tmpPath) {
201-
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
202-
try {
203-
Files.walkFileTree(
204-
tmpPath,
205-
new SimpleFileVisitor<Path>() {
206-
@Override
207-
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
208-
Files.delete(dir);
209-
return FileVisitResult.CONTINUE;
210-
}
195+
Runtime.getRuntime()
196+
.addShutdownHook(
197+
new Thread(
198+
() -> {
199+
try {
200+
Files.walkFileTree(
201+
tmpPath,
202+
new SimpleFileVisitor<Path>() {
203+
@Override
204+
public FileVisitResult postVisitDirectory(Path dir, IOException exc)
205+
throws IOException {
206+
Files.delete(dir);
207+
return FileVisitResult.CONTINUE;
208+
}
211209

212-
@Override
213-
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
214-
Files.delete(file);
215-
return FileVisitResult.CONTINUE;
216-
}
217-
});
218-
} catch (IOException e) {
219-
// Do nothing. We're just tidying up.
220-
}
221-
}));
210+
@Override
211+
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
212+
throws IOException {
213+
Files.delete(file);
214+
return FileVisitResult.CONTINUE;
215+
}
216+
});
217+
} catch (IOException e) {
218+
// Do nothing. We're just tidying up.
219+
}
220+
}));
222221
}
223222

224223
/**

java/src/org/openqa/selenium/manager/SeleniumManagerOutput.java

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import java.util.List;
2020
import java.util.Objects;
21-
2221
import org.openqa.selenium.json.JsonInput;
2322

2423
public class SeleniumManagerOutput {
@@ -123,12 +122,19 @@ public void setBrowserPath(String browserPath) {
123122

124123
@Override
125124
public String toString() {
126-
return "Result{" +
127-
"code=" + code +
128-
", message='" + message + '\'' +
129-
", driverPath='" + driverPath + '\'' +
130-
", browserPath='" + browserPath + '\'' +
131-
'}';
125+
return "Result{"
126+
+ "code="
127+
+ code
128+
+ ", message='"
129+
+ message
130+
+ '\''
131+
+ ", driverPath='"
132+
+ driverPath
133+
+ '\''
134+
+ ", browserPath='"
135+
+ browserPath
136+
+ '\''
137+
+ '}';
132138
}
133139

134140
@Override
@@ -137,7 +143,10 @@ public boolean equals(Object o) {
137143
return false;
138144
}
139145
Result that = (Result) o;
140-
return code == that.code && Objects.equals(message, that.message) && Objects.equals(driverPath, that.driverPath) && Objects.equals(browserPath, that.browserPath);
146+
return code == that.code
147+
&& Objects.equals(message, that.message)
148+
&& Objects.equals(driverPath, that.driverPath)
149+
&& Objects.equals(browserPath, that.browserPath);
141150
}
142151

143152
@Override

java/test/org/openqa/selenium/testing/drivers/OutOfProcessSeleniumServer.java

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,9 @@
2626
import java.util.ArrayList;
2727
import java.util.List;
2828
import java.util.Objects;
29-
import java.util.ServiceLoader;
3029
import java.util.logging.Logger;
31-
import java.util.stream.Collectors;
3230
import java.util.stream.Stream;
3331
import org.openqa.selenium.Platform;
34-
import org.openqa.selenium.WebDriverInfo;
3532
import org.openqa.selenium.build.BazelBuild;
3633
import org.openqa.selenium.build.DevMode;
3734
import org.openqa.selenium.build.InProject;
@@ -87,14 +84,15 @@ public OutOfProcessSeleniumServer start(String mode, String... extraFlags) {
8784
.map(entry -> "--jvm_flag=-D" + entry.getKey() + "=" + entry.getValue());
8885

8986
// Only use Selenium Manager if we're not running with pinned browsers.
90-
boolean driverProvided = Stream.of(
91-
GeckoDriverService.createDefaultService(),
92-
EdgeDriverService.createDefaultService(),
93-
ChromeDriverService.createDefaultService())
94-
.map(DriverService::getDriverProperty)
95-
.filter(Objects::nonNull)
96-
.map(System::getProperty)
97-
.anyMatch(Objects::nonNull);
87+
boolean driverProvided =
88+
Stream.of(
89+
GeckoDriverService.createDefaultService(),
90+
EdgeDriverService.createDefaultService(),
91+
ChromeDriverService.createDefaultService())
92+
.map(DriverService::getDriverProperty)
93+
.filter(Objects::nonNull)
94+
.map(System::getProperty)
95+
.anyMatch(Objects::nonNull);
9896

9997
List<String> startupArgs = new ArrayList<>();
10098
startupArgs.add(mode);
@@ -111,9 +109,8 @@ public OutOfProcessSeleniumServer start(String mode, String... extraFlags) {
111109
Stream.concat(
112110
javaFlags,
113111
Stream.concat(
114-
// If the driver is provided, we _don't_ want to use Selenium Manager
115-
startupArgs.stream(),
116-
Stream.of(extraFlags)))
112+
// If the driver is provided, we _don't_ want to use Selenium Manager
113+
startupArgs.stream(), Stream.of(extraFlags)))
117114
.toArray(String[]::new));
118115
if (Platform.getCurrent().is(Platform.WINDOWS)) {
119116
File workingDir = findBinRoot(new File(".").getAbsoluteFile());
@@ -165,13 +162,10 @@ public void stop() {
165162
private String buildServerAndClasspath() {
166163
if (DevMode.isInDevMode()) {
167164
Path serverJar =
168-
InProject.locate(
169-
"bazel-bin/java/src/org/openqa/selenium/grid/selenium_server");
165+
InProject.locate("bazel-bin/java/src/org/openqa/selenium/grid/selenium_server");
170166
if (serverJar == null) {
171167
new BazelBuild().build("grid");
172-
serverJar =
173-
InProject.locate(
174-
"bazel-bin/java/src/org/openqa/selenium/grid/selenium_server");
168+
serverJar = InProject.locate("bazel-bin/java/src/org/openqa/selenium/grid/selenium_server");
175169
}
176170
if (serverJar != null) {
177171
return serverJar.toAbsolutePath().toString();

0 commit comments

Comments
 (0)