You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
In 5.2.5 version MockServerRequest has been deprecated in favor of ServerRequest.create(ServerWebExchange, List)} combined with MockServerWebExchange.
Implementation of pathVariables() method in DefaultServerRequest looks like:
And the problem is that URI_TEMPLATE_VARIABLES_ATTRIBUTE attribute is not set during creation of MockServerWebExchange.
So, it's impossible to get pathVariables from DefaultServerRequest implementation of ServerRequest when it's created from MockServerRequest and MockServerWebExchange.
Example of how I'm using MockServerRequest in tests (Spock).
final mockServerHttpRequest = MockServerHttpRequest
.post('/foo/{bar}/{bar1}', 'var1', 'var2')
.contentType(MediaType.APPLICATION_JSON)
.body('{}')
final mockServerWebExchange = MockServerWebExchange.from(mockServerHttpRequest)
final mockServerRequest = ServerRequest.create(mockServerWebExchange, HandlerStrategies.withDefaults().messageReaders())
And then this mockServerRequest is passed into handler function as an argument.
The text was updated successfully, but these errors were encountered:
IbrayevRamil
changed the title
DefaultServerRequest bug with pathVariables
DefaultServerRequest bug with pathVariables when using MockServerRequest and MockServerWebExchange
May 16, 2020
Setting path variables (and making sure they are available in a
HandlerFunction) is more convenient with MockServerRequest than
having to set attributes in MockServerWebExchange.
This commit removes MockServerRequest's deprecation.
Closesspring-projectsgh-25087
Affects: 5.2.5
Description
In 5.2.5 version
MockServerRequest
has been deprecated in favor ofServerRequest.create(ServerWebExchange, List)}
combined withMockServerWebExchange
.Implementation of
pathVariables()
method inDefaultServerRequest
looks like:And the problem is that
URI_TEMPLATE_VARIABLES_ATTRIBUTE
attribute is not set during creation ofMockServerWebExchange
.So, it's impossible to get
pathVariables
fromDefaultServerRequest
implementation of ServerRequest when it's created fromMockServerRequest
andMockServerWebExchange
.Example of how I'm using MockServerRequest in tests (Spock).
And then this
mockServerRequest
is passed into handler function as an argument.The text was updated successfully, but these errors were encountered: