equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
23 |
23 |
24 import com.sun.net.httpserver.HttpServer; |
24 import com.sun.net.httpserver.HttpServer; |
25 import com.sun.net.httpserver.HttpsConfigurator; |
25 import com.sun.net.httpserver.HttpsConfigurator; |
26 import com.sun.net.httpserver.HttpsServer; |
26 import com.sun.net.httpserver.HttpsServer; |
27 import jdk.test.lib.net.SimpleSSLContext; |
27 import jdk.test.lib.net.SimpleSSLContext; |
|
28 import org.testng.ITestContext; |
28 import org.testng.annotations.AfterTest; |
29 import org.testng.annotations.AfterTest; |
29 import org.testng.annotations.AfterClass; |
30 import org.testng.annotations.AfterClass; |
|
31 import org.testng.annotations.BeforeMethod; |
30 import org.testng.annotations.BeforeTest; |
32 import org.testng.annotations.BeforeTest; |
31 import org.testng.annotations.DataProvider; |
33 import org.testng.annotations.DataProvider; |
32 import org.testng.annotations.Test; |
34 import org.testng.annotations.Test; |
33 |
35 |
34 import javax.net.ssl.SSLContext; |
36 import javax.net.ssl.SSLContext; |
129 } |
131 } |
130 }); |
132 }); |
131 } |
133 } |
132 } |
134 } |
133 |
135 |
|
136 protected boolean stopAfterFirstFailure() { |
|
137 return Boolean.getBoolean("jdk.internal.httpclient.debug"); |
|
138 } |
|
139 |
|
140 @BeforeMethod |
|
141 void beforeMethod(ITestContext context) { |
|
142 if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { |
|
143 throw new RuntimeException("some tests failed"); |
|
144 } |
|
145 } |
|
146 |
134 @AfterClass |
147 @AfterClass |
135 static final void printFailedTests() { |
148 static final void printFailedTests() { |
136 out.println("\n========================="); |
149 out.println("\n========================="); |
137 try { |
150 try { |
138 out.printf("%n%sCreated %d servers and %d clients%n", |
151 out.printf("%n%sCreated %d servers and %d clients%n", |
180 assert i == uris.length * 2; |
193 assert i == uris.length * 2; |
181 return result; |
194 return result; |
182 } |
195 } |
183 |
196 |
184 @DataProvider(name = "variants") |
197 @DataProvider(name = "variants") |
185 public Object[][] variants() { |
198 public Object[][] variants(ITestContext context) { |
|
199 if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { |
|
200 return new Object[0][]; |
|
201 } |
186 String[] uris = uris(); |
202 String[] uris = uris(); |
187 Object[][] result = new Object[uris.length * 2 * 2][]; |
203 Object[][] result = new Object[uris.length * 2 * 2][]; |
188 int i = 0; |
204 int i = 0; |
189 for (Thrower thrower : List.of( |
205 for (Thrower thrower : List.of( |
190 new UncheckedIOExceptionThrower(), |
206 new UncheckedIOExceptionThrower(), |