@@ -181,29 +181,19 @@ void shouldApplyOrderFromOrderAttribute() {
181
181
}
182
182
183
183
@ Test
184
- @ SuppressWarnings ("unchecked" )
185
184
void shouldApplyExtendedServletRegistrationAnnotation () {
186
185
load (ServletConfigurationWithExtendedAttributes .class );
187
- // Grab all initializers in the context, including beans that are adapted from @ServletRegistration
188
186
ServletContextInitializerBeans initializerBeans = new ServletContextInitializerBeans (
189
187
this .context .getBeanFactory (), TestServletContextInitializer .class );
190
188
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
195
189
ServletRegistrationBean <?> bean = findServletRegistrationBeanByName (initializerBeans , "extended" );
196
- assertThat (bean ).as ("extended servlet registration bean" ).isNotNull ();
197
190
198
- // Verify that the standard attributes were applied
199
191
assertThat (bean .getServletName ()).isEqualTo ("extended" );
200
192
assertThat (bean .getUrlMappings ()).containsExactly ("/extended/*" );
201
193
202
- // Verify our new initParameters
203
194
assertThat (bean .getInitParameters ()).containsEntry ("hello" , "world" )
204
195
.containsEntry ("flag" , "true" );
205
196
206
- // Verify multi-part config
207
197
assertThat (bean .getMultipartConfig ()).isNotNull ();
208
198
assertThat (bean .getMultipartConfig ().getLocation ()).isEqualTo ("/tmp" );
209
199
assertThat (bean .getMultipartConfig ().getMaxFileSize ()).isEqualTo (1024 );
@@ -212,28 +202,20 @@ void shouldApplyExtendedServletRegistrationAnnotation() {
212
202
}
213
203
214
204
@ Test
215
- @ SuppressWarnings ("unchecked" )
216
205
void shouldApplyServletRegistrationAnnotationWithExtraRegistrationBeans () {
217
206
load (ServletConfigurationWithExtendedAttributes .class );
218
207
ServletContextInitializerBeans initializerBeans = new ServletContextInitializerBeans (
219
208
this .context .getBeanFactory (), TestServletContextInitializer .class );
220
209
221
- // 2) Check the one referencing 'servletRegistrationBeans'
222
210
ServletRegistrationBean <?> bean = findServletRegistrationBeanByName (initializerBeans , "extendedWithExtraBeans" );
223
211
assertThat (bean ).as ("extendedWithExtraBeans registration bean" ).isNotNull ();
224
212
225
- // Confirm standard attributes
226
213
assertThat (bean .getServletName ()).isEqualTo ("extendedWithExtraBeans" );
227
214
assertThat (bean .getUrlMappings ()).containsExactly ("/extra/*" );
228
215
229
- // Confirm that the extra init param from MyExtraServletRegistrationBean was merged
230
216
assertThat (bean .getInitParameters ()).containsEntry ("extra" , "fromExtraBean" );
231
217
}
232
218
233
- /**
234
- * Simple helper method to locate a specific ServletRegistrationBean by its name
235
- * from the given ServletContextInitializerBeans collection.
236
- */
237
219
@ SuppressWarnings ("rawtypes" )
238
220
private ServletRegistrationBean findServletRegistrationBeanByName (
239
221
ServletContextInitializerBeans initializerBeans , String servletName ) {
0 commit comments