1
1
/*
2
- * Copyright 2002-2020 the original author or authors.
2
+ * Copyright 2002-2022 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
57
57
* @since 12.08.2003
58
58
* @see org.springframework.web.context.support.Spr8510Tests
59
59
*/
60
- public class ContextLoaderTests {
60
+ class ContextLoaderTests {
61
61
62
62
@ Test
63
- public void testContextLoaderListenerWithDefaultContext () {
63
+ void contextLoaderListenerWithDefaultContext () {
64
64
MockServletContext sc = new MockServletContext ("" );
65
65
sc .addInitParameter (ContextLoader .CONFIG_LOCATION_PARAM ,
66
66
"/org/springframework/web/context/WEB-INF/applicationContext.xml " +
@@ -94,8 +94,8 @@ public void testContextLoaderListenerWithDefaultContext() {
94
94
* context before calling refresh in ContextLoaders</em>.
95
95
*/
96
96
@ Test
97
- public void testContextLoaderListenerWithCustomizedContextLoader () {
98
- final StringBuffer buffer = new StringBuffer ();
97
+ void contextLoaderListenerWithCustomizedContextLoader () {
98
+ final StringBuilder builder = new StringBuilder ();
99
99
final String expectedContents = "customizeContext() was called" ;
100
100
final MockServletContext sc = new MockServletContext ("" );
101
101
sc .addInitParameter (ContextLoader .CONFIG_LOCATION_PARAM ,
@@ -106,15 +106,15 @@ protected void customizeContext(ServletContext sc, ConfigurableWebApplicationCon
106
106
assertThat (sc ).as ("The ServletContext should not be null." ).isNotNull ();
107
107
assertThat (sc ).as ("Verifying that we received the expected ServletContext." ).isEqualTo (sc );
108
108
assertThat (wac .isActive ()).as ("The ApplicationContext should not yet have been refreshed." ).isFalse ();
109
- buffer .append (expectedContents );
109
+ builder .append (expectedContents );
110
110
}
111
111
};
112
112
listener .contextInitialized (new ServletContextEvent (sc ));
113
- assertThat (buffer .toString ()).as ("customizeContext() should have been called." ).isEqualTo (expectedContents );
113
+ assertThat (builder .toString ()).as ("customizeContext() should have been called." ).isEqualTo (expectedContents );
114
114
}
115
115
116
116
@ Test
117
- public void testContextLoaderListenerWithLocalContextInitializers () {
117
+ void contextLoaderListenerWithLocalContextInitializers () {
118
118
MockServletContext sc = new MockServletContext ("" );
119
119
sc .addInitParameter (ContextLoader .CONFIG_LOCATION_PARAM ,
120
120
"org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml" );
@@ -129,7 +129,7 @@ public void testContextLoaderListenerWithLocalContextInitializers() {
129
129
}
130
130
131
131
@ Test
132
- public void testContextLoaderListenerWithGlobalContextInitializers () {
132
+ void contextLoaderListenerWithGlobalContextInitializers () {
133
133
MockServletContext sc = new MockServletContext ("" );
134
134
sc .addInitParameter (ContextLoader .CONFIG_LOCATION_PARAM ,
135
135
"org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml" );
@@ -144,7 +144,7 @@ public void testContextLoaderListenerWithGlobalContextInitializers() {
144
144
}
145
145
146
146
@ Test
147
- public void testContextLoaderListenerWithMixedContextInitializers () {
147
+ void contextLoaderListenerWithMixedContextInitializers () {
148
148
MockServletContext sc = new MockServletContext ("" );
149
149
sc .addInitParameter (ContextLoader .CONFIG_LOCATION_PARAM ,
150
150
"org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml" );
@@ -159,7 +159,7 @@ public void testContextLoaderListenerWithMixedContextInitializers() {
159
159
}
160
160
161
161
@ Test
162
- public void testContextLoaderListenerWithProgrammaticInitializers () {
162
+ void contextLoaderListenerWithProgrammaticInitializers () {
163
163
MockServletContext sc = new MockServletContext ("" );
164
164
sc .addInitParameter (ContextLoader .CONFIG_LOCATION_PARAM ,
165
165
"org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml" );
@@ -173,7 +173,7 @@ public void testContextLoaderListenerWithProgrammaticInitializers() {
173
173
}
174
174
175
175
@ Test
176
- public void testContextLoaderListenerWithProgrammaticAndLocalInitializers () {
176
+ void contextLoaderListenerWithProgrammaticAndLocalInitializers () {
177
177
MockServletContext sc = new MockServletContext ("" );
178
178
sc .addInitParameter (ContextLoader .CONFIG_LOCATION_PARAM ,
179
179
"org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml" );
@@ -188,7 +188,7 @@ public void testContextLoaderListenerWithProgrammaticAndLocalInitializers() {
188
188
}
189
189
190
190
@ Test
191
- public void testContextLoaderListenerWithProgrammaticAndGlobalInitializers () {
191
+ void contextLoaderListenerWithProgrammaticAndGlobalInitializers () {
192
192
MockServletContext sc = new MockServletContext ("" );
193
193
sc .addInitParameter (ContextLoader .CONFIG_LOCATION_PARAM ,
194
194
"org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml" );
@@ -203,7 +203,7 @@ public void testContextLoaderListenerWithProgrammaticAndGlobalInitializers() {
203
203
}
204
204
205
205
@ Test
206
- public void testRegisteredContextInitializerCanAccessServletContextParamsViaEnvironment () {
206
+ void registeredContextInitializerCanAccessServletContextParamsViaEnvironment () {
207
207
MockServletContext sc = new MockServletContext ("" );
208
208
// config file doesn't matter - just a placeholder
209
209
sc .addInitParameter (ContextLoader .CONFIG_LOCATION_PARAM ,
@@ -217,7 +217,7 @@ public void testRegisteredContextInitializerCanAccessServletContextParamsViaEnvi
217
217
}
218
218
219
219
@ Test
220
- public void testContextLoaderListenerWithUnknownContextInitializer () {
220
+ void contextLoaderListenerWithUnknownContextInitializer () {
221
221
MockServletContext sc = new MockServletContext ("" );
222
222
// config file doesn't matter. just a placeholder
223
223
sc .addInitParameter (ContextLoader .CONFIG_LOCATION_PARAM ,
@@ -231,7 +231,7 @@ public void testContextLoaderListenerWithUnknownContextInitializer() {
231
231
}
232
232
233
233
@ Test
234
- public void testContextLoaderWithCustomContext () throws Exception {
234
+ void contextLoaderWithCustomContext () throws Exception {
235
235
MockServletContext sc = new MockServletContext ("" );
236
236
sc .addInitParameter (ContextLoader .CONTEXT_CLASS_PARAM ,
237
237
"org.springframework.web.servlet.SimpleWebApplicationContext" );
@@ -245,7 +245,7 @@ public void testContextLoaderWithCustomContext() throws Exception {
245
245
}
246
246
247
247
@ Test
248
- public void testContextLoaderWithInvalidLocation () throws Exception {
248
+ void contextLoaderWithInvalidLocation () throws Exception {
249
249
MockServletContext sc = new MockServletContext ("" );
250
250
sc .addInitParameter (ContextLoader .CONFIG_LOCATION_PARAM , "/WEB-INF/myContext.xml" );
251
251
ServletContextListener listener = new ContextLoaderListener ();
@@ -256,7 +256,7 @@ public void testContextLoaderWithInvalidLocation() throws Exception {
256
256
}
257
257
258
258
@ Test
259
- public void testContextLoaderWithInvalidContext () throws Exception {
259
+ void contextLoaderWithInvalidContext () throws Exception {
260
260
MockServletContext sc = new MockServletContext ("" );
261
261
sc .addInitParameter (ContextLoader .CONTEXT_CLASS_PARAM ,
262
262
"org.springframework.web.context.support.InvalidWebApplicationContext" );
@@ -268,7 +268,7 @@ public void testContextLoaderWithInvalidContext() throws Exception {
268
268
}
269
269
270
270
@ Test
271
- public void testContextLoaderWithDefaultLocation () throws Exception {
271
+ void contextLoaderWithDefaultLocation () throws Exception {
272
272
MockServletContext sc = new MockServletContext ("" );
273
273
ServletContextListener listener = new ContextLoaderListener ();
274
274
ServletContextEvent event = new ServletContextEvent (sc );
@@ -280,7 +280,7 @@ public void testContextLoaderWithDefaultLocation() throws Exception {
280
280
}
281
281
282
282
@ Test
283
- public void testFrameworkServletWithDefaultLocation () throws Exception {
283
+ void frameworkServletWithDefaultLocation () throws Exception {
284
284
DispatcherServlet servlet = new DispatcherServlet ();
285
285
servlet .setContextClass (XmlWebApplicationContext .class );
286
286
assertThatExceptionOfType (BeanDefinitionStoreException .class )
@@ -291,7 +291,7 @@ public void testFrameworkServletWithDefaultLocation() throws Exception {
291
291
}
292
292
293
293
@ Test
294
- public void testFrameworkServletWithCustomLocation () throws Exception {
294
+ void frameworkServletWithCustomLocation () throws Exception {
295
295
DispatcherServlet servlet = new DispatcherServlet ();
296
296
servlet .setContextConfigLocation ("/org/springframework/web/context/WEB-INF/testNamespace.xml "
297
297
+ "/org/springframework/web/context/WEB-INF/context-addition.xml" );
@@ -302,7 +302,7 @@ public void testFrameworkServletWithCustomLocation() throws Exception {
302
302
303
303
@ Test
304
304
@ SuppressWarnings ("resource" )
305
- public void testClassPathXmlApplicationContext () throws IOException {
305
+ void classPathXmlApplicationContext () throws IOException {
306
306
ApplicationContext context = new ClassPathXmlApplicationContext (
307
307
"/org/springframework/web/context/WEB-INF/applicationContext.xml" );
308
308
assertThat (context .containsBean ("father" )).as ("Has father" ).isTrue ();
@@ -321,7 +321,7 @@ public void testClassPathXmlApplicationContext() throws IOException {
321
321
322
322
@ Test
323
323
@ SuppressWarnings ("resource" )
324
- public void testSingletonDestructionOnStartupFailure () throws IOException {
324
+ void singletonDestructionOnStartupFailure () throws IOException {
325
325
assertThatExceptionOfType (BeanCreationException .class ).isThrownBy (() ->
326
326
new ClassPathXmlApplicationContext (new String [] {
327
327
"/org/springframework/web/context/WEB-INF/applicationContext.xml" ,
0 commit comments