Skip to content

Commit 85638a4

Browse files
committed
Minor tweak to test setup. No logical changes
Looking up host names can be slow on OS X from Java. Cache the lookup of the host and port to try and speed things up for this test. Perhaps this is why the test is timing out on Travis?
1 parent d2b1c51 commit 85638a4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

java/client/test/org/openqa/selenium/ReferrerTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import com.google.common.base.Charsets;
3333
import com.google.common.base.Joiner;
3434
import com.google.common.base.Objects;
35+
import com.google.common.base.Preconditions;
3536
import com.google.common.collect.ImmutableList;
3637
import com.google.common.collect.Lists;
3738
import com.google.common.net.HostAndPort;
@@ -454,6 +455,7 @@ protected void after() {
454455
*/
455456
private abstract static class ServerResource extends ExternalResource {
456457
protected final Server server;
458+
private HostAndPort hostAndPort;
457459

458460
ServerResource() {
459461
server = new Server();
@@ -470,7 +472,7 @@ void addHandler(Handler handler) {
470472
}
471473

472474
HostAndPort getHostAndPort() {
473-
return HostAndPort.fromParts(server.getURI().getHost(), server.getURI().getPort());
475+
return Preconditions.checkNotNull(hostAndPort);
474476
}
475477

476478
String getBaseUrl() {
@@ -480,6 +482,7 @@ String getBaseUrl() {
480482
void start() {
481483
try {
482484
server.start();
485+
hostAndPort = HostAndPort.fromParts(server.getURI().getHost(), server.getURI().getPort());
483486
new UrlChecker().waitUntilAvailable(10, TimeUnit.SECONDS, new URL(getBaseUrl()));
484487
} catch (Exception e) {
485488
throw new RuntimeException(e);

0 commit comments

Comments
 (0)