Skip to content

Commit 0b88138

Browse files
committed
8231504: Update networking tests to avoid implicit dependency on the system proxies
Reviewed-by: dfuchs
1 parent 6212eb3 commit 0b88138

File tree

20 files changed

+43
-29
lines changed

20 files changed

+43
-29
lines changed

test/jdk/java/net/CookieHandler/LocalHostCookie.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,7 @@
2828
import java.net.*;
2929
import java.util.List;
3030
import java.util.Map;
31-
import java.util.concurrent.Executors;
31+
import static java.net.Proxy.NO_PROXY;
3232

3333
/*
3434
* @test
@@ -52,7 +52,7 @@ public void runTest() throws Exception {
5252
s = new Server();
5353
s.startServer();
5454
URL url = new URL("http","localhost", s.getPort(), "/");
55-
HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection();
55+
HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection(NO_PROXY);
5656
urlConnection.setRequestMethod("GET");
5757
urlConnection.setDoOutput(true);
5858
urlConnection.connect();

test/jdk/java/net/HttpURLConnection/SetAuthenticator/HTTPTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import javax.net.ssl.SSLContext;
4141
import javax.net.ssl.SSLSession;
4242
import jdk.test.lib.net.SimpleSSLContext;
43+
import static java.net.Proxy.NO_PROXY;
4344

4445
/*
4546
* @test
@@ -296,7 +297,7 @@ public static HttpURLConnection openConnection(URL url,
296297
HttpURLConnection conn = (HttpURLConnection)
297298
(authType == HttpAuthType.PROXY
298299
? url.openConnection(proxy)
299-
: url.openConnection());
300+
: url.openConnection(NO_PROXY));
300301
return conn;
301302
}
302303
}

test/jdk/java/net/ProxySelector/NullSelector.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* @bug 6215885
2626
* @library /test/lib
2727
* @summary URLConnection.openConnection NPE if ProxySelector.setDefault is set to null
28+
* @run main/othervm NullSelector
2829
*/
2930

3031
import java.net.*;

test/jdk/java/net/ResponseCache/B6181108.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.util.*;
3434
import java.io.*;
3535
import jdk.test.lib.net.URIBuilder;
36+
import static java.net.Proxy.NO_PROXY;
3637

3738
public class B6181108 implements Runnable {
3839
ServerSocket ss;
@@ -105,7 +106,7 @@ public CacheRequest put(URI uri, URLConnection urlc) {
105106
.toString();
106107
urlWithSpace = base + "/space%20test/page1.html";
107108
URL url = new URL(urlWithSpace);
108-
URLConnection urlc = url.openConnection();
109+
URLConnection urlc = url.openConnection(NO_PROXY);
109110
int i = ((HttpURLConnection)(urlc)).getResponseCode();
110111
System.out.println("response code = " + i);
111112
ResponseCache.setDefault(null);

test/jdk/java/net/ResponseCache/ResponseCacheTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.io.*;
3434
import javax.net.ssl.*;
3535
import jdk.test.lib.net.URIBuilder;
36+
import static java.net.Proxy.NO_PROXY;
3637

3738
/**
3839
* Request should get serviced by the cache handler. Response get
@@ -137,7 +138,7 @@ public boolean verify(String hostname, SSLSession session) {
137138
.port(ss.getLocalPort())
138139
.path("/file2.1")
139140
.toURL();
140-
http = (HttpURLConnection)url2.openConnection();
141+
http = (HttpURLConnection)url2.openConnection(NO_PROXY);
141142
System.out.println("responsecode2 is :"+http.getResponseCode());
142143
Map<String,List<String>> headers2 = http.getHeaderFields();
143144

test/jdk/java/net/ResponseCache/getResponseCode.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
3030
import java.net.*;
3131
import java.util.*;
3232
import java.io.*;
33+
import static java.net.Proxy.NO_PROXY;
3334

3435

3536
/**
@@ -43,7 +44,7 @@ public class getResponseCode {
4344

4445
getResponseCode() throws Exception {
4546
url = new URL("http://localhost/file1.cache");
46-
HttpURLConnection http = (HttpURLConnection)url.openConnection();
47+
HttpURLConnection http = (HttpURLConnection)url.openConnection(NO_PROXY);
4748
int respCode = http.getResponseCode();
4849
http.disconnect();
4950

test/jdk/java/net/URLConnection/B5052093.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.net.*;
3434
import java.io.*;
3535
import sun.net.www.protocol.file.FileURLConnection;
36+
import static java.net.Proxy.NO_PROXY;
3637

3738
public class B5052093 implements HttpCallback {
3839
private static TestHttpServer server;
@@ -68,7 +69,7 @@ public static void main(String[] args) throws Exception {
6869
server = new TestHttpServer(new B5052093(), 1, 10, loopback, 0);
6970
try {
7071
URL url = new URL("http://" + server.getAuthority() + "/foo");
71-
URLConnection conn = url.openConnection();
72+
URLConnection conn = url.openConnection(NO_PROXY);
7273
int i = conn.getContentLength();
7374
long l = conn.getContentLengthLong();
7475
if (i != -1 || l != testSize) {

test/jdk/java/net/URLConnection/DisconnectAfterEOF.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
import java.io.*;
3434
import java.util.*;
3535
import jdk.test.lib.net.URIBuilder;
36-
37-
36+
import static java.net.Proxy.NO_PROXY;
3837

3938
public class DisconnectAfterEOF {
4039

@@ -217,7 +216,7 @@ public void shutdown() {
217216
}
218217

219218
static URLConnection doRequest(String uri) throws IOException {
220-
URLConnection uc = (new URL(uri)).openConnection();
219+
URLConnection uc = (new URL(uri)).openConnection(NO_PROXY);
221220
uc.setDoOutput(true);
222221
OutputStream out = uc.getOutputStream();
223222
out.write(new byte[16000]);

test/jdk/java/net/URLConnection/HttpContinueStackOverflow.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
import java.net.Socket;
3939
import java.net.URL;
4040
import java.net.HttpURLConnection;
41-
4241
import jdk.test.lib.net.URIBuilder;
42+
import static java.net.Proxy.NO_PROXY;
4343

4444
public class HttpContinueStackOverflow {
4545

@@ -93,7 +93,7 @@ public void run() {
9393
.path("/anything.html")
9494
.toURL();
9595

96-
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
96+
HttpURLConnection conn = (HttpURLConnection)url.openConnection(NO_PROXY);
9797
conn.getResponseCode();
9898
System.out.println("TEST PASSED");
9999
}

test/jdk/java/net/URLConnection/Redirect307Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
*/
3030
import java.io.*;
3131
import java.net.*;
32-
3332
import jdk.test.lib.net.URIBuilder;
33+
import static java.net.Proxy.NO_PROXY;
3434

3535
class RedirServer extends Thread {
3636

@@ -113,7 +113,7 @@ public static void main(String[] args) throws Exception {
113113
.loopback()
114114
.port(port)
115115
.toURL();
116-
URLConnection conURL = url.openConnection();
116+
URLConnection conURL = url.openConnection(NO_PROXY);
117117
conURL.setDoInput(true);
118118
conURL.setAllowUserInteraction(false);
119119
conURL.setUseCaches(false);

0 commit comments

Comments
 (0)