@@ -33,6 +33,7 @@ import spock.lang.Specification
3333 *
3434 */
3535class AbstractSecurityWebApplicationInitializerTests extends Specification {
36+ def DEFAULT_DISPATCH = EnumSet . of(DispatcherType . REQUEST , DispatcherType . ERROR , DispatcherType . ASYNC )
3637
3738 def defaults () {
3839 setup :
@@ -42,7 +43,7 @@ class AbstractSecurityWebApplicationInitializerTests extends Specification {
4243 new AbstractSecurityWebApplicationInitializer (){}. onStartup(context)
4344 then :
4445 1 * context. addFilter(" springSecurityFilterChain" , {DelegatingFilterProxy f -> f. targetBeanName == " springSecurityFilterChain" && f. contextAttribute == null }) >> registration
45- 1 * registration. addMappingForUrlPatterns(EnumSet . of( DispatcherType . REQUEST , DispatcherType . ERROR ) , false , " /*" );
46+ 1 * registration. addMappingForUrlPatterns(DEFAULT_DISPATCH , false , " /*" );
4647 1 * registration. setAsyncSupported(true )
4748 0 * context. addListener(_)
4849 }
@@ -55,7 +56,7 @@ class AbstractSecurityWebApplicationInitializerTests extends Specification {
5556 new AbstractSecurityWebApplicationInitializer (MyRootConfiguration ){}. onStartup(context)
5657 then :
5758 1 * context. addFilter(" springSecurityFilterChain" , {DelegatingFilterProxy f -> f. targetBeanName == " springSecurityFilterChain" && f. contextAttribute == null }) >> registration
58- 1 * registration. addMappingForUrlPatterns(EnumSet . of( DispatcherType . REQUEST , DispatcherType . ERROR ) , false , " /*" );
59+ 1 * registration. addMappingForUrlPatterns(DEFAULT_DISPATCH , false , " /*" );
5960 1 * registration. setAsyncSupported(true )
6061 1 * context. addListener(_ as ContextLoaderListener )
6162 }
@@ -75,7 +76,7 @@ class AbstractSecurityWebApplicationInitializerTests extends Specification {
7576 }. onStartup(context)
7677 then :
7778 1 * context. addFilter(" springSecurityFilterChain" , {DelegatingFilterProxy f -> f. targetBeanName == " springSecurityFilterChain" && f. contextAttribute == null }) >> registration
78- 1 * registration. addMappingForUrlPatterns(EnumSet . of( DispatcherType . REQUEST , DispatcherType . ERROR ) , false , " /*" );
79+ 1 * registration. addMappingForUrlPatterns(DEFAULT_DISPATCH , false , " /*" );
7980 1 * registration. setAsyncSupported(true )
8081 1 * context. addListener(HttpSessionEventPublisher . class. name)
8182 }
@@ -109,7 +110,7 @@ class AbstractSecurityWebApplicationInitializerTests extends Specification {
109110 }.onStartup(context)
110111 then:
111112 1 * context.addFilter("springSecurityFilterChain", {DelegatingFilterProxy f -> f.targetBeanName == "springSecurityFilterChain" && f.contextAttribute == "org.springframework.web.servlet.FrameworkServlet.CONTEXT.dispatcher"}) >> registration
112- 1 * registration.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST, DispatcherType.ERROR) , false, "/*");
113+ 1 * registration.addMappingForUrlPatterns(DEFAULT_DISPATCH , false, "/*");
113114 1 * registration.setAsyncSupported(true)
114115 0 * context.addListener(_)
115116 }
@@ -140,7 +141,7 @@ class AbstractSecurityWebApplicationInitializerTests extends Specification {
140141 }.onStartup(context)
141142 then:
142143 1 * context.addFilter("springSecurityFilterChain", {DelegatingFilterProxy f -> f.targetBeanName == "springSecurityFilterChain" && f.contextAttribute == null}) >> registration
143- 3 * registration.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST, DispatcherType.ERROR) , false, "/*");
144+ 3 * registration.addMappingForUrlPatterns(DEFAULT_DISPATCH , false, "/*");
144145 3 * registration.setAsyncSupported(true)
145146 0 * context.addListener(_)
146147 1 * context.addFilter(_, filter1) >> registration
@@ -160,7 +161,7 @@ class AbstractSecurityWebApplicationInitializerTests extends Specification {
160161 }.onStartup(context)
161162 then:
162163 1 * context.addFilter("springSecurityFilterChain", {DelegatingFilterProxy f -> f.targetBeanName == "springSecurityFilterChain" && f.contextAttribute == null}) >> registration
163- 1 * registration.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST, DispatcherType.ERROR) , false, "/*");
164+ 1 * registration.addMappingForUrlPatterns(DEFAULT_DISPATCH , false, "/*");
164165 1 * context.addFilter(_, filter1) >> null
165166 IllegalStateException success = thrown()
166167 success.message == "Duplicate Filter registration for 'filter'. Check to ensure the Filter is only configured once."
@@ -213,8 +214,8 @@ class AbstractSecurityWebApplicationInitializerTests extends Specification {
213214 }.onStartup(context)
214215 then:
215216 1 * context.addFilter("springSecurityFilterChain", {DelegatingFilterProxy f -> f.targetBeanName == "springSecurityFilterChain" && f.contextAttribute == null}) >> registration
216- 1 * registration.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST, DispatcherType.ERROR) , false, "/*");
217- 2 * registration.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST, DispatcherType.ERROR) , true, "/*");
217+ 1 * registration.addMappingForUrlPatterns(DEFAULT_DISPATCH , false, "/*");
218+ 2 * registration.addMappingForUrlPatterns(DEFAULT_DISPATCH , true, "/*");
218219 3 * registration.setAsyncSupported(true)
219220 0 * context.addListener(_)
220221 1 * context.addFilter(_, filter1) >> registration
@@ -234,7 +235,7 @@ class AbstractSecurityWebApplicationInitializerTests extends Specification {
234235 }.onStartup(context)
235236 then:
236237 1 * context.addFilter("springSecurityFilterChain", {DelegatingFilterProxy f -> f.targetBeanName == "springSecurityFilterChain" && f.contextAttribute == null}) >> registration
237- 1 * registration.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST, DispatcherType.ERROR) , false, "/*");
238+ 1 * registration.addMappingForUrlPatterns(DEFAULT_DISPATCH , false, "/*");
238239 1 * context.addFilter(_, filter1) >> null
239240 IllegalStateException success = thrown()
240241 success.message == "Duplicate Filter registration for 'filter'. Check to ensure the Filter is only configured once."
0 commit comments