Interface MockServerConfigurer


public interface MockServerConfigurer
Contract that frameworks or applications can use to pre-package a set of customizations to a WebTestClient.MockServerSpec and expose that as a shortcut.

An implementation of this interface can be plugged in via WebTestClient.MockServerSpec.apply(org.springframework.test.web.reactive.server.MockServerConfigurer) where instances are likely obtained via static methods, for example:

 import static org.example.ExampleSetup.securitySetup;

 // ...

 WebTestClient.bindToController(new TestController())
     .apply(securitySetup("foo","bar"))
     .build();
 
Since:
5.0
Author:
Rossen Stoyanchev
See Also:
  • Method Details

    • afterConfigureAdded

      default void afterConfigureAdded(WebTestClient.MockServerSpec<?> serverSpec)
      Invoked immediately, i.e. before this method returns.
      Parameters:
      serverSpec - the serverSpec to which the configurer is added
    • beforeServerCreated

      default void beforeServerCreated(WebHttpHandlerBuilder builder)
      Invoked just before the mock server is built. Use this hook to inspect and/or modify application-declared filters and exception handlers.
      Parameters:
      builder - the builder for the HttpHandler that will handle requests (i.e. the mock server)