2929 * with bad header fields.
3030 * @library /test/lib /test/jdk/java/net/httpclient/lib
3131 * @build jdk.httpclient.test.lib.http2.Http2TestServer jdk.test.lib.net.SimpleSSLContext
32- * @run testng /othervm -Djdk.internal.httpclient.debug=true BadHeadersTest
32+ * @run junit /othervm -Djdk.internal.httpclient.debug=true BadHeadersTest
3333 */
3434
3535import jdk .internal .net .http .common .HttpHeadersBuilder ;
3838import jdk .internal .net .http .frame .HeadersFrame ;
3939import jdk .internal .net .http .frame .Http2Frame ;
4040import jdk .test .lib .net .SimpleSSLContext ;
41- import org .testng . annotations . AfterTest ;
42- import org .testng . annotations . BeforeTest ;
43- import org .testng . annotations . DataProvider ;
44- import org .testng . annotations . Test ;
41+ import org .junit . jupiter . api . AfterAll ;
42+ import org .junit . jupiter . api . BeforeAll ;
43+ import org .junit . jupiter . params . ParameterizedTest ;
44+ import org .junit . jupiter . params . provider . MethodSource ;
4545import javax .net .ssl .SSLContext ;
4646import javax .net .ssl .SSLSession ;
4747import java .io .IOException ;
6161import java .util .Map .Entry ;
6262import java .util .concurrent .ExecutionException ;
6363import java .util .function .BiFunction ;
64+
6465import jdk .httpclient .test .lib .http2 .Http2TestServer ;
6566import jdk .httpclient .test .lib .http2 .Http2TestExchange ;
6667import jdk .httpclient .test .lib .http2 .Http2TestExchangeImpl ;
6970import jdk .httpclient .test .lib .http2 .Http2TestServerConnection ;
7071import static java .util .List .of ;
7172import static java .util .Map .entry ;
72- import static org .testng .Assert .assertTrue ;
73- import static org .testng .Assert .fail ;
73+ import static org .junit .jupiter .api .Assertions .assertInstanceOf ;
74+ import static org .junit .jupiter .api .Assertions .assertTrue ;
75+ import static org .junit .jupiter .api .Assertions .fail ;
7476
7577// Code copied from ContinuationFrameTest
7678public class BadHeadersTest {
@@ -85,11 +87,11 @@ public class BadHeadersTest {
8587 of (entry ("hello" , "world!" ), entry (":status" , "200" )) // Pseudo header is not the first one
8688 );
8789
88- SSLContext sslContext ;
89- Http2TestServer http2TestServer ; // HTTP/2 ( h2c )
90- Http2TestServer https2TestServer ; // HTTP/2 ( h2 )
91- String http2URI ;
92- String https2URI ;
90+ private static SSLContext sslContext ;
91+ private static Http2TestServer http2TestServer ; // HTTP/2 ( h2c )
92+ private static Http2TestServer https2TestServer ; // HTTP/2 ( h2 )
93+ private static String http2URI ;
94+ private static String https2URI ;
9395
9496 /**
9597 * A function that returns a list of 1) one HEADERS frame ( with an empty
@@ -127,8 +129,7 @@ public class BadHeadersTest {
127129 return frames ;
128130 };
129131
130- @ DataProvider (name = "variants" )
131- public Object [][] variants () {
132+ static Object [][] variants () {
132133 return new Object [][] {
133134 { http2URI , false , oneContinuation },
134135 { https2URI , false , oneContinuation },
@@ -142,8 +143,8 @@ public Object[][] variants() {
142143 };
143144 }
144145
145-
146- @ Test ( dataProvider = "variants" )
146+ @ ParameterizedTest
147+ @ MethodSource ( "variants" )
147148 void test (String uri ,
148149 boolean sameClient ,
149150 BiFunction <Integer ,List <ByteBuffer >,List <Http2Frame >> headerFramesSupplier )
@@ -172,7 +173,8 @@ void test(String uri,
172173 }
173174 }
174175
175- @ Test (dataProvider = "variants" )
176+ @ ParameterizedTest
177+ @ MethodSource ("variants" )
176178 void testAsync (String uri ,
177179 boolean sameClient ,
178180 BiFunction <Integer ,List <ByteBuffer >,List <Http2Frame >> headerFramesSupplier )
@@ -211,8 +213,7 @@ void testAsync(String uri,
211213 // sync with implementation.
212214 static void assertDetailMessage (Throwable throwable , int iterationIndex ) {
213215 try {
214- assertTrue (throwable instanceof ProtocolException ,
215- "Expected ProtocolException, got " + throwable );
216+ assertInstanceOf (ProtocolException .class , throwable , "Expected ProtocolException, got " + throwable );
216217 assertTrue (throwable .getMessage ().contains ("malformed response" ),
217218 "Expected \" malformed response\" in: " + throwable .getMessage ());
218219
@@ -239,8 +240,8 @@ static void assertDetailMessage(Throwable throwable, int iterationIndex) {
239240 }
240241 }
241242
242- @ BeforeTest
243- public void setup () throws Exception {
243+ @ BeforeAll
244+ static void setup () throws Exception {
244245 sslContext = new SimpleSSLContext ().get ();
245246 if (sslContext == null )
246247 throw new AssertionError ("Unexpected null sslContext" );
@@ -264,8 +265,8 @@ public void setup() throws Exception {
264265 https2TestServer .start ();
265266 }
266267
267- @ AfterTest
268- public void teardown () throws Exception {
268+ @ AfterAll
269+ static void teardown () throws Exception {
269270 http2TestServer .stop ();
270271 https2TestServer .stop ();
271272 }
0 commit comments