Skip to content

Commit c46cb7d

Browse files
Fix for issue #45001 - ServletRegistrationBean has those properties, but @ServletRegistration hasn't: initParameters, servletRegistrationBeans, multipartConfig Signed-off-by: Dmytro Danilenkov <[email protected]>
Signed-off-by: Dmytro Danilenkov <[email protected]>
1 parent 23e5216 commit c46cb7d

File tree

1 file changed

+0
-18
lines changed

1 file changed

+0
-18
lines changed

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletContextInitializerBeansTests.java

-18
Original file line numberDiff line numberDiff line change
@@ -181,29 +181,19 @@ void shouldApplyOrderFromOrderAttribute() {
181181
}
182182

183183
@Test
184-
@SuppressWarnings("unchecked")
185184
void shouldApplyExtendedServletRegistrationAnnotation() {
186185
load(ServletConfigurationWithExtendedAttributes.class);
187-
// Grab all initializers in the context, including beans that are adapted from @ServletRegistration
188186
ServletContextInitializerBeans initializerBeans = new ServletContextInitializerBeans(
189187
this.context.getBeanFactory(), TestServletContextInitializer.class);
190188

191-
// We expect two registrations in this config: 'testServletWithInitParametersAndMultipart'
192-
// and 'testServletWithExtraBean'. So let's filter them individually or pick the one we want to assert.
193-
194-
// 1) Check the one with initParameters + multipartConfig
195189
ServletRegistrationBean<?> bean = findServletRegistrationBeanByName(initializerBeans, "extended");
196-
assertThat(bean).as("extended servlet registration bean").isNotNull();
197190

198-
// Verify that the standard attributes were applied
199191
assertThat(bean.getServletName()).isEqualTo("extended");
200192
assertThat(bean.getUrlMappings()).containsExactly("/extended/*");
201193

202-
// Verify our new initParameters
203194
assertThat(bean.getInitParameters()).containsEntry("hello", "world")
204195
.containsEntry("flag", "true");
205196

206-
// Verify multi-part config
207197
assertThat(bean.getMultipartConfig()).isNotNull();
208198
assertThat(bean.getMultipartConfig().getLocation()).isEqualTo("/tmp");
209199
assertThat(bean.getMultipartConfig().getMaxFileSize()).isEqualTo(1024);
@@ -212,28 +202,20 @@ void shouldApplyExtendedServletRegistrationAnnotation() {
212202
}
213203

214204
@Test
215-
@SuppressWarnings("unchecked")
216205
void shouldApplyServletRegistrationAnnotationWithExtraRegistrationBeans() {
217206
load(ServletConfigurationWithExtendedAttributes.class);
218207
ServletContextInitializerBeans initializerBeans = new ServletContextInitializerBeans(
219208
this.context.getBeanFactory(), TestServletContextInitializer.class);
220209

221-
// 2) Check the one referencing 'servletRegistrationBeans'
222210
ServletRegistrationBean<?> bean = findServletRegistrationBeanByName(initializerBeans, "extendedWithExtraBeans");
223211
assertThat(bean).as("extendedWithExtraBeans registration bean").isNotNull();
224212

225-
// Confirm standard attributes
226213
assertThat(bean.getServletName()).isEqualTo("extendedWithExtraBeans");
227214
assertThat(bean.getUrlMappings()).containsExactly("/extra/*");
228215

229-
// Confirm that the extra init param from MyExtraServletRegistrationBean was merged
230216
assertThat(bean.getInitParameters()).containsEntry("extra", "fromExtraBean");
231217
}
232218

233-
/**
234-
* Simple helper method to locate a specific ServletRegistrationBean by its name
235-
* from the given ServletContextInitializerBeans collection.
236-
*/
237219
@SuppressWarnings("rawtypes")
238220
private ServletRegistrationBean findServletRegistrationBeanByName(
239221
ServletContextInitializerBeans initializerBeans, String servletName) {

0 commit comments

Comments
 (0)