test/java/net/Authenticator/B4769350.java
Print this page
@@ -23,11 +23,11 @@
/**
* @test
* @bug 4769350
* @library ../../../sun/net/www/httptest/
- * @build HttpCallback HttpServer ClosedChannelList HttpTransaction AbstractCallback
+ * @build HttpCallback TestHttpServer ClosedChannelList HttpTransaction AbstractCallback
* @run main/othervm B4769350 server
* @run main/othervm B4769350 proxy
* @summary proxy authentication username and password caching only works in serial case
* Run in othervm since the test sets system properties that are read by the
* networking stack and cached when the HTTP handler is invoked, and previous
@@ -140,14 +140,14 @@
*/
void doT1a (HttpTransaction req, int count) throws IOException {
switch (count) {
case 0:
errorReply (req, "Basic realm=\"realm1\"");
- HttpServer.rendezvous ("one", 2);
+ TestHttpServer.rendezvous ("one", 2);
break;
case 1:
- HttpServer.waitForCondition ("cond2");
+ TestHttpServer.waitForCondition ("cond2");
okReply (req);
break;
default:
System.out.println ("Unexpected request");
}
@@ -156,15 +156,15 @@
void doT1b (HttpTransaction req, int count) throws IOException {
switch (count) {
case 0:
errorReply (req, "Basic realm=\"realm2\"");
- HttpServer.rendezvous ("one", 2);
- HttpServer.setCondition ("cond1");
+ TestHttpServer.rendezvous ("one", 2);
+ TestHttpServer.setCondition ("cond1");
break;
case 1:
- HttpServer.waitForCondition ("cond2");
+ TestHttpServer.waitForCondition ("cond2");
okReply (req);
break;
default:
System.out.println ("Unexpected request");
}
@@ -172,11 +172,11 @@
void doT1c (HttpTransaction req, int count) throws IOException {
switch (count) {
case 0:
errorReply (req, "Basic realm=\"realm1\"");
- HttpServer.rendezvous ("two", 2);
+ TestHttpServer.rendezvous ("two", 2);
break;
case 1:
okReply (req);
break;
default:
@@ -186,12 +186,12 @@
void doT1d (HttpTransaction req, int count) throws IOException {
switch (count) {
case 0:
errorReply (req, "Basic realm=\"realm2\"");
- HttpServer.rendezvous ("two", 2);
- HttpServer.setCondition ("cond2");
+ TestHttpServer.rendezvous ("two", 2);
+ TestHttpServer.setCondition ("cond2");
break;
case 1:
okReply (req);
break;
default:
@@ -205,11 +205,11 @@
*/
void doT2a (HttpTransaction req, int count) throws IOException {
/* This will be called several times */
if (count == 1) {
- HttpServer.setCondition ("T2cond1");
+ TestHttpServer.setCondition ("T2cond1");
}
errorReply (req, "Basic realm=\"realm3\"");
}
void doT2b (HttpTransaction req, int count) throws IOException {
@@ -231,11 +231,11 @@
*/
void doT3a (HttpTransaction req, int count) throws IOException {
switch (count) {
case 0:
proxyReply (req, "Basic realm=\"proxy\"");
- HttpServer.setCondition ("T3cond1");
+ TestHttpServer.setCondition ("T3cond1");
break;
case 1:
errorReply (req, "Basic realm=\"realm4\"");
break;
case 2:
@@ -258,11 +258,11 @@
System.out.println ("Unexpected request");
}
}
};
- static HttpServer server;
+ static TestHttpServer server;
static MyAuthenticator auth = new MyAuthenticator ();
static int redirects = 4;
static Client c1,c2,c3,c4,c5,c6,c7,c8,c9;
@@ -274,11 +274,11 @@
c2 = new Client (authority, "/test/realm2/t1b", false);
c3 = new Client (authority, "/test/realm1/t1c", false);
c4 = new Client (authority, "/test/realm2/t1d", false);
c1.start(); c2.start();
- HttpServer.waitForCondition ("cond1");
+ TestHttpServer.waitForCondition ("cond1");
c3.start(); c4.start();
c1.join(); c2.join(); c3.join(); c4.join();
int f = auth.getCount();
if (f != 2) {
@@ -292,11 +292,11 @@
System.out.println ("T2");
c5 = new Client (authority, "/test/realm3/t2a", true);
c6 = new Client (authority, "/test/realm3/t2b", false);
c5.start ();
- HttpServer.waitForCondition ("T2cond1");
+ TestHttpServer.waitForCondition ("T2cond1");
c6.start ();
c5.join(); c6.join();
f = auth.getCount();
if (f != redirects+1) {
@@ -311,11 +311,11 @@
System.out.println ("Doing Proxy tests");
c7 = new Client (authority, "/test/realm4/t3a", false);
c8 = new Client (authority, "/test/realm4/t3b", false);
c9 = new Client (authority, "/test/realm4/t3c", false);
c7.start ();
- HttpServer.waitForCondition ("T3cond1");
+ TestHttpServer.waitForCondition ("T3cond1");
c8.start ();
c9.start ();
c7.join(); c8.join(); c9.join();
int f = auth.getCount();
@@ -331,11 +331,11 @@
System.setProperty ("http.maxRedirects", Integer.toString (redirects));
System.setProperty ("http.auth.serializeRequests", "true");
Authenticator.setDefault (auth);
boolean proxy = args[0].equals ("proxy");
try {
- server = new HttpServer (new CallBack(), 10, 1, 0);
+ server = new TestHttpServer (new CallBack(), 10, 1, 0);
System.out.println ("Server: listening on port: " + server.getLocalPort());
if (proxy) {
System.setProperty ("http.proxyHost", "localhost");
System.setProperty ("http.proxyPort",Integer.toString(server.getLocalPort()));
doProxyTests ("www.foo.com");