Skip to content

Commit 0d4469d

Browse files
committed
Suppressing warnings for deprecation of SimpleJdbcTemplate; polishing JavaDoc; using TestNG assertions in TestNG tests.
1 parent 266e109 commit 0d4469d

File tree

28 files changed

+76
-78
lines changed

28 files changed

+76
-78
lines changed

org.springframework.test/src/main/java/org/springframework/test/context/junit4/AbstractTransactionalJUnit4SpringContextTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2010 the original author or authors.
2+
* Copyright 2002-2011 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.
@@ -77,6 +77,7 @@
7777
* @see org.springframework.test.context.junit38.AbstractTransactionalJUnit38SpringContextTests
7878
* @see org.springframework.test.context.testng.AbstractTransactionalTestNGSpringContextTests
7979
*/
80+
@SuppressWarnings("deprecation")
8081
@TestExecutionListeners(TransactionalTestExecutionListener.class)
8182
@Transactional
8283
public abstract class AbstractTransactionalJUnit4SpringContextTests extends AbstractJUnit4SpringContextTests {

org.springframework.test/src/main/java/org/springframework/test/context/testng/AbstractTransactionalTestNGSpringContextTests.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2008 the original author or authors.
2+
* Copyright 2002-2011 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.
@@ -65,6 +65,7 @@
6565
* @see org.springframework.test.context.junit38.AbstractTransactionalJUnit38SpringContextTests
6666
* @see org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests
6767
*/
68+
@SuppressWarnings("deprecation")
6869
@TestExecutionListeners(TransactionalTestExecutionListener.class)
6970
@Transactional
7071
public abstract class AbstractTransactionalTestNGSpringContextTests extends AbstractTestNGSpringContextTests {
@@ -94,7 +95,6 @@ public void setSqlScriptEncoding(String sqlScriptEncoding) {
9495
this.sqlScriptEncoding = sqlScriptEncoding;
9596
}
9697

97-
9898
/**
9999
* Count the rows in the given table.
100100
* @param tableName table name to count rows in
@@ -125,12 +125,11 @@ protected int deleteFromTables(String... names) {
125125
* @throws DataAccessException if there is an error executing a statement
126126
* and continueOnError was <code>false</code>
127127
*/
128-
protected void executeSqlScript(String sqlResourcePath, boolean continueOnError)
129-
throws DataAccessException {
128+
protected void executeSqlScript(String sqlResourcePath, boolean continueOnError) throws DataAccessException {
130129

131130
Resource resource = this.applicationContext.getResource(sqlResourcePath);
132-
SimpleJdbcTestUtils.executeSqlScript(
133-
this.simpleJdbcTemplate, new EncodedResource(resource, this.sqlScriptEncoding), continueOnError);
131+
SimpleJdbcTestUtils.executeSqlScript(this.simpleJdbcTemplate, new EncodedResource(resource,
132+
this.sqlScriptEncoding), continueOnError);
134133
}
135134

136135
}

org.springframework.test/src/main/java/org/springframework/test/jdbc/SimpleJdbcTestUtils.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2008 the original author or authors.
2+
* Copyright 2002-2011 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.
@@ -23,7 +23,6 @@
2323

2424
import org.apache.commons.logging.Log;
2525
import org.apache.commons.logging.LogFactory;
26-
2726
import org.springframework.core.io.Resource;
2827
import org.springframework.core.io.ResourceLoader;
2928
import org.springframework.core.io.support.EncodedResource;
@@ -40,6 +39,7 @@
4039
* @author Thomas Risberg
4140
* @since 2.5
4241
*/
42+
@SuppressWarnings("deprecation")
4343
public abstract class SimpleJdbcTestUtils {
4444

4545
private static final Log logger = LogFactory.getLog(SimpleJdbcTestUtils.class);
@@ -86,9 +86,8 @@ public static int deleteFromTables(SimpleJdbcTemplate simpleJdbcTemplate, String
8686
* @throws DataAccessException if there is an error executing a statement
8787
* and continueOnError was <code>false</code>
8888
*/
89-
public static void executeSqlScript(SimpleJdbcTemplate simpleJdbcTemplate,
90-
ResourceLoader resourceLoader, String sqlResourcePath, boolean continueOnError)
91-
throws DataAccessException {
89+
public static void executeSqlScript(SimpleJdbcTemplate simpleJdbcTemplate, ResourceLoader resourceLoader,
90+
String sqlResourcePath, boolean continueOnError) throws DataAccessException {
9291

9392
Resource resource = resourceLoader.getResource(sqlResourcePath);
9493
executeSqlScript(simpleJdbcTemplate, resource, continueOnError);
@@ -107,8 +106,8 @@ public static void executeSqlScript(SimpleJdbcTemplate simpleJdbcTemplate,
107106
* @throws DataAccessException if there is an error executing a statement
108107
* and continueOnError was <code>false</code>
109108
*/
110-
public static void executeSqlScript(SimpleJdbcTemplate simpleJdbcTemplate,
111-
Resource resource, boolean continueOnError) throws DataAccessException {
109+
public static void executeSqlScript(SimpleJdbcTemplate simpleJdbcTemplate, Resource resource,
110+
boolean continueOnError) throws DataAccessException {
112111

113112
executeSqlScript(simpleJdbcTemplate, new EncodedResource(resource), continueOnError);
114113
}
@@ -126,8 +125,8 @@ public static void executeSqlScript(SimpleJdbcTemplate simpleJdbcTemplate,
126125
* @throws DataAccessException if there is an error executing a statement
127126
* and continueOnError was <code>false</code>
128127
*/
129-
public static void executeSqlScript(SimpleJdbcTemplate simpleJdbcTemplate,
130-
EncodedResource resource, boolean continueOnError) throws DataAccessException {
128+
public static void executeSqlScript(SimpleJdbcTemplate simpleJdbcTemplate, EncodedResource resource,
129+
boolean continueOnError) throws DataAccessException {
131130

132131
if (logger.isInfoEnabled()) {
133132
logger.info("Executing SQL script from " + resource);
@@ -140,7 +139,7 @@ public static void executeSqlScript(SimpleJdbcTemplate simpleJdbcTemplate,
140139
String script = JdbcTestUtils.readScript(lnr);
141140
char delimiter = ';';
142141
if (!JdbcTestUtils.containsSqlScriptDelimiters(script, delimiter)) {
143-
delimiter = '\n';
142+
delimiter = '\n';
144143
}
145144
JdbcTestUtils.splitSqlScript(script, delimiter, statements);
146145
for (String statement : statements) {

org.springframework.test/src/test/java/org/springframework/test/context/junit38/ConcreteTransactionalJUnit38SpringContextTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import org.springframework.test.jdbc.SimpleJdbcTestUtils;
4040

4141
/**
42-
* Combined unit test for {@link AbstractJUnit38SpringContextTests} and
42+
* Combined integration test for {@link AbstractJUnit38SpringContextTests} and
4343
* {@link AbstractTransactionalJUnit38SpringContextTests}.
4444
*
4545
* @author Sam Brannen

org.springframework.test/src/test/java/org/springframework/test/context/junit38/FailingBeforeAndAfterMethodsTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
/**
4040
* <p>
41-
* JUnit 4 based unit test for verifying that '<em>before</em>' and '<em>after</em>'
41+
* JUnit 4 based integration test for verifying that '<em>before</em>' and '<em>after</em>'
4242
* methods of {@link TestExecutionListener TestExecutionListeners} as well as
4343
* {@link BeforeTransaction @BeforeTransaction} and
4444
* {@link AfterTransaction @AfterTransaction} methods can fail a test in a JUnit

org.springframework.test/src/test/java/org/springframework/test/context/junit4/BeforeAndAfterTransactionAnnotationTests.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,17 @@
1616

1717
package org.springframework.test.context.junit4;
1818

19-
import javax.annotation.Resource;
20-
import javax.sql.DataSource;
21-
2219
import static org.junit.Assert.assertEquals;
2320
import static org.springframework.test.transaction.TransactionTestUtils.assertInTransaction;
2421

22+
import javax.annotation.Resource;
23+
import javax.sql.DataSource;
24+
2525
import org.junit.AfterClass;
2626
import org.junit.Before;
2727
import org.junit.BeforeClass;
2828
import org.junit.Test;
2929
import org.junit.runner.RunWith;
30-
3130
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
3231
import org.springframework.test.context.ContextConfiguration;
3332
import org.springframework.test.context.TestExecutionListeners;
@@ -37,16 +36,17 @@
3736
import org.springframework.transaction.annotation.Transactional;
3837

3938
/**
40-
* JUnit 4 based unit test which verifies
39+
* JUnit 4 based integration test which verifies
4140
* {@link BeforeTransaction @BeforeTransaction} and
4241
* {@link AfterTransaction @AfterTransaction} behavior.
4342
*
4443
* @author Sam Brannen
4544
* @since 2.5
4645
*/
46+
@SuppressWarnings("deprecation")
4747
@RunWith(SpringJUnit4ClassRunner.class)
4848
@ContextConfiguration
49-
@TestExecutionListeners({TransactionalTestExecutionListener.class})
49+
@TestExecutionListeners({ TransactionalTestExecutionListener.class })
5050
public class BeforeAndAfterTransactionAnnotationTests extends AbstractTransactionalSpringRunnerTests {
5151

5252
protected static SimpleJdbcTemplate simpleJdbcTemplate;
@@ -66,14 +66,13 @@ public static void beforeClass() {
6666
@AfterClass
6767
public static void afterClass() {
6868
assertEquals("Verifying the final number of rows in the person table after all tests.", 3,
69-
countRowsInPersonTable(simpleJdbcTemplate));
69+
countRowsInPersonTable(simpleJdbcTemplate));
7070
assertEquals("Verifying the total number of calls to beforeTransaction().", 2,
71-
BeforeAndAfterTransactionAnnotationTests.numBeforeTransactionCalls);
71+
BeforeAndAfterTransactionAnnotationTests.numBeforeTransactionCalls);
7272
assertEquals("Verifying the total number of calls to afterTransaction().", 2,
73-
BeforeAndAfterTransactionAnnotationTests.numAfterTransactionCalls);
73+
BeforeAndAfterTransactionAnnotationTests.numAfterTransactionCalls);
7474
}
7575

76-
7776
@BeforeTransaction
7877
public void beforeTransaction() {
7978
assertInTransaction(false);
@@ -90,12 +89,13 @@ public void afterTransaction() {
9089
BeforeAndAfterTransactionAnnotationTests.numAfterTransactionCalls++;
9190
assertEquals("Deleting yoda", 1, deletePerson(simpleJdbcTemplate, YODA));
9291
assertEquals("Verifying the number of rows in the person table after a transactional test method.", 0,
93-
countRowsInPersonTable(simpleJdbcTemplate));
92+
countRowsInPersonTable(simpleJdbcTemplate));
9493
}
9594

9695
@Before
9796
public void before() {
98-
assertEquals("Verifying the number of rows in the person table before a test method.", (this.inTransaction ? 1 : 0), countRowsInPersonTable(simpleJdbcTemplate));
97+
assertEquals("Verifying the number of rows in the person table before a test method.", (this.inTransaction ? 1
98+
: 0), countRowsInPersonTable(simpleJdbcTemplate));
9999
}
100100

101101
@Test
@@ -104,7 +104,7 @@ public void transactionalMethod1() {
104104
assertInTransaction(true);
105105
assertEquals("Adding jane", 1, addPerson(simpleJdbcTemplate, JANE));
106106
assertEquals("Verifying the number of rows in the person table within transactionalMethod1().", 2,
107-
countRowsInPersonTable(simpleJdbcTemplate));
107+
countRowsInPersonTable(simpleJdbcTemplate));
108108
}
109109

110110
@Test
@@ -114,7 +114,7 @@ public void transactionalMethod2() {
114114
assertEquals("Adding jane", 1, addPerson(simpleJdbcTemplate, JANE));
115115
assertEquals("Adding sue", 1, addPerson(simpleJdbcTemplate, SUE));
116116
assertEquals("Verifying the number of rows in the person table within transactionalMethod2().", 3,
117-
countRowsInPersonTable(simpleJdbcTemplate));
117+
countRowsInPersonTable(simpleJdbcTemplate));
118118
}
119119

120120
@Test
@@ -124,7 +124,7 @@ public void nonTransactionalMethod() {
124124
assertEquals("Adding leia", 1, addPerson(simpleJdbcTemplate, LEIA));
125125
assertEquals("Adding yoda", 1, addPerson(simpleJdbcTemplate, YODA));
126126
assertEquals("Verifying the number of rows in the person table without a transaction.", 3,
127-
countRowsInPersonTable(simpleJdbcTemplate));
127+
countRowsInPersonTable(simpleJdbcTemplate));
128128
}
129129

130130

org.springframework.test/src/test/java/org/springframework/test/context/junit4/ClassLevelTransactionalSpringRunnerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
/**
4040
* <p>
41-
* JUnit 4 based unit test which verifies support of Spring's
41+
* JUnit 4 based integration test which verifies support of Spring's
4242
* {@link Transactional &#64;Transactional}, {@link NotTransactional
4343
* &#64;NotTransactional}, {@link TestExecutionListeners
4444
* &#64;TestExecutionListeners}, and {@link ContextConfiguration

org.springframework.test/src/test/java/org/springframework/test/context/junit4/ConcreteTransactionalJUnit4SpringContextTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
import org.springframework.test.jdbc.SimpleJdbcTestUtils;
4444

4545
/**
46-
* Combined unit test for {@link AbstractJUnit4SpringContextTests} and
46+
* Combined integration test for {@link AbstractJUnit4SpringContextTests} and
4747
* {@link AbstractTransactionalJUnit4SpringContextTests}.
4848
*
4949
* @author Sam Brannen

org.springframework.test/src/test/java/org/springframework/test/context/junit4/CustomDefaultContextLoaderClassSpringRunnerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.springframework.test.context.support.GenericPropertiesContextLoader;
2929

3030
/**
31-
* Unit tests which verify that a subclass of {@link SpringJUnit4ClassRunner}
31+
* Integration tests which verify that a subclass of {@link SpringJUnit4ClassRunner}
3232
* can specify a custom <em>default ContextLoader class name</em> that overrides
3333
* the standard default class name.
3434
*

org.springframework.test/src/test/java/org/springframework/test/context/junit4/DefaultRollbackFalseTransactionalSpringRunnerTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@
2626
import org.junit.Before;
2727
import org.junit.Test;
2828
import org.junit.runner.RunWith;
29-
3029
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
3130
import org.springframework.test.context.ContextConfiguration;
3231
import org.springframework.test.context.transaction.TransactionConfiguration;
3332
import org.springframework.transaction.annotation.Transactional;
3433

3534
/**
3635
* <p>
37-
* JUnit 4 based unit test which verifies proper transactional behavior when the
36+
* JUnit 4 based integration test which verifies proper transactional behavior when the
3837
* {@link TransactionConfiguration#defaultRollback() defaultRollback} attribute
3938
* of the {@link TransactionConfiguration} annotation is set to <strong><code>false</code></strong>.
4039
* Also tests configuration of the
@@ -45,6 +44,7 @@
4544
* @since 2.5
4645
* @see TransactionConfiguration
4746
*/
47+
@SuppressWarnings("deprecation")
4848
@RunWith(SpringJUnit4ClassRunner.class)
4949
@ContextConfiguration
5050
@TransactionConfiguration(transactionManager = "txMgr", defaultRollback = false)
@@ -57,15 +57,15 @@ public class DefaultRollbackFalseTransactionalSpringRunnerTests extends Abstract
5757
@AfterClass
5858
public static void verifyFinalTestData() {
5959
assertEquals("Verifying the final number of rows in the person table after all tests.", 2,
60-
countRowsInPersonTable(simpleJdbcTemplate));
60+
countRowsInPersonTable(simpleJdbcTemplate));
6161
}
6262

6363
@Before
6464
public void verifyInitialTestData() {
6565
clearPersonTable(simpleJdbcTemplate);
6666
assertEquals("Adding bob", 1, addPerson(simpleJdbcTemplate, BOB));
6767
assertEquals("Verifying the initial number of rows in the person table.", 1,
68-
countRowsInPersonTable(simpleJdbcTemplate));
68+
countRowsInPersonTable(simpleJdbcTemplate));
6969
}
7070

7171
@Test
@@ -75,7 +75,7 @@ public void modifyTestDataWithinTransaction() {
7575
assertEquals("Adding jane", 1, addPerson(simpleJdbcTemplate, JANE));
7676
assertEquals("Adding sue", 1, addPerson(simpleJdbcTemplate, SUE));
7777
assertEquals("Verifying the number of rows in the person table within a transaction.", 2,
78-
countRowsInPersonTable(simpleJdbcTemplate));
78+
countRowsInPersonTable(simpleJdbcTemplate));
7979
}
8080

8181

0 commit comments

Comments
 (0)