aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorMultiplexerIntegrationTest.java28
-rw-r--r--src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorTest.java40
-rw-r--r--src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/ProxyHelperTest.java4
3 files changed, 36 insertions, 36 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorMultiplexerIntegrationTest.java b/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorMultiplexerIntegrationTest.java
index c9c2a7e758..875501b2c7 100644
--- a/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorMultiplexerIntegrationTest.java
+++ b/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorMultiplexerIntegrationTest.java
@@ -92,8 +92,8 @@ public class HttpConnectorMultiplexerIntegrationTest {
@Test
public void normalRequest() throws Exception {
final Phaser phaser = new Phaser(3);
- try (ServerSocket server1 = new ServerSocket(0, 1, InetAddress.getByName("127.0.0.1"));
- ServerSocket server2 = new ServerSocket(0, 1, InetAddress.getByName("127.0.0.1"))) {
+ try (ServerSocket server1 = new ServerSocket(0, 1, InetAddress.getByName(null));
+ ServerSocket server2 = new ServerSocket(0, 1, InetAddress.getByName(null))) {
for (final ServerSocket server : asList(server1, server2)) {
@SuppressWarnings("unused")
Future<?> possiblyIgnoredError =
@@ -123,8 +123,8 @@ public class HttpConnectorMultiplexerIntegrationTest {
try (HttpStream stream =
multiplexer.connect(
ImmutableList.of(
- new URL(String.format("http://127.0.0.1:%d", server1.getLocalPort())),
- new URL(String.format("http://127.0.0.1:%d", server2.getLocalPort()))),
+ new URL(String.format("http://localhost:%d", server1.getLocalPort())),
+ new URL(String.format("http://localhost:%d", server2.getLocalPort()))),
"2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824")) {
assertThat(toByteArray(stream)).isEqualTo("hello".getBytes(US_ASCII));
}
@@ -142,8 +142,8 @@ public class HttpConnectorMultiplexerIntegrationTest {
return null;
}
}).when(sleeper).sleepMillis(anyLong());
- try (final ServerSocket server1 = new ServerSocket(0, 1, InetAddress.getByName("127.0.0.1"));
- final ServerSocket server2 = new ServerSocket(0, 1, InetAddress.getByName("127.0.0.1"))) {
+ try (final ServerSocket server1 = new ServerSocket(0, 1, InetAddress.getByName(null));
+ final ServerSocket server2 = new ServerSocket(0, 1, InetAddress.getByName(null))) {
@SuppressWarnings("unused")
Future<?> possiblyIgnoredError =
executor.submit(
@@ -188,8 +188,8 @@ public class HttpConnectorMultiplexerIntegrationTest {
try (HttpStream stream =
multiplexer.connect(
ImmutableList.of(
- new URL(String.format("http://127.0.0.1:%d", server1.getLocalPort())),
- new URL(String.format("http://127.0.0.1:%d", server2.getLocalPort()))),
+ new URL(String.format("http://localhost:%d", server1.getLocalPort())),
+ new URL(String.format("http://localhost:%d", server2.getLocalPort()))),
"2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824")) {
assertThat(toByteArray(stream)).isEqualTo("hello".getBytes(US_ASCII));
}
@@ -199,9 +199,9 @@ public class HttpConnectorMultiplexerIntegrationTest {
@Test
public void allMirrorsDown_throwsIOException() throws Exception {
final CyclicBarrier barrier = new CyclicBarrier(4);
- try (ServerSocket server1 = new ServerSocket(0, 1, InetAddress.getByName("127.0.0.1"));
- ServerSocket server2 = new ServerSocket(0, 1, InetAddress.getByName("127.0.0.1"));
- ServerSocket server3 = new ServerSocket(0, 1, InetAddress.getByName("127.0.0.1"))) {
+ try (ServerSocket server1 = new ServerSocket(0, 1, InetAddress.getByName(null));
+ ServerSocket server2 = new ServerSocket(0, 1, InetAddress.getByName(null));
+ ServerSocket server3 = new ServerSocket(0, 1, InetAddress.getByName(null))) {
for (final ServerSocket server : asList(server1, server2, server3)) {
executor.submit(
new Callable<Object>() {
@@ -228,9 +228,9 @@ public class HttpConnectorMultiplexerIntegrationTest {
thrown.expectMessage("All mirrors are down: [GET returned 503 MELTDOWN]");
multiplexer.connect(
ImmutableList.of(
- new URL(String.format("http://127.0.0.1:%d", server1.getLocalPort())),
- new URL(String.format("http://127.0.0.1:%d", server2.getLocalPort())),
- new URL(String.format("http://127.0.0.1:%d", server3.getLocalPort()))),
+ new URL(String.format("http://localhost:%d", server1.getLocalPort())),
+ new URL(String.format("http://localhost:%d", server2.getLocalPort())),
+ new URL(String.format("http://localhost:%d", server3.getLocalPort()))),
"2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9825");
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorTest.java b/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorTest.java
index 76daccad24..d6a1c77975 100644
--- a/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorTest.java
+++ b/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorTest.java
@@ -116,7 +116,7 @@ public class HttpConnectorTest {
@Test
public void normalRequest() throws Exception {
final Map<String, String> headers = new ConcurrentHashMap<>();
- try (ServerSocket server = new ServerSocket(0, 1, InetAddress.getByName("127.0.0.1"))) {
+ try (ServerSocket server = new ServerSocket(0, 1, InetAddress.getByName(null))) {
@SuppressWarnings("unused")
Future<?> possiblyIgnoredError =
executor.submit(
@@ -141,7 +141,7 @@ public class HttpConnectorTest {
try (Reader payload =
new InputStreamReader(
connector.connect(
- new URL(String.format("http://127.0.0.1:%d/boo", server.getLocalPort())),
+ new URL(String.format("http://localhost:%d/boo", server.getLocalPort())),
ImmutableMap.of("Content-Encoding", "gzip"))
.getInputStream(),
ISO_8859_1)) {
@@ -155,7 +155,7 @@ public class HttpConnectorTest {
@Test
public void serverError_retriesConnect() throws Exception {
- try (ServerSocket server = new ServerSocket(0, 1, InetAddress.getByName("127.0.0.1"))) {
+ try (ServerSocket server = new ServerSocket(0, 1, InetAddress.getByName(null))) {
@SuppressWarnings("unused")
Future<?> possiblyIgnoredError =
executor.submit(
@@ -192,7 +192,7 @@ public class HttpConnectorTest {
try (Reader payload =
new InputStreamReader(
connector.connect(
- new URL(String.format("http://127.0.0.1:%d", server.getLocalPort())),
+ new URL(String.format("http://localhost:%d", server.getLocalPort())),
ImmutableMap.<String, String>of())
.getInputStream(),
ISO_8859_1)) {
@@ -204,7 +204,7 @@ public class HttpConnectorTest {
@Test
public void permanentError_doesNotRetryAndThrowsIOException() throws Exception {
- try (ServerSocket server = new ServerSocket(0, 1, InetAddress.getByName("127.0.0.1"))) {
+ try (ServerSocket server = new ServerSocket(0, 1, InetAddress.getByName(null))) {
@SuppressWarnings("unused")
Future<?> possiblyIgnoredError =
executor.submit(
@@ -229,7 +229,7 @@ public class HttpConnectorTest {
thrown.expect(IOException.class);
thrown.expectMessage("404 Not Here");
connector.connect(
- new URL(String.format("http://127.0.0.1:%d", server.getLocalPort())),
+ new URL(String.format("http://localhost:%d", server.getLocalPort())),
ImmutableMap.<String, String>of());
}
}
@@ -238,7 +238,7 @@ public class HttpConnectorTest {
public void permanentError_consumesPayloadBeforeReturningn() throws Exception {
final CyclicBarrier barrier = new CyclicBarrier(2);
final AtomicBoolean consumed = new AtomicBoolean();
- try (ServerSocket server = new ServerSocket(0, 1, InetAddress.getByName("127.0.0.1"))) {
+ try (ServerSocket server = new ServerSocket(0, 1, InetAddress.getByName(null))) {
@SuppressWarnings("unused")
Future<?> possiblyIgnoredError =
executor.submit(
@@ -264,7 +264,7 @@ public class HttpConnectorTest {
}
});
connector.connect(
- new URL(String.format("http://127.0.0.1:%d", server.getLocalPort())),
+ new URL(String.format("http://localhost:%d", server.getLocalPort())),
ImmutableMap.<String, String>of());
fail();
} catch (IOException ignored) {
@@ -279,7 +279,7 @@ public class HttpConnectorTest {
@Test
public void always500_givesUpEventually() throws Exception {
final AtomicInteger tries = new AtomicInteger();
- try (ServerSocket server = new ServerSocket(0, 1, InetAddress.getByName("127.0.0.1"))) {
+ try (ServerSocket server = new ServerSocket(0, 1, InetAddress.getByName(null))) {
@SuppressWarnings("unused")
Future<?> possiblyIgnoredError =
executor.submit(
@@ -307,7 +307,7 @@ public class HttpConnectorTest {
thrown.expectMessage("500 Oh My");
try {
connector.connect(
- new URL(String.format("http://127.0.0.1:%d", server.getLocalPort())),
+ new URL(String.format("http://localhost:%d", server.getLocalPort())),
ImmutableMap.<String, String>of());
} finally {
assertThat(tries.get()).isGreaterThan(2);
@@ -318,7 +318,7 @@ public class HttpConnectorTest {
@Test
public void serverSays403_clientRetriesAnyway() throws Exception {
final AtomicInteger tries = new AtomicInteger();
- try (ServerSocket server = new ServerSocket(0, 1, InetAddress.getByName("127.0.0.1"))) {
+ try (ServerSocket server = new ServerSocket(0, 1, InetAddress.getByName(null))) {
@SuppressWarnings("unused")
Future<?> possiblyIgnoredError =
executor.submit(
@@ -346,7 +346,7 @@ public class HttpConnectorTest {
thrown.expectMessage("403 Forbidden");
try {
connector.connect(
- new URL(String.format("http://127.0.0.1:%d", server.getLocalPort())),
+ new URL(String.format("http://localhost:%d", server.getLocalPort())),
ImmutableMap.<String, String>of());
} finally {
assertThat(tries.get()).isGreaterThan(2);
@@ -358,7 +358,7 @@ public class HttpConnectorTest {
public void redirectToDifferentPath_works() throws Exception {
final Map<String, String> headers1 = new ConcurrentHashMap<>();
final Map<String, String> headers2 = new ConcurrentHashMap<>();
- try (ServerSocket server = new ServerSocket(0, 1, InetAddress.getByName("127.0.0.1"))) {
+ try (ServerSocket server = new ServerSocket(0, 1, InetAddress.getByName(null))) {
@SuppressWarnings("unused")
Future<?> possiblyIgnoredError =
executor.submit(
@@ -394,10 +394,10 @@ public class HttpConnectorTest {
});
URLConnection connection =
connector.connect(
- new URL(String.format("http://127.0.0.1:%d", server.getLocalPort())),
+ new URL(String.format("http://localhost:%d", server.getLocalPort())),
ImmutableMap.<String, String>of());
assertThat(connection.getURL()).isEqualTo(
- new URL(String.format("http://127.0.0.1:%d/doodle.tar.gz", server.getLocalPort())));
+ new URL(String.format("http://localhost:%d/doodle.tar.gz", server.getLocalPort())));
try (InputStream input = connection.getInputStream()) {
assertThat(ByteStreams.toByteArray(input)).isEmpty();
}
@@ -408,8 +408,8 @@ public class HttpConnectorTest {
@Test
public void redirectToDifferentServer_works() throws Exception {
- try (ServerSocket server1 = new ServerSocket(0, 1, InetAddress.getByName("127.0.0.1"));
- ServerSocket server2 = new ServerSocket(0, 1, InetAddress.getByName("127.0.0.1"))) {
+ try (ServerSocket server1 = new ServerSocket(0, 1, InetAddress.getByName(null));
+ ServerSocket server2 = new ServerSocket(0, 1, InetAddress.getByName(null))) {
@SuppressWarnings("unused")
Future<?> possiblyIgnoredError =
executor.submit(
@@ -424,7 +424,7 @@ public class HttpConnectorTest {
"Date: Fri, 31 Dec 1999 23:59:59 GMT",
"Connection: close",
String.format(
- "Location: http://127.0.0.1:%d/doodle.tar.gz", server2.getLocalPort()),
+ "Location: http://localhost:%d/doodle.tar.gz", server2.getLocalPort()),
"Content-Length: 0",
"",
"");
@@ -455,10 +455,10 @@ public class HttpConnectorTest {
});
URLConnection connection =
connector.connect(
- new URL(String.format("http://127.0.0.1:%d", server1.getLocalPort())),
+ new URL(String.format("http://localhost:%d", server1.getLocalPort())),
ImmutableMap.<String, String>of());
assertThat(connection.getURL()).isEqualTo(
- new URL(String.format("http://127.0.0.1:%d/doodle.tar.gz", server2.getLocalPort())));
+ new URL(String.format("http://localhost:%d/doodle.tar.gz", server2.getLocalPort())));
try (InputStream input = connection.getInputStream()) {
assertThat(ByteStreams.toByteArray(input)).isEqualTo("hello".getBytes(US_ASCII));
}
diff --git a/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/ProxyHelperTest.java b/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/ProxyHelperTest.java
index 6063ae5054..050cadb980 100644
--- a/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/ProxyHelperTest.java
+++ b/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/ProxyHelperTest.java
@@ -173,10 +173,10 @@ public class ProxyHelperTest {
@Test
public void testNoProxyAuth() throws Exception {
- Proxy proxy = ProxyHelper.createProxy("http://127.0.0.1:3128/");
+ Proxy proxy = ProxyHelper.createProxy("http://localhost:3128/");
assertEquals(Proxy.Type.HTTP, proxy.type());
assertThat(proxy.toString()).endsWith(":3128");
- assertEquals(System.getProperty("http.proxyHost"), "127.0.0.1");
+ assertEquals(System.getProperty("http.proxyHost"), "localhost");
assertEquals(System.getProperty("http.proxyPort"), "3128");
}