3535import reactor .netty .resources .ConnectionProvider ;
3636import reactor .netty .tcp .SslProvider .ProtocolSslContextSpec ;
3737import reactor .test .StepVerifier ;
38+ import reactor .util .annotation .Nullable ;
3839import reactor .util .function .Tuple2 ;
3940
4041import java .security .cert .CertificateException ;
@@ -79,25 +80,25 @@ static void createSelfSignedCertificate() throws CertificateException {
7980
8081 @ Test
8182 void testHttpNoSslH2Fails () {
82- StepVerifier . create (
83- createServer ( )
84- . protocol ( HttpProtocol . H2 )
85- . handle (( req , res ) -> res . sendString ( Mono . just ( "Hello" )) )
86- . bind () )
87- .verifyErrorMessage (H2_WITHOUT_TLS_SERVER );
83+ createServer ()
84+ . protocol ( HttpProtocol . H2 )
85+ . handle (( req , res ) -> res . sendString ( Mono . just ( "Hello" )) )
86+ . bind ( )
87+ . as ( StepVerifier :: create )
88+ .verifyErrorMessage (H2_WITHOUT_TLS_SERVER );
8889 }
8990
9091 @ Test
9192 void testHttpSslH2CFails () {
9293 Http2SslContextSpec serverOptions = Http2SslContextSpec .forServer (ssc .certificate (), ssc .privateKey ());
9394
94- StepVerifier . create (
95- createServer ( )
96- . protocol ( HttpProtocol . H2C )
97- . secure ( ssl -> ssl . sslContext ( serverOptions ))
98- . handle (( req , res ) -> res . sendString ( Mono . just ( "Hello" )) )
99- . bind () )
100- .verifyErrorMessage (H2C_WITH_TLS_SERVER );
95+ createServer ()
96+ . protocol ( HttpProtocol . H2C )
97+ . secure ( ssl -> ssl . sslContext ( serverOptions ) )
98+ . handle (( req , res ) -> res . sendString ( Mono . just ( "Hello" ) ))
99+ . bind ( )
100+ . as ( StepVerifier :: create )
101+ .verifyErrorMessage (H2C_WITH_TLS_SERVER );
101102 }
102103
103104 @ Test
@@ -179,18 +180,18 @@ void testMaxActiveStreams_1_CustomPool_Custom_AcquireTimer() throws Exception {
179180 assertThat (latch .await (10 , TimeUnit .SECONDS )).isTrue ();
180181 }
181182
182- void doTestMaxActiveStreams_1_CustomPool (BiFunction <Runnable , Duration , Disposable > pendingAcquireTimer ) throws Exception {
183+ void doTestMaxActiveStreams_1_CustomPool (@ Nullable BiFunction <Runnable , Duration , Disposable > pendingAcquireTimer ) throws Exception {
183184 ConnectionProvider .Builder builder =
184185 ConnectionProvider .builder ("testMaxActiveStreams_1_CustomPool" )
185- .maxConnections (1 )
186- .pendingAcquireTimeout (Duration .ofMillis (10 )); // the default is 45s
186+ .maxConnections (1 )
187+ .pendingAcquireTimeout (Duration .ofMillis (10 )); // the default is 45s
187188 if (pendingAcquireTimer != null ) {
188189 builder = builder .pendingAcquireTimer (pendingAcquireTimer );
189190 }
190191 ConnectionProvider provider = builder .build ();
191192 doTestMaxActiveStreams (HttpClient .create (provider ), 1 , 1 , 1 );
192193 provider .disposeLater ()
193- .block ();
194+ .block ();
194195 }
195196
196197 @ Test
@@ -249,7 +250,7 @@ void doTestMaxActiveStreams(HttpClient baseClient, int maxActiveStreams, int con
249250 .aggregate ()
250251 .asString ()
251252 .materialize (),
252- concurrency , prefetch )
253+ concurrency , prefetch )
253254 .collectList ()
254255 .doFinally (fin -> latch .countDown ())
255256 .block (Duration .ofSeconds (30 ));
@@ -330,15 +331,15 @@ void testHttpClientDefaultSslProvider() {
330331
331332 doTestHttpClientDefaultSslProvider (client .protocol (HttpProtocol .H2 ));
332333 doTestHttpClientDefaultSslProvider (client .protocol (HttpProtocol .H2 )
333- .secure ());
334+ .secure ());
334335 doTestHttpClientDefaultSslProvider (client .secure ()
335- .protocol (HttpProtocol .H2 ));
336+ .protocol (HttpProtocol .H2 ));
336337 doTestHttpClientDefaultSslProvider (client .protocol (HttpProtocol .HTTP11 )
337- .secure ()
338- .protocol (HttpProtocol .H2 ));
338+ .secure ()
339+ .protocol (HttpProtocol .H2 ));
339340 }
340341
341- private void doTestHttpClientDefaultSslProvider (HttpClient client ) {
342+ private static void doTestHttpClientDefaultSslProvider (HttpClient client ) {
342343 AtomicBoolean channel = new AtomicBoolean ();
343344 StepVerifier .create (client .doOnRequest ((req , conn ) -> channel .set (conn .channel ().parent () != null ))
344345 .get ()
@@ -488,7 +489,7 @@ void testIssue1394_SchemeHttpsConfiguredHTTP11AndH2CNegotiatedHTTP11() {
488489 doTestIssue1394_SchemeHttps ("null" ::equals , HttpProtocol .HTTP11 , HttpProtocol .H2C );
489490 }
490491
491- private void doTestIssue1394_SchemeHttps (Predicate <String > predicate , HttpProtocol ... protocols ) {
492+ private static void doTestIssue1394_SchemeHttps (Predicate <String > predicate , HttpProtocol ... protocols ) {
492493 HttpClient .create ()
493494 .protocol (protocols )
494495 .wiretap (true )
@@ -511,7 +512,7 @@ void testIssue1394_SchemeHttpsConfiguredH2C() {
511512 doTestIssue1394_ProtocolSchemeNotCompatible (HttpProtocol .H2C , "https" , H2C_WITH_TLS_CLIENT );
512513 }
513514
514- private void doTestIssue1394_ProtocolSchemeNotCompatible (HttpProtocol protocol , String scheme , String expectedMessage ) {
515+ private static void doTestIssue1394_ProtocolSchemeNotCompatible (HttpProtocol protocol , String scheme , String expectedMessage ) {
515516 HttpClient .create ()
516517 .protocol (protocol )
517518 .wiretap (true )
@@ -589,40 +590,40 @@ void testPR2659_SchemeHttpConfiguredNoSsl() {
589590 private void doTestPR2659_SchemeHttp (String expectedStreamId ) {
590591 disposableServer =
591592 createServer ()
592- .host ("localhost" )
593- .protocol (HttpProtocol .HTTP11 , HttpProtocol .H2C )
594- .handle ((req , res ) -> res .sendString (Mono .just ("testPR2659" )))
595- .bindNow (Duration .ofSeconds (30 ));
593+ .host ("localhost" )
594+ .protocol (HttpProtocol .HTTP11 , HttpProtocol .H2C )
595+ .handle ((req , res ) -> res .sendString (Mono .just ("testPR2659" )))
596+ .bindNow (Duration .ofSeconds (30 ));
596597
597598 HttpClient .create ()
598- .protocol (HttpProtocol .HTTP11 , HttpProtocol .H2 , HttpProtocol .H2C )
599- .wiretap (true )
600- .get ()
601- .uri ("http://localhost:" + disposableServer .port () + "/" )
602- .responseSingle ((res , bytes ) -> Mono .just (res .responseHeaders ().get ("x-http2-stream-id" , "null" )))
603- .as (StepVerifier ::create )
604- .expectNext (expectedStreamId )
605- .expectComplete ()
606- .verify (Duration .ofSeconds (30 ));
599+ .protocol (HttpProtocol .HTTP11 , HttpProtocol .H2 , HttpProtocol .H2C )
600+ .wiretap (true )
601+ .get ()
602+ .uri ("http://localhost:" + disposableServer .port () + "/" )
603+ .responseSingle ((res , bytes ) -> Mono .just (res .responseHeaders ().get ("x-http2-stream-id" , "null" )))
604+ .as (StepVerifier ::create )
605+ .expectNext (expectedStreamId )
606+ .expectComplete ()
607+ .verify (Duration .ofSeconds (30 ));
607608 }
608609
609610 @ Test
610611 void testPR2659_SchemeHttpsConfiguredWithSsl () {
611612 doTestPR2659_SchemeHttps (s -> !"null" .equals (s ));
612613 }
613614
614- private void doTestPR2659_SchemeHttps (Predicate <String > predicate ) {
615+ private static void doTestPR2659_SchemeHttps (Predicate <String > predicate ) {
615616 HttpClient .create ()
616- .protocol (HttpProtocol .HTTP11 , HttpProtocol .H2 , HttpProtocol .H2C )
617- .secure (sslContextSpec -> sslContextSpec .sslContext (Http2SslContextSpec .forClient ()))
618- .wiretap (true )
619- .get ()
620- .uri ("https://example.com" )
621- .responseSingle ((res , bytes ) -> Mono .just (res .responseHeaders ().get ("x-http2-stream-id" , "null" )))
622- .as (StepVerifier ::create )
623- .expectNextMatches (predicate )
624- .expectComplete ()
625- .verify (Duration .ofSeconds (30 ));
617+ .protocol (HttpProtocol .HTTP11 , HttpProtocol .H2 , HttpProtocol .H2C )
618+ .secure (sslContextSpec -> sslContextSpec .sslContext (Http2SslContextSpec .forClient ()))
619+ .wiretap (true )
620+ .get ()
621+ .uri ("https://example.com" )
622+ .responseSingle ((res , bytes ) -> Mono .just (res .responseHeaders ().get ("x-http2-stream-id" , "null" )))
623+ .as (StepVerifier ::create )
624+ .expectNextMatches (predicate )
625+ .expectComplete ()
626+ .verify (Duration .ofSeconds (30 ));
626627 }
627628
628629}
0 commit comments