Fix HelloWebflux tests

Fixes gh-4353
This commit is contained in:
Joe Grandja 2017-05-24 21:17:26 -04:00
parent dd8952f700
commit 86d0fd77a7
2 changed files with 10 additions and 4 deletions

View File

@ -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()

View File

@ -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()