Skip to content

Add protected method to StandaloneMockMvcBuilder to register additional MVC infrastructure components [SPR-17520] #22052

@spring-projects-issues

Description

@spring-projects-issues

Reijhanniel Jearl Campos opened SPR-17520 and commented

We're heavily using Spring MVC, and its awesome Spring MVC test. Our use case is fairly advanced, for we write our custom org.springframework.web.servlet.HandlerMapping and org.springframework.web.servlet.HandlerAdapter . To make use of Spring MVC test however, we needed to duplicate org.springframework.test.web.servlet.setup.StandaloneMockMvcBuilder just to allow customization of such beans.

I found a ticket (#16166) that similarly describes the same, albeit only for:

/**
 * Configure factory to create a custom {@link RequestMappingHandlerMapping}.
 * @param factory the factory
 * @since 5.0
 */
public StandaloneMockMvcBuilder setCustomHandlerMapping(Supplier<RequestMappingHandlerMapping> factory) {
   this.handlerMappingFactory = factory;
   return this;
}

We cannot use this method, because we're not relying on RequestMappingHandlerMapping and it doesn't yet have a setter for custom HandlerAdapter s.

Is there a better way to do this?


Affects: 5.1.2

Issue Links:

Referenced from: commits 2700993

Metadata

Metadata

Assignees

Labels

in: testIssues in the test modulein: webIssues in web modules (web, webmvc, webflux, websocket)type: taskA general task

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions