You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2018/05/06 16:20:43 UTC
[1/2] commons-dbutils git commit: Add final modifier to local
variables.
Repository: commons-dbutils
Updated Branches:
refs/heads/master 41e682d63 -> e2c137f95
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/MockResultSetMetaData.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/MockResultSetMetaData.java b/src/test/java/org/apache/commons/dbutils/MockResultSetMetaData.java
index 92e4f29..2208d33 100644
--- a/src/test/java/org/apache/commons/dbutils/MockResultSetMetaData.java
+++ b/src/test/java/org/apache/commons/dbutils/MockResultSetMetaData.java
@@ -62,7 +62,7 @@ public class MockResultSetMetaData implements InvocationHandler {
public Object invoke(final Object proxy, final Method method, final Object[] args)
throws Throwable {
- String methodName = method.getName();
+ final String methodName = method.getName();
if (methodName.equals("getColumnCount")) {
return Integer.valueOf(this.columnNames.length);
@@ -70,13 +70,13 @@ public class MockResultSetMetaData implements InvocationHandler {
} else if (
methodName.equals("getColumnName")) {
- int col = ((Integer) args[0]).intValue() - 1;
+ final int col = ((Integer) args[0]).intValue() - 1;
return this.columnNames[col];
} else if (
methodName.equals("getColumnLabel")) {
- int col = ((Integer) args[0]).intValue() - 1;
+ final int col = ((Integer) args[0]).intValue() - 1;
return this.columnLabels[col];
} else if (methodName.equals("hashCode")) {
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/QueryLoaderTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/QueryLoaderTest.java b/src/test/java/org/apache/commons/dbutils/QueryLoaderTest.java
index 830272c..49901b0 100644
--- a/src/test/java/org/apache/commons/dbutils/QueryLoaderTest.java
+++ b/src/test/java/org/apache/commons/dbutils/QueryLoaderTest.java
@@ -28,25 +28,25 @@ public class QueryLoaderTest extends BaseTestCase {
"/org/apache/commons/dbutils/TestQueries.properties";
public void testLoad() throws IOException {
- QueryLoader loader = QueryLoader.instance();
- Map<String,String> q = loader.load(QUERIES);
- Map<String,String> q2 = loader.load(QUERIES);
+ final QueryLoader loader = QueryLoader.instance();
+ final Map<String,String> q = loader.load(QUERIES);
+ final Map<String,String> q2 = loader.load(QUERIES);
assertTrue(q == q2); // pointer comparison should return true
assertEquals("SELECT * FROM SomeTable", q.get("test.query"));
loader.unload(QUERIES);
- Map<String,String> q3 = loader.load(QUERIES);
+ final Map<String,String> q3 = loader.load(QUERIES);
assertTrue(q != q3); // pointer comparison should return false
}
public void testLoadThrowsIllegalArgumentException() throws IOException {
- QueryLoader queryLoader = QueryLoader.instance();
+ final QueryLoader queryLoader = QueryLoader.instance();
try {
queryLoader.load("e");
fail("Expecting exception: IllegalArgumentException");
- } catch(IllegalArgumentException e) {
+ } catch(final IllegalArgumentException e) {
assertEquals("e not found.",e.getMessage());
assertEquals(QueryLoader.class.getName(), e.getStackTrace()[0].getClassName());
}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java b/src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java
index f95ac95..ddf7e8f 100644
--- a/src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java
+++ b/src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java
@@ -108,7 +108,7 @@ public class QueryRunnerTest {
@Test
public void testGoodBatch() throws Exception {
- String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
+ final String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
callGoodBatch(params);
}
@@ -116,7 +116,7 @@ public class QueryRunnerTest {
@Test
public void testGoodBatchPmdTrue() throws Exception {
runner = new QueryRunner(dataSource, true);
- String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
+ final String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
callGoodBatch(params);
}
@@ -124,14 +124,14 @@ public class QueryRunnerTest {
@Test
public void testGoodBatchDefaultConstructor() throws Exception {
runner = new QueryRunner();
- String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
+ final String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
callGoodBatch(conn, params);
}
@Test
public void testNullParamsBatch() throws Exception {
- String[][] params = new String[][] { { null, "unit" }, { "test", null } };
+ final String[][] params = new String[][] { { null, "unit" }, { "test", null } };
callGoodBatch(params);
}
@@ -149,7 +149,7 @@ public class QueryRunnerTest {
verify(stmt, times(1)).executeBatch();
verify(stmt, times(1)).close(); // make sure the statement is closed
verify(conn, times(1)).close(); // make sure the connection is closed
- } catch(SQLException e) {
+ } catch(final SQLException e) {
caught = true;
}
@@ -160,21 +160,21 @@ public class QueryRunnerTest {
@Test
public void testTooFewParamsBatch() throws Exception {
- String[][] params = new String[][] { { "unit" }, { "test" } };
+ final String[][] params = new String[][] { { "unit" }, { "test" } };
callBatchWithException("select * from blah where ? = ?", params);
}
@Test
public void testTooManyParamsBatch() throws Exception {
- String[][] params = new String[][] { { "unit", "unit", "unit" }, { "test", "test", "test" } };
+ final String[][] params = new String[][] { { "unit", "unit", "unit" }, { "test", "test", "test" } };
callBatchWithException("select * from blah where ? = ?", params);
}
@Test(expected=SQLException.class)
public void testNullConnectionBatch() throws Exception {
- String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
+ final String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
when(meta.getParameterCount()).thenReturn(2);
when(dataSource.getConnection()).thenReturn(null);
@@ -184,7 +184,7 @@ public class QueryRunnerTest {
@Test(expected=SQLException.class)
public void testNullSqlBatch() throws Exception {
- String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
+ final String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
when(meta.getParameterCount()).thenReturn(2);
@@ -200,7 +200,7 @@ public class QueryRunnerTest {
@Test
public void testAddBatchException() throws Exception {
- String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
+ final String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
doThrow(new SQLException()).when(stmt).addBatch();
@@ -209,7 +209,7 @@ public class QueryRunnerTest {
@Test
public void testExecuteBatchException() throws Exception {
- String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
+ final String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
doThrow(new SQLException()).when(stmt).executeBatch();
@@ -289,7 +289,7 @@ public class QueryRunnerTest {
verify(results, times(1)).close();
verify(stmt, times(1)).close(); // make sure we closed the statement
verify(conn, times(1)).close(); // make sure we closed the connection
- } catch(SQLException e) {
+ } catch(final SQLException e) {
caught = true;
}
@@ -423,7 +423,7 @@ public class QueryRunnerTest {
when(results.next()).thenReturn(true).thenReturn(false);
when(results.getObject(1)).thenReturn(1L);
- Long generatedKey = runner.insert("INSERT INTO blah(col1, col2) VALUES(?,?)", new ScalarHandler<Long>(), "unit", "test");
+ final Long generatedKey = runner.insert("INSERT INTO blah(col1, col2) VALUES(?,?)", new ScalarHandler<Long>(), "unit", "test");
verify(stmt, times(1)).executeUpdate();
verify(stmt, times(1)).close(); // make sure we closed the statement
@@ -444,12 +444,12 @@ public class QueryRunnerTest {
when(results.getMetaData()).thenReturn(resultsMeta);
when(resultsMeta.getColumnCount()).thenReturn(1);
- ResultSetHandler<List<Object>> handler = new ResultSetHandler<List<Object>>()
+ final ResultSetHandler<List<Object>> handler = new ResultSetHandler<List<Object>>()
{
@Override
public List<Object> handle(final ResultSet rs) throws SQLException
{
- List<Object> objects = new ArrayList<>();
+ final List<Object> objects = new ArrayList<>();
while (rs.next())
{
objects.add(new Object());
@@ -458,13 +458,13 @@ public class QueryRunnerTest {
}
};
- Object[][] params = new Object[2][2];
+ final Object[][] params = new Object[2][2];
params[0][0] = "Test";
params[0][1] = "Blah";
params[1][0] = "Test2";
params[1][1] = "Blah2";
- List<Object> generatedKeys = runner.insertBatch("INSERT INTO blah(col1, col2) VALUES(?,?)", handler, params);
+ final List<Object> generatedKeys = runner.insertBatch("INSERT INTO blah(col1, col2) VALUES(?,?)", handler, params);
verify(stmt, times(2)).addBatch();
verify(stmt, times(1)).executeBatch();
@@ -485,7 +485,7 @@ public class QueryRunnerTest {
verify(stmt, times(1)).executeUpdate();
verify(stmt, times(1)).close(); // make sure we closed the statement
verify(conn, times(1)).close(); // make sure we closed the connection
- } catch(SQLException e) {
+ } catch(final SQLException e) {
caught = true;
}
@@ -533,8 +533,8 @@ public class QueryRunnerTest {
@Test
public void testStatementConfiguration() throws Exception {
- StatementConfiguration stmtConfig = new StatementConfiguration(1, 2, 3, 4, 5);
- QueryRunner queryRunner = new QueryRunner(stmtConfig);
+ final StatementConfiguration stmtConfig = new StatementConfiguration(1, 2, 3, 4, 5);
+ final QueryRunner queryRunner = new QueryRunner(stmtConfig);
queryRunner.prepareStatement(conn, "select 1");
verify(stmt).setFetchDirection(eq(1));
@@ -573,7 +573,7 @@ public class QueryRunnerTest {
// Test single OUT parameter
when(meta.getParameterCount()).thenReturn(1);
when(call.getObject(1)).thenReturn(42);
- OutParameter<Integer> intParam =
+ final OutParameter<Integer> intParam =
new OutParameter<>(Types.INTEGER, Integer.class);
result = runner.execute(conn, "{?= call my_proc()}", intParam);
@@ -602,7 +602,7 @@ public class QueryRunnerTest {
when(call.getObject(1)).thenReturn(24);
when(call.getObject(3)).thenReturn("out");
intParam.setValue(null);
- OutParameter<String> stringParam =
+ final OutParameter<String> stringParam =
new OutParameter<>(Types.VARCHAR, String.class, "in");
result = runner.execute(conn, "{?= call my_proc(?, ?)}", intParam, "test", stringParam);
@@ -641,7 +641,7 @@ public class QueryRunnerTest {
// Test single OUT parameter
when(meta.getParameterCount()).thenReturn(1);
when(call.getObject(1)).thenReturn(42);
- OutParameter<Integer> intParam =
+ final OutParameter<Integer> intParam =
new OutParameter<>(Types.INTEGER, Integer.class);
result = runner.execute("{?= call my_proc()}", intParam);
@@ -670,7 +670,7 @@ public class QueryRunnerTest {
when(call.getObject(1)).thenReturn(24);
when(call.getObject(3)).thenReturn("out");
intParam.setValue(null);
- OutParameter<String> stringParam =
+ final OutParameter<String> stringParam =
new OutParameter<>(Types.VARCHAR, String.class, "in");
result = runner.execute("{?= call my_proc(?, ?)}", intParam, "test", stringParam);
@@ -709,7 +709,7 @@ public class QueryRunnerTest {
when(meta.getParameterCount()).thenReturn(2);
runner.query("{call my_proc(?, ?)}", handler, params);
- } catch(SQLException e) {
+ } catch(final SQLException e) {
caught = true;
}
@@ -779,7 +779,7 @@ public class QueryRunnerTest {
}
});
when(meta.getParameterCount()).thenReturn(0);
- List<Object[]> objects = runner.execute("{call my_proc()}", handler);
+ final List<Object[]> objects = runner.execute("{call my_proc()}", handler);
Assert.assertEquals(3, objects.size());
verify(call, times(1)).execute();
@@ -812,7 +812,7 @@ public class QueryRunnerTest {
// Test single OUT parameter
when(meta.getParameterCount()).thenReturn(1);
when(call.getObject(1)).thenReturn(42);
- OutParameter<Integer> intParam =
+ final OutParameter<Integer> intParam =
new OutParameter<>(Types.INTEGER, Integer.class);
runner.execute(conn, "{?= call my_proc()}", handler, intParam);
@@ -841,7 +841,7 @@ public class QueryRunnerTest {
when(call.getObject(1)).thenReturn(24);
when(call.getObject(3)).thenReturn("out");
intParam.setValue(null);
- OutParameter<String> stringParam =
+ final OutParameter<String> stringParam =
new OutParameter<>(Types.VARCHAR, String.class, "in");
runner.execute(conn, "{?= call my_proc(?, ?)}", handler, intParam, "test", stringParam);
@@ -877,7 +877,7 @@ public class QueryRunnerTest {
// Test single OUT parameter
when(meta.getParameterCount()).thenReturn(1);
when(call.getObject(1)).thenReturn(42);
- OutParameter<Integer> intParam =
+ final OutParameter<Integer> intParam =
new OutParameter<>(Types.INTEGER, Integer.class);
runner.execute("{?= call my_proc()}", handler, intParam);
@@ -906,7 +906,7 @@ public class QueryRunnerTest {
when(call.getObject(1)).thenReturn(24);
when(call.getObject(3)).thenReturn("out");
intParam.setValue(null);
- OutParameter<String> stringParam =
+ final OutParameter<String> stringParam =
new OutParameter<>(Types.VARCHAR, String.class, "in");
runner.execute("{?= call my_proc(?, ?)}", handler, intParam, "test", stringParam);
@@ -945,7 +945,7 @@ public class QueryRunnerTest {
when(meta.getParameterCount()).thenReturn(2);
runner.query("{call my_proc(?, ?)}", handler, params);
- } catch(SQLException e) {
+ } catch(final SQLException e) {
caught = true;
}
@@ -1016,14 +1016,14 @@ public class QueryRunnerTest {
@Test
public void testFillStatementWithBean() throws Exception {
- MyBean bean = new MyBean();
+ final MyBean bean = new MyBean();
when(meta.getParameterCount()).thenReturn(3);
runner.fillStatementWithBean(stmt, bean, new String[] { "a", "b", "c" });
}
@Test(expected=NullPointerException.class)
public void testFillStatementWithBeanNullNames() throws Exception {
- MyBean bean = new MyBean();
+ final MyBean bean = new MyBean();
when(meta.getParameterCount()).thenReturn(3);
runner.fillStatementWithBean(stmt, bean, new String[] { "a", "b", null });
}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/ResultSetIteratorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/ResultSetIteratorTest.java b/src/test/java/org/apache/commons/dbutils/ResultSetIteratorTest.java
index e632f77..23cda5c 100644
--- a/src/test/java/org/apache/commons/dbutils/ResultSetIteratorTest.java
+++ b/src/test/java/org/apache/commons/dbutils/ResultSetIteratorTest.java
@@ -31,7 +31,7 @@ public class ResultSetIteratorTest extends BaseTestCase {
public void testNext() {
- Iterator<Object[]> iter = new ResultSetIterator(this.rs);
+ final Iterator<Object[]> iter = new ResultSetIterator(this.rs);
Object[] row = null;
assertTrue(iter.hasNext());
@@ -55,14 +55,14 @@ public class ResultSetIteratorTest extends BaseTestCase {
@Test
public void testRethrowThrowsRuntimeException() {
- ResultSetIterator resultSetIterator = new ResultSetIterator((ResultSet) null);
- Throwable throwable = new Throwable();
- SQLException sQLException = new SQLException(throwable);
+ final ResultSetIterator resultSetIterator = new ResultSetIterator((ResultSet) null);
+ final Throwable throwable = new Throwable();
+ final SQLException sQLException = new SQLException(throwable);
try {
resultSetIterator.rethrow(sQLException);
fail("Expecting exception: RuntimeException");
- } catch(RuntimeException e) {
+ } catch(final RuntimeException e) {
assertEquals(ResultSetIterator.class.getName(), e.getStackTrace()[0].getClassName());
}
@@ -71,8 +71,8 @@ public class ResultSetIteratorTest extends BaseTestCase {
@Test
public void testCreatesResultSetIteratorTakingThreeArgumentsAndCallsRemove() {
- ResultSet resultSet = mock(ResultSet.class);
- ResultSetIterator resultSetIterator = new ResultSetIterator(resultSet,null);
+ final ResultSet resultSet = mock(ResultSet.class);
+ final ResultSetIterator resultSetIterator = new ResultSetIterator(resultSet,null);
resultSetIterator.remove();
}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/ServiceLoaderTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/ServiceLoaderTest.java b/src/test/java/org/apache/commons/dbutils/ServiceLoaderTest.java
index 52f8204..694b80a 100644
--- a/src/test/java/org/apache/commons/dbutils/ServiceLoaderTest.java
+++ b/src/test/java/org/apache/commons/dbutils/ServiceLoaderTest.java
@@ -38,7 +38,7 @@ public class ServiceLoaderTest {
@Test
public void testFindsLocalColumnHandler() {
boolean found = false;
- for (ColumnHandler handler : columns) {
+ for (final ColumnHandler handler : columns) {
// this class is defined outside of the main classes in dbutils
if (handler instanceof TestColumnHandler) {
found = true;
@@ -51,7 +51,7 @@ public class ServiceLoaderTest {
@Test
public void testFindsLocalPropertyHandler() {
boolean found = false;
- for (PropertyHandler handler : properties) {
+ for (final PropertyHandler handler : properties) {
// this class is defined outside of the main classes in dbutils
if (handler instanceof TestPropertyHandler) {
found = true;
@@ -68,7 +68,7 @@ public class ServiceLoaderTest {
@Test
public void testFindMoreThanLocalColumns() {
int count = 0;
- for (ColumnHandler handler : columns) {
+ for (final ColumnHandler handler : columns) {
count++;
}
@@ -82,7 +82,7 @@ public class ServiceLoaderTest {
@Test
public void testFindMoreThanLocalProperties() {
int count = 0;
- for (PropertyHandler handler : properties) {
+ for (final PropertyHandler handler : properties) {
count++;
}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/StatementConfigurationTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/StatementConfigurationTest.java b/src/test/java/org/apache/commons/dbutils/StatementConfigurationTest.java
index 1e33c4f..7361373 100644
--- a/src/test/java/org/apache/commons/dbutils/StatementConfigurationTest.java
+++ b/src/test/java/org/apache/commons/dbutils/StatementConfigurationTest.java
@@ -28,7 +28,7 @@ public class StatementConfigurationTest {
*/
@Test
public void testEmptyBuilder() {
- StatementConfiguration config = new StatementConfiguration.Builder().build();
+ final StatementConfiguration config = new StatementConfiguration.Builder().build();
assertFalse(config.isFetchDirectionSet());
assertFalse(config.isFetchSizeSet());
@@ -42,13 +42,13 @@ public class StatementConfigurationTest {
*/
@Test
public void testBuilder() {
- StatementConfiguration.Builder builder = new StatementConfiguration.Builder()
+ final StatementConfiguration.Builder builder = new StatementConfiguration.Builder()
.fetchDirection(1)
.fetchSize(2)
.maxFieldSize(3)
.maxRows(4)
.queryTimeout(5);
- StatementConfiguration config = builder.build();
+ final StatementConfiguration config = builder.build();
assertTrue(config.isFetchDirectionSet());
assertEquals(Integer.valueOf(1), config.getFetchDirection());
@@ -71,7 +71,7 @@ public class StatementConfigurationTest {
*/
@Test
public void testConstructor() {
- StatementConfiguration config = new StatementConfiguration(1, 2, 3, 4, 5);
+ final StatementConfiguration config = new StatementConfiguration(1, 2, 3, 4, 5);
assertEquals(Integer.valueOf(1), config.getFetchDirection());
assertEquals(Integer.valueOf(2), config.getFetchSize());
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/handlers/ArrayHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/handlers/ArrayHandlerTest.java b/src/test/java/org/apache/commons/dbutils/handlers/ArrayHandlerTest.java
index 32aec57..c9888bd 100644
--- a/src/test/java/org/apache/commons/dbutils/handlers/ArrayHandlerTest.java
+++ b/src/test/java/org/apache/commons/dbutils/handlers/ArrayHandlerTest.java
@@ -31,8 +31,8 @@ import org.apache.commons.dbutils.ResultSetHandler;
public class ArrayHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException {
- ResultSetHandler<Object[]> h = new ArrayHandler();
- Object[] results = h.handle(this.rs);
+ final ResultSetHandler<Object[]> h = new ArrayHandler();
+ final Object[] results = h.handle(this.rs);
assertNotNull(results);
assertEquals(COLS, results.length);
@@ -42,8 +42,8 @@ public class ArrayHandlerTest extends BaseTestCase {
}
public void testEmptyResultSetHandle() throws SQLException {
- ResultSetHandler<Object[]> h = new ArrayHandler();
- Object[] results = h.handle(this.emptyResultSet);
+ final ResultSetHandler<Object[]> h = new ArrayHandler();
+ final Object[] results = h.handle(this.emptyResultSet);
assertThat(results, is(emptyArray()));
}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/handlers/ArrayListHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/handlers/ArrayListHandlerTest.java b/src/test/java/org/apache/commons/dbutils/handlers/ArrayListHandlerTest.java
index c60da2c..a8013ac 100644
--- a/src/test/java/org/apache/commons/dbutils/handlers/ArrayListHandlerTest.java
+++ b/src/test/java/org/apache/commons/dbutils/handlers/ArrayListHandlerTest.java
@@ -29,13 +29,13 @@ import org.apache.commons.dbutils.ResultSetHandler;
public class ArrayListHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException {
- ResultSetHandler<List<Object[]>> h = new ArrayListHandler();
- List<Object[]> results = h.handle(this.rs);
+ final ResultSetHandler<List<Object[]>> h = new ArrayListHandler();
+ final List<Object[]> results = h.handle(this.rs);
assertNotNull(results);
assertEquals(ROWS, results.size());
- Iterator<Object[]> iter = results.iterator();
+ final Iterator<Object[]> iter = results.iterator();
Object[] row = null;
assertTrue(iter.hasNext());
row = iter.next();
@@ -56,8 +56,8 @@ public class ArrayListHandlerTest extends BaseTestCase {
}
public void testEmptyResultSetHandle() throws SQLException {
- ResultSetHandler<List<Object[]>> h = new ArrayListHandler();
- List<Object[]> results = h.handle(this.emptyResultSet);
+ final ResultSetHandler<List<Object[]>> h = new ArrayListHandler();
+ final List<Object[]> results = h.handle(this.emptyResultSet);
assertNotNull(results);
assertTrue(results.isEmpty());
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/handlers/BeanHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/handlers/BeanHandlerTest.java b/src/test/java/org/apache/commons/dbutils/handlers/BeanHandlerTest.java
index 6d5e2cb..4a2e0c7 100644
--- a/src/test/java/org/apache/commons/dbutils/handlers/BeanHandlerTest.java
+++ b/src/test/java/org/apache/commons/dbutils/handlers/BeanHandlerTest.java
@@ -28,8 +28,8 @@ import org.apache.commons.dbutils.TestBean;
public class BeanHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException {
- ResultSetHandler<TestBean> h = new BeanHandler<>(TestBean.class);
- TestBean results = h.handle(this.rs);
+ final ResultSetHandler<TestBean> h = new BeanHandler<>(TestBean.class);
+ final TestBean results = h.handle(this.rs);
assertNotNull(results);
assertEquals("1", results.getOne());
@@ -39,15 +39,15 @@ public class BeanHandlerTest extends BaseTestCase {
}
public void testEmptyResultSetHandle() throws SQLException {
- ResultSetHandler<TestBean> h = new BeanHandler<>(TestBean.class);
- TestBean results = h.handle(this.emptyResultSet);
+ final ResultSetHandler<TestBean> h = new BeanHandler<>(TestBean.class);
+ final TestBean results = h.handle(this.emptyResultSet);
assertNull(results);
}
public void testHandleToSuperClass() throws SQLException {
- ResultSetHandler<TestBean> h = new BeanHandler<TestBean>(SubTestBean.class);
- TestBean results = h.handle(this.rs);
+ final ResultSetHandler<TestBean> h = new BeanHandler<TestBean>(SubTestBean.class);
+ final TestBean results = h.handle(this.rs);
assertNotNull(results);
assertEquals("1", results.getOne());
@@ -57,8 +57,8 @@ public class BeanHandlerTest extends BaseTestCase {
}
public void testHandleToInterface() throws SQLException {
- ResultSetHandler<SubTestBeanInterface> h = new BeanHandler<SubTestBeanInterface>(SubTestBean.class);
- SubTestBeanInterface results = h.handle(this.rs);
+ final ResultSetHandler<SubTestBeanInterface> h = new BeanHandler<SubTestBeanInterface>(SubTestBean.class);
+ final SubTestBeanInterface results = h.handle(this.rs);
assertNotNull(results);
assertEquals("1", results.getOne());
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/handlers/BeanListHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/handlers/BeanListHandlerTest.java b/src/test/java/org/apache/commons/dbutils/handlers/BeanListHandlerTest.java
index d5b293b..0284cdf 100644
--- a/src/test/java/org/apache/commons/dbutils/handlers/BeanListHandlerTest.java
+++ b/src/test/java/org/apache/commons/dbutils/handlers/BeanListHandlerTest.java
@@ -30,13 +30,13 @@ import org.apache.commons.dbutils.TestBean;
public class BeanListHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException {
- ResultSetHandler<List<TestBean>> h = new BeanListHandler<>(TestBean.class);
- List<TestBean> results = h.handle(this.rs);
+ final ResultSetHandler<List<TestBean>> h = new BeanListHandler<>(TestBean.class);
+ final List<TestBean> results = h.handle(this.rs);
assertNotNull(results);
assertEquals(ROWS, results.size());
- Iterator<TestBean> iter = results.iterator();
+ final Iterator<TestBean> iter = results.iterator();
TestBean row = null;
assertTrue(iter.hasNext());
row = iter.next();
@@ -57,21 +57,21 @@ public class BeanListHandlerTest extends BaseTestCase {
}
public void testEmptyResultSetHandle() throws SQLException {
- ResultSetHandler<List<TestBean>> h = new BeanListHandler<>(TestBean.class);
- List<TestBean> results = h.handle(this.emptyResultSet);
+ final ResultSetHandler<List<TestBean>> h = new BeanListHandler<>(TestBean.class);
+ final List<TestBean> results = h.handle(this.emptyResultSet);
assertNotNull(results);
assertTrue(results.isEmpty());
}
public void testHandleToSuperClass() throws SQLException {
- ResultSetHandler<List<TestBean>> h = new BeanListHandler<TestBean>(SubTestBean.class);
- List<TestBean> results = h.handle(this.rs);
+ final ResultSetHandler<List<TestBean>> h = new BeanListHandler<TestBean>(SubTestBean.class);
+ final List<TestBean> results = h.handle(this.rs);
assertNotNull(results);
assertEquals(ROWS, results.size());
- Iterator<TestBean> iter = results.iterator();
+ final Iterator<TestBean> iter = results.iterator();
TestBean row = null;
assertTrue(iter.hasNext());
row = iter.next();
@@ -95,13 +95,13 @@ public class BeanListHandlerTest extends BaseTestCase {
}
public void testHandleToInterface() throws SQLException {
- ResultSetHandler<List<SubTestBeanInterface>> h = new BeanListHandler<SubTestBeanInterface>(SubTestBean.class);
- List<SubTestBeanInterface> results = h.handle(this.rs);
+ final ResultSetHandler<List<SubTestBeanInterface>> h = new BeanListHandler<SubTestBeanInterface>(SubTestBean.class);
+ final List<SubTestBeanInterface> results = h.handle(this.rs);
assertNotNull(results);
assertEquals(ROWS, results.size());
- Iterator<SubTestBeanInterface> iter = results.iterator();
+ final Iterator<SubTestBeanInterface> iter = results.iterator();
SubTestBeanInterface row = null;
assertTrue(iter.hasNext());
row = iter.next();
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/handlers/ColumnListHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/handlers/ColumnListHandlerTest.java b/src/test/java/org/apache/commons/dbutils/handlers/ColumnListHandlerTest.java
index f6f8513..dd19d2d 100644
--- a/src/test/java/org/apache/commons/dbutils/handlers/ColumnListHandlerTest.java
+++ b/src/test/java/org/apache/commons/dbutils/handlers/ColumnListHandlerTest.java
@@ -28,8 +28,8 @@ import org.apache.commons.dbutils.ResultSetHandler;
public class ColumnListHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException {
- ResultSetHandler<List<String>> h = new ColumnListHandler<>();
- List<String> results = h.handle(this.rs);
+ final ResultSetHandler<List<String>> h = new ColumnListHandler<>();
+ final List<String> results = h.handle(this.rs);
assertNotNull(results);
assertEquals(ROWS, results.size());
@@ -39,8 +39,8 @@ public class ColumnListHandlerTest extends BaseTestCase {
}
public void testColumnIndexHandle() throws SQLException {
- ResultSetHandler<List<String>> h = new ColumnListHandler<>(2);
- List<String> results = h.handle(this.rs);
+ final ResultSetHandler<List<String>> h = new ColumnListHandler<>(2);
+ final List<String> results = h.handle(this.rs);
assertNotNull(results);
assertEquals(ROWS, results.size());
@@ -50,8 +50,8 @@ public class ColumnListHandlerTest extends BaseTestCase {
}
public void testColumnNameHandle() throws SQLException {
- ResultSetHandler<List<Integer>> h = new ColumnListHandler<>("intTest");
- List<Integer> results = h.handle(this.rs);
+ final ResultSetHandler<List<Integer>> h = new ColumnListHandler<>("intTest");
+ final List<Integer> results = h.handle(this.rs);
assertNotNull(results);
assertEquals(ROWS, results.size());
@@ -61,8 +61,8 @@ public class ColumnListHandlerTest extends BaseTestCase {
}
public void testEmptyResultSetHandle() throws SQLException {
- ResultSetHandler<List<String>> h = new ColumnListHandler<>();
- List<String> results = h.handle(this.emptyResultSet);
+ final ResultSetHandler<List<String>> h = new ColumnListHandler<>();
+ final List<String> results = h.handle(this.emptyResultSet);
assertNotNull(results);
assertTrue(results.isEmpty());
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/handlers/KeyedHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/handlers/KeyedHandlerTest.java b/src/test/java/org/apache/commons/dbutils/handlers/KeyedHandlerTest.java
index 8a9f97d..b81c076 100644
--- a/src/test/java/org/apache/commons/dbutils/handlers/KeyedHandlerTest.java
+++ b/src/test/java/org/apache/commons/dbutils/handlers/KeyedHandlerTest.java
@@ -26,17 +26,17 @@ import org.apache.commons.dbutils.ResultSetHandler;
public class KeyedHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException {
- ResultSetHandler<Map<String,Map<String,Object>>> h = new KeyedHandler<>();
+ final ResultSetHandler<Map<String,Map<String,Object>>> h = new KeyedHandler<>();
- Map<String,Map<String,Object>> results = h.handle(this.rs);
+ final Map<String,Map<String,Object>> results = h.handle(this.rs);
assertNotNull(results);
assertEquals(ROWS, results.size());
Map<String,Object> row = null;
- for(Entry<String, Map<String, Object>> entry : results.entrySet())
+ for(final Entry<String, Map<String, Object>> entry : results.entrySet())
{
- Object key = entry.getKey();
+ final Object key = entry.getKey();
assertNotNull(key);
row = entry.getValue();
assertNotNull(row);
@@ -49,16 +49,16 @@ public class KeyedHandlerTest extends BaseTestCase {
}
public void testColumnIndexHandle() throws SQLException {
- ResultSetHandler<Map<String,Map<String,Object>>> h = new KeyedHandler<>(2);
- Map<String,Map<String,Object>> results = h.handle(this.rs);
+ final ResultSetHandler<Map<String,Map<String,Object>>> h = new KeyedHandler<>(2);
+ final Map<String,Map<String,Object>> results = h.handle(this.rs);
assertNotNull(results);
assertEquals(ROWS, results.size());
Map<String,Object> row = null;
- for(Entry<String, Map<String, Object>> entry : results.entrySet())
+ for(final Entry<String, Map<String, Object>> entry : results.entrySet())
{
- Object key = entry.getKey();
+ final Object key = entry.getKey();
assertNotNull(key);
row = entry.getValue();
assertNotNull(row);
@@ -71,16 +71,16 @@ public class KeyedHandlerTest extends BaseTestCase {
}
public void testColumnNameHandle() throws SQLException {
- ResultSetHandler<Map<Integer,Map<String,Object>>> h = new KeyedHandler<>("intTest");
- Map<Integer,Map<String,Object>> results = h.handle(this.rs);
+ final ResultSetHandler<Map<Integer,Map<String,Object>>> h = new KeyedHandler<>("intTest");
+ final Map<Integer,Map<String,Object>> results = h.handle(this.rs);
assertNotNull(results);
assertEquals(ROWS, results.size());
Map<String,Object> row = null;
- for(Entry<Integer, Map<String, Object>> entry : results.entrySet())
+ for(final Entry<Integer, Map<String, Object>> entry : results.entrySet())
{
- Object key = entry.getKey();
+ final Object key = entry.getKey();
assertNotNull(key);
row = entry.getValue();
assertNotNull(row);
@@ -93,8 +93,8 @@ public class KeyedHandlerTest extends BaseTestCase {
}
public void testEmptyResultSetHandle() throws SQLException {
- ResultSetHandler<Map<String,Map<String,Object>>> h = new KeyedHandler<>();
- Map<String,Map<String,Object>> results = h.handle(this.emptyResultSet);
+ final ResultSetHandler<Map<String,Map<String,Object>>> h = new KeyedHandler<>();
+ final Map<String,Map<String,Object>> results = h.handle(this.emptyResultSet);
assertNotNull(results);
assertTrue(results.isEmpty());
}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/handlers/MapHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/handlers/MapHandlerTest.java b/src/test/java/org/apache/commons/dbutils/handlers/MapHandlerTest.java
index 380f4f8..1bbc07e 100644
--- a/src/test/java/org/apache/commons/dbutils/handlers/MapHandlerTest.java
+++ b/src/test/java/org/apache/commons/dbutils/handlers/MapHandlerTest.java
@@ -28,8 +28,8 @@ import org.apache.commons.dbutils.ResultSetHandler;
public class MapHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException {
- ResultSetHandler<Map<String,Object>> h = new MapHandler();
- Map<String,Object> results = h.handle(this.rs);
+ final ResultSetHandler<Map<String,Object>> h = new MapHandler();
+ final Map<String,Object> results = h.handle(this.rs);
assertNotNull(results);
assertEquals(COLS, results.keySet().size());
@@ -39,8 +39,8 @@ public class MapHandlerTest extends BaseTestCase {
}
public void testEmptyResultSetHandle() throws SQLException {
- ResultSetHandler<Map<String,Object>> h = new MapHandler();
- Map<String,Object> results = h.handle(this.emptyResultSet);
+ final ResultSetHandler<Map<String,Object>> h = new MapHandler();
+ final Map<String,Object> results = h.handle(this.emptyResultSet);
assertNull(results);
}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/handlers/MapListHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/handlers/MapListHandlerTest.java b/src/test/java/org/apache/commons/dbutils/handlers/MapListHandlerTest.java
index c46a38e..e7eb5a7 100644
--- a/src/test/java/org/apache/commons/dbutils/handlers/MapListHandlerTest.java
+++ b/src/test/java/org/apache/commons/dbutils/handlers/MapListHandlerTest.java
@@ -30,13 +30,13 @@ import org.apache.commons.dbutils.ResultSetHandler;
public class MapListHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException {
- ResultSetHandler<List<Map<String,Object>>> h = new MapListHandler();
- List<Map<String,Object>> results = h.handle(this.rs);
+ final ResultSetHandler<List<Map<String,Object>>> h = new MapListHandler();
+ final List<Map<String,Object>> results = h.handle(this.rs);
assertNotNull(results);
assertEquals(ROWS, results.size());
- Iterator<Map<String,Object>> iter = results.iterator();
+ final Iterator<Map<String,Object>> iter = results.iterator();
Map<String,Object> row = null;
assertTrue(iter.hasNext());
row = iter.next();
@@ -57,8 +57,8 @@ public class MapListHandlerTest extends BaseTestCase {
}
public void testEmptyResultSetHandle() throws SQLException {
- ResultSetHandler<List<Map<String,Object>>> h = new MapListHandler();
- List<Map<String,Object>> results = h.handle(this.emptyResultSet);
+ final ResultSetHandler<List<Map<String,Object>>> h = new MapListHandler();
+ final List<Map<String,Object>> results = h.handle(this.emptyResultSet);
assertNotNull(results);
assertTrue(results.isEmpty());
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/handlers/ScalarHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/handlers/ScalarHandlerTest.java b/src/test/java/org/apache/commons/dbutils/handlers/ScalarHandlerTest.java
index ef635fb..a0e1a89 100644
--- a/src/test/java/org/apache/commons/dbutils/handlers/ScalarHandlerTest.java
+++ b/src/test/java/org/apache/commons/dbutils/handlers/ScalarHandlerTest.java
@@ -24,29 +24,29 @@ import org.apache.commons.dbutils.ResultSetHandler;
public class ScalarHandlerTest extends BaseTestCase {
public void testHandle() throws SQLException {
- ResultSetHandler<String> h = new ScalarHandler<>();
- Object results = h.handle(this.rs);
+ final ResultSetHandler<String> h = new ScalarHandler<>();
+ final Object results = h.handle(this.rs);
assertNotNull(results);
assertEquals("1", results);
}
public void testColumnIndexHandle() throws SQLException {
- ResultSetHandler<String> h = new ScalarHandler<>(2);
- Object results = h.handle(this.rs);
+ final ResultSetHandler<String> h = new ScalarHandler<>(2);
+ final Object results = h.handle(this.rs);
assertNotNull(results);
assertEquals("2", results);
}
public void testColumnNameHandle() throws SQLException {
- ResultSetHandler<Integer> h = new ScalarHandler<>("intTest");
- Object results = h.handle(this.rs);
+ final ResultSetHandler<Integer> h = new ScalarHandler<>("intTest");
+ final Object results = h.handle(this.rs);
assertNotNull(results);
assertEquals(Integer.valueOf(1), results);
}
public void testEmptyResultSetHandle() throws SQLException {
- ResultSetHandler<String> h = new ScalarHandler<>();
- Object results = h.handle(this.emptyResultSet);
+ final ResultSetHandler<String> h = new ScalarHandler<>();
+ final Object results = h.handle(this.emptyResultSet);
assertNull(results);
}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/handlers/properties/DatePropertyHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/handlers/properties/DatePropertyHandlerTest.java b/src/test/java/org/apache/commons/dbutils/handlers/properties/DatePropertyHandlerTest.java
index d3550ce..81380a0 100644
--- a/src/test/java/org/apache/commons/dbutils/handlers/properties/DatePropertyHandlerTest.java
+++ b/src/test/java/org/apache/commons/dbutils/handlers/properties/DatePropertyHandlerTest.java
@@ -59,7 +59,7 @@ public class DatePropertyHandlerTest {
@Test
public void testApplyTypeOfTimestamp() throws Exception {
- Timestamp ts = new Timestamp(new java.util.Date().getTime());
+ final Timestamp ts = new Timestamp(new java.util.Date().getTime());
assertEquals(Timestamp.class, handler.apply(java.sql.Timestamp.class, ts).getClass());
}
}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/handlers/properties/PropertyHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/handlers/properties/PropertyHandlerTest.java b/src/test/java/org/apache/commons/dbutils/handlers/properties/PropertyHandlerTest.java
index 8d605fe..5b642b2 100644
--- a/src/test/java/org/apache/commons/dbutils/handlers/properties/PropertyHandlerTest.java
+++ b/src/test/java/org/apache/commons/dbutils/handlers/properties/PropertyHandlerTest.java
@@ -35,7 +35,7 @@ public class PropertyHandlerTest {
@Test
public void testServiceLoaderFindsMultipleRegistries() {
boolean found = false;
- for (PropertyHandler handler : loader) {
+ for (final PropertyHandler handler : loader) {
// this class is defined outside of the main classes of dbutils
if (handler instanceof TestPropertyHandler) {
found = true;
@@ -52,7 +52,7 @@ public class PropertyHandlerTest {
@Test
public void testFoundMoreThanLocal() {
int count = 0;
- for (PropertyHandler handler : loader) {
+ for (final PropertyHandler handler : loader) {
count++;
}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java b/src/test/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java
index d26f933..906bf8a 100644
--- a/src/test/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java
+++ b/src/test/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java
@@ -73,7 +73,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertNull(rs.getAsciiStream("column"));
assertTrue(rs.wasNull());
// Set what gets returned to something other than the default
- InputStream stream = new ByteArrayInputStream(new byte[0]);
+ final InputStream stream = new ByteArrayInputStream(new byte[0]);
rs2.setNullAsciiStream(stream);
assertNotNull(rs.getAsciiStream(1));
assertEquals(stream, rs.getAsciiStream(1));
@@ -92,7 +92,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertNull(rs.getBigDecimal("column"));
assertTrue(rs.wasNull());
// Set what gets returned to something other than the default
- BigDecimal bd = new BigDecimal(5.0);
+ final BigDecimal bd = new BigDecimal(5.0);
rs2.setNullBigDecimal(bd);
assertNotNull(rs.getBigDecimal(1));
assertEquals(bd, rs.getBigDecimal(1));
@@ -111,7 +111,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertNull(rs.getBinaryStream("column"));
assertTrue(rs.wasNull());
// Set what gets returned to something other than the default
- InputStream stream = new ByteArrayInputStream(new byte[0]);
+ final InputStream stream = new ByteArrayInputStream(new byte[0]);
rs2.setNullBinaryStream(stream);
assertNotNull(rs.getBinaryStream(1));
assertEquals(stream, rs.getBinaryStream(1));
@@ -130,7 +130,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertNull(rs.getBlob("column"));
assertTrue(rs.wasNull());
// Set what gets returned to something other than the default
- Blob blob = new SqlNullCheckedResultSetMockBlob();
+ final Blob blob = new SqlNullCheckedResultSetMockBlob();
rs2.setNullBlob(blob);
assertNotNull(rs.getBlob(1));
assertEquals(blob, rs.getBlob(1));
@@ -165,7 +165,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertEquals((byte) 0, rs.getByte("column"));
assertTrue(rs.wasNull());
// Set what gets returned to something other than the default
- byte b = (byte) 10;
+ final byte b = (byte) 10;
rs2.setNullByte(b);
assertEquals(b, rs.getByte(1));
assertEquals(b, rs.getByte("column"));
@@ -182,7 +182,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertNull(rs.getBytes("column"));
assertTrue(rs.wasNull());
// Set what gets returned to something other than the default
- byte[] b = new byte[5];
+ final byte[] b = new byte[5];
for (int i = 0; i < 5; i++) {
b[0] = (byte) i;
}
@@ -202,8 +202,8 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
failNotEquals(null, Arrays.toString(expected), Arrays.toString(actual));
}
for (int i = 0; i < expected.length; i++) {
- byte expectedItem = expected[i];
- byte actualItem = actual[i];
+ final byte expectedItem = expected[i];
+ final byte actualItem = actual[i];
assertEquals("Array not equal at index " + i, expectedItem, actualItem);
}
}
@@ -218,7 +218,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertNull(rs.getCharacterStream("column"));
assertTrue(rs.wasNull());
// Set what gets returned to something other than the default
- Reader reader = new CharArrayReader("this is a string".toCharArray());
+ final Reader reader = new CharArrayReader("this is a string".toCharArray());
rs2.setNullCharacterStream(reader);
assertNotNull(rs.getCharacterStream(1));
assertEquals(reader, rs.getCharacterStream(1));
@@ -237,7 +237,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertNull(rs.getClob("column"));
assertTrue(rs.wasNull());
// Set what gets returned to something other than the default
- Clob clob = new SqlNullCheckedResultSetMockClob();
+ final Clob clob = new SqlNullCheckedResultSetMockClob();
rs2.setNullClob(clob);
assertNotNull(rs.getClob(1));
assertEquals(clob, rs.getClob(1));
@@ -260,7 +260,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertNull(rs.getDate("column", Calendar.getInstance()));
assertTrue(rs.wasNull());
// Set what gets returned to something other than the default
- java.sql.Date date = new java.sql.Date(new java.util.Date().getTime());
+ final java.sql.Date date = new java.sql.Date(new java.util.Date().getTime());
rs2.setNullDate(date);
assertNotNull(rs.getDate(1));
assertEquals(date, rs.getDate(1));
@@ -283,7 +283,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertEquals(0.0, rs.getDouble("column"), 0.0);
assertTrue(rs.wasNull());
// Set what gets returned to something other than the default
- double d = 10.0;
+ final double d = 10.0;
rs2.setNullDouble(d);
assertEquals(d, rs.getDouble(1), 0.0);
assertEquals(d, rs.getDouble("column"), 0.0);
@@ -299,7 +299,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertEquals(0, rs.getFloat("column"), 0.0);
assertTrue(rs.wasNull());
// Set what gets returned to something other than the default
- float f = 10;
+ final float f = 10;
rs2.setNullFloat(f);
assertEquals(f, rs.getFloat(1), 0.0);
assertEquals(f, rs.getFloat("column"), 0.0);
@@ -314,7 +314,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertEquals(0, rs.getInt("column"));
assertTrue(rs.wasNull());
// Set what gets returned to something other than the default
- int i = 10;
+ final int i = 10;
rs2.setNullInt(i);
assertEquals(i, rs.getInt(1));
assertEquals(i, rs.getInt("column"));
@@ -329,7 +329,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertEquals(0, rs.getLong("column"));
assertTrue(rs.wasNull());
// Set what gets returned to something other than the default
- long l = 10;
+ final long l = 10;
rs2.setNullLong(l);
assertEquals(l, rs.getLong(1));
assertEquals(l, rs.getLong("column"));
@@ -349,7 +349,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertNull(rs.getObject("column", (Map<String, Class<?>>) null));
assertTrue(rs.wasNull());
// Set what gets returned to something other than the default
- Object o = new Object();
+ final Object o = new Object();
rs2.setNullObject(o);
assertNotNull(rs.getObject(1));
assertEquals(o, rs.getObject(1));
@@ -372,7 +372,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertNull(rs.getRef("column"));
assertTrue(rs.wasNull());
// Set what gets returned to something other than the default
- Ref ref = new SqlNullCheckedResultSetMockRef();
+ final Ref ref = new SqlNullCheckedResultSetMockRef();
rs2.setNullRef(ref);
assertNotNull(rs.getRef(1));
assertEquals(ref, rs.getRef(1));
@@ -391,7 +391,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertEquals((short) 0, rs.getShort("column"));
assertTrue(rs.wasNull());
// Set what gets returned to something other than the default
- short s = (short) 10;
+ final short s = (short) 10;
rs2.setNullShort(s);
assertEquals(s, rs.getShort(1));
assertEquals(s, rs.getShort("column"));
@@ -406,7 +406,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertEquals(null, rs.getString("column"));
assertTrue(rs.wasNull());
// Set what gets returned to something other than the default
- String s = "hello, world";
+ final String s = "hello, world";
rs2.setNullString(s);
assertEquals(s, rs.getString(1));
assertEquals(s, rs.getString("column"));
@@ -426,7 +426,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertNull(rs.getTime("column", Calendar.getInstance()));
assertTrue(rs.wasNull());
// Set what gets returned to something other than the default
- Time time = new Time(new java.util.Date().getTime());
+ final Time time = new Time(new java.util.Date().getTime());
rs2.setNullTime(time);
assertNotNull(rs.getTime(1));
assertEquals(time, rs.getTime(1));
@@ -453,7 +453,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertNull(rs.getTimestamp("column", Calendar.getInstance()));
assertTrue(rs.wasNull());
// Set what gets returned to something other than the default
- Timestamp ts = new Timestamp(new java.util.Date().getTime());
+ final Timestamp ts = new Timestamp(new java.util.Date().getTime());
rs2.setNullTimestamp(ts);
assertNotNull(rs.getTimestamp(1));
assertEquals(ts, rs.getTimestamp(1));
@@ -481,9 +481,9 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
new Class[] { Integer.TYPE } );
getUrlString = ResultSet.class.getMethod("getURL",
new Class[] { String.class } );
- } catch(NoSuchMethodException e) {
+ } catch(final NoSuchMethodException e) {
// ignore
- } catch(SecurityException e) {
+ } catch(final SecurityException e) {
// ignore
}
if (getUrlInt != null && getUrlString != null) {
@@ -494,7 +494,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
new Object[] { "column" } ) );
assertTrue(rs.wasNull());
// Set what gets returned to something other than the default
- URL u = new URL("http://www.apache.org");
+ final URL u = new URL("http://www.apache.org");
rs2.setNullURL(u);
assertEquals(u, getUrlInt.invoke(rs,
new Object[] { Integer.valueOf(1) } ) );
@@ -510,7 +510,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertNull(rs2.getNullAsciiStream());
// Set what gets returned to something other than the default
- InputStream stream = new ByteArrayInputStream(new byte[0]);
+ final InputStream stream = new ByteArrayInputStream(new byte[0]);
rs2.setNullAsciiStream(stream);
assertNotNull(rs.getAsciiStream(1));
assertEquals(stream, rs.getAsciiStream(1));
@@ -526,7 +526,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertNull(rs2.getNullBigDecimal());
// Set what gets returned to something other than the default
- BigDecimal bd = new BigDecimal(5.0);
+ final BigDecimal bd = new BigDecimal(5.0);
rs2.setNullBigDecimal(bd);
assertNotNull(rs.getBigDecimal(1));
assertEquals(bd, rs.getBigDecimal(1));
@@ -542,7 +542,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertNull(rs2.getNullBinaryStream());
// Set what gets returned to something other than the default
- InputStream stream = new ByteArrayInputStream(new byte[0]);
+ final InputStream stream = new ByteArrayInputStream(new byte[0]);
rs2.setNullBinaryStream(stream);
assertNotNull(rs.getBinaryStream(1));
assertEquals(stream, rs.getBinaryStream(1));
@@ -558,7 +558,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertNull(rs2.getNullBlob());
// Set what gets returned to something other than the default
- Blob blob = new SqlNullCheckedResultSetMockBlob();
+ final Blob blob = new SqlNullCheckedResultSetMockBlob();
rs2.setNullBlob(blob);
assertNotNull(rs.getBlob(1));
assertEquals(blob, rs.getBlob(1));
@@ -587,7 +587,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertEquals((byte) 0, rs2.getNullByte());
// Set what gets returned to something other than the default
- byte b = (byte) 10;
+ final byte b = (byte) 10;
rs2.setNullByte(b);
assertEquals(b, rs.getByte(1));
assertEquals(b, rs.getByte("column"));
@@ -601,7 +601,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertNull(rs2.getNullBytes());
// Set what gets returned to something other than the default
- byte[] b = new byte[5];
+ final byte[] b = new byte[5];
for (int i = 0; i < 5; i++) {
b[0] = (byte) i;
}
@@ -620,7 +620,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertNull(rs2.getNullCharacterStream());
// Set what gets returned to something other than the default
- Reader reader = new CharArrayReader("this is a string".toCharArray());
+ final Reader reader = new CharArrayReader("this is a string".toCharArray());
rs2.setNullCharacterStream(reader);
assertNotNull(rs.getCharacterStream(1));
assertEquals(reader, rs.getCharacterStream(1));
@@ -636,7 +636,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertNull(rs2.getNullClob());
// Set what gets returned to something other than the default
- Clob clob = new SqlNullCheckedResultSetMockClob();
+ final Clob clob = new SqlNullCheckedResultSetMockClob();
rs2.setNullClob(clob);
assertNotNull(rs.getClob(1));
assertEquals(clob, rs.getClob(1));
@@ -652,7 +652,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertNull(rs2.getNullDate());
// Set what gets returned to something other than the default
- java.sql.Date date = new java.sql.Date(new java.util.Date().getTime());
+ final java.sql.Date date = new java.sql.Date(new java.util.Date().getTime());
rs2.setNullDate(date);
assertNotNull(rs.getDate(1));
assertEquals(date, rs.getDate(1));
@@ -671,7 +671,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
public void testSetNullDouble() throws SQLException {
assertEquals(0.0, rs2.getNullDouble(), 0.0);
// Set what gets returned to something other than the default
- double d = 10.0;
+ final double d = 10.0;
rs2.setNullDouble(d);
assertEquals(d, rs.getDouble(1), 0.0);
assertEquals(d, rs.getDouble("column"), 0.0);
@@ -683,7 +683,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
public void testSetNullFloat() throws SQLException {
assertEquals((float) 0.0, rs2.getNullFloat(), 0.0);
// Set what gets returned to something other than the default
- float f = (float) 10.0;
+ final float f = (float) 10.0;
rs2.setNullFloat(f);
assertEquals(f, rs.getFloat(1), 0.0);
assertEquals(f, rs.getFloat("column"), 0.0);
@@ -699,7 +699,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertEquals(0, rs.getInt("column"));
assertTrue(rs.wasNull());
// Set what gets returned to something other than the default
- int i = 10;
+ final int i = 10;
rs2.setNullInt(i);
assertEquals(i, rs.getInt(1));
assertEquals(i, rs.getInt("column"));
@@ -711,7 +711,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
public void testSetNullLong() throws SQLException {
assertEquals(0, rs2.getNullLong());
// Set what gets returned to something other than the default
- long l = 10;
+ final long l = 10;
rs2.setNullLong(l);
assertEquals(l, rs.getLong(1));
assertEquals(l, rs.getLong("column"));
@@ -723,7 +723,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
public void testSetNullObject() throws SQLException {
assertNull(rs2.getNullObject());
// Set what gets returned to something other than the default
- Object o = new Object();
+ final Object o = new Object();
rs2.setNullObject(o);
assertNotNull(rs.getObject(1));
assertEquals(o, rs.getObject(1));
@@ -742,7 +742,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
assertEquals((short) 0, rs2.getNullShort());
// Set what gets returned to something other than the default
- short s = (short) 10;
+ final short s = (short) 10;
rs2.setNullShort(s);
assertEquals(s, rs.getShort(1));
assertEquals(s, rs.getShort("column"));
@@ -755,7 +755,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
public void testSetNullString() throws SQLException {
assertEquals(null, rs2.getNullString());
// Set what gets returned to something other than the default
- String s = "hello, world";
+ final String s = "hello, world";
rs2.setNullString(s);
assertEquals(s, rs.getString(1));
assertEquals(s, rs.getString("column"));
@@ -767,7 +767,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
public void testSetNullRef() throws SQLException {
assertNull(rs2.getNullRef());
// Set what gets returned to something other than the default
- Ref ref = new SqlNullCheckedResultSetMockRef();
+ final Ref ref = new SqlNullCheckedResultSetMockRef();
rs2.setNullRef(ref);
assertNotNull(rs.getRef(1));
assertEquals(ref, rs.getRef(1));
@@ -781,7 +781,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
public void testSetNullTime() throws SQLException {
assertEquals(null, rs2.getNullTime());
// Set what gets returned to something other than the default
- Time time = new Time(new java.util.Date().getTime());
+ final Time time = new Time(new java.util.Date().getTime());
rs2.setNullTime(time);
assertNotNull(rs.getTime(1));
assertEquals(time, rs.getTime(1));
@@ -799,7 +799,7 @@ public class SqlNullCheckedResultSetTest extends BaseTestCase {
public void testSetNullTimestamp() throws SQLException {
assertEquals(null, rs2.getNullTimestamp());
// Set what gets returned to something other than the default
- Timestamp ts = new Timestamp(new java.util.Date().getTime());
+ final Timestamp ts = new Timestamp(new java.util.Date().getTime());
rs2.setNullTimestamp(ts);
assertNotNull(rs.getTimestamp(1));
assertEquals(ts, rs.getTimestamp(1));
@@ -823,7 +823,7 @@ class SqlNullUncheckedMockResultSet implements InvocationHandler {
public Object invoke(final Object proxy, final Method method, final Object[] args)
throws Throwable {
- Class<?> returnType = method.getReturnType();
+ final Class<?> returnType = method.getReturnType();
if (method.getName().equals("wasNull")) {
return Boolean.TRUE;
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/wrappers/StringTrimmedResultSetTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/wrappers/StringTrimmedResultSetTest.java b/src/test/java/org/apache/commons/dbutils/wrappers/StringTrimmedResultSetTest.java
index 3df4070..ca14afb 100644
--- a/src/test/java/org/apache/commons/dbutils/wrappers/StringTrimmedResultSetTest.java
+++ b/src/test/java/org/apache/commons/dbutils/wrappers/StringTrimmedResultSetTest.java
@@ -50,12 +50,12 @@ public class StringTrimmedResultSetTest extends BaseTestCase {
*/
public void testMultipleWrappers() throws Exception {
// Create a ResultSet with data
- Object[][] rows = new Object[][] { { null }
+ final Object[][] rows = new Object[][] { { null }
};
ResultSet rs = MockResultSet.create(metaData, rows);
// Wrap the ResultSet with a null checked version
- SqlNullCheckedResultSet ncrs = new SqlNullCheckedResultSet(rs);
+ final SqlNullCheckedResultSet ncrs = new SqlNullCheckedResultSet(rs);
ncrs.setNullString(" trim this ");
rs = ProxyFactory.instance().createResultSet(ncrs);
[2/2] commons-dbutils git commit: Add final modifier to local
variables.
Posted by gg...@apache.org.
Add final modifier to local variables.
Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/e2c137f9
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/e2c137f9
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/e2c137f9
Branch: refs/heads/master
Commit: e2c137f955cbc8c34366eed9fdc098f27cb5d06e
Parents: 41e682d
Author: Gary Gregory <ga...@gmail.com>
Authored: Sun May 6 10:20:39 2018 -0600
Committer: Gary Gregory <ga...@gmail.com>
Committed: Sun May 6 10:20:39 2018 -0600
----------------------------------------------------------------------
.../commons/dbutils/AbstractQueryRunner.java | 38 +-
.../commons/dbutils/AsyncQueryRunner.java | 6 +-
.../commons/dbutils/BasicRowProcessor.java | 28 +-
.../apache/commons/dbutils/BeanProcessor.java | 60 +-
.../org/apache/commons/dbutils/DbUtils.java | 33 +-
.../apache/commons/dbutils/OutParameter.java | 2 +-
.../org/apache/commons/dbutils/QueryLoader.java | 1 +
.../org/apache/commons/dbutils/QueryRunner.java | 40 +-
.../commons/dbutils/ResultSetIterator.java | 6 +-
.../dbutils/handlers/AbstractKeyedHandler.java | 2 +-
.../dbutils/handlers/AbstractListHandler.java | 2 +-
.../properties/DatePropertyHandler.java | 4 +-
.../wrappers/SqlNullCheckedResultSet.java | 14 +-
.../commons/dbutils/AsyncQueryRunnerTest.java | 32 +-
.../dbutils/BaseResultSetHandlerTest.java | 8 +-
.../commons/dbutils/BasicRowProcessorTest.java | 6 +-
.../commons/dbutils/BeanProcessorTest.java | 24 +-
.../org/apache/commons/dbutils/DbUtilsTest.java | 570 +++++++++----------
.../dbutils/GenerousBeanProcessorTest.java | 8 +-
.../apache/commons/dbutils/MockResultSet.java | 38 +-
.../commons/dbutils/MockResultSetMetaData.java | 6 +-
.../apache/commons/dbutils/QueryLoaderTest.java | 12 +-
.../apache/commons/dbutils/QueryRunnerTest.java | 66 +--
.../commons/dbutils/ResultSetIteratorTest.java | 14 +-
.../commons/dbutils/ServiceLoaderTest.java | 8 +-
.../dbutils/StatementConfigurationTest.java | 8 +-
.../dbutils/handlers/ArrayHandlerTest.java | 8 +-
.../dbutils/handlers/ArrayListHandlerTest.java | 10 +-
.../dbutils/handlers/BeanHandlerTest.java | 16 +-
.../dbutils/handlers/BeanListHandlerTest.java | 22 +-
.../dbutils/handlers/ColumnListHandlerTest.java | 16 +-
.../dbutils/handlers/KeyedHandlerTest.java | 28 +-
.../dbutils/handlers/MapHandlerTest.java | 8 +-
.../dbutils/handlers/MapListHandlerTest.java | 10 +-
.../dbutils/handlers/ScalarHandlerTest.java | 16 +-
.../properties/DatePropertyHandlerTest.java | 2 +-
.../properties/PropertyHandlerTest.java | 4 +-
.../wrappers/SqlNullCheckedResultSetTest.java | 88 +--
.../wrappers/StringTrimmedResultSetTest.java | 4 +-
39 files changed, 636 insertions(+), 632 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java b/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java
index 2ed174e..13bb1db 100644
--- a/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java
+++ b/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java
@@ -281,15 +281,15 @@ public abstract class AbstractQueryRunner {
if (pmd == null) { // can be returned by implementations that don't support the method
pmdKnownBroken = true;
} else {
- int stmtCount = pmd.getParameterCount();
- int paramsCount = params == null ? 0 : params.length;
+ final int stmtCount = pmd.getParameterCount();
+ final int paramsCount = params == null ? 0 : params.length;
if (stmtCount != paramsCount) {
throw new SQLException("Wrong number of parameters: expected "
+ stmtCount + ", was given " + paramsCount);
}
}
- } catch (SQLFeatureNotSupportedException ex) {
+ } catch (final SQLFeatureNotSupportedException ex) {
pmdKnownBroken = true;
}
// TODO see DBUTILS-117: would it make sense to catch any other SQLEx types here?
@@ -326,7 +326,7 @@ public abstract class AbstractQueryRunner {
* be null here.
*/
sqlType = pmd.getParameterType(i + 1);
- } catch (SQLException e) {
+ } catch (final SQLException e) {
pmdKnownBroken = true;
}
}
@@ -351,24 +351,24 @@ public abstract class AbstractQueryRunner {
*/
public void fillStatementWithBean(final PreparedStatement stmt, final Object bean,
final PropertyDescriptor[] properties) throws SQLException {
- Object[] params = new Object[properties.length];
+ final Object[] params = new Object[properties.length];
for (int i = 0; i < properties.length; i++) {
- PropertyDescriptor property = properties[i];
+ final PropertyDescriptor property = properties[i];
Object value = null;
- Method method = property.getReadMethod();
+ final Method method = property.getReadMethod();
if (method == null) {
throw new RuntimeException("No read method for bean property "
+ bean.getClass() + " " + property.getName());
}
try {
value = method.invoke(bean, new Object[0]);
- } catch (InvocationTargetException e) {
+ } catch (final InvocationTargetException e) {
throw new RuntimeException("Couldn't invoke method: " + method,
e);
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
throw new RuntimeException(
"Couldn't invoke method with 0 arguments: " + method, e);
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
throw new RuntimeException("Couldn't invoke method: " + method,
e);
}
@@ -398,20 +398,20 @@ public abstract class AbstractQueryRunner {
try {
descriptors = Introspector.getBeanInfo(bean.getClass())
.getPropertyDescriptors();
- } catch (IntrospectionException e) {
+ } catch (final IntrospectionException e) {
throw new RuntimeException("Couldn't introspect bean "
+ bean.getClass().toString(), e);
}
- PropertyDescriptor[] sorted = new PropertyDescriptor[propertyNames.length];
+ final PropertyDescriptor[] sorted = new PropertyDescriptor[propertyNames.length];
for (int i = 0; i < propertyNames.length; i++) {
- String propertyName = propertyNames[i];
+ final String propertyName = propertyNames[i];
if (propertyName == null) {
throw new NullPointerException("propertyName can't be null: "
+ i);
}
boolean found = false;
for (int j = 0; j < descriptors.length; j++) {
- PropertyDescriptor descriptor = descriptors[j];
+ final PropertyDescriptor descriptor = descriptors[j];
if (propertyName.equals(descriptor.getName())) {
sorted[i] = descriptor;
found = true;
@@ -517,10 +517,11 @@ public abstract class AbstractQueryRunner {
throws SQLException {
@SuppressWarnings("resource")
+ final
PreparedStatement ps = conn.prepareStatement(sql);
try {
configureStatement(ps);
- } catch (SQLException e) {
+ } catch (final SQLException e) {
ps.close();
throw e;
}
@@ -554,10 +555,11 @@ public abstract class AbstractQueryRunner {
throws SQLException {
@SuppressWarnings("resource")
+ final
PreparedStatement ps = conn.prepareStatement(sql, returnedKeys);
try {
configureStatement(ps);
- } catch (SQLException e) {
+ } catch (final SQLException e) {
ps.close();
throw e;
}
@@ -588,7 +590,7 @@ public abstract class AbstractQueryRunner {
if (causeMessage == null) {
causeMessage = "";
}
- StringBuffer msg = new StringBuffer(causeMessage);
+ final StringBuffer msg = new StringBuffer(causeMessage);
msg.append(" Query: ");
msg.append(sql);
@@ -600,7 +602,7 @@ public abstract class AbstractQueryRunner {
msg.append(Arrays.deepToString(params));
}
- SQLException e = new SQLException(msg.toString(), cause.getSQLState(),
+ final SQLException e = new SQLException(msg.toString(), cause.getSQLState(),
cause.getErrorCode());
e.setNextException(cause);
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/main/java/org/apache/commons/dbutils/AsyncQueryRunner.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/AsyncQueryRunner.java b/src/main/java/org/apache/commons/dbutils/AsyncQueryRunner.java
index 94a29b2..0b6540c 100644
--- a/src/main/java/org/apache/commons/dbutils/AsyncQueryRunner.java
+++ b/src/main/java/org/apache/commons/dbutils/AsyncQueryRunner.java
@@ -150,7 +150,7 @@ public class AsyncQueryRunner extends AbstractQueryRunner {
try {
ret = ps.executeBatch();
- } catch (SQLException e) {
+ } catch (final SQLException e) {
rethrow(e, sql, (Object[])params);
} finally {
close(ps);
@@ -256,7 +256,7 @@ public class AsyncQueryRunner extends AbstractQueryRunner {
try {
rs = wrap(ps.executeQuery());
ret = rsh.handle(rs);
- } catch (SQLException e) {
+ } catch (final SQLException e) {
rethrow(e, sql, params);
} finally {
try {
@@ -409,7 +409,7 @@ public class AsyncQueryRunner extends AbstractQueryRunner {
try {
rows = ps.executeUpdate();
- } catch (SQLException e) {
+ } catch (final SQLException e) {
rethrow(e, sql, params);
} finally {
close(ps);
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/main/java/org/apache/commons/dbutils/BasicRowProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/BasicRowProcessor.java b/src/main/java/org/apache/commons/dbutils/BasicRowProcessor.java
index 06c276e..afffbd6 100644
--- a/src/main/java/org/apache/commons/dbutils/BasicRowProcessor.java
+++ b/src/main/java/org/apache/commons/dbutils/BasicRowProcessor.java
@@ -100,9 +100,9 @@ public class BasicRowProcessor implements RowProcessor {
*/
@Override
public Object[] toArray(final ResultSet rs) throws SQLException {
- ResultSetMetaData meta = rs.getMetaData();
- int cols = meta.getColumnCount();
- Object[] result = new Object[cols];
+ final ResultSetMetaData meta = rs.getMetaData();
+ final int cols = meta.getColumnCount();
+ final Object[] result = new Object[cols];
for (int i = 0; i < cols; i++) {
result[i] = rs.getObject(i + 1);
@@ -161,9 +161,9 @@ public class BasicRowProcessor implements RowProcessor {
*/
@Override
public Map<String, Object> toMap(final ResultSet rs) throws SQLException {
- ResultSetMetaData rsmd = rs.getMetaData();
- int cols = rsmd.getColumnCount();
- Map<String, Object> result = createCaseInsensitiveHashMap(cols);
+ final ResultSetMetaData rsmd = rs.getMetaData();
+ final int cols = rsmd.getColumnCount();
+ final Map<String, Object> result = createCaseInsensitiveHashMap(cols);
for (int i = 1; i <= cols; i++) {
String columnName = rsmd.getColumnLabel(i);
@@ -224,7 +224,7 @@ public class BasicRowProcessor implements RowProcessor {
/** {@inheritDoc} */
@Override
public boolean containsKey(final Object key) {
- Object realKey = lowerCaseMap.get(key.toString().toLowerCase(Locale.ENGLISH));
+ final Object realKey = lowerCaseMap.get(key.toString().toLowerCase(Locale.ENGLISH));
return super.containsKey(realKey);
// Possible optimisation here:
// Since the lowerCaseMap contains a mapping for all the keys,
@@ -235,7 +235,7 @@ public class BasicRowProcessor implements RowProcessor {
/** {@inheritDoc} */
@Override
public Object get(final Object key) {
- Object realKey = lowerCaseMap.get(key.toString().toLowerCase(Locale.ENGLISH));
+ final Object realKey = lowerCaseMap.get(key.toString().toLowerCase(Locale.ENGLISH));
return super.get(realKey);
}
@@ -249,8 +249,8 @@ public class BasicRowProcessor implements RowProcessor {
* (That's why we call super.remove(oldKey) and not just
* super.put(key, value))
*/
- Object oldKey = lowerCaseMap.put(key.toLowerCase(Locale.ENGLISH), key);
- Object oldValue = super.remove(oldKey);
+ final Object oldKey = lowerCaseMap.put(key.toLowerCase(Locale.ENGLISH), key);
+ final Object oldValue = super.remove(oldKey);
super.put(key, value);
return oldValue;
}
@@ -258,9 +258,9 @@ public class BasicRowProcessor implements RowProcessor {
/** {@inheritDoc} */
@Override
public void putAll(final Map<? extends String, ?> m) {
- for (Map.Entry<? extends String, ?> entry : m.entrySet()) {
- String key = entry.getKey();
- Object value = entry.getValue();
+ for (final Map.Entry<? extends String, ?> entry : m.entrySet()) {
+ final String key = entry.getKey();
+ final Object value = entry.getValue();
this.put(key, value);
}
}
@@ -268,7 +268,7 @@ public class BasicRowProcessor implements RowProcessor {
/** {@inheritDoc} */
@Override
public Object remove(final Object key) {
- Object realKey = lowerCaseMap.remove(key.toString().toLowerCase(Locale.ENGLISH));
+ final Object realKey = lowerCaseMap.remove(key.toString().toLowerCase(Locale.ENGLISH));
return super.remove(realKey);
}
}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/main/java/org/apache/commons/dbutils/BeanProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/BeanProcessor.java b/src/main/java/org/apache/commons/dbutils/BeanProcessor.java
index caee455..0f0b7ce 100644
--- a/src/main/java/org/apache/commons/dbutils/BeanProcessor.java
+++ b/src/main/java/org/apache/commons/dbutils/BeanProcessor.java
@@ -85,12 +85,12 @@ public class BeanProcessor {
primitiveDefaults.put(Character.TYPE, Character.valueOf((char) 0));
// Use a ServiceLoader to find implementations
- for (ColumnHandler handler : ServiceLoader.load(ColumnHandler.class)) {
+ for (final ColumnHandler handler : ServiceLoader.load(ColumnHandler.class)) {
columnHandlers.add(handler);
}
// Use a ServiceLoader to find implementations
- for (PropertyHandler handler : ServiceLoader.load(PropertyHandler.class)) {
+ for (final PropertyHandler handler : ServiceLoader.load(PropertyHandler.class)) {
propertyHandlers.add(handler);
}
}
@@ -150,7 +150,7 @@ public class BeanProcessor {
* @return the newly created bean
*/
public <T> T toBean(final ResultSet rs, final Class<? extends T> type) throws SQLException {
- T bean = this.newInstance(type);
+ final T bean = this.newInstance(type);
return this.populateBean(rs, bean);
}
@@ -188,15 +188,15 @@ public class BeanProcessor {
* @return the newly created List of beans
*/
public <T> List<T> toBeanList(final ResultSet rs, final Class<? extends T> type) throws SQLException {
- List<T> results = new ArrayList<>();
+ final List<T> results = new ArrayList<>();
if (!rs.next()) {
return results;
}
- PropertyDescriptor[] props = this.propertyDescriptors(type);
- ResultSetMetaData rsmd = rs.getMetaData();
- int[] columnToProperty = this.mapColumnsToProperties(rsmd, props);
+ final PropertyDescriptor[] props = this.propertyDescriptors(type);
+ final ResultSetMetaData rsmd = rs.getMetaData();
+ final int[] columnToProperty = this.mapColumnsToProperties(rsmd, props);
do {
results.add(this.createBean(rs, type, props, columnToProperty));
@@ -219,7 +219,7 @@ public class BeanProcessor {
final PropertyDescriptor[] props, final int[] columnToProperty)
throws SQLException {
- T bean = this.newInstance(type);
+ final T bean = this.newInstance(type);
return populateBean(rs, bean, props, columnToProperty);
}
@@ -232,9 +232,9 @@ public class BeanProcessor {
* @throws SQLException if a database error occurs.
*/
public <T> T populateBean(final ResultSet rs, final T bean) throws SQLException {
- PropertyDescriptor[] props = this.propertyDescriptors(bean.getClass());
- ResultSetMetaData rsmd = rs.getMetaData();
- int[] columnToProperty = this.mapColumnsToProperties(rsmd, props);
+ final PropertyDescriptor[] props = this.propertyDescriptors(bean.getClass());
+ final ResultSetMetaData rsmd = rs.getMetaData();
+ final int[] columnToProperty = this.mapColumnsToProperties(rsmd, props);
return populateBean(rs, bean, props, columnToProperty);
}
@@ -260,8 +260,8 @@ public class BeanProcessor {
continue;
}
- PropertyDescriptor prop = props[columnToProperty[i]];
- Class<?> propType = prop.getPropertyType();
+ final PropertyDescriptor prop = props[columnToProperty[i]];
+ final Class<?> propType = prop.getPropertyType();
Object value = null;
if(propType != null) {
@@ -289,15 +289,15 @@ public class BeanProcessor {
private void callSetter(final Object target, final PropertyDescriptor prop, Object value)
throws SQLException {
- Method setter = getWriteMethod(target, prop, value);
+ final Method setter = getWriteMethod(target, prop, value);
if (setter == null || setter.getParameterTypes().length != 1) {
return;
}
try {
- Class<?> firstParam = setter.getParameterTypes()[0];
- for (PropertyHandler handler : propertyHandlers) {
+ final Class<?> firstParam = setter.getParameterTypes()[0];
+ for (final PropertyHandler handler : propertyHandlers) {
if (handler.match(firstParam, value)) {
value = handler.apply(firstParam, value);
break;
@@ -314,15 +314,15 @@ public class BeanProcessor {
// value cannot be null here because isCompatibleType allows null
}
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
throw new SQLException(
"Cannot set " + prop.getName() + ": " + e.getMessage());
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
throw new SQLException(
"Cannot set " + prop.getName() + ": " + e.getMessage());
- } catch (InvocationTargetException e) {
+ } catch (final InvocationTargetException e) {
throw new SQLException(
"Cannot set " + prop.getName() + ": " + e.getMessage());
}
@@ -363,16 +363,16 @@ public class BeanProcessor {
try {
// see if there is a "TYPE" field. This is present for primitive wrappers.
- Field typeField = valueType.getField("TYPE");
- Object primitiveValueType = typeField.get(valueType);
+ final Field typeField = valueType.getField("TYPE");
+ final Object primitiveValueType = typeField.get(valueType);
if (targetType == primitiveValueType) {
return true;
}
- } catch (NoSuchFieldException e) {
+ } catch (final NoSuchFieldException e) {
// lacking the TYPE field is a good sign that we're not working with a primitive wrapper.
// we can't match for compatibility
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// an inaccessible TYPE field is a good sign that we're not working with a primitive wrapper.
// nothing to do. we can't match for compatibility
}
@@ -389,7 +389,7 @@ public class BeanProcessor {
* there is no suitable write method.
*/
protected Method getWriteMethod(final Object target, final PropertyDescriptor prop, final Object value) {
- Method method = prop.getWriteMethod();
+ final Method method = prop.getWriteMethod();
return method;
}
@@ -407,11 +407,11 @@ public class BeanProcessor {
try {
return c.newInstance();
- } catch (InstantiationException e) {
+ } catch (final InstantiationException e) {
throw new SQLException(
"Cannot create " + c.getName() + ": " + e.getMessage());
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
throw new SQLException(
"Cannot create " + c.getName() + ": " + e.getMessage());
}
@@ -431,7 +431,7 @@ public class BeanProcessor {
try {
beanInfo = Introspector.getBeanInfo(c);
- } catch (IntrospectionException e) {
+ } catch (final IntrospectionException e) {
throw new SQLException(
"Bean introspection failed: " + e.getMessage());
}
@@ -459,8 +459,8 @@ public class BeanProcessor {
protected int[] mapColumnsToProperties(final ResultSetMetaData rsmd,
final PropertyDescriptor[] props) throws SQLException {
- int cols = rsmd.getColumnCount();
- int[] columnToProperty = new int[cols + 1];
+ final int cols = rsmd.getColumnCount();
+ final int[] columnToProperty = new int[cols + 1];
Arrays.fill(columnToProperty, PROPERTY_NOT_FOUND);
for (int col = 1; col <= cols; col++) {
@@ -520,7 +520,7 @@ public class BeanProcessor {
return null;
}
- for (ColumnHandler handler : columnHandlers) {
+ for (final ColumnHandler handler : columnHandlers) {
if (handler.match(propType)) {
retval = handler.apply(rs, index);
break;
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/main/java/org/apache/commons/dbutils/DbUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/DbUtils.java b/src/main/java/org/apache/commons/dbutils/DbUtils.java
index d65d277..fc61af3 100644
--- a/src/main/java/org/apache/commons/dbutils/DbUtils.java
+++ b/src/main/java/org/apache/commons/dbutils/DbUtils.java
@@ -94,7 +94,7 @@ public final class DbUtils {
public static void closeQuietly(final Connection conn) {
try {
close(conn);
- } catch (SQLException e) { // NOPMD
+ } catch (final SQLException e) { // NOPMD
// quiet
}
}
@@ -132,7 +132,7 @@ public final class DbUtils {
public static void closeQuietly(final ResultSet rs) {
try {
close(rs);
- } catch (SQLException e) { // NOPMD
+ } catch (final SQLException e) { // NOPMD
// quiet
}
}
@@ -146,7 +146,7 @@ public final class DbUtils {
public static void closeQuietly(final Statement stmt) {
try {
close(stmt);
- } catch (SQLException e) { // NOPMD
+ } catch (final SQLException e) { // NOPMD
// quiet
}
}
@@ -176,7 +176,7 @@ public final class DbUtils {
public static void commitAndCloseQuietly(final Connection conn) {
try {
commitAndClose(conn);
- } catch (SQLException e) { // NOPMD
+ } catch (final SQLException e) { // NOPMD
// quiet
}
}
@@ -203,33 +203,34 @@ public final class DbUtils {
*/
public static boolean loadDriver(final ClassLoader classLoader, final String driverClassName) {
try {
- Class<?> loadedClass = classLoader.loadClass(driverClassName);
+ final Class<?> loadedClass = classLoader.loadClass(driverClassName);
if (!Driver.class.isAssignableFrom(loadedClass)) {
return false;
}
@SuppressWarnings("unchecked") // guarded by previous check
+ final
Class<Driver> driverClass = (Class<Driver>) loadedClass;
- Constructor<Driver> driverConstructor = driverClass.getConstructor();
+ final Constructor<Driver> driverConstructor = driverClass.getConstructor();
// make Constructor accessible if it is private
- boolean isConstructorAccessible = driverConstructor.isAccessible();
+ final boolean isConstructorAccessible = driverConstructor.isAccessible();
if (!isConstructorAccessible) {
driverConstructor.setAccessible(true);
}
try {
- Driver driver = driverConstructor.newInstance();
+ final Driver driver = driverConstructor.newInstance();
registerDriver(new DriverProxy(driver));
} finally {
driverConstructor.setAccessible(isConstructorAccessible);
}
return true;
- } catch (RuntimeException e) {
+ } catch (final RuntimeException e) {
return false;
- } catch (Exception e) {
+ } catch (final Exception e) {
return false;
}
}
@@ -281,7 +282,7 @@ public final class DbUtils {
if (conn != null) {
try {
printStackTrace(conn.getWarnings(), pw);
- } catch (SQLException e) {
+ } catch (final SQLException e) {
printStackTrace(e, pw);
}
}
@@ -326,7 +327,7 @@ public final class DbUtils {
public static void rollbackAndCloseQuietly(final Connection conn) {
try {
rollbackAndClose(conn);
- } catch (SQLException e) { // NOPMD
+ } catch (final SQLException e) { // NOPMD
// quiet
}
}
@@ -408,15 +409,15 @@ public final class DbUtils {
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
if (parentLoggerSupported) {
try {
- Method method = adapted.getClass().getMethod("getParentLogger", new Class[0]);
+ final Method method = adapted.getClass().getMethod("getParentLogger", new Class[0]);
return (Logger)method.invoke(adapted, new Object[0]);
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
parentLoggerSupported = false;
throw new SQLFeatureNotSupportedException(e);
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
parentLoggerSupported = false;
throw new SQLFeatureNotSupportedException(e);
- } catch (InvocationTargetException e) {
+ } catch (final InvocationTargetException e) {
parentLoggerSupported = false;
throw new SQLFeatureNotSupportedException(e);
}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/main/java/org/apache/commons/dbutils/OutParameter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/OutParameter.java b/src/main/java/org/apache/commons/dbutils/OutParameter.java
index e3996a1..93e00fb 100644
--- a/src/main/java/org/apache/commons/dbutils/OutParameter.java
+++ b/src/main/java/org/apache/commons/dbutils/OutParameter.java
@@ -113,7 +113,7 @@ public class OutParameter<T> {
* statement.
*/
void setValue(final CallableStatement stmt, final int index) throws SQLException {
- Object object = stmt.getObject(index);
+ final Object object = stmt.getObject(index);
value = javaType.cast(object);
}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/main/java/org/apache/commons/dbutils/QueryLoader.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/QueryLoader.java b/src/main/java/org/apache/commons/dbutils/QueryLoader.java
index 2fd032c..a38e530 100644
--- a/src/main/java/org/apache/commons/dbutils/QueryLoader.java
+++ b/src/main/java/org/apache/commons/dbutils/QueryLoader.java
@@ -127,6 +127,7 @@ public class QueryLoader {
// Copy to HashMap for better performance
@SuppressWarnings({"rawtypes", "unchecked" }) // load() always creates <String,String> entries
+ final
HashMap<String, String> hashMap = new HashMap(props);
return hashMap;
}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/main/java/org/apache/commons/dbutils/QueryRunner.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/QueryRunner.java b/src/main/java/org/apache/commons/dbutils/QueryRunner.java
index f4f3f4b..b7fb46b 100644
--- a/src/main/java/org/apache/commons/dbutils/QueryRunner.java
+++ b/src/main/java/org/apache/commons/dbutils/QueryRunner.java
@@ -146,7 +146,7 @@ public class QueryRunner extends AbstractQueryRunner {
* @since DbUtils 1.1
*/
public int[] batch(final String sql, final Object[][] params) throws SQLException {
- Connection conn = this.prepareConnection();
+ final Connection conn = this.prepareConnection();
return this.batch(conn, true, sql, params);
}
@@ -191,7 +191,7 @@ public class QueryRunner extends AbstractQueryRunner {
}
rows = stmt.executeBatch();
- } catch (SQLException e) {
+ } catch (final SQLException e) {
this.rethrow(e, sql, (Object[])params);
} finally {
close(stmt);
@@ -282,7 +282,7 @@ public class QueryRunner extends AbstractQueryRunner {
*/
@Deprecated
public <T> T query(final String sql, final Object param, final ResultSetHandler<T> rsh) throws SQLException {
- Connection conn = this.prepareConnection();
+ final Connection conn = this.prepareConnection();
return this.<T>query(conn, true, sql, rsh, new Object[]{param});
}
@@ -305,7 +305,7 @@ public class QueryRunner extends AbstractQueryRunner {
*/
@Deprecated
public <T> T query(final String sql, final Object[] params, final ResultSetHandler<T> rsh) throws SQLException {
- Connection conn = this.prepareConnection();
+ final Connection conn = this.prepareConnection();
return this.<T>query(conn, true, sql, rsh, params);
}
@@ -324,7 +324,7 @@ public class QueryRunner extends AbstractQueryRunner {
* @throws SQLException if a database access error occurs
*/
public <T> T query(final String sql, final ResultSetHandler<T> rsh, final Object... params) throws SQLException {
- Connection conn = this.prepareConnection();
+ final Connection conn = this.prepareConnection();
return this.<T>query(conn, true, sql, rsh, params);
}
@@ -342,7 +342,7 @@ public class QueryRunner extends AbstractQueryRunner {
* @throws SQLException if a database access error occurs
*/
public <T> T query(final String sql, final ResultSetHandler<T> rsh) throws SQLException {
- Connection conn = this.prepareConnection();
+ final Connection conn = this.prepareConnection();
return this.<T>query(conn, true, sql, rsh, (Object[]) null);
}
@@ -387,7 +387,7 @@ public class QueryRunner extends AbstractQueryRunner {
rs = this.wrap(stmt.executeQuery());
result = rsh.handle(rs);
- } catch (SQLException e) {
+ } catch (final SQLException e) {
this.rethrow(e, sql, params);
} finally {
@@ -453,7 +453,7 @@ public class QueryRunner extends AbstractQueryRunner {
* @return The number of rows updated.
*/
public int update(final String sql) throws SQLException {
- Connection conn = this.prepareConnection();
+ final Connection conn = this.prepareConnection();
return this.update(conn, true, sql, (Object[]) null);
}
@@ -471,7 +471,7 @@ public class QueryRunner extends AbstractQueryRunner {
* @return The number of rows updated.
*/
public int update(final String sql, final Object param) throws SQLException {
- Connection conn = this.prepareConnection();
+ final Connection conn = this.prepareConnection();
return this.update(conn, true, sql, new Object[]{param});
}
@@ -489,7 +489,7 @@ public class QueryRunner extends AbstractQueryRunner {
* @return The number of rows updated.
*/
public int update(final String sql, final Object... params) throws SQLException {
- Connection conn = this.prepareConnection();
+ final Connection conn = this.prepareConnection();
return this.update(conn, true, sql, params);
}
@@ -524,7 +524,7 @@ public class QueryRunner extends AbstractQueryRunner {
this.fillStatement(stmt, params);
rows = stmt.executeUpdate();
- } catch (SQLException e) {
+ } catch (final SQLException e) {
this.rethrow(e, sql, params);
} finally {
@@ -641,9 +641,9 @@ public class QueryRunner extends AbstractQueryRunner {
stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
this.fillStatement(stmt, params);
stmt.executeUpdate();
- ResultSet resultSet = stmt.getGeneratedKeys();
+ final ResultSet resultSet = stmt.getGeneratedKeys();
generatedKeys = rsh.handle(resultSet);
- } catch (SQLException e) {
+ } catch (final SQLException e) {
this.rethrow(e, sql, params);
} finally {
close(stmt);
@@ -731,10 +731,10 @@ public class QueryRunner extends AbstractQueryRunner {
stmt.addBatch();
}
stmt.executeBatch();
- ResultSet rs = stmt.getGeneratedKeys();
+ final ResultSet rs = stmt.getGeneratedKeys();
generatedKeys = rsh.handle(rs);
- } catch (SQLException e) {
+ } catch (final SQLException e) {
this.rethrow(e, sql, (Object[])params);
} finally {
close(stmt);
@@ -792,7 +792,7 @@ public class QueryRunner extends AbstractQueryRunner {
* @return The number of rows updated.
*/
public int execute(final String sql, final Object... params) throws SQLException {
- Connection conn = this.prepareConnection();
+ final Connection conn = this.prepareConnection();
return this.execute(conn, true, sql, params);
}
@@ -845,7 +845,7 @@ public class QueryRunner extends AbstractQueryRunner {
* @throws SQLException if a database access error occurs
*/
public <T> List<T> execute(final String sql, final ResultSetHandler<T> rsh, final Object... params) throws SQLException {
- Connection conn = this.prepareConnection();
+ final Connection conn = this.prepareConnection();
return this.execute(conn, true, sql, rsh, params);
}
@@ -883,7 +883,7 @@ public class QueryRunner extends AbstractQueryRunner {
rows = stmt.getUpdateCount();
this.retrieveOutParameters(stmt, params);
- } catch (SQLException e) {
+ } catch (final SQLException e) {
this.rethrow(e, sql, params);
} finally {
@@ -928,7 +928,7 @@ public class QueryRunner extends AbstractQueryRunner {
}
CallableStatement stmt = null;
- List<T> results = new LinkedList<>();
+ final List<T> results = new LinkedList<>();
try {
stmt = this.prepareCall(conn, sql);
@@ -949,7 +949,7 @@ public class QueryRunner extends AbstractQueryRunner {
}
this.retrieveOutParameters(stmt, params);
- } catch (SQLException e) {
+ } catch (final SQLException e) {
this.rethrow(e, sql, params);
} finally {
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/main/java/org/apache/commons/dbutils/ResultSetIterator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/ResultSetIterator.java b/src/main/java/org/apache/commons/dbutils/ResultSetIterator.java
index a7ce7c9..025a2dd 100644
--- a/src/main/java/org/apache/commons/dbutils/ResultSetIterator.java
+++ b/src/main/java/org/apache/commons/dbutils/ResultSetIterator.java
@@ -73,7 +73,7 @@ public class ResultSetIterator implements Iterator<Object[]> {
public boolean hasNext() {
try {
return !rs.isLast();
- } catch (SQLException e) {
+ } catch (final SQLException e) {
rethrow(e);
return false;
}
@@ -91,7 +91,7 @@ public class ResultSetIterator implements Iterator<Object[]> {
try {
rs.next();
return this.convert.toArray(rs);
- } catch (SQLException e) {
+ } catch (final SQLException e) {
rethrow(e);
return null;
}
@@ -106,7 +106,7 @@ public class ResultSetIterator implements Iterator<Object[]> {
public void remove() {
try {
this.rs.deleteRow();
- } catch (SQLException e) {
+ } catch (final SQLException e) {
rethrow(e);
}
}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/main/java/org/apache/commons/dbutils/handlers/AbstractKeyedHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/handlers/AbstractKeyedHandler.java b/src/main/java/org/apache/commons/dbutils/handlers/AbstractKeyedHandler.java
index 69e3a64..d694f30 100644
--- a/src/main/java/org/apache/commons/dbutils/handlers/AbstractKeyedHandler.java
+++ b/src/main/java/org/apache/commons/dbutils/handlers/AbstractKeyedHandler.java
@@ -48,7 +48,7 @@ public abstract class AbstractKeyedHandler<K, V> implements ResultSetHandler<Map
*/
@Override
public Map<K, V> handle(final ResultSet rs) throws SQLException {
- Map<K, V> result = createMap();
+ final Map<K, V> result = createMap();
while (rs.next()) {
result.put(createKey(rs), createRow(rs));
}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/main/java/org/apache/commons/dbutils/handlers/AbstractListHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/handlers/AbstractListHandler.java b/src/main/java/org/apache/commons/dbutils/handlers/AbstractListHandler.java
index d360155..6db0bb8 100644
--- a/src/main/java/org/apache/commons/dbutils/handlers/AbstractListHandler.java
+++ b/src/main/java/org/apache/commons/dbutils/handlers/AbstractListHandler.java
@@ -43,7 +43,7 @@ public abstract class AbstractListHandler<T> implements ResultSetHandler<List<T>
*/
@Override
public List<T> handle(final ResultSet rs) throws SQLException {
- List<T> rows = new ArrayList<>();
+ final List<T> rows = new ArrayList<>();
while (rs.next()) {
rows.add(this.handleRow(rs));
}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/main/java/org/apache/commons/dbutils/handlers/properties/DatePropertyHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/handlers/properties/DatePropertyHandler.java b/src/main/java/org/apache/commons/dbutils/handlers/properties/DatePropertyHandler.java
index 3c83cb0..0c6a89e 100644
--- a/src/main/java/org/apache/commons/dbutils/handlers/properties/DatePropertyHandler.java
+++ b/src/main/java/org/apache/commons/dbutils/handlers/properties/DatePropertyHandler.java
@@ -49,8 +49,8 @@ public class DatePropertyHandler implements PropertyHandler {
value = new java.sql.Time(((java.util.Date) value).getTime());
} else
if ("java.sql.Timestamp".equals(targetType)) {
- Timestamp tsValue = (Timestamp) value;
- int nanos = tsValue.getNanos();
+ final Timestamp tsValue = (Timestamp) value;
+ final int nanos = tsValue.getNanos();
value = new java.sql.Timestamp(tsValue.getTime());
((Timestamp) value).setNanos(nanos);
}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/main/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSet.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSet.java b/src/main/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSet.java
index 4ef433e..fa42f41 100644
--- a/src/main/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSet.java
+++ b/src/main/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSet.java
@@ -83,12 +83,12 @@ public class SqlNullCheckedResultSet implements InvocationHandler {
private static final String GET_NULL_PREFIX = "getNull";
static {
- Method[] methods = SqlNullCheckedResultSet.class.getMethods();
+ final Method[] methods = SqlNullCheckedResultSet.class.getMethods();
for (int i = 0; i < methods.length; i++) {
- String methodName = methods[i].getName();
+ final String methodName = methods[i].getName();
if (methodName.startsWith(GET_NULL_PREFIX)) {
- String normalName = "get" + methodName.substring(GET_NULL_PREFIX.length());
+ final String normalName = "get" + methodName.substring(GET_NULL_PREFIX.length());
nullMethods.put(normalName, methods[i]);
}
}
@@ -221,7 +221,7 @@ public class SqlNullCheckedResultSet implements InvocationHandler {
if (this.nullBytes == null) {
return null;
}
- byte[] copy = new byte[this.nullBytes.length];
+ final byte[] copy = new byte[this.nullBytes.length];
System.arraycopy(this.nullBytes, 0, copy, 0, this.nullBytes.length);
return copy;
}
@@ -382,9 +382,9 @@ public class SqlNullCheckedResultSet implements InvocationHandler {
public Object invoke(final Object proxy, final Method method, final Object[] args)
throws Throwable {
- Object result = method.invoke(this.rs, args);
+ final Object result = method.invoke(this.rs, args);
- Method nullMethod = nullMethods.get(method.getName());
+ final Method nullMethod = nullMethods.get(method.getName());
// Check nullMethod != null first so that we don't call wasNull()
// before a true getter method was invoked on the ResultSet.
@@ -460,7 +460,7 @@ public class SqlNullCheckedResultSet implements InvocationHandler {
* @param nullBytes the value
*/
public void setNullBytes(final byte[] nullBytes) {
- byte[] copy = new byte[nullBytes.length];
+ final byte[] copy = new byte[nullBytes.length];
System.arraycopy(nullBytes, 0, copy, 0, nullBytes.length);
this.nullBytes = copy;
}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java b/src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java
index 6c0a769..f900feb 100644
--- a/src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java
+++ b/src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java
@@ -73,7 +73,7 @@ public class AsyncQueryRunnerTest {
//
private void callGoodBatch(final Connection conn, final Object[][] params) throws Exception {
when(meta.getParameterCount()).thenReturn(2);
- Future<int[]> future = runner.batch(conn, "select * from blah where ? = ?", params);
+ final Future<int[]> future = runner.batch(conn, "select * from blah where ? = ?", params);
future.get();
@@ -85,7 +85,7 @@ public class AsyncQueryRunnerTest {
private void callGoodBatch(final Object[][] params) throws Exception {
when(meta.getParameterCount()).thenReturn(2);
- Future<int[]> future = runner.batch("select * from blah where ? = ?", params);
+ final Future<int[]> future = runner.batch("select * from blah where ? = ?", params);
future.get();
@@ -97,7 +97,7 @@ public class AsyncQueryRunnerTest {
@Test
public void testGoodBatch() throws Exception {
- String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
+ final String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
callGoodBatch(params);
}
@@ -106,7 +106,7 @@ public class AsyncQueryRunnerTest {
@Test
public void testGoodBatchPmdTrue() throws Exception {
runner = new AsyncQueryRunner(dataSource, true, Executors.newFixedThreadPool(1));
- String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
+ final String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
callGoodBatch(params);
}
@@ -114,14 +114,14 @@ public class AsyncQueryRunnerTest {
@Test
public void testGoodBatchDefaultConstructor() throws Exception {
runner = new AsyncQueryRunner(Executors.newFixedThreadPool(1));
- String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
+ final String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
callGoodBatch(conn, params);
}
@Test
public void testNullParamsBatch() throws Exception {
- String[][] params = new String[][] { { null, "unit" }, { "test", null } };
+ final String[][] params = new String[][] { { null, "unit" }, { "test", null } };
callGoodBatch(params);
}
@@ -142,7 +142,7 @@ public class AsyncQueryRunnerTest {
verify(stmt, times(1)).executeBatch();
verify(stmt, times(1)).close(); // make sure the statement is closed
verify(conn, times(1)).close(); // make sure the connection is closed
- } catch(Exception e) {
+ } catch(final Exception e) {
caught = true;
}
@@ -153,21 +153,21 @@ public class AsyncQueryRunnerTest {
@Test
public void testTooFewParamsBatch() throws Exception {
- String[][] params = new String[][] { { "unit" }, { "test" } };
+ final String[][] params = new String[][] { { "unit" }, { "test" } };
callBatchWithException("select * from blah where ? = ?", params);
}
@Test
public void testTooManyParamsBatch() throws Exception {
- String[][] params = new String[][] { { "unit", "unit", "unit" }, { "test", "test", "test" } };
+ final String[][] params = new String[][] { { "unit", "unit", "unit" }, { "test", "test", "test" } };
callBatchWithException("select * from blah where ? = ?", params);
}
@Test(expected=ExecutionException.class)
public void testNullConnectionBatch() throws Exception {
- String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
+ final String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
when(meta.getParameterCount()).thenReturn(2);
when(dataSource.getConnection()).thenReturn(null);
@@ -177,7 +177,7 @@ public class AsyncQueryRunnerTest {
@Test(expected=ExecutionException.class)
public void testNullSqlBatch() throws Exception {
- String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
+ final String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
when(meta.getParameterCount()).thenReturn(2);
@@ -193,7 +193,7 @@ public class AsyncQueryRunnerTest {
@Test
public void testAddBatchException() throws Exception {
- String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
+ final String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
doThrow(new SQLException()).when(stmt).addBatch();
@@ -202,7 +202,7 @@ public class AsyncQueryRunnerTest {
@Test
public void testExecuteBatchException() throws Exception {
- String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
+ final String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } };
doThrow(new SQLException()).when(stmt).executeBatch();
@@ -282,7 +282,7 @@ public class AsyncQueryRunnerTest {
verify(results, times(1)).close();
verify(stmt, times(1)).close(); // make sure we closed the statement
verify(conn, times(1)).close(); // make sure we closed the connection
- } catch(Exception e) {
+ } catch(final Exception e) {
caught = true;
}
@@ -418,7 +418,7 @@ public class AsyncQueryRunnerTest {
verify(stmt, times(1)).executeUpdate();
verify(stmt, times(1)).close(); // make sure we closed the statement
verify(conn, times(1)).close(); // make sure we closed the connection
- } catch(Exception e) {
+ } catch(final Exception e) {
caught = true;
}
@@ -444,7 +444,7 @@ public class AsyncQueryRunnerTest {
@Test
public void testInsertUsesGivenQueryRunner() throws Exception {
- QueryRunner mockQueryRunner = mock(QueryRunner.class
+ final QueryRunner mockQueryRunner = mock(QueryRunner.class
, org.mockito.Mockito.withSettings().verboseLogging() // debug for Continuum
);
runner = new AsyncQueryRunner(Executors.newSingleThreadExecutor(), mockQueryRunner);
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/BaseResultSetHandlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/BaseResultSetHandlerTest.java b/src/test/java/org/apache/commons/dbutils/BaseResultSetHandlerTest.java
index e37422f..f4b81a2 100644
--- a/src/test/java/org/apache/commons/dbutils/BaseResultSetHandlerTest.java
+++ b/src/test/java/org/apache/commons/dbutils/BaseResultSetHandlerTest.java
@@ -28,11 +28,11 @@ public final class BaseResultSetHandlerTest extends BaseTestCase {
@Test
public void handleWithoutExplicitResultSetInvocation() throws Exception {
- Collection<Map<String, Object>> result = new ToMapCollectionHandler().handle(createMockResultSet());
+ final Collection<Map<String, Object>> result = new ToMapCollectionHandler().handle(createMockResultSet());
assertFalse(result.isEmpty());
- for (Map<String, Object> current : result) {
+ for (final Map<String, Object> current : result) {
assertTrue(current.containsKey("one"));
assertTrue(current.containsKey("two"));
assertTrue(current.containsKey("three"));
@@ -51,10 +51,10 @@ public final class BaseResultSetHandlerTest extends BaseTestCase {
@Override
protected Collection<Map<String, Object>> handle() throws SQLException {
- Collection<Map<String, Object>> result = new LinkedList<>();
+ final Collection<Map<String, Object>> result = new LinkedList<>();
while (next()) {
- Map<String, Object> current = new HashMap<>();
+ final Map<String, Object> current = new HashMap<>();
for (int i = 1; i <= getMetaData().getColumnCount(); i++) {
current.put(getMetaData().getColumnName(i), getObject(i));
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/BasicRowProcessorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/BasicRowProcessorTest.java b/src/test/java/org/apache/commons/dbutils/BasicRowProcessorTest.java
index 7c701cd..49458ea 100644
--- a/src/test/java/org/apache/commons/dbutils/BasicRowProcessorTest.java
+++ b/src/test/java/org/apache/commons/dbutils/BasicRowProcessorTest.java
@@ -92,7 +92,7 @@ public class BasicRowProcessorTest extends BaseTestCase {
public void testToBeanList() throws SQLException, ParseException {
- List<TestBean> list = processor.toBeanList(this.rs, TestBean.class);
+ final List<TestBean> list = processor.toBeanList(this.rs, TestBean.class);
assertNotNull(list);
assertEquals(ROWS, list.size());
@@ -141,9 +141,9 @@ public class BasicRowProcessorTest extends BaseTestCase {
public void testToMapOrdering() throws SQLException {
assertTrue(this.rs.next());
- Map<String, Object> m = processor.toMap(this.rs);
+ final Map<String, Object> m = processor.toMap(this.rs);
- Iterator<String> itr = m.keySet().iterator();
+ final Iterator<String> itr = m.keySet().iterator();
assertEquals("one", itr.next());
assertEquals("two", itr.next());
assertEquals("three", itr.next());
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/BeanProcessorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/BeanProcessorTest.java b/src/test/java/org/apache/commons/dbutils/BeanProcessorTest.java
index e1606e4..a1f6cea 100644
--- a/src/test/java/org/apache/commons/dbutils/BeanProcessorTest.java
+++ b/src/test/java/org/apache/commons/dbutils/BeanProcessorTest.java
@@ -101,29 +101,29 @@ public class BeanProcessorTest extends BaseTestCase {
}
public void testMapColumnToProperties() throws Exception {
- String[] columnNames = { "test", "test", "three" };
- String[] columnLabels = { "one", "two", null };
- ResultSetMetaData rsmd = ProxyFactory.instance().createResultSetMetaData(
+ final String[] columnNames = { "test", "test", "three" };
+ final String[] columnLabels = { "one", "two", null };
+ final ResultSetMetaData rsmd = ProxyFactory.instance().createResultSetMetaData(
new MockResultSetMetaData(columnNames, columnLabels));
- PropertyDescriptor[] props = Introspector.getBeanInfo(MapColumnToPropertiesBean.class).getPropertyDescriptors();
+ final PropertyDescriptor[] props = Introspector.getBeanInfo(MapColumnToPropertiesBean.class).getPropertyDescriptors();
- int[] columns = beanProc.mapColumnsToProperties(rsmd, props);
+ final int[] columns = beanProc.mapColumnsToProperties(rsmd, props);
for (int i = 1; i < columns.length; i++) {
assertTrue(columns[i] != BeanProcessor.PROPERTY_NOT_FOUND);
}
}
public void testMapColumnToPropertiesWithOverrides() throws Exception {
- Map<String, String> columnToPropertyOverrides = new HashMap<>();
+ final Map<String, String> columnToPropertyOverrides = new HashMap<>();
columnToPropertyOverrides.put("five", "four");
- BeanProcessor beanProc = new BeanProcessor(columnToPropertyOverrides);
- String[] columnNames = { "test", "test", "three", "five" };
- String[] columnLabels = { "one", "two", null, null };
- ResultSetMetaData rsmd = ProxyFactory.instance().createResultSetMetaData(
+ final BeanProcessor beanProc = new BeanProcessor(columnToPropertyOverrides);
+ final String[] columnNames = { "test", "test", "three", "five" };
+ final String[] columnLabels = { "one", "two", null, null };
+ final ResultSetMetaData rsmd = ProxyFactory.instance().createResultSetMetaData(
new MockResultSetMetaData(columnNames, columnLabels));
- PropertyDescriptor[] props = Introspector.getBeanInfo(MapColumnToPropertiesBean.class).getPropertyDescriptors();
+ final PropertyDescriptor[] props = Introspector.getBeanInfo(MapColumnToPropertiesBean.class).getPropertyDescriptors();
- int[] columns = beanProc.mapColumnsToProperties(rsmd, props);
+ final int[] columns = beanProc.mapColumnsToProperties(rsmd, props);
for (int i = 1; i < columns.length; i++) {
assertTrue(columns[i] != BeanProcessor.PROPERTY_NOT_FOUND);
}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/DbUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/DbUtilsTest.java b/src/test/java/org/apache/commons/dbutils/DbUtilsTest.java
index 78e9081..52b42d2 100644
--- a/src/test/java/org/apache/commons/dbutils/DbUtilsTest.java
+++ b/src/test/java/org/apache/commons/dbutils/DbUtilsTest.java
@@ -1,285 +1,285 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.dbutils;
-
-import org.junit.Test;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.*;
-
-public class DbUtilsTest {
-
- @Test
- public void closeNullConnection() throws Exception {
- DbUtils.close((Connection) null);
- }
-
- @Test
- public void closeConnection() throws Exception {
- Connection mockCon = mock(Connection.class);
- DbUtils.close(mockCon);
- verify(mockCon).close();
- }
-
- @Test
- public void closeNullResultSet() throws Exception {
- DbUtils.close((ResultSet) null);
- }
-
- @Test
- public void closeResultSet() throws Exception {
- ResultSet mockResultSet = mock(ResultSet.class);
- DbUtils.close(mockResultSet);
- verify(mockResultSet).close();
- }
-
- @Test
- public void closeNullStatement() throws Exception {
- DbUtils.close((Statement) null);
- }
-
- @Test
- public void closeStatement() throws Exception {
- Statement mockStatement = mock(Statement.class);
- DbUtils.close(mockStatement);
- verify(mockStatement).close();
- }
-
- @Test
- public void closeQuietlyNullConnection() throws Exception {
- DbUtils.closeQuietly((Connection) null);
- }
-
- @Test
- public void closeQuietlyConnection() throws Exception {
- Connection mockConnection = mock(Connection.class);
- DbUtils.closeQuietly(mockConnection);
- verify(mockConnection).close();
- }
-
- @Test
- public void closeQuietlyConnectionThrowingException() throws Exception {
- Connection mockConnection = mock(Connection.class);
- doThrow(SQLException.class).when(mockConnection).close();
- DbUtils.closeQuietly(mockConnection);
- }
-
- @Test
- public void closeQuietlyNullResultSet() throws Exception {
- DbUtils.closeQuietly((ResultSet) null);
- }
-
- @Test
- public void closeQuietlyResultSet() throws Exception {
- ResultSet mockResultSet = mock(ResultSet.class);
- DbUtils.closeQuietly(mockResultSet);
- verify(mockResultSet).close();
- }
-
- @Test
- public void closeQuietlyResultSetThrowingException() throws Exception {
- ResultSet mockResultSet = mock(ResultSet.class);
- doThrow(SQLException.class).when(mockResultSet).close();
- DbUtils.closeQuietly(mockResultSet);
- }
-
- @Test
- public void closeQuietlyNullStatement() throws Exception {
- DbUtils.closeQuietly((Statement) null);
- }
-
- @Test
- public void closeQuietlyStatement() throws Exception {
- Statement mockStatement = mock(Statement.class);
- DbUtils.closeQuietly(mockStatement);
- verify(mockStatement).close();
- }
-
- @Test
- public void closeQuietlyStatementThrowingException() throws Exception {
- Statement mockStatement = mock(Statement.class);
- doThrow(SQLException.class).when(mockStatement).close();
- DbUtils.closeQuietly(mockStatement);
- }
-
- @Test
- public void closeQuietlyConnectionResultSetStatement() throws Exception {
- Connection mockConnection = mock(Connection.class);
- ResultSet mockResultSet = mock(ResultSet.class);
- Statement mockStatement = mock(Statement.class);
- DbUtils.closeQuietly(mockConnection, mockStatement, mockResultSet);
- verify(mockConnection).close();
- verify(mockResultSet).close();
- verify(mockStatement).close();
- }
-
- @Test
- public void closeQuietlyConnectionThrowingExceptionResultSetStatement() throws Exception {
- Connection mockConnection = mock(Connection.class);
- doThrow(SQLException.class).when(mockConnection).close();
- ResultSet mockResultSet = mock(ResultSet.class);
- Statement mockStatement = mock(Statement.class);
- DbUtils.closeQuietly(mockConnection, mockStatement, mockResultSet);
- verify(mockConnection).close();
- verify(mockResultSet).close();
- verify(mockStatement).close();
- }
-
- @Test
- public void closeQuietlyConnectionResultSetThrowingExceptionStatement() throws Exception {
- Connection mockConnection = mock(Connection.class);
- ResultSet mockResultSet = mock(ResultSet.class);
- doThrow(SQLException.class).when(mockResultSet).close();
- Statement mockStatement = mock(Statement.class);
- DbUtils.closeQuietly(mockConnection, mockStatement, mockResultSet);
- verify(mockConnection).close();
- verify(mockResultSet).close();
- verify(mockStatement).close();
- }
-
- @Test
- public void closeQuietlyConnectionResultSetStatementThrowingException() throws Exception {
- Connection mockConnection = mock(Connection.class);
- ResultSet mockResultSet = mock(ResultSet.class);
- Statement mockStatement = mock(Statement.class);
- doThrow(SQLException.class).when(mockStatement).close();
- DbUtils.closeQuietly(mockConnection, mockStatement, mockResultSet);
- verify(mockConnection).close();
- verify(mockResultSet).close();
- verify(mockStatement).close();
- }
-
- @Test
- public void commitAndClose() throws Exception {
- Connection mockConnection = mock(Connection.class);
- DbUtils.commitAndClose(mockConnection);
- verify(mockConnection).commit();
- verify(mockConnection).close();
- }
-
- @Test
- public void commitAndCloseWithException() throws Exception {
- Connection mockConnection = mock(Connection.class);
- doThrow(SQLException.class).when(mockConnection).commit();
- try {
- DbUtils.commitAndClose(mockConnection);
- fail("DbUtils.commitAndClose() swallowed SQLEception!");
- } catch (SQLException e) {
- // we expect this exception
- }
- verify(mockConnection).close();
- }
-
- @Test
- public void commitAndCloseQuietly() throws Exception {
- Connection mockConnection = mock(Connection.class);
- DbUtils.commitAndClose(mockConnection);
- verify(mockConnection).commit();
- verify(mockConnection).close();
- }
-
- @Test
- public void commitAndCloseQuietlyWithException() throws Exception {
- Connection mockConnection = mock(Connection.class);
- doThrow(SQLException.class).when(mockConnection).close();
- DbUtils.commitAndCloseQuietly(mockConnection);
- verify(mockConnection).commit();
- verify(mockConnection).close();
- }
-
- @Test
- public void rollbackNull() throws Exception {
- DbUtils.rollback(null);
- }
-
- @Test
- public void rollback() throws Exception {
- Connection mockConnection = mock(Connection.class);
- DbUtils.rollback(mockConnection);
- verify(mockConnection).rollback();
- }
-
- @Test
- public void rollbackAndCloseNull() throws Exception {
- DbUtils.rollbackAndClose(null);
- }
-
- @Test
- public void rollbackAndClose() throws Exception {
- Connection mockConnection = mock(Connection.class);
- DbUtils.rollbackAndClose(mockConnection);
- verify(mockConnection).rollback();
- verify(mockConnection).close();
- }
-
- @Test
- public void rollbackAndCloseWithException() throws Exception {
- Connection mockConnection = mock(Connection.class);
- doThrow(SQLException.class).when(mockConnection).rollback();
- try {
- DbUtils.rollbackAndClose(mockConnection);
- fail("DbUtils.rollbackAndClose() swallowed SQLException!");
- } catch (SQLException e) {
- // we expect this exeption
- }
- verify(mockConnection).rollback();
- verify(mockConnection).close();
- }
-
- @Test
- public void rollbackAndCloseQuietlyNull() throws Exception {
- DbUtils.rollbackAndCloseQuietly(null);
- }
-
- @Test
- public void rollbackAndCloseQuietly() throws Exception {
- Connection mockConnection = mock(Connection.class);
- DbUtils.rollbackAndCloseQuietly(mockConnection);
- verify(mockConnection).rollback();
- verify(mockConnection).close();
- }
-
- @Test
- public void rollbackAndCloseQuietlyWithException() throws Exception {
- Connection mockConnection = mock(Connection.class);
- doThrow(SQLException.class).when(mockConnection).rollback();
- DbUtils.rollbackAndCloseQuietly(mockConnection);
- verify(mockConnection).rollback();
- verify(mockConnection).close();
- }
-
- @Test
- public void testLoadDriverReturnsFalse() {
-
- assertFalse(DbUtils.loadDriver(""));
-
- }
-
- @Test
- public void testCommitAndCloseQuietlyWithNullDoesNotThrowAnSQLException() {
-
- DbUtils.commitAndCloseQuietly(null);
-
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbutils;
+
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.*;
+
+public class DbUtilsTest {
+
+ @Test
+ public void closeNullConnection() throws Exception {
+ DbUtils.close((Connection) null);
+ }
+
+ @Test
+ public void closeConnection() throws Exception {
+ final Connection mockCon = mock(Connection.class);
+ DbUtils.close(mockCon);
+ verify(mockCon).close();
+ }
+
+ @Test
+ public void closeNullResultSet() throws Exception {
+ DbUtils.close((ResultSet) null);
+ }
+
+ @Test
+ public void closeResultSet() throws Exception {
+ final ResultSet mockResultSet = mock(ResultSet.class);
+ DbUtils.close(mockResultSet);
+ verify(mockResultSet).close();
+ }
+
+ @Test
+ public void closeNullStatement() throws Exception {
+ DbUtils.close((Statement) null);
+ }
+
+ @Test
+ public void closeStatement() throws Exception {
+ final Statement mockStatement = mock(Statement.class);
+ DbUtils.close(mockStatement);
+ verify(mockStatement).close();
+ }
+
+ @Test
+ public void closeQuietlyNullConnection() throws Exception {
+ DbUtils.closeQuietly((Connection) null);
+ }
+
+ @Test
+ public void closeQuietlyConnection() throws Exception {
+ final Connection mockConnection = mock(Connection.class);
+ DbUtils.closeQuietly(mockConnection);
+ verify(mockConnection).close();
+ }
+
+ @Test
+ public void closeQuietlyConnectionThrowingException() throws Exception {
+ final Connection mockConnection = mock(Connection.class);
+ doThrow(SQLException.class).when(mockConnection).close();
+ DbUtils.closeQuietly(mockConnection);
+ }
+
+ @Test
+ public void closeQuietlyNullResultSet() throws Exception {
+ DbUtils.closeQuietly((ResultSet) null);
+ }
+
+ @Test
+ public void closeQuietlyResultSet() throws Exception {
+ final ResultSet mockResultSet = mock(ResultSet.class);
+ DbUtils.closeQuietly(mockResultSet);
+ verify(mockResultSet).close();
+ }
+
+ @Test
+ public void closeQuietlyResultSetThrowingException() throws Exception {
+ final ResultSet mockResultSet = mock(ResultSet.class);
+ doThrow(SQLException.class).when(mockResultSet).close();
+ DbUtils.closeQuietly(mockResultSet);
+ }
+
+ @Test
+ public void closeQuietlyNullStatement() throws Exception {
+ DbUtils.closeQuietly((Statement) null);
+ }
+
+ @Test
+ public void closeQuietlyStatement() throws Exception {
+ final Statement mockStatement = mock(Statement.class);
+ DbUtils.closeQuietly(mockStatement);
+ verify(mockStatement).close();
+ }
+
+ @Test
+ public void closeQuietlyStatementThrowingException() throws Exception {
+ final Statement mockStatement = mock(Statement.class);
+ doThrow(SQLException.class).when(mockStatement).close();
+ DbUtils.closeQuietly(mockStatement);
+ }
+
+ @Test
+ public void closeQuietlyConnectionResultSetStatement() throws Exception {
+ final Connection mockConnection = mock(Connection.class);
+ final ResultSet mockResultSet = mock(ResultSet.class);
+ final Statement mockStatement = mock(Statement.class);
+ DbUtils.closeQuietly(mockConnection, mockStatement, mockResultSet);
+ verify(mockConnection).close();
+ verify(mockResultSet).close();
+ verify(mockStatement).close();
+ }
+
+ @Test
+ public void closeQuietlyConnectionThrowingExceptionResultSetStatement() throws Exception {
+ final Connection mockConnection = mock(Connection.class);
+ doThrow(SQLException.class).when(mockConnection).close();
+ final ResultSet mockResultSet = mock(ResultSet.class);
+ final Statement mockStatement = mock(Statement.class);
+ DbUtils.closeQuietly(mockConnection, mockStatement, mockResultSet);
+ verify(mockConnection).close();
+ verify(mockResultSet).close();
+ verify(mockStatement).close();
+ }
+
+ @Test
+ public void closeQuietlyConnectionResultSetThrowingExceptionStatement() throws Exception {
+ final Connection mockConnection = mock(Connection.class);
+ final ResultSet mockResultSet = mock(ResultSet.class);
+ doThrow(SQLException.class).when(mockResultSet).close();
+ final Statement mockStatement = mock(Statement.class);
+ DbUtils.closeQuietly(mockConnection, mockStatement, mockResultSet);
+ verify(mockConnection).close();
+ verify(mockResultSet).close();
+ verify(mockStatement).close();
+ }
+
+ @Test
+ public void closeQuietlyConnectionResultSetStatementThrowingException() throws Exception {
+ final Connection mockConnection = mock(Connection.class);
+ final ResultSet mockResultSet = mock(ResultSet.class);
+ final Statement mockStatement = mock(Statement.class);
+ doThrow(SQLException.class).when(mockStatement).close();
+ DbUtils.closeQuietly(mockConnection, mockStatement, mockResultSet);
+ verify(mockConnection).close();
+ verify(mockResultSet).close();
+ verify(mockStatement).close();
+ }
+
+ @Test
+ public void commitAndClose() throws Exception {
+ final Connection mockConnection = mock(Connection.class);
+ DbUtils.commitAndClose(mockConnection);
+ verify(mockConnection).commit();
+ verify(mockConnection).close();
+ }
+
+ @Test
+ public void commitAndCloseWithException() throws Exception {
+ final Connection mockConnection = mock(Connection.class);
+ doThrow(SQLException.class).when(mockConnection).commit();
+ try {
+ DbUtils.commitAndClose(mockConnection);
+ fail("DbUtils.commitAndClose() swallowed SQLEception!");
+ } catch (final SQLException e) {
+ // we expect this exception
+ }
+ verify(mockConnection).close();
+ }
+
+ @Test
+ public void commitAndCloseQuietly() throws Exception {
+ final Connection mockConnection = mock(Connection.class);
+ DbUtils.commitAndClose(mockConnection);
+ verify(mockConnection).commit();
+ verify(mockConnection).close();
+ }
+
+ @Test
+ public void commitAndCloseQuietlyWithException() throws Exception {
+ final Connection mockConnection = mock(Connection.class);
+ doThrow(SQLException.class).when(mockConnection).close();
+ DbUtils.commitAndCloseQuietly(mockConnection);
+ verify(mockConnection).commit();
+ verify(mockConnection).close();
+ }
+
+ @Test
+ public void rollbackNull() throws Exception {
+ DbUtils.rollback(null);
+ }
+
+ @Test
+ public void rollback() throws Exception {
+ final Connection mockConnection = mock(Connection.class);
+ DbUtils.rollback(mockConnection);
+ verify(mockConnection).rollback();
+ }
+
+ @Test
+ public void rollbackAndCloseNull() throws Exception {
+ DbUtils.rollbackAndClose(null);
+ }
+
+ @Test
+ public void rollbackAndClose() throws Exception {
+ final Connection mockConnection = mock(Connection.class);
+ DbUtils.rollbackAndClose(mockConnection);
+ verify(mockConnection).rollback();
+ verify(mockConnection).close();
+ }
+
+ @Test
+ public void rollbackAndCloseWithException() throws Exception {
+ final Connection mockConnection = mock(Connection.class);
+ doThrow(SQLException.class).when(mockConnection).rollback();
+ try {
+ DbUtils.rollbackAndClose(mockConnection);
+ fail("DbUtils.rollbackAndClose() swallowed SQLException!");
+ } catch (final SQLException e) {
+ // we expect this exeption
+ }
+ verify(mockConnection).rollback();
+ verify(mockConnection).close();
+ }
+
+ @Test
+ public void rollbackAndCloseQuietlyNull() throws Exception {
+ DbUtils.rollbackAndCloseQuietly(null);
+ }
+
+ @Test
+ public void rollbackAndCloseQuietly() throws Exception {
+ final Connection mockConnection = mock(Connection.class);
+ DbUtils.rollbackAndCloseQuietly(mockConnection);
+ verify(mockConnection).rollback();
+ verify(mockConnection).close();
+ }
+
+ @Test
+ public void rollbackAndCloseQuietlyWithException() throws Exception {
+ final Connection mockConnection = mock(Connection.class);
+ doThrow(SQLException.class).when(mockConnection).rollback();
+ DbUtils.rollbackAndCloseQuietly(mockConnection);
+ verify(mockConnection).rollback();
+ verify(mockConnection).close();
+ }
+
+ @Test
+ public void testLoadDriverReturnsFalse() {
+
+ assertFalse(DbUtils.loadDriver(""));
+
+ }
+
+ @Test
+ public void testCommitAndCloseQuietlyWithNullDoesNotThrowAnSQLException() {
+
+ DbUtils.commitAndCloseQuietly(null);
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java b/src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java
index 24a5639..95cf5a4 100644
--- a/src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java
+++ b/src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java
@@ -55,7 +55,7 @@ public class GenerousBeanProcessorTest {
when(metaData.getColumnLabel(2)).thenReturn("one");
when(metaData.getColumnLabel(3)).thenReturn("two");
- int[] ret = processor.mapColumnsToProperties(metaData, propDescriptors);
+ final int[] ret = processor.mapColumnsToProperties(metaData, propDescriptors);
assertNotNull(ret);
assertEquals(4, ret.length);
@@ -74,7 +74,7 @@ public class GenerousBeanProcessorTest {
when(metaData.getColumnLabel(2)).thenReturn("One");
when(metaData.getColumnLabel(3)).thenReturn("tWO");
- int[] ret = processor.mapColumnsToProperties(metaData, propDescriptors);
+ final int[] ret = processor.mapColumnsToProperties(metaData, propDescriptors);
assertNotNull(ret);
assertEquals(4, ret.length);
@@ -93,7 +93,7 @@ public class GenerousBeanProcessorTest {
when(metaData.getColumnLabel(2)).thenReturn("o_n_e");
when(metaData.getColumnLabel(3)).thenReturn("t_w_o");
- int[] ret = processor.mapColumnsToProperties(metaData, propDescriptors);
+ final int[] ret = processor.mapColumnsToProperties(metaData, propDescriptors);
assertNotNull(ret);
assertEquals(4, ret.length);
@@ -113,7 +113,7 @@ public class GenerousBeanProcessorTest {
when(metaData.getColumnLabel(2)).thenReturn("One");
when(metaData.getColumnLabel(3)).thenReturn("tWO");
- int[] ret = processor.mapColumnsToProperties(metaData, propDescriptors);
+ final int[] ret = processor.mapColumnsToProperties(metaData, propDescriptors);
assertNotNull(ret);
assertEquals(2, ret.length);
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/MockResultSet.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbutils/MockResultSet.java b/src/test/java/org/apache/commons/dbutils/MockResultSet.java
index c89b5bd..8815bd8 100644
--- a/src/test/java/org/apache/commons/dbutils/MockResultSet.java
+++ b/src/test/java/org/apache/commons/dbutils/MockResultSet.java
@@ -63,7 +63,7 @@ public class MockResultSet implements InvocationHandler {
super();
this.metaData = metaData;
if (rows == null) {
- List<Object[]> empty = Collections.emptyList();
+ final List<Object[]> empty = Collections.emptyList();
this.iter = empty.iterator();
} else {
this.iter = Arrays.asList(rows).iterator();
@@ -98,7 +98,7 @@ public class MockResultSet implements InvocationHandler {
*/
private int columnNameToIndex(final String columnName) throws SQLException {
for (int i = 0; i < this.currentRow.length; i++) {
- int c = i + 1;
+ final int c = i + 1;
if (this.metaData.getColumnName(c).equalsIgnoreCase(columnName)) {
return c;
}
@@ -113,7 +113,7 @@ public class MockResultSet implements InvocationHandler {
* @throws SQLException if a database access error occurs
*/
protected Object getBoolean(final int columnIndex) throws SQLException {
- Object obj = this.currentRow[columnIndex - 1];
+ final Object obj = this.currentRow[columnIndex - 1];
this.setWasNull(obj);
try {
@@ -121,7 +121,7 @@ public class MockResultSet implements InvocationHandler {
? Boolean.FALSE
: Boolean.valueOf(obj.toString());
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
throw new SQLException(e.getMessage());
}
}
@@ -132,7 +132,7 @@ public class MockResultSet implements InvocationHandler {
* @throws SQLException if a database access error occurs
*/
protected Object getByte(final int columnIndex) throws SQLException {
- Object obj = this.currentRow[columnIndex - 1];
+ final Object obj = this.currentRow[columnIndex - 1];
this.setWasNull(obj);
try {
@@ -140,7 +140,7 @@ public class MockResultSet implements InvocationHandler {
? Byte.valueOf((byte) 0)
: Byte.valueOf(obj.toString());
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
throw new SQLException(e.getMessage());
}
}
@@ -151,7 +151,7 @@ public class MockResultSet implements InvocationHandler {
* @throws SQLException if a database access error occurs
*/
protected Object getDouble(final int columnIndex) throws SQLException {
- Object obj = this.currentRow[columnIndex - 1];
+ final Object obj = this.currentRow[columnIndex - 1];
this.setWasNull(obj);
try {
@@ -159,7 +159,7 @@ public class MockResultSet implements InvocationHandler {
? new Double(0)
: Double.valueOf(obj.toString());
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
throw new SQLException(e.getMessage());
}
}
@@ -170,13 +170,13 @@ public class MockResultSet implements InvocationHandler {
* @throws SQLException if a database access error occurs
*/
protected Object getFloat(final int columnIndex) throws SQLException {
- Object obj = this.currentRow[columnIndex - 1];
+ final Object obj = this.currentRow[columnIndex - 1];
this.setWasNull(obj);
try {
return (obj == null) ? new Float(0) : Float.valueOf(obj.toString());
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
throw new SQLException(e.getMessage());
}
}
@@ -187,7 +187,7 @@ public class MockResultSet implements InvocationHandler {
* @throws SQLException if a database access error occurs
*/
protected Object getInt(final int columnIndex) throws SQLException {
- Object obj = this.currentRow[columnIndex - 1];
+ final Object obj = this.currentRow[columnIndex - 1];
this.setWasNull(obj);
try {
@@ -195,7 +195,7 @@ public class MockResultSet implements InvocationHandler {
? Integer.valueOf(0)
: Integer.valueOf(obj.toString());
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
throw new SQLException(e.getMessage());
}
}
@@ -206,13 +206,13 @@ public class MockResultSet implements InvocationHandler {
* @throws SQLException if a database access error occurs
*/
protected Object getLong(final int columnIndex) throws SQLException {
- Object obj = this.currentRow[columnIndex - 1];
+ final Object obj = this.currentRow[columnIndex - 1];
this.setWasNull(obj);
try {
return (obj == null) ? Long.valueOf(0) : Long.valueOf(obj.toString());
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
throw new SQLException(e.getMessage());
}
}
@@ -230,7 +230,7 @@ public class MockResultSet implements InvocationHandler {
* @throws SQLException if a database access error occurs
*/
protected Object getObject(final int columnIndex) throws SQLException {
- Object obj = this.currentRow[columnIndex - 1];
+ final Object obj = this.currentRow[columnIndex - 1];
this.setWasNull(obj);
return obj;
}
@@ -241,7 +241,7 @@ public class MockResultSet implements InvocationHandler {
* @throws SQLException if a database access error occurs
*/
protected Object getShort(final int columnIndex) throws SQLException {
- Object obj = this.currentRow[columnIndex - 1];
+ final Object obj = this.currentRow[columnIndex - 1];
this.setWasNull(obj);
try {
@@ -249,7 +249,7 @@ public class MockResultSet implements InvocationHandler {
? Short.valueOf((short) 0)
: Short.valueOf(obj.toString());
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
throw new SQLException(e.getMessage());
}
}
@@ -260,7 +260,7 @@ public class MockResultSet implements InvocationHandler {
* @throws SQLException if a database access error occurs
*/
protected String getString(final int columnIndex) throws SQLException {
- Object obj = this.getObject(columnIndex);
+ final Object obj = this.getObject(columnIndex);
this.setWasNull(obj);
return (obj == null) ? null : obj.toString();
}
@@ -269,7 +269,7 @@ public class MockResultSet implements InvocationHandler {
public Object invoke(final Object proxy, final Method method, final Object[] args)
throws Throwable {
- String methodName = method.getName();
+ final String methodName = method.getName();
if (methodName.equals("getMetaData")) {
return this.getMetaData();