Skip to content

Commit 197434b

Browse files
committed
Polish TestNG integration tests
1 parent 8161852 commit 197434b

File tree

5 files changed

+55
-55
lines changed

5 files changed

+55
-55
lines changed

spring-test/src/test/java/org/springframework/test/context/cache/ClassLevelDirtiesContextTestNGTests.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2016 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.
@@ -171,7 +171,7 @@ public static void verifyFinalCacheState() {
171171
@TestExecutionListeners(listeners = { DependencyInjectionTestExecutionListener.class,
172172
DirtiesContextTestExecutionListener.class }, inheritListeners = false)
173173
@ContextConfiguration
174-
public static abstract class BaseTestCase extends AbstractTestNGSpringContextTests {
174+
static abstract class BaseTestCase extends AbstractTestNGSpringContextTests {
175175

176176
@Configuration
177177
static class Config {
@@ -189,75 +189,75 @@ protected void assertApplicationContextWasAutowired() {
189189
}
190190
}
191191

192-
public static final class CleanTestCase extends BaseTestCase {
192+
static final class CleanTestCase extends BaseTestCase {
193193

194194
@org.testng.annotations.Test
195-
public void verifyContextWasAutowired() {
195+
void verifyContextWasAutowired() {
196196
assertApplicationContextWasAutowired();
197197
}
198198

199199
}
200200

201201
@DirtiesContext
202-
public static class ClassLevelDirtiesContextWithCleanMethodsAndDefaultModeTestCase extends BaseTestCase {
202+
static class ClassLevelDirtiesContextWithCleanMethodsAndDefaultModeTestCase extends BaseTestCase {
203203

204204
@org.testng.annotations.Test
205-
public void verifyContextWasAutowired() {
205+
void verifyContextWasAutowired() {
206206
assertApplicationContextWasAutowired();
207207
}
208208
}
209209

210-
public static class InheritedClassLevelDirtiesContextWithCleanMethodsAndDefaultModeTestCase extends
210+
static class InheritedClassLevelDirtiesContextWithCleanMethodsAndDefaultModeTestCase extends
211211
ClassLevelDirtiesContextWithCleanMethodsAndDefaultModeTestCase {
212212
}
213213

214214
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
215-
public static class ClassLevelDirtiesContextWithCleanMethodsAndAfterClassModeTestCase extends BaseTestCase {
215+
static class ClassLevelDirtiesContextWithCleanMethodsAndAfterClassModeTestCase extends BaseTestCase {
216216

217217
@org.testng.annotations.Test
218-
public void verifyContextWasAutowired() {
218+
void verifyContextWasAutowired() {
219219
assertApplicationContextWasAutowired();
220220
}
221221
}
222222

223-
public static class InheritedClassLevelDirtiesContextWithCleanMethodsAndAfterClassModeTestCase extends
223+
static class InheritedClassLevelDirtiesContextWithCleanMethodsAndAfterClassModeTestCase extends
224224
ClassLevelDirtiesContextWithCleanMethodsAndAfterClassModeTestCase {
225225
}
226226

227227
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
228-
public static class ClassLevelDirtiesContextWithAfterEachTestMethodModeTestCase extends BaseTestCase {
228+
static class ClassLevelDirtiesContextWithAfterEachTestMethodModeTestCase extends BaseTestCase {
229229

230230
@org.testng.annotations.Test
231-
public void verifyContextWasAutowired1() {
231+
void verifyContextWasAutowired1() {
232232
assertApplicationContextWasAutowired();
233233
}
234234

235235
@org.testng.annotations.Test
236-
public void verifyContextWasAutowired2() {
236+
void verifyContextWasAutowired2() {
237237
assertApplicationContextWasAutowired();
238238
}
239239

240240
@org.testng.annotations.Test
241-
public void verifyContextWasAutowired3() {
241+
void verifyContextWasAutowired3() {
242242
assertApplicationContextWasAutowired();
243243
}
244244
}
245245

246-
public static class InheritedClassLevelDirtiesContextWithAfterEachTestMethodModeTestCase extends
246+
static class InheritedClassLevelDirtiesContextWithAfterEachTestMethodModeTestCase extends
247247
ClassLevelDirtiesContextWithAfterEachTestMethodModeTestCase {
248248
}
249249

250250
@DirtiesContext
251-
public static class ClassLevelDirtiesContextWithDirtyMethodsTestCase extends BaseTestCase {
251+
static class ClassLevelDirtiesContextWithDirtyMethodsTestCase extends BaseTestCase {
252252

253253
@org.testng.annotations.Test
254254
@DirtiesContext
255-
public void dirtyContext() {
255+
void dirtyContext() {
256256
assertApplicationContextWasAutowired();
257257
}
258258
}
259259

260-
public static class InheritedClassLevelDirtiesContextWithDirtyMethodsTestCase extends
260+
static class InheritedClassLevelDirtiesContextWithDirtyMethodsTestCase extends
261261
ClassLevelDirtiesContextWithDirtyMethodsTestCase {
262262
}
263263

spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTransactionalTestNGSpringContextTests.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
* @since 3.1
5555
*/
5656
@ContextConfiguration
57-
public class AnnotationConfigTransactionalTestNGSpringContextTests extends
58-
AbstractTransactionalTestNGSpringContextTests {
57+
public class AnnotationConfigTransactionalTestNGSpringContextTests
58+
extends AbstractTransactionalTestNGSpringContextTests {
5959

6060
private static final String JANE = "jane";
6161
private static final String SUE = "sue";
@@ -94,15 +94,15 @@ private void assertAddPerson(final String name) {
9494
}
9595

9696
@BeforeClass
97-
public void beforeClass() {
97+
void beforeClass() {
9898
numSetUpCalls = 0;
9999
numSetUpCallsInTransaction = 0;
100100
numTearDownCalls = 0;
101101
numTearDownCallsInTransaction = 0;
102102
}
103103

104104
@AfterClass
105-
public void afterClass() {
105+
void afterClass() {
106106
assertEquals(numSetUpCalls, NUM_TESTS, "number of calls to setUp().");
107107
assertEquals(numSetUpCallsInTransaction, NUM_TX_TESTS, "number of calls to setUp() within a transaction.");
108108
assertEquals(numTearDownCalls, NUM_TESTS, "number of calls to tearDown().");
@@ -111,7 +111,7 @@ public void afterClass() {
111111

112112
@Test
113113
@Transactional(propagation = Propagation.NOT_SUPPORTED)
114-
public void autowiringFromConfigClass() {
114+
void autowiringFromConfigClass() {
115115
assertNotNull(employee, "The employee should have been autowired.");
116116
assertEquals(employee.getName(), "John Smith");
117117

@@ -126,7 +126,7 @@ void beforeTransaction() {
126126
}
127127

128128
@BeforeMethod
129-
public void setUp() throws Exception {
129+
void setUp() throws Exception {
130130
numSetUpCalls++;
131131
if (inTransaction()) {
132132
numSetUpCallsInTransaction++;
@@ -143,7 +143,7 @@ public void modifyTestDataWithinTransaction() {
143143
}
144144

145145
@AfterMethod
146-
public void tearDown() throws Exception {
146+
void tearDown() throws Exception {
147147
numTearDownCalls++;
148148
if (inTransaction()) {
149149
numTearDownCallsInTransaction++;
@@ -162,7 +162,7 @@ void afterTransaction() {
162162
static class ContextConfiguration {
163163

164164
@Bean
165-
public Employee employee() {
165+
Employee employee() {
166166
Employee employee = new Employee();
167167
employee.setName("John Smith");
168168
employee.setAge(42);
@@ -171,17 +171,17 @@ public Employee employee() {
171171
}
172172

173173
@Bean
174-
public Pet pet() {
174+
Pet pet() {
175175
return new Pet("Fido");
176176
}
177177

178178
@Bean
179-
public PlatformTransactionManager transactionManager() {
179+
PlatformTransactionManager transactionManager() {
180180
return new DataSourceTransactionManager(dataSource());
181181
}
182182

183183
@Bean
184-
public DataSource dataSource() {
184+
DataSource dataSource() {
185185
return new EmbeddedDatabaseBuilder()//
186186
.addScript("classpath:/org/springframework/test/jdbc/schema.sql")//
187187
.addScript("classpath:/org/springframework/test/jdbc/data.sql")//

spring-test/src/test/java/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,15 @@ private void assertAddPerson(final String name) {
117117
}
118118

119119
@BeforeClass
120-
public void beforeClass() {
120+
void beforeClass() {
121121
numSetUpCalls = 0;
122122
numSetUpCallsInTransaction = 0;
123123
numTearDownCalls = 0;
124124
numTearDownCallsInTransaction = 0;
125125
}
126126

127127
@AfterClass
128-
public void afterClass() {
128+
void afterClass() {
129129
assertEquals(numSetUpCalls, NUM_TESTS, "number of calls to setUp().");
130130
assertEquals(numSetUpCallsInTransaction, NUM_TX_TESTS, "number of calls to setUp() within a transaction.");
131131
assertEquals(numTearDownCalls, NUM_TESTS, "number of calls to tearDown().");
@@ -134,7 +134,7 @@ public void afterClass() {
134134

135135
@Test
136136
@Transactional(propagation = Propagation.NOT_SUPPORTED)
137-
public void verifyApplicationContextSet() {
137+
void verifyApplicationContextSet() {
138138
assertInTransaction(false);
139139
assertNotNull(super.applicationContext,
140140
"The application context should have been set due to ApplicationContextAware semantics.");
@@ -144,23 +144,23 @@ public void verifyApplicationContextSet() {
144144

145145
@Test
146146
@Transactional(propagation = Propagation.NOT_SUPPORTED)
147-
public void verifyBeanInitialized() {
147+
void verifyBeanInitialized() {
148148
assertInTransaction(false);
149149
assertTrue(beanInitialized,
150150
"This test instance should have been initialized due to InitializingBean semantics.");
151151
}
152152

153153
@Test
154154
@Transactional(propagation = Propagation.NOT_SUPPORTED)
155-
public void verifyBeanNameSet() {
155+
void verifyBeanNameSet() {
156156
assertInTransaction(false);
157157
assertEquals(beanName, getClass().getName(),
158158
"The bean name of this test instance should have been set due to BeanNameAware semantics.");
159159
}
160160

161161
@Test
162162
@Transactional(propagation = Propagation.NOT_SUPPORTED)
163-
public void verifyAnnotationAutowiredFields() {
163+
void verifyAnnotationAutowiredFields() {
164164
assertInTransaction(false);
165165
assertNull(nonrequiredLong, "The nonrequiredLong field should NOT have been autowired.");
166166
assertNotNull(pet, "The pet field should have been autowired.");
@@ -169,22 +169,22 @@ public void verifyAnnotationAutowiredFields() {
169169

170170
@Test
171171
@Transactional(propagation = Propagation.NOT_SUPPORTED)
172-
public void verifyAnnotationAutowiredMethods() {
172+
void verifyAnnotationAutowiredMethods() {
173173
assertInTransaction(false);
174174
assertNotNull(employee, "The setEmployee() method should have been autowired.");
175175
assertEquals(employee.getName(), "John Smith", "employee's name.");
176176
}
177177

178178
@Test
179179
@Transactional(propagation = Propagation.NOT_SUPPORTED)
180-
public void verifyResourceAnnotationInjectedFields() {
180+
void verifyResourceAnnotationInjectedFields() {
181181
assertInTransaction(false);
182182
assertEquals(foo, "Foo", "The foo field should have been injected via @Resource.");
183183
}
184184

185185
@Test
186186
@Transactional(propagation = Propagation.NOT_SUPPORTED)
187-
public void verifyResourceAnnotationInjectedMethods() {
187+
void verifyResourceAnnotationInjectedMethods() {
188188
assertInTransaction(false);
189189
assertEquals(bar, "Bar", "The setBar() method should have been injected via @Resource.");
190190
}
@@ -196,7 +196,7 @@ void beforeTransaction() {
196196
}
197197

198198
@BeforeMethod
199-
public void setUp() throws Exception {
199+
void setUp() throws Exception {
200200
numSetUpCalls++;
201201
if (inTransaction()) {
202202
numSetUpCallsInTransaction++;
@@ -213,7 +213,7 @@ public void modifyTestDataWithinTransaction() {
213213
}
214214

215215
@AfterMethod
216-
public void tearDown() throws Exception {
216+
void tearDown() throws Exception {
217217
numTearDownCalls++;
218218
if (inTransaction()) {
219219
numTearDownCallsInTransaction++;

spring-test/src/test/java/org/springframework/test/context/testng/web/ServletTestExecutionListenerTestNGIntegrationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2016 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.
@@ -57,7 +57,7 @@ static class Config {
5757
* @see #ensureMocksAreReinjectedBetweenTests_2
5858
*/
5959
@Test
60-
public void ensureMocksAreReinjectedBetweenTests_1() {
60+
void ensureMocksAreReinjectedBetweenTests_1() {
6161
assertInjectedServletRequestEqualsRequestInRequestContextHolder();
6262
}
6363

@@ -67,7 +67,7 @@ public void ensureMocksAreReinjectedBetweenTests_1() {
6767
* @see #ensureMocksAreReinjectedBetweenTests_1
6868
*/
6969
@Test
70-
public void ensureMocksAreReinjectedBetweenTests_2() {
70+
void ensureMocksAreReinjectedBetweenTests_2() {
7171
assertInjectedServletRequestEqualsRequestInRequestContextHolder();
7272
}
7373

spring-test/src/test/java/org/springframework/test/context/testng/web/TestNGSpringContextWebTests.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2016 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.
@@ -52,34 +52,34 @@ public class TestNGSpringContextWebTests extends AbstractTestNGSpringContextTest
5252
static class Config {
5353

5454
@Bean
55-
public String foo() {
55+
String foo() {
5656
return "enigma";
5757
}
5858
}
5959

6060

61-
protected ServletContext servletContext;
61+
ServletContext servletContext;
6262

6363
@Autowired
64-
protected WebApplicationContext wac;
64+
WebApplicationContext wac;
6565

6666
@Autowired
67-
protected MockServletContext mockServletContext;
67+
MockServletContext mockServletContext;
6868

6969
@Autowired
70-
protected MockHttpServletRequest request;
70+
MockHttpServletRequest request;
7171

7272
@Autowired
73-
protected MockHttpServletResponse response;
73+
MockHttpServletResponse response;
7474

7575
@Autowired
76-
protected MockHttpSession session;
76+
MockHttpSession session;
7777

7878
@Autowired
79-
protected ServletWebRequest webRequest;
79+
ServletWebRequest webRequest;
8080

8181
@Autowired
82-
protected String foo;
82+
String foo;
8383

8484

8585
@Override
@@ -88,7 +88,7 @@ public void setServletContext(ServletContext servletContext) {
8888
}
8989

9090
@Test
91-
public void basicWacFeatures() throws Exception {
91+
void basicWacFeatures() throws Exception {
9292
assertNotNull("ServletContext should be set in the WAC.", wac.getServletContext());
9393

9494
assertNotNull("ServletContext should have been set via ServletContextAware.", servletContext);
@@ -112,7 +112,7 @@ public void basicWacFeatures() throws Exception {
112112
}
113113

114114
@Test
115-
public void fooEnigmaAutowired() {
115+
void fooEnigmaAutowired() {
116116
assertEquals("enigma", foo);
117117
}
118118

0 commit comments

Comments
 (0)