1
1
/*
2
- * Copyright (c) 2020, 2023 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2020, 2024 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
@@ -205,18 +205,18 @@ static final void printFailedTests(ITestContext context) {
205
205
@ DataProvider (name = "all" )
206
206
public Object [][] allcases () {
207
207
List <Object []> result = new ArrayList <>();
208
- for (var client : List .of (authClient , noAuthClient )) {
208
+ for (boolean useAuth : List .of (true , false )) {
209
209
for (boolean async : List .of (true , false )) {
210
210
for (int code : List .of (UNAUTHORIZED , PROXY_UNAUTHORIZED )) {
211
211
var srv = code == PROXY_UNAUTHORIZED ? "/proxy" : "/server" ;
212
212
for (var auth : List .of ("/auth" , "/noauth" )) {
213
213
var pcode = code ;
214
214
if (auth .equals ("/noauth" )) {
215
- if (client == authClient ) continue ;
215
+ if (useAuth ) continue ;
216
216
pcode = FORBIDDEN ;
217
217
}
218
218
for (var uri : List .of (httpURI , httpsURI , http2URI , https2URI )) {
219
- result .add (new Object []{uri + srv + auth , pcode , async , client });
219
+ result .add (new Object []{uri + srv + auth , pcode , async , useAuth });
220
220
}
221
221
}
222
222
}
@@ -237,12 +237,13 @@ protected PasswordAuthentication getPasswordAuthentication() {
237
237
static final AtomicLong sleepCount = new AtomicLong ();
238
238
239
239
@ Test (dataProvider = "all" )
240
- void test (String uriString , int code , boolean async , HttpClient client ) throws Throwable {
240
+ void test (String uriString , int code , boolean async , boolean useAuth ) throws Throwable {
241
241
checkSkip ();
242
+ HttpClient client = useAuth ? authClient : noAuthClient ;
242
243
var name = String .format ("test(%s, %d, %s, %s)" , uriString , code , async ? "async" : "sync" ,
243
244
client .authenticator ().isPresent () ? "authClient" : "noAuthClient" );
244
245
out .printf ("%n---- starting %s ----%n" , name );
245
- assert client .authenticator ().isPresent () ? client == authClient : client == noAuthClient ;
246
+ assert client .authenticator ().isPresent () == useAuth ;
246
247
uriString = uriString + "/ForbiddenTest" ;
247
248
for (int i =0 ; i <ITERATIONS ; i ++) {
248
249
if (ITERATIONS > 1 ) out .printf ("---- ITERATION %d%n" ,i );
@@ -381,13 +382,16 @@ public void teardown() throws Exception {
381
382
authClient = noAuthClient = null ;
382
383
Thread .sleep (100 );
383
384
AssertionError fail = TRACKER .check (500 );
384
-
385
- proxy .stop ();
386
- authproxy .stop ();
387
- httpTestServer .stop ();
388
- httpsTestServer .stop ();
389
- http2TestServer .stop ();
390
- https2TestServer .stop ();
385
+ try {
386
+ proxy .stop ();
387
+ authproxy .stop ();
388
+ httpTestServer .stop ();
389
+ httpsTestServer .stop ();
390
+ http2TestServer .stop ();
391
+ https2TestServer .stop ();
392
+ } finally {
393
+ if (fail != null ) throw fail ;
394
+ }
391
395
}
392
396
393
397
static class TestProxySelector extends ProxySelector {
0 commit comments