2626
2727import  org .springframework .http .HttpHeaders ;
2828import  org .springframework .http .MediaType ;
29+ import  org .springframework .util .AntPathMatcher ;
2930import  org .springframework .web .bind .annotation .RequestMethod ;
3031import  org .springframework .web .servlet .handler .PathPatternsParameterizedTest ;
3132import  org .springframework .web .servlet .handler .PathPatternsTestUtils ;
@@ -48,8 +49,8 @@ class RequestMappingInfoTests {
4849	@ SuppressWarnings ("unused" )
4950	static  Stream <RequestMappingInfo .Builder > pathPatternsArguments () {
5051		RequestMappingInfo .BuilderConfiguration  config  = new  RequestMappingInfo .BuilderConfiguration ();
51- 		config .setPatternParser (new  PathPatternParser ());
52- 		return  Stream .of (RequestMappingInfo .paths (). options ( config ) , RequestMappingInfo .paths ());
52+ 		config .setPathMatcher (new  AntPathMatcher ());
53+ 		return  Stream .of (RequestMappingInfo .paths (), RequestMappingInfo .paths (). options ( config ));
5354	}
5455
5556
@@ -86,6 +87,13 @@ void createEmpty(RequestMappingInfo.Builder infoBuilder) {
8687		assertThat (info .getCustomCondition ()).isSameAs (result .getCustomCondition ());
8788	}
8889
90+ 	@ Test  // gh-31662 
91+ 	void  pathPatternByDefault () {
92+ 		RequestMappingInfo  info  = RequestMappingInfo .paths ().build ();
93+ 		assertThat (info .getPathPatternsCondition ()).isNotNull ();
94+ 		assertThat (info .getPatternsCondition ()).isNull ();
95+ 	}
96+ 
8997	@ PathPatternsParameterizedTest 
9098	void  matchPatternsCondition (RequestMappingInfo .Builder  builder ) {
9199
@@ -105,7 +113,7 @@ void matchPatternsCondition(RequestMappingInfo.Builder builder) {
105113
106114	@ Test 
107115	void  matchParamsCondition () {
108- 		MockHttpServletRequest  request  = PathPatternsTestUtils .initRequest ("GET" , "/foo" , false );
116+ 		MockHttpServletRequest  request  = PathPatternsTestUtils .initRequest ("GET" , "/foo" , true );
109117		request .setParameter ("foo" , "bar" );
110118
111119		RequestMappingInfo  info  = RequestMappingInfo .paths ("/foo" ).params ("foo=bar" ).build ();
@@ -121,7 +129,7 @@ void matchParamsCondition() {
121129
122130	@ Test 
123131	void  matchHeadersCondition () {
124- 		MockHttpServletRequest  request  = PathPatternsTestUtils .initRequest ("GET" , "/foo" , false );
132+ 		MockHttpServletRequest  request  = PathPatternsTestUtils .initRequest ("GET" , "/foo" , true );
125133		request .addHeader ("foo" , "bar" );
126134
127135		RequestMappingInfo  info  = RequestMappingInfo .paths ("/foo" ).headers ("foo=bar" ).build ();
@@ -137,7 +145,7 @@ void matchHeadersCondition() {
137145
138146	@ Test 
139147	void  matchConsumesCondition () {
140- 		MockHttpServletRequest  request  = PathPatternsTestUtils .initRequest ("GET" , "/foo" , false );
148+ 		MockHttpServletRequest  request  = PathPatternsTestUtils .initRequest ("GET" , "/foo" , true );
141149		request .setContentType ("text/plain" );
142150
143151		RequestMappingInfo  info  = RequestMappingInfo .paths ("/foo" ).consumes ("text/plain" ).build ();
@@ -153,7 +161,7 @@ void matchConsumesCondition() {
153161
154162	@ Test 
155163	void  matchProducesCondition () {
156- 		MockHttpServletRequest  request  = PathPatternsTestUtils .initRequest ("GET" , "/foo" , false );
164+ 		MockHttpServletRequest  request  = PathPatternsTestUtils .initRequest ("GET" , "/foo" , true );
157165		request .addHeader ("Accept" , "text/plain" );
158166
159167		RequestMappingInfo  info  = RequestMappingInfo .paths ("/foo" ).produces ("text/plain" ).build ();
@@ -169,7 +177,7 @@ void matchProducesCondition() {
169177
170178	@ Test 
171179	void  matchCustomCondition () {
172- 		MockHttpServletRequest  request  = PathPatternsTestUtils .initRequest ("GET" , "/foo" , false );
180+ 		MockHttpServletRequest  request  = PathPatternsTestUtils .initRequest ("GET" , "/foo" , true );
173181		request .setParameter ("foo" , "bar" );
174182
175183		RequestMappingInfo  info  = RequestMappingInfo .paths ("/foo" ).params ("foo=bar" ).build ();
@@ -189,7 +197,7 @@ void compareToWithImplicitVsExplicitHttpMethodDeclaration() {
189197		RequestMappingInfo  oneMethod  = RequestMappingInfo .paths ().methods (GET ).build ();
190198		RequestMappingInfo  oneMethodOneParam  = RequestMappingInfo .paths ().methods (GET ).params ("foo" ).build ();
191199
192- 		MockHttpServletRequest  request  = PathPatternsTestUtils .initRequest ("GET" , "/" , false );
200+ 		MockHttpServletRequest  request  = PathPatternsTestUtils .initRequest ("GET" , "/" , true );
193201		Comparator <RequestMappingInfo > comparator  = (info , otherInfo ) -> info .compareTo (otherInfo , request );
194202
195203		List <RequestMappingInfo > list  = asList (noMethods , oneMethod , oneMethodOneParam );
@@ -204,7 +212,7 @@ void compareToWithImplicitVsExplicitHttpMethodDeclaration() {
204212	@ Test 
205213		// SPR-14383 
206214	void  compareToWithHttpHeadMapping () {
207- 		MockHttpServletRequest  request  = PathPatternsTestUtils .initRequest ("GET" , "/" , false );
215+ 		MockHttpServletRequest  request  = PathPatternsTestUtils .initRequest ("GET" , "/" , true );
208216		request .setMethod ("HEAD" );
209217		request .addHeader ("Accept" , "application/json" );
210218
@@ -297,7 +305,7 @@ void equalsMethod(RequestMappingInfo.Builder infoBuilder) {
297305
298306	@ Test 
299307	void  preFlightRequest () {
300- 		MockHttpServletRequest  request  = PathPatternsTestUtils .initRequest ("OPTIONS" , "/foo" , false );
308+ 		MockHttpServletRequest  request  = PathPatternsTestUtils .initRequest ("OPTIONS" , "/foo" , true );
301309		request .addHeader (HttpHeaders .ORIGIN , "https://domain.com" );
302310		request .addHeader (HttpHeaders .ACCESS_CONTROL_REQUEST_METHOD , "POST" );
303311
0 commit comments