Java Code Examples for org.springframework.test.web.reactive.server.WebTestClient#Builder

The following examples show how to use org.springframework.test.web.reactive.server.WebTestClient#Builder . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExchangeMutatorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public void afterConfigurerAdded(WebTestClient.Builder builder,
		@Nullable WebHttpHandlerBuilder httpHandlerBuilder,
		@Nullable ClientHttpConnector connector) {

	Assert.notNull(httpHandlerBuilder, "Not a mock server");
	httpHandlerBuilder.filters(filters -> {
		filters.removeIf(filter -> filter instanceof IdentityFilter);
		filters.add(0, this.filter);
	});
}
 
Example 2
Source File: ExchangeMutatorTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public void afterConfigurerAdded(WebTestClient.Builder builder,
		@Nullable WebHttpHandlerBuilder httpHandlerBuilder,
		@Nullable ClientHttpConnector connector) {

	Assert.notNull(httpHandlerBuilder, "Not a mock server");
	httpHandlerBuilder.filters(filters -> {
		filters.removeIf(filter -> filter instanceof IdentityFilter);
		filters.add(0, this.filter);
	});
}
 
Example 3
Source File: VertxWebTestClientSupplier.java    From vertx-spring-boot with Apache License 2.0 5 votes vote down vote up
private void customizeWebTestClientCodecs(WebTestClient.Builder builder) {
    Collection<CodecCustomizer> customizers = applicationContext.getBeansOfType(CodecCustomizer.class).values();

    ExchangeStrategies strategies = ExchangeStrategies.builder()
        .codecs(codecs -> customizers.forEach(customizer -> customizer.customize(codecs)))
        .build();

    builder.exchangeStrategies(strategies);
}
 
Example 4
Source File: VertxWebTestClientSupplier.java    From vertx-spring-boot with Apache License 2.0 3 votes vote down vote up
private WebTestClient createWebTestClient() {
    VertxClientHttpConnector connector = applicationContext.getBean(VertxClientHttpConnector.class);

    WebTestClient.Builder builder = WebTestClient.bindToServer(connector);

    String baseUrl = String.format("%s://localhost:%s", getProtocol(), getPort());
    builder.baseUrl(baseUrl);

    customizeWebTestClientCodecs(builder);

    return builder.build();
}