From 86d0fd77a79c0df32fe8cbaf4a2c20bcdbd78056 Mon Sep 17 00:00:00 2001 From: Joe Grandja Date: Wed, 24 May 2017 21:17:26 -0400 Subject: [PATCH] Fix HelloWebflux tests Fixes gh-4353 --- .../src/test/java/sample/HelloWebfluxApplicationTests.java | 7 +++++-- .../test/java/sample/HelloWebfluxFnApplicationTests.java | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/samples/javaconfig/hellowebflux/src/test/java/sample/HelloWebfluxApplicationTests.java b/samples/javaconfig/hellowebflux/src/test/java/sample/HelloWebfluxApplicationTests.java index 091c3f05ea..46670d8c05 100644 --- a/samples/javaconfig/hellowebflux/src/test/java/sample/HelloWebfluxApplicationTests.java +++ b/samples/javaconfig/hellowebflux/src/test/java/sample/HelloWebfluxApplicationTests.java @@ -30,6 +30,7 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.reactive.server.ExchangeResult; +import org.springframework.test.web.reactive.server.MockServerExchangeMutator; import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.web.reactive.function.client.ExchangeFilterFunction; @@ -160,8 +161,10 @@ public class HelloWebfluxApplicationTests { @Test public void mockSupport() throws Exception { - this.rest - .exchangeMutator( withUser() ) + MockServerExchangeMutator exchangeMutator = new MockServerExchangeMutator(withUser()); + WebTestClient mockRest = WebTestClient.bindToApplicationContext(this.context).webFilter(exchangeMutator).build(); + + exchangeMutator.filterClient(mockRest, withUser()) .get() .uri("/principal") .exchange() diff --git a/samples/javaconfig/hellowebfluxfn/src/test/java/sample/HelloWebfluxFnApplicationTests.java b/samples/javaconfig/hellowebfluxfn/src/test/java/sample/HelloWebfluxFnApplicationTests.java index 8323737494..98c1523e1a 100644 --- a/samples/javaconfig/hellowebfluxfn/src/test/java/sample/HelloWebfluxFnApplicationTests.java +++ b/samples/javaconfig/hellowebfluxfn/src/test/java/sample/HelloWebfluxFnApplicationTests.java @@ -30,6 +30,7 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.reactive.server.ExchangeResult; +import org.springframework.test.web.reactive.server.MockServerExchangeMutator; import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.web.reactive.function.client.ExchangeFilterFunction; import org.springframework.web.reactive.function.server.RouterFunction; @@ -166,8 +167,10 @@ public class HelloWebfluxFnApplicationTests { @Test public void mockSupport() throws Exception { - this.rest - .exchangeMutator( withUser() ) + MockServerExchangeMutator exchangeMutator = new MockServerExchangeMutator(withUser()); + WebTestClient mockRest = WebTestClient.bindToRouterFunction(this.routerFunction).webFilter(exchangeMutator).build(); + + exchangeMutator.filterClient(mockRest, withUser()) .get() .uri("/principal") .exchange()