Fix (most) test checkstyle issues
diff --git a/pom.xml b/pom.xml
index 33a2eef..e0c9dd1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -279,6 +279,7 @@
<configLocation>${checkstyle.config.file}</configLocation>
<enableRulesSummary>false</enableRulesSummary>
<headerLocation>${checkstyle.header.file}</headerLocation>
+ <includeTestSourceDirectory>false</includeTestSourceDirectory> <!-- TODO -->
<suppressionsLocation>${basedir}/src/conf/checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
<suppressionsFileExpression>${basedir}/src/conf/checkstyle/checkstyle-suppressions.xml</suppressionsFileExpression>
</configuration>
diff --git a/src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java b/src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java
index 32c10ca..827e91c 100644
--- a/src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java
+++ b/src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java
@@ -50,12 +50,18 @@
AsyncQueryRunner runner;
ArrayHandler handler;
- @Mock DataSource dataSource;
- @Mock Connection conn;
- @Mock PreparedStatement prepStmt;
- @Mock Statement stmt;
- @Mock ParameterMetaData meta;
- @Mock ResultSet results;
+ @Mock
+ DataSource dataSource;
+ @Mock
+ Connection conn;
+ @Mock
+ PreparedStatement prepStmt;
+ @Mock
+ Statement stmt;
+ @Mock
+ ParameterMetaData meta;
+ @Mock
+ ResultSet results;
// helper method for calling batch when an exception is expected
private void callBatchWithException(final String sql, final Object[][] params) throws Exception {
@@ -69,8 +75,8 @@
verify(prepStmt, times(2)).addBatch();
verify(prepStmt, times(1)).executeBatch();
- verify(prepStmt, times(1)).close(); // make sure the statement is closed
- verify(conn, times(1)).close(); // make sure the connection is closed
+ verify(prepStmt, times(1)).close(); // make sure the statement is closed
+ verify(conn, times(1)).close(); // make sure the connection is closed
} catch (final Exception e) {
caught = true;
}
@@ -208,8 +214,6 @@
verify(conn, times(0)).close(); // make sure we closed the connection
}
-
-
// helper method for calling batch when an exception is expected
private void callQueryWithException(final Object... params) throws Exception {
boolean caught = false;
@@ -220,8 +224,8 @@
verify(prepStmt, times(1)).executeQuery();
verify(results, times(1)).close();
- verify(prepStmt, times(1)).close(); // make sure we closed the statement
- verify(conn, times(1)).close(); // make sure we closed the connection
+ verify(prepStmt, times(1)).close(); // make sure we closed the statement
+ verify(conn, times(1)).close(); // make sure we closed the connection
} catch (final Exception e) {
caught = true;
}
@@ -240,8 +244,8 @@
runner.update("select * from blah where ? = ?", params).get();
verify(prepStmt, times(1)).executeUpdate();
- verify(prepStmt, times(1)).close(); // make sure we closed the statement
- verify(conn, times(1)).close(); // make sure we closed the connection
+ verify(prepStmt, times(1)).close(); // make sure we closed the statement
+ verify(conn, times(1)).close(); // make sure we closed the connection
} catch (final Exception e) {
caught = true;
}
@@ -278,7 +282,7 @@
//
// Random tests
//
- @Test(expected=ExecutionException.class)
+ @Test(expected = ExecutionException.class)
public void testBadPrepareConnection() throws Exception {
runner = new AsyncQueryRunner(Executors.newFixedThreadPool(1));
runner.update("update blah set unit = test").get();
@@ -303,7 +307,6 @@
callUpdateWithException("unit", "test");
}
-
@Test
public void testGoodBatch() throws Exception {
final String[][] params = { { "unit", "unit" }, { "test", "test" } };
@@ -339,7 +342,6 @@
callGoodQuery(conn);
}
-
@SuppressWarnings("deprecation") // deliberate test of deprecated code
@Test
public void testGoodQueryPmdTrue() throws Exception {
@@ -367,9 +369,8 @@
@Test
public void testInsertUsesGivenQueryRunner() throws Exception {
- final QueryRunner mockQueryRunner = mock(QueryRunner.class
- , org.mockito.Mockito.withSettings().verboseLogging() // debug for Continuum
- );
+ final QueryRunner mockQueryRunner = mock(QueryRunner.class, org.mockito.Mockito.withSettings().verboseLogging() // debug for Continuum
+ );
runner = new AsyncQueryRunner(Executors.newSingleThreadExecutor(), mockQueryRunner);
runner.insert("1", handler);
@@ -396,7 +397,7 @@
callGoodUpdate();
}
- @Test(expected=ExecutionException.class)
+ @Test(expected = ExecutionException.class)
public void testNullConnectionBatch() throws Exception {
final String[][] params = { { "unit", "unit" }, { "test", "test" } };
@@ -405,27 +406,26 @@
runner.batch("select * from blah where ? = ?", params).get();
}
-
- @Test(expected=ExecutionException.class)
+ @Test(expected = ExecutionException.class)
public void testNullConnectionQuery() throws Exception {
when(dataSource.getConnection()).thenReturn(null);
runner.query("select * from blah where ? = ?", handler, "unit", "test").get();
}
- @Test(expected=ExecutionException.class)
+ @Test(expected = ExecutionException.class)
public void testNullConnectionUpdate() throws Exception {
when(dataSource.getConnection()).thenReturn(null);
runner.update("select * from blah where ? = ?", "unit", "test").get();
}
- @Test(expected=ExecutionException.class)
+ @Test(expected = ExecutionException.class)
public void testNullHandlerQuery() throws Exception {
runner.query("select * from blah where ? = ?", null).get();
}
- @Test(expected=ExecutionException.class)
+ @Test(expected = ExecutionException.class)
public void testNullParamsArgBatch() throws Exception {
runner.batch("select * from blah where ? = ?", null).get();
}
@@ -437,19 +437,19 @@
callGoodBatch(params);
}
- @Test(expected=ExecutionException.class)
+ @Test(expected = ExecutionException.class)
public void testNullSqlBatch() throws Exception {
final String[][] params = { { "unit", "unit" }, { "test", "test" } };
runner.batch(null, params).get();
}
- @Test(expected=ExecutionException.class)
+ @Test(expected = ExecutionException.class)
public void testNullSqlQuery() throws Exception {
runner.query(null, handler).get();
}
- @Test(expected=ExecutionException.class)
+ @Test(expected = ExecutionException.class)
public void testNullSqlUpdate() throws Exception {
runner.update(null).get();
}
diff --git a/src/test/java/org/apache/commons/dbutils/BaseResultSetHandlerTest.java b/src/test/java/org/apache/commons/dbutils/BaseResultSetHandlerTest.java
index d04dbe6..0bc2b40 100644
--- a/src/test/java/org/apache/commons/dbutils/BaseResultSetHandlerTest.java
+++ b/src/test/java/org/apache/commons/dbutils/BaseResultSetHandlerTest.java
@@ -26,8 +26,7 @@
public final class BaseResultSetHandlerTest extends BaseTestCase {
- private static final class ToMapCollectionHandler
- extends BaseResultSetHandler<Collection<Map<String, Object>>> {
+ private static final class ToMapCollectionHandler extends BaseResultSetHandler<Collection<Map<String, Object>>> {
@Override
protected Collection<Map<String, Object>> handle() throws SQLException {
diff --git a/src/test/java/org/apache/commons/dbutils/BaseTestCase.java b/src/test/java/org/apache/commons/dbutils/BaseTestCase.java
index bb7f7f0..0157cc1 100644
--- a/src/test/java/org/apache/commons/dbutils/BaseTestCase.java
+++ b/src/test/java/org/apache/commons/dbutils/BaseTestCase.java
@@ -25,33 +25,19 @@
import junit.framework.TestCase;
/**
- * BaseTestCase is the base class for all test cases as well as the "all tests"
- * runner.
+ * BaseTestCase is the base class for all test cases as well as the "all tests" runner.
*/
public class BaseTestCase extends TestCase {
- private static final String[] columnNames =
- {
- "one",
- "two",
- "three",
- "notInBean",
- "intTest",
- "integerTest",
- "nullObjectTest",
- "nullPrimitiveTest",
- "notDate",
- "columnProcessorDoubleTest",
- null
- };
+ private static final String[] columnNames = { "one", "two", "three", "notInBean", "intTest", "integerTest", "nullObjectTest", "nullPrimitiveTest",
+ "notDate", "columnProcessorDoubleTest", null };
/**
* The number of columns in the MockResultSet.
*/
protected static final int COLS = columnNames.length;
- protected static final ResultSetMetaData metaData =
- MockResultSetMetaData.create(columnNames);
+ protected static final ResultSetMetaData metaData = MockResultSetMetaData.create(columnNames);
/**
* A Timestamp for test purposes having 9 decimals
@@ -63,35 +49,11 @@
ts789456123.setNanos(789456123);
}
- private static final Object[] row1 =
- {
- "1",
- "2",
- "THREE",
- " notInBean ",
- Integer.valueOf(1),
- Integer.valueOf(2),
- null,
- null,
- new Date(),
- BigInteger.valueOf(13),
- null
- };
+ private static final Object[] row1 = { "1", "2", "THREE", " notInBean ", Integer.valueOf(1), Integer.valueOf(2), null, null, new Date(),
+ BigInteger.valueOf(13), null };
- private static final Object[] row2 =
- {
- "4",
- "5",
- "SIX",
- " notInBean ",
- Integer.valueOf(3),
- Integer.valueOf(4),
- null,
- null,
- ts789456123,
- BigInteger.valueOf(13),
- null
- };
+ private static final Object[] row2 = { "4", "5", "SIX", " notInBean ", Integer.valueOf(3), Integer.valueOf(4), null, null, ts789456123,
+ BigInteger.valueOf(13), null };
private static final Object[][] rows = { row1, row2 };
@@ -118,8 +80,8 @@
}
/**
- * This is called before each test method so ResultSet will be fresh each
- * time.
+ * This is called before each test method so ResultSet will be fresh each time.
+ *
* @see junit.framework.TestCase#setUp()
*/
@Override
diff --git a/src/test/java/org/apache/commons/dbutils/BasicRowProcessorTest.java b/src/test/java/org/apache/commons/dbutils/BasicRowProcessorTest.java
index e4995e3..d95924e 100644
--- a/src/test/java/org/apache/commons/dbutils/BasicRowProcessorTest.java
+++ b/src/test/java/org/apache/commons/dbutils/BasicRowProcessorTest.java
@@ -34,11 +34,9 @@
private static final RowProcessor processor = new BasicRowProcessor();
/**
- * Format that matches Date.toString().
- * Sun Mar 14 15:19:15 MST 2004
+ * Format that matches Date.toString(). Sun Mar 14 15:19:15 MST 2004
*/
- private static final DateFormat datef =
- new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
+ private static final DateFormat datef = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
public void testPutAllContainsKeyAndRemove() throws Exception {
final Map<String, Object> test = new HashMap<>(3);
diff --git a/src/test/java/org/apache/commons/dbutils/BeanProcessorTest.java b/src/test/java/org/apache/commons/dbutils/BeanProcessorTest.java
index 865e111..67364c2 100644
--- a/src/test/java/org/apache/commons/dbutils/BeanProcessorTest.java
+++ b/src/test/java/org/apache/commons/dbutils/BeanProcessorTest.java
@@ -176,8 +176,8 @@
}
/**
- * dbutils checks for a setter with exactly 1 param. This tests resilience
- * to a found setter that doesn't match expectations.
+ * dbutils checks for a setter with exactly 1 param. This tests resilience to a found setter that doesn't match expectations.
+ *
* @param idx
* @param testField
*/
@@ -189,13 +189,11 @@
private static final BeanProcessor beanProc = new BeanProcessor();
public void testCheckAnnotationOnMissingReadMethod() throws Exception {
- final String[] colNames = {"testField"};
+ final String[] colNames = { "testField" };
final ResultSetMetaData metaData = MockResultSetMetaData.create(colNames);
final String testField = "first";
- final Object[][] rows = {
- new Object[] {testField}
- };
+ final Object[][] rows = { new Object[] { testField } };
final ResultSet rs = MockResultSet.create(metaData, rows);
assertTrue(rs.next());
@@ -205,23 +203,20 @@
}
/**
- * Based on the report in DBUTILS-150. This test validates that indexed
- * property descriptors are not used, and indexed getter/setter methods
- * are not inspected.
+ * Based on the report in DBUTILS-150. This test validates that indexed property descriptors are not used, and indexed getter/setter methods are not
+ * inspected.
*
* @throws Exception
* @see <a href="https://issues.apache.org/jira/browse/DBUTILS-150">DBUTILS-150</a>
*/
public void testIndexedPropertyDescriptor() throws Exception {
- final String[] colNames = {"name", "things", "stuff"};
+ final String[] colNames = { "name", "things", "stuff" };
final ResultSetMetaData metaData = MockResultSetMetaData.create(colNames);
final String name = "first";
final List<String> things = Arrays.asList("1", "2", "3", "4");
final List<String> stuff = things;
- final Object[][] rows = {
- new Object[] {name, things, stuff}
- };
+ final Object[][] rows = { new Object[] { name, things, stuff } };
final ResultSet rs = MockResultSet.create(metaData, rows);
assertTrue(rs.next());
@@ -235,8 +230,7 @@
public void testMapColumnToAnnotationField() throws Exception {
final String[] columnNames = { "test", "test", "three_" };
final String[] columnLabels = { "one", "two", null };
- final ResultSetMetaData rsmd = ProxyFactory.instance().createResultSetMetaData(
- new MockResultSetMetaData(columnNames, columnLabels));
+ final ResultSetMetaData rsmd = ProxyFactory.instance().createResultSetMetaData(new MockResultSetMetaData(columnNames, columnLabels));
final PropertyDescriptor[] props = Introspector.getBeanInfo(MapColumnToAnnotationFieldBean.class).getPropertyDescriptors();
final int[] columns = beanProc.mapColumnsToProperties(rsmd, props);
@@ -248,8 +242,7 @@
public void testMapColumnToProperties() throws Exception {
final String[] columnNames = { "test", "test", "three" };
final String[] columnLabels = { "one", "two", null };
- final ResultSetMetaData rsmd = ProxyFactory.instance().createResultSetMetaData(
- new MockResultSetMetaData(columnNames, columnLabels));
+ final ResultSetMetaData rsmd = ProxyFactory.instance().createResultSetMetaData(new MockResultSetMetaData(columnNames, columnLabels));
final PropertyDescriptor[] props = Introspector.getBeanInfo(MapColumnToPropertiesBean.class).getPropertyDescriptors();
final int[] columns = beanProc.mapColumnsToProperties(rsmd, props);
@@ -264,8 +257,7 @@
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));
+ final ResultSetMetaData rsmd = ProxyFactory.instance().createResultSetMetaData(new MockResultSetMetaData(columnNames, columnLabels));
final PropertyDescriptor[] props = Introspector.getBeanInfo(MapColumnToPropertiesBean.class).getPropertyDescriptors();
final int[] columns = beanProc.mapColumnsToProperties(rsmd, props);
@@ -305,13 +297,11 @@
}
public void testWrongSetterParamCount() throws Exception {
- final String[] colNames = {"testField"};
+ final String[] colNames = { "testField" };
final ResultSetMetaData metaData = MockResultSetMetaData.create(colNames);
final Integer testField = 1;
- final Object[][] rows = {
- new Object[] {testField}
- };
+ final Object[][] rows = { new Object[] { testField } };
final ResultSet rs = MockResultSet.create(metaData, rows);
assertTrue(rs.next());
diff --git a/src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java b/src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java
index 4016d75..1e0552b 100644
--- a/src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java
+++ b/src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java
@@ -61,8 +61,10 @@
this.two = two;
}
}
+
GenerousBeanProcessor processor = new GenerousBeanProcessor();
- @Mock ResultSetMetaData metaData;
+ @Mock
+ ResultSetMetaData metaData;
PropertyDescriptor[] propDescriptors;
diff --git a/src/test/java/org/apache/commons/dbutils/MockResultSet.java b/src/test/java/org/apache/commons/dbutils/MockResultSet.java
index 46be542..35bd234 100644
--- a/src/test/java/org/apache/commons/dbutils/MockResultSet.java
+++ b/src/test/java/org/apache/commons/dbutils/MockResultSet.java
@@ -32,21 +32,20 @@
public class MockResultSet implements InvocationHandler {
/**
- * Create a {@code MockResultSet} proxy object. This is equivalent to:
+ * Create a {@code MockResultSet} proxy object. This is equivalent to:
+ *
* <pre>
* ProxyFactory.instance().createResultSet(new MockResultSet(metaData, rows));
* </pre>
*
* @param metaData
- * @param rows A null value indicates an empty {@code ResultSet}.
+ * @param rows A null value indicates an empty {@code ResultSet}.
*/
- public static ResultSet create(final ResultSetMetaData metaData,
- final Object[][] rows) {
- return ProxyFactory.instance().createResultSet(
- new MockResultSet(metaData, rows));
+ public static ResultSet create(final ResultSetMetaData metaData, final Object[][] rows) {
+ return ProxyFactory.instance().createResultSet(new MockResultSet(metaData, rows));
}
- private Object[] currentRow = null;
+ private Object[] currentRow;
private Iterator<Object[]> iter;
@@ -56,8 +55,9 @@
/**
* MockResultSet constructor.
+ *
* @param metaData
- * @param rows A null value indicates an empty {@code ResultSet}.
+ * @param rows A null value indicates an empty {@code ResultSet}.
*/
public MockResultSet(final ResultSetMetaData metaData, final Object[][] rows) {
this.metaData = metaData;
@@ -70,9 +70,9 @@
}
/**
- * The get* methods can have an int column index or a String column name as
- * the parameter. This method handles both cases and returns the column
- * index that the client is trying to get at.
+ * The get* methods can have an int column index or a String column name as the parameter. This method handles both cases and returns the column index that
+ * the client is trying to get at.
+ *
* @param args
* @return A column index.
* @throws SQLException if a database access error occurs
@@ -92,6 +92,7 @@
/**
* Returns the column index for the given column name.
+ *
* @return A 1 based index
* @throws SQLException if the column name is invalid
*/
@@ -108,6 +109,7 @@
/**
* Gets the boolean value at the given column index.
+ *
* @param columnIndex A 1 based index.
* @throws SQLException if a database access error occurs
*/
@@ -116,9 +118,7 @@
this.setWasNull(obj);
try {
- return obj == null
- ? Boolean.FALSE
- : Boolean.valueOf(obj.toString());
+ return obj == null ? Boolean.FALSE : Boolean.valueOf(obj.toString());
} catch (final NumberFormatException e) {
throw new SQLException(e.getMessage());
@@ -127,6 +127,7 @@
/**
* Gets the byte value at the given column index.
+ *
* @param columnIndex A 1 based index.
* @throws SQLException if a database access error occurs
*/
@@ -135,9 +136,7 @@
this.setWasNull(obj);
try {
- return obj == null
- ? Byte.valueOf((byte) 0)
- : Byte.valueOf(obj.toString());
+ return obj == null ? Byte.valueOf((byte) 0) : Byte.valueOf(obj.toString());
} catch (final NumberFormatException e) {
throw new SQLException(e.getMessage());
@@ -146,6 +145,7 @@
/**
* Gets the double value at the given column index.
+ *
* @param columnIndex A 1 based index.
* @throws SQLException if a database access error occurs
*/
@@ -154,9 +154,7 @@
this.setWasNull(obj);
try {
- return obj == null
- ? Double.valueOf(0)
- : Double.valueOf(obj.toString());
+ return obj == null ? Double.valueOf(0) : Double.valueOf(obj.toString());
} catch (final NumberFormatException e) {
throw new SQLException(e.getMessage());
@@ -165,6 +163,7 @@
/**
* Gets the float value at the given column index.
+ *
* @param columnIndex A 1 based index.
* @throws SQLException if a database access error occurs
*/
@@ -182,6 +181,7 @@
/**
* Gets the int value at the given column index.
+ *
* @param columnIndex A 1 based index.
* @throws SQLException if a database access error occurs
*/
@@ -190,9 +190,7 @@
this.setWasNull(obj);
try {
- return obj == null
- ? Integer.valueOf(0)
- : Integer.valueOf(obj.toString());
+ return obj == null ? Integer.valueOf(0) : Integer.valueOf(obj.toString());
} catch (final NumberFormatException e) {
throw new SQLException(e.getMessage());
@@ -201,6 +199,7 @@
/**
* Gets the long value at the given column index.
+ *
* @param columnIndex A 1 based index.
* @throws SQLException if a database access error occurs
*/
@@ -225,6 +224,7 @@
/**
* Gets the object at the given column index.
+ *
* @param columnIndex A 1 based index.
* @throws SQLException if a database access error occurs
*/
@@ -236,6 +236,7 @@
/**
* Gets the short value at the given column index.
+ *
* @param columnIndex A 1 based index.
* @throws SQLException if a database access error occurs
*/
@@ -244,9 +245,7 @@
this.setWasNull(obj);
try {
- return obj == null
- ? Short.valueOf((short) 0)
- : Short.valueOf(obj.toString());
+ return obj == null ? Short.valueOf((short) 0) : Short.valueOf(obj.toString());
} catch (final NumberFormatException e) {
throw new SQLException(e.getMessage());
@@ -255,6 +254,7 @@
/**
* Gets the String at the given column index.
+ *
* @param columnIndex A 1 based index.
* @throws SQLException if a database access error occurs
*/
@@ -265,8 +265,7 @@
}
@Override
- public Object invoke(final Object proxy, final Method method, final Object[] args)
- throws Throwable {
+ public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
final String methodName = method.getName();
@@ -278,9 +277,7 @@
return this.next();
}
- if (methodName.equals("previous")) {
-
- } else if (methodName.equals("close")) {
+ if (methodName.equals("previous") || methodName.equals("close")) {
} else if (methodName.equals("getBoolean")) {
return this.getBoolean(columnIndex(args));
@@ -348,6 +345,7 @@
/**
* Assigns this.wasNull a Boolean value based on the object passed in.
+ *
* @param isNull
*/
private void setWasNull(final Object isNull) {
diff --git a/src/test/java/org/apache/commons/dbutils/MockResultSetMetaData.java b/src/test/java/org/apache/commons/dbutils/MockResultSetMetaData.java
index 7ae5763..e17d1c7 100644
--- a/src/test/java/org/apache/commons/dbutils/MockResultSetMetaData.java
+++ b/src/test/java/org/apache/commons/dbutils/MockResultSetMetaData.java
@@ -21,14 +21,13 @@
import java.sql.ResultSetMetaData;
/**
- * MockResultSetMetaData dynamically implements the ResultSetMetaData
- * interface.
+ * MockResultSetMetaData dynamically implements the ResultSetMetaData interface.
*/
public class MockResultSetMetaData implements InvocationHandler {
/**
- * Create a {@code MockResultSetMetaData} proxy object. This is
- * equivalent to:
+ * Create a {@code MockResultSetMetaData} proxy object. This is equivalent to:
+ *
* <pre>
* ProxyFactory.instance().createResultSetMetaData(new MockResultSetMetaData(columnNames));
* </pre>
@@ -37,12 +36,12 @@
* @return the proxy object
*/
public static ResultSetMetaData create(final String[] columnNames) {
- return ProxyFactory.instance().createResultSetMetaData(
- new MockResultSetMetaData(columnNames));
+ return ProxyFactory.instance().createResultSetMetaData(new MockResultSetMetaData(columnNames));
}
- private String[] columnNames = null;
- private String[] columnLabels = null;
+ private String[] columnNames;
+
+ private String[] columnLabels;
public MockResultSetMetaData(final String[] columnNames) {
this.columnNames = columnNames;
@@ -53,12 +52,10 @@
public MockResultSetMetaData(final String[] columnNames, final String[] columnLabels) {
this.columnNames = columnNames;
this.columnLabels = columnLabels;
-
}
@Override
- public Object invoke(final Object proxy, final Method method, final Object[] args)
- throws Throwable {
+ public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
final String methodName = method.getName();
@@ -66,18 +63,16 @@
return Integer.valueOf(this.columnNames.length);
}
- if (
- methodName.equals("getColumnName")) {
+ if (methodName.equals("getColumnName")) {
- final int col = ((Integer) args[0]).intValue() - 1;
- return this.columnNames[col];
+ final int col = ((Integer) args[0]).intValue() - 1;
+ return this.columnNames[col];
}
- if (
- methodName.equals("getColumnLabel")) {
+ if (methodName.equals("getColumnLabel")) {
- final int col = ((Integer) args[0]).intValue() - 1;
- return this.columnLabels[col];
+ final int col = ((Integer) args[0]).intValue() - 1;
+ return this.columnLabels[col];
}
if (methodName.equals("hashCode")) {
diff --git a/src/test/java/org/apache/commons/dbutils/OutParameterTest.java b/src/test/java/org/apache/commons/dbutils/OutParameterTest.java
index ec657e1..cb5481e 100644
--- a/src/test/java/org/apache/commons/dbutils/OutParameterTest.java
+++ b/src/test/java/org/apache/commons/dbutils/OutParameterTest.java
@@ -38,7 +38,8 @@
private static final int INDEX = 2;
private static final int VALUE = 42;
- @Mock CallableStatement stmt;
+ @Mock
+ CallableStatement stmt;
OutParameter<Number> parameter;
diff --git a/src/test/java/org/apache/commons/dbutils/ProxyFactoryTest.java b/src/test/java/org/apache/commons/dbutils/ProxyFactoryTest.java
index 5642687..1353a7e 100644
--- a/src/test/java/org/apache/commons/dbutils/ProxyFactoryTest.java
+++ b/src/test/java/org/apache/commons/dbutils/ProxyFactoryTest.java
@@ -19,8 +19,7 @@
import java.lang.reflect.InvocationHandler;
/**
- * ProxyFactoryTest performs simple type checking on proxy objects returned
- * from a ProxyFactory.
+ * ProxyFactoryTest performs simple type checking on proxy objects returned from a ProxyFactory.
*/
public class ProxyFactoryTest extends BaseTestCase {
diff --git a/src/test/java/org/apache/commons/dbutils/QueryLoaderTest.java b/src/test/java/org/apache/commons/dbutils/QueryLoaderTest.java
index 1f1b2ec..82f096f 100644
--- a/src/test/java/org/apache/commons/dbutils/QueryLoaderTest.java
+++ b/src/test/java/org/apache/commons/dbutils/QueryLoaderTest.java
@@ -24,18 +24,17 @@
*/
public class QueryLoaderTest extends BaseTestCase {
- private static final String QUERIES =
- "/org/apache/commons/dbutils/TestQueries.properties";
+ private static final String QUERIES = "/org/apache/commons/dbutils/TestQueries.properties";
public void testLoad() throws IOException {
final QueryLoader loader = QueryLoader.instance();
- final Map<String,String> q = loader.load(QUERIES);
- final Map<String,String> q2 = loader.load(QUERIES);
+ final Map<String, String> q = loader.load(QUERIES);
+ final Map<String, String> q2 = loader.load(QUERIES);
assertSame(q, q2); // pointer comparison should return true
assertEquals("SELECT * FROM SomeTable", q.get("test.query"));
loader.unload(QUERIES);
- final Map<String,String> q3 = loader.load(QUERIES);
+ final Map<String, String> q3 = loader.load(QUERIES);
assertTrue(q != q3); // pointer comparison should return false
}
diff --git a/src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java b/src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java
index 7ae4a1a..a33d038 100644
--- a/src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java
+++ b/src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java
@@ -62,25 +62,58 @@
private double b;
private String c;
- public int getA() { return a; }
- public double getB() { return b; }
- public String getC() { return c; }
- public void setA(final int a) { this.a = a; }
- public void setB(final double b) { this.b = b; }
- public void setC(final String c) { this.c = c; }
+ public int getA() {
+ return a;
+ }
+
+ public double getB() {
+ return b;
+ }
+
+ public String getC() {
+ return c;
+ }
+
+ public void setA(final int a) {
+ this.a = a;
+ }
+
+ public void setB(final double b) {
+ this.b = b;
+ }
+
+ public void setC(final String c) {
+ this.c = c;
+ }
}
+
QueryRunner runner;
ArrayHandler handler;
- @Mock DataSource dataSource;
- @Mock Connection conn;
- @Mock PreparedStatement prepStmt;
- @Mock Statement stmt;
- @Mock CallableStatement call;
- @Mock ParameterMetaData meta;
- @Mock ResultSet results;
- @Mock ResultSetMetaData resultsMeta;
+ @Mock
+ DataSource dataSource;
+
+ @Mock
+ Connection conn;
+
+ @Mock
+ PreparedStatement prepStmt;
+
+ @Mock
+ Statement stmt;
+
+ @Mock
+ CallableStatement call;
+
+ @Mock
+ ParameterMetaData meta;
+
+ @Mock
+ ResultSet results;
+
+ @Mock
+ ResultSetMetaData resultsMeta;
//
// Batch test cases
@@ -144,7 +177,6 @@
}
}
-
private void callGoodBatch(final Connection conn, final Object[][] params) throws Exception {
when(meta.getParameterCount()).thenReturn(2);
runner.batch(conn, "select * from blah where ? = ?", params);
@@ -152,8 +184,10 @@
verify(prepStmt, times(1)).getParameterMetaData();
verify(prepStmt, times(2)).addBatch();
verify(prepStmt, times(1)).executeBatch();
- verify(prepStmt, times(1)).close(); // make sure we closed the statement
- verify(conn, times(0)).close(); // make sure we do not close the connection, since QueryRunner.batch(Connection, String, Object[][]) does not close connections
+ // make sure we closed the statement
+ verify(prepStmt, times(1)).close();
+ // make sure we do not close the connection, since QueryRunner.batch(Connection, String, Object[][]) does not close connections
+ verify(conn, times(0)).close();
}
private void callGoodBatch(final Object[][] params) throws Exception {
@@ -239,7 +273,6 @@
verify(conn, times(5)).close(); // make sure we do not close the connection
}
-
//
// Execute tests
//
@@ -461,7 +494,6 @@
verify(conn, times(2)).close(); // make sure we closed the connection
}
-
//
// Query test cases
//
@@ -473,8 +505,8 @@
verify(prepStmt, times(1)).executeQuery();
verify(results, times(1)).close();
verify(prepStmt, times(1)).close(); // make sure we closed the statement
- verify(conn, times(0)).close(); // make sure we do not close the connection, since QueryRunner.query(Connection, String, ResultSetHandler<T>, Object...) does not close connections
-
+ // make sure we do not close the connection, since QueryRunner.query(Connection, String, ResultSetHandler<T>, Object...) does not close connections
+ verify(conn, times(0)).close();
// call the other variation of query
sql = "select * from blah";
runner.query(conn, sql, handler);
@@ -485,7 +517,6 @@
verify(conn, times(0)).close(); // make sure we do not close the connection, see above
}
-
private void callGoodUpdate() throws Exception {
when(meta.getParameterCount()).thenReturn(2);
String sql = "update blah set ? = ?";
@@ -523,8 +554,8 @@
verify(prepStmt, times(1)).executeUpdate();
verify(prepStmt, times(1)).close(); // make sure we closed the statement
- verify(conn, times(0)).close(); // make sure we do not close the connection, since QueryRunner.update(Connection, String, Object...) does not close connections
-
+ // make sure we do not close the connection, since QueryRunner.update(Connection, String, Object...) does not close connections
+ verify(conn, times(0)).close();
// call the other variation
when(meta.getParameterCount()).thenReturn(0);
final String sql = "update blah set unit = test";
@@ -543,7 +574,7 @@
verify(conn, times(0)).close(); // make sure we do not close the connection, see above
}
- // helper method for calling batch when an exception is expected
+ /** helper method for calling batch when an exception is expected. */
private void callQueryWithException(final Object... params) throws Exception {
boolean caught = false;
@@ -552,11 +583,11 @@
final String sql = "select * from blah where ? = ?";
runner.query(sql, handler, params);
- verify(prepStmt, never()).close(); // make sure the statement is still open
+ verify(prepStmt, never()).close(); // make sure the statement is still open
verify(prepStmt, times(1)).executeQuery();
- verify(prepStmt, times(1)).close(); // make sure we closed the statement
+ verify(prepStmt, times(1)).close(); // make sure we closed the statement
verify(results, times(1)).close();
- verify(conn, times(1)).close(); // make sure we closed the connection
+ verify(conn, times(1)).close(); // make sure we closed the connection
} catch (final SQLException e) {
caught = true;
}
@@ -566,8 +597,6 @@
}
}
-
-
// helper method for calling batch when an exception is expected
private void callUpdateWithException(final Object... params) throws Exception {
boolean caught = false;
@@ -578,8 +607,8 @@
runner.update(sql, params);
verify(prepStmt, times(1)).executeUpdate();
- verify(prepStmt, times(1)).close(); // make sure we closed the statement
- verify(conn, times(1)).close(); // make sure we closed the connection
+ verify(prepStmt, times(1)).close(); // make sure we closed the statement
+ verify(conn, times(1)).close(); // make sure we closed the connection
} catch (final SQLException e) {
caught = true;
}
@@ -620,7 +649,7 @@
callBatchWithException("select * from blah where ? = ?", params);
}
- @Test(expected=SQLException.class)
+ @Test(expected = SQLException.class)
public void testBadPrepareConnection() throws Exception {
runner = new QueryRunner();
runner.update("update blah set unit = test");
@@ -635,7 +664,6 @@
callBatchWithException("select * from blah where ? = ?", params);
}
-
@Test
public void testExecuteException() throws Exception {
callExecuteWithException(handler, "unit", "test");
@@ -656,12 +684,10 @@
@Test
public void testExecuteWithMultipleResultSets() throws Exception {
when(call.execute()).thenReturn(true);
- when(call.getMoreResults()).thenAnswer(new Answer<Boolean>()
- {
+ when(call.getMoreResults()).thenAnswer(new Answer<Boolean>() {
int count = 1;
@Override
- public Boolean answer(final InvocationOnMock invocation)
- {
+ public Boolean answer(final InvocationOnMock invocation) {
return ++count <= 3;
}
});
@@ -688,7 +714,7 @@
runner.fillStatementWithBean(prepStmt, bean, "a", "b", "c");
}
- @Test(expected=NullPointerException.class)
+ @Test(expected = NullPointerException.class)
public void testFillStatementWithBeanNullNames() throws Exception {
final MyBean bean = new MyBean();
runner.fillStatementWithBean(prepStmt, bean, "a", "b", null);
@@ -701,7 +727,6 @@
callGoodBatch(params);
}
-
@Test
public void testGoodBatchDefaultConstructor() throws Exception {
runner = new QueryRunner();
@@ -722,8 +747,7 @@
final ResultSetHandler<List<Object>> handler = rs -> {
final List<Object> objects = new ArrayList<>();
- while (rs.next())
- {
+ while (rs.next()) {
objects.add(new Object());
}
return objects;
@@ -739,8 +763,8 @@
verify(prepStmt, times(2)).addBatch();
verify(prepStmt, times(1)).executeBatch();
- verify(prepStmt, times(1)).close(); // make sure we closed the statement
- verify(conn, times(1)).close(); // make sure we closed the connection
+ verify(prepStmt, times(1)).close(); // make sure we closed the statement
+ verify(conn, times(1)).close(); // make sure we closed the connection
Assert.assertEquals(2, generatedKeys.size());
}
@@ -800,8 +824,8 @@
final Long generatedKey = runner.insert("INSERT INTO blah(col1, col2) VALUES(?,?)", new ScalarHandler<>(), "unit", "test");
verify(prepStmt, times(1)).executeUpdate();
- verify(prepStmt, times(1)).close(); // make sure we closed the statement
- verify(conn, times(1)).close(); // make sure we closed the connection
+ verify(prepStmt, times(1)).close(); // make sure we closed the statement
+ verify(conn, times(1)).close(); // make sure we closed the connection
Assert.assertEquals(1L, generatedKey.longValue());
}
@@ -860,7 +884,7 @@
callGoodUpdate();
}
- @Test(expected=SQLException.class)
+ @Test(expected = SQLException.class)
public void testNullConnectionBatch() throws Exception {
final String[][] params = { { "unit", "unit" }, { "test", "test" } };
@@ -869,47 +893,47 @@
runner.batch("select * from blah where ? = ?", params);
}
- @Test(expected=SQLException.class)
+ @Test(expected = SQLException.class)
public void testNullConnectionExecute() throws Exception {
when(dataSource.getConnection()).thenReturn(null);
runner.execute("{call my_proc(?, ?)}", "unit", "test");
}
- @Test(expected=SQLException.class)
+ @Test(expected = SQLException.class)
public void testNullConnectionExecuteWithResultSet() throws Exception {
when(dataSource.getConnection()).thenReturn(null);
runner.execute("{call my_proc(?, ?)}", handler, "unit", "test");
}
- @Test(expected=SQLException.class)
+ @Test(expected = SQLException.class)
public void testNullConnectionQuery() throws Exception {
when(dataSource.getConnection()).thenReturn(null);
runner.query("select * from blah where ? = ?", handler, "unit", "test");
}
- @Test(expected=SQLException.class)
+ @Test(expected = SQLException.class)
public void testNullConnectionUpdate() throws Exception {
when(dataSource.getConnection()).thenReturn(null);
runner.update("select * from blah where ? = ?", "unit", "test");
}
- @Test(expected=SQLException.class)
+ @Test(expected = SQLException.class)
public void testNullHandlerExecute() throws Exception {
when(meta.getParameterCount()).thenReturn(2);
runner.execute("{call my_proc(?, ?)}");
}
- @Test(expected=SQLException.class)
+ @Test(expected = SQLException.class)
public void testNullHandlerExecuteWithResultSet() throws Exception {
- runner.execute("{call my_proc(?, ?)}", (ResultSetHandler)null);
+ runner.execute("{call my_proc(?, ?)}", (ResultSetHandler) null);
}
- @Test(expected=SQLException.class)
+ @Test(expected = SQLException.class)
public void testNullHandlerQuery() throws Exception {
runner.query("select * from blah where ? = ?", null);
}
@@ -918,7 +942,7 @@
// Execute with ResultSetHandler
//
- @Test(expected=SQLException.class)
+ @Test(expected = SQLException.class)
public void testNullParamsArgBatch() throws Exception {
runner.batch("select * from blah where ? = ?", null);
}
@@ -930,29 +954,29 @@
callGoodBatch(params);
}
- @Test(expected=SQLException.class)
+ @Test(expected = SQLException.class)
public void testNullSqlBatch() throws Exception {
final String[][] params = { { "unit", "unit" }, { "test", "test" } };
runner.batch(null, params);
}
- @Test(expected=SQLException.class)
+ @Test(expected = SQLException.class)
public void testNullSqlExecute() throws Exception {
runner.execute(null);
}
- @Test(expected=SQLException.class)
+ @Test(expected = SQLException.class)
public void testNullSqlExecuteWithResultSet() throws Exception {
runner.execute(null, handler);
}
- @Test(expected=SQLException.class)
+ @Test(expected = SQLException.class)
public void testNullSqlQuery() throws Exception {
runner.query(null, handler);
}
- @Test(expected=SQLException.class)
+ @Test(expected = SQLException.class)
public void testNullSqlUpdate() throws Exception {
runner.update(null);
}
diff --git a/src/test/java/org/apache/commons/dbutils/ResultSetIteratorTest.java b/src/test/java/org/apache/commons/dbutils/ResultSetIteratorTest.java
index 010e5da..ad18c68 100644
--- a/src/test/java/org/apache/commons/dbutils/ResultSetIteratorTest.java
+++ b/src/test/java/org/apache/commons/dbutils/ResultSetIteratorTest.java
@@ -76,5 +76,4 @@
}
-
}
diff --git a/src/test/java/org/apache/commons/dbutils/ServiceLoaderTest.java b/src/test/java/org/apache/commons/dbutils/ServiceLoaderTest.java
index c817779..c73e01d 100644
--- a/src/test/java/org/apache/commons/dbutils/ServiceLoaderTest.java
+++ b/src/test/java/org/apache/commons/dbutils/ServiceLoaderTest.java
@@ -36,8 +36,7 @@
}
/**
- * Verifying 'more than 1' shows that we found more than we loaded locally which assumes the core handlers
- * were loaded, too.
+ * Verifying 'more than 1' shows that we found more than we loaded locally which assumes the core handlers were loaded, too.
*/
@Test
public void testFindMoreThanLocalColumns() {
@@ -50,8 +49,7 @@
}
/**
- * Verifying 'more than 1' shows that we found more than we loaded locally which assumes the core handlers
- * were loaded, too.
+ * Verifying 'more than 1' shows that we found more than we loaded locally which assumes the core handlers were loaded, too.
*/
@Test
public void testFindMoreThanLocalProperties() {
diff --git a/src/test/java/org/apache/commons/dbutils/StatementConfigurationTest.java b/src/test/java/org/apache/commons/dbutils/StatementConfigurationTest.java
index 8902cab..7f79676 100644
--- a/src/test/java/org/apache/commons/dbutils/StatementConfigurationTest.java
+++ b/src/test/java/org/apache/commons/dbutils/StatementConfigurationTest.java
@@ -30,11 +30,7 @@
*/
@Test
public void testBuilder() {
- final StatementConfiguration.Builder builder = new StatementConfiguration.Builder()
- .fetchDirection(1)
- .fetchSize(2)
- .maxFieldSize(3)
- .maxRows(4)
+ final StatementConfiguration.Builder builder = new StatementConfiguration.Builder().fetchDirection(1).fetchSize(2).maxFieldSize(3).maxRows(4)
.queryTimeout(5);
final StatementConfiguration config = builder.build();
@@ -55,7 +51,7 @@
assertTrue(config.isQueryTimeoutSet());
assertEquals(Duration.ofSeconds(5), config.getQueryTimeoutDuration());
-
+
final StatementConfiguration config2 = builder.queryTimeout(Duration.ofSeconds(3)).build();
assertTrue(config2.isQueryTimeoutSet());
diff --git a/src/test/java/org/apache/commons/dbutils/TestBean.java b/src/test/java/org/apache/commons/dbutils/TestBean.java
index 83fe007..a0093dc 100644
--- a/src/test/java/org/apache/commons/dbutils/TestBean.java
+++ b/src/test/java/org/apache/commons/dbutils/TestBean.java
@@ -42,27 +42,22 @@
private String doNotSet = "not set";
/**
- * toBean() should set primitive fields to their defaults (ie. 0) when
- * null is returned from the ResultSet.
+ * toBean() should set primitive fields to their defaults (ie. 0) when null is returned from the ResultSet.
*/
private int nullPrimitiveTest = 7;
/**
- * toBean() should set Object fields to null when null is returned from the
- * ResultSet
+ * toBean() should set Object fields to null when null is returned from the ResultSet
*/
private Object nullObjectTest = "overwrite";
/**
- * A Date will be returned from the ResultSet but the property is a String.
- * BeanProcessor should create a String from the Date and set this property.
+ * A Date will be returned from the ResultSet but the property is a String. BeanProcessor should create a String from the Date and set this property.
*/
private String notDate = "not a date";
/**
- * The ResultSet will have a BigDecimal in this column and the
- * BasicColumnProcessor should convert that to a double and store the value
- * in this property.
+ * The ResultSet will have a BigDecimal in this column and the BasicColumnProcessor should convert that to a double and store the value in this property.
*/
private double columnProcessorDoubleTest = -1;
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 1ebe3ab..63913f0 100644
--- a/src/test/java/org/apache/commons/dbutils/handlers/BeanHandlerTest.java
+++ b/src/test/java/org/apache/commons/dbutils/handlers/BeanHandlerTest.java
@@ -27,7 +27,8 @@
*/
public class BeanHandlerTest extends BaseTestCase {
- public static class SubTestBean extends TestBean implements SubTestBeanInterface { }
+ public static class SubTestBean extends TestBean implements SubTestBeanInterface {
+ }
public interface SubTestBeanInterface {
String getDoNotSet();
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 cc70922..1d60cc4 100644
--- a/src/test/java/org/apache/commons/dbutils/handlers/BeanListHandlerTest.java
+++ b/src/test/java/org/apache/commons/dbutils/handlers/BeanListHandlerTest.java
@@ -29,7 +29,8 @@
*/
public class BeanListHandlerTest extends BaseTestCase {
- public static class SubTestBean extends TestBean implements SubTestBeanInterface { }
+ public static class SubTestBean extends TestBean implements SubTestBeanInterface {
+ }
public interface SubTestBeanInterface {
String getDoNotSet();
diff --git a/src/test/java/org/apache/commons/dbutils/handlers/BeanMapHandlerTest.java b/src/test/java/org/apache/commons/dbutils/handlers/BeanMapHandlerTest.java
index 4511766..04d2e4b 100644
--- a/src/test/java/org/apache/commons/dbutils/handlers/BeanMapHandlerTest.java
+++ b/src/test/java/org/apache/commons/dbutils/handlers/BeanMapHandlerTest.java
@@ -37,9 +37,12 @@
private BeanMapHandler<Long, TestBean> bmh;
private Map<Long, TestBean> res;
- @Mock private ResultSet rs;
- @Mock private ResultSetMetaData rsmd;
- @Mock private RowProcessor rp;
+ @Mock
+ private ResultSet rs;
+ @Mock
+ private ResultSetMetaData rsmd;
+ @Mock
+ private RowProcessor rp;
private void handle() throws Exception {
res = bmh.handle(rs);
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 6de10a0..6202f43 100644
--- a/src/test/java/org/apache/commons/dbutils/handlers/KeyedHandlerTest.java
+++ b/src/test/java/org/apache/commons/dbutils/handlers/KeyedHandlerTest.java
@@ -29,15 +29,14 @@
public class KeyedHandlerTest extends BaseTestCase {
public void testColumnIndexHandle() throws SQLException {
- final ResultSetHandler<Map<String,Map<String,Object>>> h = new KeyedHandler<>(2);
- final 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(final Entry<String, Map<String, Object>> entry : results.entrySet())
- {
+ Map<String, Object> row = null;
+ for (final Entry<String, Map<String, Object>> entry : results.entrySet()) {
final Object key = entry.getKey();
assertNotNull(key);
row = entry.getValue();
@@ -51,15 +50,14 @@
}
public void testColumnNameHandle() throws SQLException {
- final ResultSetHandler<Map<Integer,Map<String,Object>>> h = new KeyedHandler<>("intTest");
- final 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(final Entry<Integer, Map<String, Object>> entry : results.entrySet())
- {
+ Map<String, Object> row = null;
+ for (final Entry<Integer, Map<String, Object>> entry : results.entrySet()) {
final Object key = entry.getKey();
assertNotNull(key);
row = entry.getValue();
@@ -73,23 +71,22 @@
}
public void testEmptyResultSetHandle() throws SQLException {
- final ResultSetHandler<Map<String,Map<String,Object>>> h = new KeyedHandler<>();
- final 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());
}
public void testHandle() throws SQLException {
- final ResultSetHandler<Map<String,Map<String,Object>>> h = new KeyedHandler<>();
+ final ResultSetHandler<Map<String, Map<String, Object>>> h = new KeyedHandler<>();
- final 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(final Entry<String, Map<String, Object>> entry : results.entrySet())
- {
+ Map<String, Object> row = null;
+ for (final Entry<String, Map<String, Object>> entry : results.entrySet()) {
final Object key = entry.getKey();
assertNotNull(key);
row = entry.getValue();
@@ -104,15 +101,14 @@
public void testInjectedRowProcess() throws Exception {
final RowProcessor mockProc = mock(RowProcessor.class);
- final ResultSetHandler<Map<String,Map<String,Object>>> h = new KeyedHandler<>(mockProc);
- final Map<String,Map<String,Object>> results = h.handle(this.rs);
+ final ResultSetHandler<Map<String, Map<String, Object>>> h = new KeyedHandler<>(mockProc);
+ final Map<String, Map<String, Object>> results = h.handle(this.rs);
assertNotNull(results);
assertEquals(ROWS, results.size());
- Map<String,Object> row = null;
- for(final Entry<String, Map<String, Object>> entry : results.entrySet())
- {
+ Map<String, Object> row = null;
+ for (final Entry<String, Map<String, Object>> entry : results.entrySet()) {
row = entry.getValue();
assertNotNull(row);
assertTrue(row.isEmpty());
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 f91e61d..4026266 100644
--- a/src/test/java/org/apache/commons/dbutils/handlers/MapHandlerTest.java
+++ b/src/test/java/org/apache/commons/dbutils/handlers/MapHandlerTest.java
@@ -28,15 +28,15 @@
public class MapHandlerTest extends BaseTestCase {
public void testEmptyResultSetHandle() throws SQLException {
- final ResultSetHandler<Map<String,Object>> h = new MapHandler();
- final 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);
}
public void testHandle() throws SQLException {
- final ResultSetHandler<Map<String,Object>> h = new MapHandler();
- final 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.size());
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 7a553dd..12efe2c 100644
--- a/src/test/java/org/apache/commons/dbutils/handlers/MapListHandlerTest.java
+++ b/src/test/java/org/apache/commons/dbutils/handlers/MapListHandlerTest.java
@@ -30,23 +30,23 @@
public class MapListHandlerTest extends BaseTestCase {
public void testEmptyResultSetHandle() throws SQLException {
- final ResultSetHandler<List<Map<String,Object>>> h = new MapListHandler();
- final 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());
}
public void testHandle() throws SQLException {
- final ResultSetHandler<List<Map<String,Object>>> h = new MapListHandler();
- final 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());
- final Iterator<Map<String,Object>> iter = results.iterator();
+ final Iterator<Map<String, Object>> iter = results.iterator();
assertTrue(iter.hasNext());
- Map<String,Object> row = iter.next();
+ Map<String, Object> row = iter.next();
assertEquals(COLS, row.size());
assertEquals("1", row.get("one"));
assertEquals("2", row.get("TWO"));
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 d91702b..8361ae9 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
@@ -33,8 +33,7 @@
}
/**
- * Verifying 'more than 1' shows that we found more than we loaded locally which assumes the core handlers
- * were loaded, too.
+ * Verifying 'more than 1' shows that we found more than we loaded locally which assumes the core handlers were loaded, too.
*/
@Test
public void testFoundMoreThanLocal() {
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 53a3abb..f2614f6 100644
--- a/src/test/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java
+++ b/src/test/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java
@@ -65,7 +65,7 @@
*/
@Override
public InputStream getBinaryStream(final long pos, final long length) throws SQLException {
- return null;
+ return null;
}
@Override
@@ -99,8 +99,7 @@
}
@Override
- public int setBytes(final long pos, final byte[] bytes, final int offset, final int len)
- throws SQLException {
+ public int setBytes(final long pos, final byte[] bytes, final int offset, final int len) throws SQLException {
return 0;
}
@@ -136,7 +135,7 @@
*/
@Override
public Reader getCharacterStream(final long pos, final long length) throws SQLException {
- return null;
+ return null;
}
@Override
@@ -175,8 +174,7 @@
}
@Override
- public int setString(final long pos, final String str, final int offset, final int len)
- throws SQLException {
+ public int setString(final long pos, final String str, final int offset, final int len) throws SQLException {
return 0;
}
@@ -200,13 +198,13 @@
}
@Override
- public Object getObject(final Map<String,Class<?>> map) throws SQLException {
+ public Object getObject(final Map<String, Class<?>> map) throws SQLException {
return null;
}
@Override
public void setObject(final Object value) throws SQLException {
-
+ // no-op
}
}
@@ -239,10 +237,7 @@
public void setUp() throws Exception {
super.setUp();
- rs2 =
- new SqlNullCheckedResultSet(
- ProxyFactory.instance().createResultSet(
- new SqlNullUncheckedMockResultSet()));
+ rs2 = new SqlNullCheckedResultSet(ProxyFactory.instance().createResultSet(new SqlNullUncheckedMockResultSet()));
rs = ProxyFactory.instance().createResultSet(rs2); // Override superclass field
}
@@ -994,11 +989,11 @@
/**
* Always return false for booleans, 0 for numerics, and null for Objects.
+ *
* @see java.lang.reflect.InvocationHandler#invoke(Object, java.lang.reflect.Method, Object[])
*/
@Override
- public Object invoke(final Object proxy, final Method method, final Object[] args)
- throws Throwable {
+ public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
final Class<?> returnType = method.getReturnType();
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 dd137b8..2510340 100644
--- a/src/test/java/org/apache/commons/dbutils/wrappers/StringTrimmedResultSetTest.java
+++ b/src/test/java/org/apache/commons/dbutils/wrappers/StringTrimmedResultSetTest.java
@@ -46,12 +46,12 @@
/**
* Make sure 2 wrappers work together.
+ *
* @throws SQLException if a database access error occurs
*/
public void testMultipleWrappers() throws Exception {
// Create a ResultSet with data
- final Object[][] rows = { { null }
- };
+ final Object[][] rows = { { null } };
ResultSet rs = MockResultSet.create(metaData, rows);
// Wrap the ResultSet with a null checked version