test/java/net/Authenticator/B4769350.java
Print this page
*** 23,33 ****
/**
* @test
* @bug 4769350
* @library ../../../sun/net/www/httptest/
! * @build HttpCallback HttpServer 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
--- 23,33 ----
/**
* @test
* @bug 4769350
* @library ../../../sun/net/www/httptest/
! * @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,153 ****
*/
void doT1a (HttpTransaction req, int count) throws IOException {
switch (count) {
case 0:
errorReply (req, "Basic realm=\"realm1\"");
! HttpServer.rendezvous ("one", 2);
break;
case 1:
! HttpServer.waitForCondition ("cond2");
okReply (req);
break;
default:
System.out.println ("Unexpected request");
}
--- 140,153 ----
*/
void doT1a (HttpTransaction req, int count) throws IOException {
switch (count) {
case 0:
errorReply (req, "Basic realm=\"realm1\"");
! TestHttpServer.rendezvous ("one", 2);
break;
case 1:
! TestHttpServer.waitForCondition ("cond2");
okReply (req);
break;
default:
System.out.println ("Unexpected request");
}
*** 156,170 ****
void doT1b (HttpTransaction req, int count) throws IOException {
switch (count) {
case 0:
errorReply (req, "Basic realm=\"realm2\"");
! HttpServer.rendezvous ("one", 2);
! HttpServer.setCondition ("cond1");
break;
case 1:
! HttpServer.waitForCondition ("cond2");
okReply (req);
break;
default:
System.out.println ("Unexpected request");
}
--- 156,170 ----
void doT1b (HttpTransaction req, int count) throws IOException {
switch (count) {
case 0:
errorReply (req, "Basic realm=\"realm2\"");
! TestHttpServer.rendezvous ("one", 2);
! TestHttpServer.setCondition ("cond1");
break;
case 1:
! TestHttpServer.waitForCondition ("cond2");
okReply (req);
break;
default:
System.out.println ("Unexpected request");
}
*** 172,182 ****
void doT1c (HttpTransaction req, int count) throws IOException {
switch (count) {
case 0:
errorReply (req, "Basic realm=\"realm1\"");
! HttpServer.rendezvous ("two", 2);
break;
case 1:
okReply (req);
break;
default:
--- 172,182 ----
void doT1c (HttpTransaction req, int count) throws IOException {
switch (count) {
case 0:
errorReply (req, "Basic realm=\"realm1\"");
! TestHttpServer.rendezvous ("two", 2);
break;
case 1:
okReply (req);
break;
default:
*** 186,197 ****
void doT1d (HttpTransaction req, int count) throws IOException {
switch (count) {
case 0:
errorReply (req, "Basic realm=\"realm2\"");
! HttpServer.rendezvous ("two", 2);
! HttpServer.setCondition ("cond2");
break;
case 1:
okReply (req);
break;
default:
--- 186,197 ----
void doT1d (HttpTransaction req, int count) throws IOException {
switch (count) {
case 0:
errorReply (req, "Basic realm=\"realm2\"");
! TestHttpServer.rendezvous ("two", 2);
! TestHttpServer.setCondition ("cond2");
break;
case 1:
okReply (req);
break;
default:
*** 205,215 ****
*/
void doT2a (HttpTransaction req, int count) throws IOException {
/* This will be called several times */
if (count == 1) {
! HttpServer.setCondition ("T2cond1");
}
errorReply (req, "Basic realm=\"realm3\"");
}
void doT2b (HttpTransaction req, int count) throws IOException {
--- 205,215 ----
*/
void doT2a (HttpTransaction req, int count) throws IOException {
/* This will be called several times */
if (count == 1) {
! TestHttpServer.setCondition ("T2cond1");
}
errorReply (req, "Basic realm=\"realm3\"");
}
void doT2b (HttpTransaction req, int count) throws IOException {
*** 231,241 ****
*/
void doT3a (HttpTransaction req, int count) throws IOException {
switch (count) {
case 0:
proxyReply (req, "Basic realm=\"proxy\"");
! HttpServer.setCondition ("T3cond1");
break;
case 1:
errorReply (req, "Basic realm=\"realm4\"");
break;
case 2:
--- 231,241 ----
*/
void doT3a (HttpTransaction req, int count) throws IOException {
switch (count) {
case 0:
proxyReply (req, "Basic realm=\"proxy\"");
! TestHttpServer.setCondition ("T3cond1");
break;
case 1:
errorReply (req, "Basic realm=\"realm4\"");
break;
case 2:
*** 258,268 ****
System.out.println ("Unexpected request");
}
}
};
! static HttpServer server;
static MyAuthenticator auth = new MyAuthenticator ();
static int redirects = 4;
static Client c1,c2,c3,c4,c5,c6,c7,c8,c9;
--- 258,268 ----
System.out.println ("Unexpected request");
}
}
};
! static TestHttpServer server;
static MyAuthenticator auth = new MyAuthenticator ();
static int redirects = 4;
static Client c1,c2,c3,c4,c5,c6,c7,c8,c9;
*** 274,284 ****
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");
c3.start(); c4.start();
c1.join(); c2.join(); c3.join(); c4.join();
int f = auth.getCount();
if (f != 2) {
--- 274,284 ----
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();
! TestHttpServer.waitForCondition ("cond1");
c3.start(); c4.start();
c1.join(); c2.join(); c3.join(); c4.join();
int f = auth.getCount();
if (f != 2) {
*** 292,302 ****
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");
c6.start ();
c5.join(); c6.join();
f = auth.getCount();
if (f != redirects+1) {
--- 292,302 ----
System.out.println ("T2");
c5 = new Client (authority, "/test/realm3/t2a", true);
c6 = new Client (authority, "/test/realm3/t2b", false);
c5.start ();
! TestHttpServer.waitForCondition ("T2cond1");
c6.start ();
c5.join(); c6.join();
f = auth.getCount();
if (f != redirects+1) {
*** 311,321 ****
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");
c8.start ();
c9.start ();
c7.join(); c8.join(); c9.join();
int f = auth.getCount();
--- 311,321 ----
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 ();
! TestHttpServer.waitForCondition ("T3cond1");
c8.start ();
c9.start ();
c7.join(); c8.join(); c9.join();
int f = auth.getCount();
*** 331,341 ****
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);
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");
--- 331,341 ----
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 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");