Skip to content

Commit 7f28ee0

Browse files
committed
[java] Formatting files
1 parent 9940567 commit 7f28ee0

7 files changed

Lines changed: 167 additions & 172 deletions

File tree

java/src/dev/selenium/tools/modules/ModuleGenerator.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -170,23 +170,24 @@ public static void main(String[] args) throws IOException {
170170
List.of(
171171
"--module-path",
172172
modulePath.stream()
173-
.map((s) -> {
174-
String file = s.getFileName().toString();
173+
.map(
174+
(s) -> {
175+
String file = s.getFileName().toString();
175176

176-
if (file.startsWith("processed_")) {
177-
Path copy = tmp.resolve(file.substring(10));
177+
if (file.startsWith("processed_")) {
178+
Path copy = tmp.resolve(file.substring(10));
178179

179-
try {
180-
Files.copy(s, copy, StandardCopyOption.REPLACE_EXISTING);
181-
} catch (IOException e) {
182-
throw new UncheckedIOException(e);
183-
}
180+
try {
181+
Files.copy(s, copy, StandardCopyOption.REPLACE_EXISTING);
182+
} catch (IOException e) {
183+
throw new UncheckedIOException(e);
184+
}
184185

185-
return copy.toString();
186-
}
186+
return copy.toString();
187+
}
187188

188-
return s.toString();
189-
})
189+
return s.toString();
190+
})
190191
.collect(Collectors.joining(File.pathSeparator))));
191192
}
192193
jdepsArgs.addAll(List.of("--generate-module-info", temp.toAbsolutePath().toString()));

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

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,9 @@ private static String runCommand(String... command) {
114114
} catch (InterruptedException e) {
115115
Thread.currentThread().interrupt();
116116
throw new WebDriverException(
117-
"Interrupted while running command: "
118-
+ Arrays.toString(command),
119-
e);
117+
"Interrupted while running command: " + Arrays.toString(command), e);
120118
} catch (Exception e) {
121-
throw new WebDriverException(
122-
"Failed to run command: "
123-
+ Arrays.toString(command),
124-
e);
119+
throw new WebDriverException("Failed to run command: " + Arrays.toString(command), e);
125120
}
126121
SeleniumManagerJsonOutput jsonOutput = null;
127122
JsonException failedToParse = null;
@@ -130,33 +125,32 @@ private static String runCommand(String... command) {
130125
try {
131126
jsonOutput = new Json().toType(output, SeleniumManagerJsonOutput.class);
132127
jsonOutput.logs.forEach(
133-
logged -> {
134-
if (logged.level.equalsIgnoreCase(WARN)) {
135-
LOG.warning(logged.message);
136-
}
137-
if (logged.level.equalsIgnoreCase(DEBUG) || logged.level.equalsIgnoreCase(INFO)) {
138-
LOG.fine(logged.message);
139-
}
140-
});
128+
logged -> {
129+
if (logged.level.equalsIgnoreCase(WARN)) {
130+
LOG.warning(logged.message);
131+
}
132+
if (logged.level.equalsIgnoreCase(DEBUG) || logged.level.equalsIgnoreCase(INFO)) {
133+
LOG.fine(logged.message);
134+
}
135+
});
141136
dump = jsonOutput.result.message;
142137
} catch (JsonException e) {
143138
failedToParse = e;
144139
}
145140
}
146141
if (code != 0) {
147142
throw new WebDriverException(
148-
"Command failed with code: "
149-
+ code
150-
+ ", executed: "
151-
+ Arrays.toString(command)
152-
+ "\n"
153-
+ dump, failedToParse);
143+
"Command failed with code: "
144+
+ code
145+
+ ", executed: "
146+
+ Arrays.toString(command)
147+
+ "\n"
148+
+ dump,
149+
failedToParse);
154150
} else if (failedToParse != null) {
155151
throw new WebDriverException(
156-
"Failed to parse json output, executed: "
157-
+ Arrays.toString(command)
158-
+ "\n"
159-
+ dump, failedToParse);
152+
"Failed to parse json output, executed: " + Arrays.toString(command) + "\n" + dump,
153+
failedToParse);
160154
}
161155
return jsonOutput.result.message;
162156
}

java/src/org/openqa/selenium/remote/service/DriverFinder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ public static String getPath(DriverService service, Capabilities options) {
2121
}
2222

2323
if (service.getDriverExecutable() != null) {
24-
// This is needed for Safari Technology Preview until Selenium Manager manages locating on PATH
24+
// This is needed for Safari Technology Preview until Selenium Manager manages locating on
25+
// PATH
2526
exePath = service.getDriverExecutable().getAbsolutePath();
2627
}
2728

java/test/org/openqa/selenium/ProxySettingTest.java

Lines changed: 36 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,12 @@
2727

2828
import com.google.common.base.Joiner;
2929
import com.google.common.net.HostAndPort;
30-
3130
import io.netty.handler.codec.http.FullHttpResponse;
3231
import io.netty.handler.codec.http.HttpRequest;
33-
3432
import java.net.URI;
3533
import java.net.URISyntaxException;
3634
import java.util.HashSet;
3735
import java.util.Set;
38-
3936
import org.junit.jupiter.api.Test;
4037
import org.openqa.selenium.netty.server.SimpleHttpServer;
4138
import org.openqa.selenium.remote.http.HttpMethod;
@@ -85,19 +82,18 @@ public void canConfigureNoProxy() throws URISyntaxException, InterruptedExceptio
8582
@NoDriverBeforeTest
8683
@NoDriverAfterTest
8784
public void canConfigureProxyThroughPACFile() throws URISyntaxException, InterruptedException {
88-
try (SimpleHttpServer helloServer = createSimpleHttpServer(
89-
appServer.whereElseIs("mouseOver.html"),
90-
"<!DOCTYPE html><title>Hello</title><h3>Hello, world!</h3>"
91-
);
85+
try (SimpleHttpServer helloServer =
86+
createSimpleHttpServer(
87+
appServer.whereElseIs("mouseOver.html"),
88+
"<!DOCTYPE html><title>Hello</title><h3>Hello, world!</h3>");
9289
SimpleHttpServer pacFileServer =
93-
createPacfileServer(
94-
"/proxy.pac",
95-
Joiner.on('\n')
96-
.join(
97-
"function FindProxyForURL(url, host) {",
98-
" return 'PROXY " + getHostAndPort(helloServer) + "';",
99-
"}"));
100-
) {
90+
createPacfileServer(
91+
"/proxy.pac",
92+
Joiner.on('\n')
93+
.join(
94+
"function FindProxyForURL(url, host) {",
95+
" return 'PROXY " + getHostAndPort(helloServer) + "';",
96+
"}")); ) {
10197

10298
Proxy proxy = new Proxy();
10399
proxy.setProxyAutoconfigUrl("http://" + getHostAndPort(pacFileServer) + "/proxy.pac");
@@ -116,26 +112,25 @@ public void canConfigureProxyThroughPACFile() throws URISyntaxException, Interru
116112
@Ignore(value = FIREFOX, travis = true)
117113
@Ignore(value = CHROME, reason = "Flaky")
118114
public void canUsePACThatOnlyProxiesCertainHosts()
119-
throws URISyntaxException, InterruptedException {
120-
try (SimpleHttpServer helloServer = createSimpleHttpServer(
121-
"/index.html",
122-
"<!DOCTYPE html><title>Hello</title><h3>Hello, world!</h3>"
123-
);
124-
SimpleHttpServer goodbyeServer = createSimpleHttpServer(
125-
helloServer.baseUri().resolve("/index.html").toString(),
126-
"<!DOCTYPE html><title>Goodbye</title><h3>Goodbye, world!</h3>"
127-
);
128-
SimpleHttpServer pacFileServer = createPacfileServer(
129-
"/proxy.pac",
130-
Joiner.on('\n')
131-
.join(
132-
"function FindProxyForURL(url, host) {",
133-
" if (url.indexOf('" + getHostAndPort(helloServer) + "') != -1) {",
134-
" return 'PROXY " + getHostAndPort(goodbyeServer) + "';",
135-
" }",
136-
" return 'DIRECT';",
137-
"}")
138-
);) {
115+
throws URISyntaxException, InterruptedException {
116+
try (SimpleHttpServer helloServer =
117+
createSimpleHttpServer(
118+
"/index.html", "<!DOCTYPE html><title>Hello</title><h3>Hello, world!</h3>");
119+
SimpleHttpServer goodbyeServer =
120+
createSimpleHttpServer(
121+
helloServer.baseUri().resolve("/index.html").toString(),
122+
"<!DOCTYPE html><title>Goodbye</title><h3>Goodbye, world!</h3>");
123+
SimpleHttpServer pacFileServer =
124+
createPacfileServer(
125+
"/proxy.pac",
126+
Joiner.on('\n')
127+
.join(
128+
"function FindProxyForURL(url, host) {",
129+
" if (url.indexOf('" + getHostAndPort(helloServer) + "') != -1) {",
130+
" return 'PROXY " + getHostAndPort(goodbyeServer) + "';",
131+
" }",
132+
" return 'DIRECT';",
133+
"}")); ) {
139134

140135
Proxy proxy = new Proxy();
141136
proxy.setProxyAutoconfigUrl("http://" + getHostAndPort(pacFileServer) + "/proxy.pac");
@@ -151,7 +146,7 @@ public void canUsePACThatOnlyProxiesCertainHosts()
151146
}
152147

153148
private SimpleHttpServer createSimpleHttpServer(String requestPath, String responseHtml)
154-
throws URISyntaxException, InterruptedException {
149+
throws URISyntaxException, InterruptedException {
155150
SimpleHttpServer server = new SimpleHttpServer();
156151
byte[] bytes = responseHtml.getBytes(UTF_8);
157152

@@ -161,11 +156,12 @@ private SimpleHttpServer createSimpleHttpServer(String requestPath, String respo
161156
}
162157

163158
private SimpleHttpServer createPacfileServer(String requestPath, String responsePac)
164-
throws URISyntaxException, InterruptedException {
165-
SimpleHttpServer server = new SimpleHttpServer();
159+
throws URISyntaxException, InterruptedException {
160+
SimpleHttpServer server = new SimpleHttpServer();
166161
byte[] bytes = responsePac.getBytes(US_ASCII);
167162

168-
server.registerEndpoint(HttpMethod.GET, requestPath, "application/x-ns-proxy-autoconfig", bytes);
163+
server.registerEndpoint(
164+
HttpMethod.GET, requestPath, "application/x-ns-proxy-autoconfig", bytes);
169165

170166
return server;
171167
}
@@ -178,9 +174,7 @@ private static HostAndPort getHostAndPort(SimpleHttpServer server) {
178174
public static class FakeProxyServer extends SimpleHttpServer {
179175
private final Set<String> resources = new HashSet<>();
180176

181-
public FakeProxyServer() throws URISyntaxException, InterruptedException {
182-
183-
}
177+
public FakeProxyServer() throws URISyntaxException, InterruptedException {}
184178

185179
@Override
186180
protected FullHttpResponse handleRequest(HttpRequest requested) {

java/test/org/openqa/selenium/grid/server/NetworkOptionsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class NetworkOptionsTest {
5050
*/
5151
@Test
5252
void triggerFailureInTracing()
53-
throws URISyntaxException, InterruptedException, MalformedURLException {
53+
throws URISyntaxException, InterruptedException, MalformedURLException {
5454
// I better explain this. The only hint that we have that our use of
5555
// OpenTelemetry is wrong is found in the log message that the
5656
// io.grpc.Context generates when `Context.detach` is called in an

java/test/org/openqa/selenium/grid/web/ReverseProxyHandlerTest.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import java.net.MalformedURLException;
2323
import java.net.URISyntaxException;
24-
2524
import org.junit.jupiter.api.Test;
2625
import org.openqa.selenium.netty.server.SimpleHttpServer;
2726
import org.openqa.selenium.remote.http.HttpClient;
@@ -38,14 +37,12 @@ class ReverseProxyHandlerTest {
3837

3938
@Test
4039
void shouldForwardRequestsToEndPoint()
41-
throws MalformedURLException, URISyntaxException, InterruptedException {
42-
try (SimpleHttpServer server = new SimpleHttpServer()){
43-
server.registerEndpoint(HttpMethod.GET, "/ok",
44-
SimpleHttpServer.ECHO_HEADERS_HANDLER);
40+
throws MalformedURLException, URISyntaxException, InterruptedException {
41+
try (SimpleHttpServer server = new SimpleHttpServer()) {
42+
server.registerEndpoint(HttpMethod.GET, "/ok", SimpleHttpServer.ECHO_HEADERS_HANDLER);
4543

46-
HttpHandler
47-
handler =
48-
new ReverseProxyHandler(tracer, factory.createClient(server.baseUri().toURL()));
44+
HttpHandler handler =
45+
new ReverseProxyHandler(tracer, factory.createClient(server.baseUri().toURL()));
4946
HttpRequest req = new HttpRequest(HttpMethod.GET, "/ok");
5047
req.addHeader("X-Cheese", "Cake");
5148
HttpResponse response = handler.execute(req);

0 commit comments

Comments
 (0)