Skip to content

Commit 3e14cdb

Browse files
committed
Polish tests
1 parent f04e9a8 commit 3e14cdb

File tree

7 files changed

+79
-82
lines changed

7 files changed

+79
-82
lines changed

spring-tx/src/test/java/org/springframework/transaction/interceptor/RollbackRuleTests.java

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,62 +34,59 @@
3434
* @author Sam Brannen
3535
* @since 09.04.2003
3636
*/
37-
public class RollbackRuleTests {
37+
class RollbackRuleTests {
3838

3939
@Test
40-
public void foundImmediatelyWithString() {
41-
RollbackRuleAttribute rr = new RollbackRuleAttribute(java.lang.Exception.class.getName());
40+
void foundImmediatelyWithString() {
41+
RollbackRuleAttribute rr = new RollbackRuleAttribute(Exception.class.getName());
4242
assertThat(rr.getDepth(new Exception())).isEqualTo(0);
4343
}
4444

4545
@Test
46-
public void foundImmediatelyWithClass() {
46+
void foundImmediatelyWithClass() {
4747
RollbackRuleAttribute rr = new RollbackRuleAttribute(Exception.class);
4848
assertThat(rr.getDepth(new Exception())).isEqualTo(0);
4949
}
5050

5151
@Test
52-
public void notFound() {
52+
void notFound() {
5353
RollbackRuleAttribute rr = new RollbackRuleAttribute(java.io.IOException.class.getName());
5454
assertThat(rr.getDepth(new MyRuntimeException(""))).isEqualTo(-1);
5555
}
5656

5757
@Test
58-
public void ancestry() {
59-
RollbackRuleAttribute rr = new RollbackRuleAttribute(java.lang.Exception.class.getName());
58+
void ancestry() {
59+
RollbackRuleAttribute rr = new RollbackRuleAttribute(Exception.class.getName());
6060
// Exception -> Runtime -> NestedRuntime -> MyRuntimeException
6161
assertThat(rr.getDepth(new MyRuntimeException(""))).isEqualTo(3);
6262
}
6363

6464
@Test
65-
public void alwaysTrueForThrowable() {
66-
RollbackRuleAttribute rr = new RollbackRuleAttribute(java.lang.Throwable.class.getName());
67-
assertThat(rr.getDepth(new MyRuntimeException("")) > 0).isTrue();
68-
assertThat(rr.getDepth(new IOException()) > 0).isTrue();
69-
assertThat(rr.getDepth(new FatalBeanException(null,null)) > 0).isTrue();
70-
assertThat(rr.getDepth(new RuntimeException()) > 0).isTrue();
65+
void alwaysTrueForThrowable() {
66+
RollbackRuleAttribute rr = new RollbackRuleAttribute(Throwable.class.getName());
67+
assertThat(rr.getDepth(new MyRuntimeException(""))).isGreaterThan(0);
68+
assertThat(rr.getDepth(new IOException())).isGreaterThan(0);
69+
assertThat(rr.getDepth(new FatalBeanException(null, null))).isGreaterThan(0);
70+
assertThat(rr.getDepth(new RuntimeException())).isGreaterThan(0);
7171
}
7272

7373
@Test
74-
public void ctorArgMustBeAThrowableClassWithNonThrowableType() {
75-
assertThatIllegalArgumentException().isThrownBy(() ->
76-
new RollbackRuleAttribute(StringBuffer.class));
74+
void ctorArgMustBeAThrowableClassWithNonThrowableType() {
75+
assertThatIllegalArgumentException().isThrownBy(() -> new RollbackRuleAttribute(Object.class));
7776
}
7877

7978
@Test
80-
public void ctorArgMustBeAThrowableClassWithNullThrowableType() {
81-
assertThatIllegalArgumentException().isThrownBy(() ->
82-
new RollbackRuleAttribute((Class<?>) null));
79+
void ctorArgMustBeAThrowableClassWithNullThrowableType() {
80+
assertThatIllegalArgumentException().isThrownBy(() -> new RollbackRuleAttribute((Class<?>) null));
8381
}
8482

8583
@Test
86-
public void ctorArgExceptionStringNameVersionWithNull() {
87-
assertThatIllegalArgumentException().isThrownBy(() ->
88-
new RollbackRuleAttribute((String) null));
84+
void ctorArgExceptionStringNameVersionWithNull() {
85+
assertThatIllegalArgumentException().isThrownBy(() -> new RollbackRuleAttribute((String) null));
8986
}
9087

9188
@Test
92-
public void foundEnclosedExceptionWithEnclosingException() {
89+
void foundEnclosedExceptionWithEnclosingException() {
9390
RollbackRuleAttribute rr = new RollbackRuleAttribute(EnclosingException.class);
9491
assertThat(rr.getDepth(new EnclosingException.EnclosedException())).isEqualTo(0);
9592
}

spring-webmvc/src/test/java/org/springframework/web/context/ContextLoaderTests.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -58,10 +58,10 @@
5858
* @since 12.08.2003
5959
* @see org.springframework.web.context.support.Spr8510Tests
6060
*/
61-
public class ContextLoaderTests {
61+
class ContextLoaderTests {
6262

6363
@Test
64-
public void testContextLoaderListenerWithDefaultContext() {
64+
void contextLoaderListenerWithDefaultContext() {
6565
MockServletContext sc = new MockServletContext("");
6666
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
6767
"/org/springframework/web/context/WEB-INF/applicationContext.xml " +
@@ -95,7 +95,7 @@ public void testContextLoaderListenerWithDefaultContext() {
9595
* context before calling refresh in ContextLoaders</em>.
9696
*/
9797
@Test
98-
public void testContextLoaderListenerWithCustomizedContextLoader() {
98+
void contextLoaderListenerWithCustomizedContextLoader() {
9999
final StringBuffer buffer = new StringBuffer();
100100
final String expectedContents = "customizeContext() was called";
101101
final MockServletContext sc = new MockServletContext("");
@@ -115,7 +115,7 @@ protected void customizeContext(ServletContext sc, ConfigurableWebApplicationCon
115115
}
116116

117117
@Test
118-
public void testContextLoaderListenerWithLocalContextInitializers() {
118+
void contextLoaderListenerWithLocalContextInitializers() {
119119
MockServletContext sc = new MockServletContext("");
120120
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
121121
"org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml");
@@ -130,7 +130,7 @@ public void testContextLoaderListenerWithLocalContextInitializers() {
130130
}
131131

132132
@Test
133-
public void testContextLoaderListenerWithGlobalContextInitializers() {
133+
void contextLoaderListenerWithGlobalContextInitializers() {
134134
MockServletContext sc = new MockServletContext("");
135135
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
136136
"org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml");
@@ -145,7 +145,7 @@ public void testContextLoaderListenerWithGlobalContextInitializers() {
145145
}
146146

147147
@Test
148-
public void testContextLoaderListenerWithMixedContextInitializers() {
148+
void contextLoaderListenerWithMixedContextInitializers() {
149149
MockServletContext sc = new MockServletContext("");
150150
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
151151
"org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml");
@@ -160,7 +160,7 @@ public void testContextLoaderListenerWithMixedContextInitializers() {
160160
}
161161

162162
@Test
163-
public void testContextLoaderListenerWithProgrammaticInitializers() {
163+
void contextLoaderListenerWithProgrammaticInitializers() {
164164
MockServletContext sc = new MockServletContext("");
165165
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
166166
"org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml");
@@ -174,7 +174,7 @@ public void testContextLoaderListenerWithProgrammaticInitializers() {
174174
}
175175

176176
@Test
177-
public void testContextLoaderListenerWithProgrammaticAndLocalInitializers() {
177+
void contextLoaderListenerWithProgrammaticAndLocalInitializers() {
178178
MockServletContext sc = new MockServletContext("");
179179
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
180180
"org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml");
@@ -189,7 +189,7 @@ public void testContextLoaderListenerWithProgrammaticAndLocalInitializers() {
189189
}
190190

191191
@Test
192-
public void testContextLoaderListenerWithProgrammaticAndGlobalInitializers() {
192+
void contextLoaderListenerWithProgrammaticAndGlobalInitializers() {
193193
MockServletContext sc = new MockServletContext("");
194194
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
195195
"org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml");
@@ -204,7 +204,7 @@ public void testContextLoaderListenerWithProgrammaticAndGlobalInitializers() {
204204
}
205205

206206
@Test
207-
public void testRegisteredContextInitializerCanAccessServletContextParamsViaEnvironment() {
207+
void registeredContextInitializerCanAccessServletContextParamsViaEnvironment() {
208208
MockServletContext sc = new MockServletContext("");
209209
// config file doesn't matter - just a placeholder
210210
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
@@ -218,7 +218,7 @@ public void testRegisteredContextInitializerCanAccessServletContextParamsViaEnvi
218218
}
219219

220220
@Test
221-
public void testContextLoaderListenerWithUnknownContextInitializer() {
221+
void contextLoaderListenerWithUnknownContextInitializer() {
222222
MockServletContext sc = new MockServletContext("");
223223
// config file doesn't matter. just a placeholder
224224
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
@@ -232,7 +232,7 @@ public void testContextLoaderListenerWithUnknownContextInitializer() {
232232
}
233233

234234
@Test
235-
public void testContextLoaderWithCustomContext() throws Exception {
235+
void contextLoaderWithCustomContext() throws Exception {
236236
MockServletContext sc = new MockServletContext("");
237237
sc.addInitParameter(ContextLoader.CONTEXT_CLASS_PARAM,
238238
"org.springframework.web.servlet.SimpleWebApplicationContext");
@@ -246,7 +246,7 @@ public void testContextLoaderWithCustomContext() throws Exception {
246246
}
247247

248248
@Test
249-
public void testContextLoaderWithInvalidLocation() throws Exception {
249+
void contextLoaderWithInvalidLocation() throws Exception {
250250
MockServletContext sc = new MockServletContext("");
251251
sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, "/WEB-INF/myContext.xml");
252252
ServletContextListener listener = new ContextLoaderListener();
@@ -257,7 +257,7 @@ public void testContextLoaderWithInvalidLocation() throws Exception {
257257
}
258258

259259
@Test
260-
public void testContextLoaderWithInvalidContext() throws Exception {
260+
void contextLoaderWithInvalidContext() throws Exception {
261261
MockServletContext sc = new MockServletContext("");
262262
sc.addInitParameter(ContextLoader.CONTEXT_CLASS_PARAM,
263263
"org.springframework.web.context.support.InvalidWebApplicationContext");
@@ -269,7 +269,7 @@ public void testContextLoaderWithInvalidContext() throws Exception {
269269
}
270270

271271
@Test
272-
public void testContextLoaderWithDefaultLocation() throws Exception {
272+
void contextLoaderWithDefaultLocation() throws Exception {
273273
MockServletContext sc = new MockServletContext("");
274274
ServletContextListener listener = new ContextLoaderListener();
275275
ServletContextEvent event = new ServletContextEvent(sc);
@@ -281,7 +281,7 @@ public void testContextLoaderWithDefaultLocation() throws Exception {
281281
}
282282

283283
@Test
284-
public void testFrameworkServletWithDefaultLocation() throws Exception {
284+
void frameworkServletWithDefaultLocation() throws Exception {
285285
DispatcherServlet servlet = new DispatcherServlet();
286286
servlet.setContextClass(XmlWebApplicationContext.class);
287287
assertThatExceptionOfType(BeanDefinitionStoreException.class)
@@ -292,7 +292,7 @@ public void testFrameworkServletWithDefaultLocation() throws Exception {
292292
}
293293

294294
@Test
295-
public void testFrameworkServletWithCustomLocation() throws Exception {
295+
void frameworkServletWithCustomLocation() throws Exception {
296296
DispatcherServlet servlet = new DispatcherServlet();
297297
servlet.setContextConfigLocation("/org/springframework/web/context/WEB-INF/testNamespace.xml "
298298
+ "/org/springframework/web/context/WEB-INF/context-addition.xml");
@@ -303,7 +303,7 @@ public void testFrameworkServletWithCustomLocation() throws Exception {
303303

304304
@Test
305305
@SuppressWarnings("resource")
306-
public void testClassPathXmlApplicationContext() throws IOException {
306+
void classPathXmlApplicationContext() throws IOException {
307307
ApplicationContext context = new ClassPathXmlApplicationContext(
308308
"/org/springframework/web/context/WEB-INF/applicationContext.xml");
309309
assertThat(context.containsBean("father")).as("Has father").isTrue();
@@ -322,7 +322,7 @@ public void testClassPathXmlApplicationContext() throws IOException {
322322

323323
@Test
324324
@SuppressWarnings("resource")
325-
public void testSingletonDestructionOnStartupFailure() throws IOException {
325+
void singletonDestructionOnStartupFailure() throws IOException {
326326
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
327327
new ClassPathXmlApplicationContext(new String[] {
328328
"/org/springframework/web/context/WEB-INF/applicationContext.xml",

spring-webmvc/src/test/java/org/springframework/web/servlet/tags/HtmlEscapeTagOutsideDispatcherServletTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
2020
* @author Juergen Hoeller
2121
* @since 14.01.2005
2222
*/
23-
public class HtmlEscapeTagOutsideDispatcherServletTests extends HtmlEscapeTagTests {
23+
class HtmlEscapeTagOutsideDispatcherServletTests extends HtmlEscapeTagTests {
2424

2525
@Override
2626
protected boolean inDispatcherServlet() {

spring-webmvc/src/test/java/org/springframework/web/servlet/tags/HtmlEscapeTagTests.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,10 +33,10 @@
3333
* @author Alef Arendsen
3434
*/
3535
@SuppressWarnings("serial")
36-
public class HtmlEscapeTagTests extends AbstractTagTests {
36+
class HtmlEscapeTagTests extends AbstractTagTests {
3737

3838
@Test
39-
public void htmlEscapeTag() throws JspException {
39+
void htmlEscapeTag() throws JspException {
4040
PageContext pc = createPageContext();
4141
HtmlEscapeTag tag = new HtmlEscapeTag();
4242
tag.setPageContext(pc);
@@ -88,7 +88,7 @@ public int doStartTagInternal() throws Exception {
8888
}
8989

9090
@Test
91-
public void htmlEscapeTagWithContextParamTrue() throws JspException {
91+
void htmlEscapeTagWithContextParamTrue() throws JspException {
9292
PageContext pc = createPageContext();
9393
MockServletContext sc = (MockServletContext) pc.getServletContext();
9494
sc.addInitParameter(WebUtils.HTML_ESCAPE_CONTEXT_PARAM, "true");
@@ -109,7 +109,7 @@ public void htmlEscapeTagWithContextParamTrue() throws JspException {
109109
}
110110

111111
@Test
112-
public void htmlEscapeTagWithContextParamFalse() throws JspException {
112+
void htmlEscapeTagWithContextParamFalse() throws JspException {
113113
PageContext pc = createPageContext();
114114
MockServletContext sc = (MockServletContext) pc.getServletContext();
115115
HtmlEscapeTag tag = new HtmlEscapeTag();
@@ -129,7 +129,7 @@ public void htmlEscapeTagWithContextParamFalse() throws JspException {
129129
}
130130

131131
@Test
132-
public void escapeBody() throws JspException {
132+
void escapeBody() throws JspException {
133133
PageContext pc = createPageContext();
134134
final StringBuffer result = new StringBuffer();
135135
EscapeBodyTag tag = new EscapeBodyTag() {
@@ -149,7 +149,7 @@ protected void writeBodyContent(String content) {
149149
}
150150

151151
@Test
152-
public void escapeBodyWithHtmlEscape() throws JspException {
152+
void escapeBodyWithHtmlEscape() throws JspException {
153153
PageContext pc = createPageContext();
154154
final StringBuffer result = new StringBuffer();
155155
EscapeBodyTag tag = new EscapeBodyTag() {
@@ -170,7 +170,7 @@ protected void writeBodyContent(String content) {
170170
}
171171

172172
@Test
173-
public void escapeBodyWithJavaScriptEscape() throws JspException {
173+
void escapeBodyWithJavaScriptEscape() throws JspException {
174174
PageContext pc = createPageContext();
175175
final StringBuffer result = new StringBuffer();
176176
EscapeBodyTag tag = new EscapeBodyTag() {
@@ -191,7 +191,7 @@ protected void writeBodyContent(String content) {
191191
}
192192

193193
@Test
194-
public void escapeBodyWithHtmlEscapeAndJavaScriptEscape() throws JspException {
194+
void escapeBodyWithHtmlEscapeAndJavaScriptEscape() throws JspException {
195195
PageContext pc = createPageContext();
196196
final StringBuffer result = new StringBuffer();
197197
EscapeBodyTag tag = new EscapeBodyTag() {

spring-webmvc/src/test/java/org/springframework/web/servlet/tags/MessageTagOutsideDispatcherServletTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
2020
* @author Juergen Hoeller
2121
* @since 14.01.2005
2222
*/
23-
public class MessageTagOutsideDispatcherServletTests extends MessageTagTests {
23+
class MessageTagOutsideDispatcherServletTests extends MessageTagTests {
2424

2525
@Override
2626
protected boolean inDispatcherServlet() {

0 commit comments

Comments
 (0)