diff --git a/.circleci/config.yml b/.circleci/config.yml
index fe4c371c..c9415c68 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -24,6 +24,8 @@ commands:
name: Run Maven
command: |
mvn -s .circleci/mvn-settings.xml << parameters.maven_subcommand >>
+ - store_artifacts:
+ path: target/site/jacoco/index.html
- run:
name: Save test results
command: |
diff --git a/pom.xml b/pom.xml
index 5c1d4e62..9b3a1082 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,6 +44,8 @@
17
true
true
+ true
+ 0.80
@@ -51,7 +53,7 @@
com.kingsrook.qqq
qqq-backend-core
- 0.2.0-SNAPSHOT
+ 0.2.0-20220714.175901-2
@@ -116,6 +118,9 @@
org.apache.maven.plugins
maven-surefire-plugin
3.0.0-M5
+
+ @{jaCoCoArgLine}
+
org.apache.maven.plugins
@@ -165,7 +170,84 @@
1
-
+
+ org.jacoco
+ jacoco-maven-plugin
+ 0.8.8
+
+
+ pre-unit-test
+
+ prepare-agent
+
+
+ jaCoCoArgLine
+
+
+
+ unit-test-check
+
+ check
+
+
+
+ ${coverage.haltOnFailure}
+
+
+ BUNDLE
+
+
+ INSTRUCTION
+ COVEREDRATIO
+ ${coverage.instructionCoveredRatioMinimum}
+
+
+
+
+
+
+
+ post-unit-test
+ verify
+
+ report
+
+
+
+
+
+ exec-maven-plugin
+ org.codehaus.mojo
+ 3.0.0
+
+
+ test-coverage-summary
+ verify
+
+ exec
+
+
+ sh
+
+ -c
+
+ /tmp/$$.headers
+xpath -q -e '/html/body/table/tfoot/tr[1]/td/text()' target/site/jacoco/index.html > /tmp/$$.values
+echo
+echo "Jacoco coverage summary report:"
+echo " See also target/site/jacoco/index.html"
+echo " and https://www.jacoco.org/jacoco/trunk/doc/counters.html"
+echo "------------------------------------------------------------"
+paste /tmp/$$.headers /tmp/$$.values | tail +2 | awk -v FS='\t' '{printf("%-20s %s\n",$1,$2)}'
+rm /tmp/$$.headers /tmp/$$.values
+ ]]>
+
+
+
+
+
+
diff --git a/src/main/java/com/kingsrook/qqq/backend/module/rdbms/jdbc/QueryManager.java b/src/main/java/com/kingsrook/qqq/backend/module/rdbms/jdbc/QueryManager.java
index 78d126e0..4496dd1d 100644
--- a/src/main/java/com/kingsrook/qqq/backend/module/rdbms/jdbc/QueryManager.java
+++ b/src/main/java/com/kingsrook/qqq/backend/module/rdbms/jdbc/QueryManager.java
@@ -640,7 +640,7 @@ public class QueryManager
/*******************************************************************************
- *
+ * index is 1-based!!
*******************************************************************************/
@SuppressWarnings("unchecked")
public static int bindParamObject(PreparedStatement statement, int index, Object value) throws SQLException
@@ -1120,15 +1120,12 @@ public class QueryManager
*******************************************************************************/
public static BigDecimal getBigDecimal(ResultSet resultSet, String column) throws SQLException
{
- throw (new NotImplementedException());
- /*
BigDecimal value = resultSet.getBigDecimal(column);
if(resultSet.wasNull())
{
return (null);
}
return (value);
- */
}
@@ -1153,15 +1150,12 @@ public class QueryManager
*******************************************************************************/
public static Date getDate(ResultSet resultSet, String column) throws SQLException
{
- throw (new NotImplementedException());
- /*
Date value = resultSet.getDate(column);
if(resultSet.wasNull())
{
return (null);
}
return (value);
- */
}
@@ -1186,8 +1180,6 @@ public class QueryManager
*******************************************************************************/
public static Calendar getCalendar(ResultSet resultSet, String column) throws SQLException
{
- throw (new NotImplementedException());
- /*
Timestamp value = resultSet.getTimestamp(column);
if(resultSet.wasNull())
{
@@ -1196,7 +1188,6 @@ public class QueryManager
Calendar rs = Calendar.getInstance();
rs.setTimeInMillis(value.getTime());
return (rs);
- */
}
@@ -1206,8 +1197,6 @@ public class QueryManager
*******************************************************************************/
public static Calendar getCalendar(ResultSet resultSet, int column) throws SQLException
{
- throw (new NotImplementedException());
- /*
Timestamp value = resultSet.getTimestamp(column);
if(resultSet.wasNull())
{
@@ -1216,7 +1205,6 @@ public class QueryManager
Calendar rs = Calendar.getInstance();
rs.setTimeInMillis(value.getTime());
return (rs);
- */
}
@@ -1227,8 +1215,6 @@ public class QueryManager
@SuppressWarnings("deprecation")
public static LocalDate getLocalDate(ResultSet resultSet, String column) throws SQLException
{
- throw (new NotImplementedException());
- /*
Timestamp value = resultSet.getTimestamp(column);
if(resultSet.wasNull())
{
@@ -1237,7 +1223,24 @@ public class QueryManager
LocalDate date = LocalDate.of(value.getYear() + NINETEEN_HUNDRED, value.getMonth() + 1, value.getDate());
return (date);
- */
+ }
+
+
+
+ /*******************************************************************************
+ **
+ *******************************************************************************/
+ @SuppressWarnings("deprecation")
+ public static LocalDate getLocalDate(ResultSet resultSet, int column) throws SQLException
+ {
+ Timestamp value = resultSet.getTimestamp(column);
+ if(resultSet.wasNull())
+ {
+ return (null);
+ }
+
+ LocalDate date = LocalDate.of(value.getYear() + NINETEEN_HUNDRED, value.getMonth() + 1, value.getDate());
+ return (date);
}
@@ -1248,8 +1251,6 @@ public class QueryManager
@SuppressWarnings("deprecation")
public static LocalDateTime getLocalDateTime(ResultSet resultSet, String column) throws SQLException
{
- throw (new NotImplementedException());
- /*
Timestamp value = resultSet.getTimestamp(column);
if(resultSet.wasNull())
{
@@ -1258,7 +1259,6 @@ public class QueryManager
LocalDateTime dateTime = LocalDateTime.of(value.getYear() + NINETEEN_HUNDRED, value.getMonth() + 1, value.getDate(), value.getHours(), value.getMinutes(), value.getSeconds(), 0);
return (dateTime);
- */
}
@@ -1287,8 +1287,6 @@ public class QueryManager
@SuppressWarnings("deprecation")
public static OffsetDateTime getOffsetDateTime(ResultSet resultSet, String column) throws SQLException
{
- throw (new NotImplementedException());
- /*
Timestamp value = resultSet.getTimestamp(column);
if(resultSet.wasNull())
{
@@ -1297,7 +1295,24 @@ public class QueryManager
OffsetDateTime dateTime = OffsetDateTime.of(value.getYear() + NINETEEN_HUNDRED, value.getMonth() + 1, value.getDate(), value.getHours(), value.getMinutes(), value.getSeconds(), 0, OffsetDateTime.now().getOffset());
return (dateTime);
- */
+ }
+
+
+
+ /*******************************************************************************
+ **
+ *******************************************************************************/
+ @SuppressWarnings("deprecation")
+ public static OffsetDateTime getOffsetDateTime(ResultSet resultSet, int column) throws SQLException
+ {
+ Timestamp value = resultSet.getTimestamp(column);
+ if(resultSet.wasNull())
+ {
+ return (null);
+ }
+
+ OffsetDateTime dateTime = OffsetDateTime.of(value.getYear() + NINETEEN_HUNDRED, value.getMonth() + 1, value.getDate(), value.getHours(), value.getMinutes(), value.getSeconds(), 0, OffsetDateTime.now().getOffset());
+ return (dateTime);
}
@@ -1307,15 +1322,12 @@ public class QueryManager
*******************************************************************************/
public static Boolean getBoolean(ResultSet resultSet, String column) throws SQLException
{
- throw (new NotImplementedException());
- /*
Boolean value = resultSet.getBoolean(column);
if(resultSet.wasNull())
{
return (null);
}
return (value);
- */
}
@@ -1325,15 +1337,12 @@ public class QueryManager
*******************************************************************************/
public static Boolean getBoolean(ResultSet resultSet, int column) throws SQLException
{
- throw (new NotImplementedException());
- /*
Boolean value = resultSet.getBoolean(column);
if(resultSet.wasNull())
{
return (null);
}
return (value);
- */
}
@@ -1343,15 +1352,12 @@ public class QueryManager
*******************************************************************************/
public static Long getLong(ResultSet resultSet, int column) throws SQLException
{
- throw (new NotImplementedException());
- /*
long value = resultSet.getLong(column);
if(resultSet.wasNull())
{
return (null);
}
return (value);
- */
}
@@ -1361,15 +1367,12 @@ public class QueryManager
*******************************************************************************/
public static Long getLong(ResultSet resultSet, String column) throws SQLException
{
- throw (new NotImplementedException());
- /*
long value = resultSet.getLong(column);
if(resultSet.wasNull())
{
return (null);
}
return (value);
- */
}
@@ -1379,15 +1382,12 @@ public class QueryManager
*******************************************************************************/
public static Timestamp getTimestamp(ResultSet resultSet, int column) throws SQLException
{
- throw (new NotImplementedException());
- /*
Timestamp value = resultSet.getTimestamp(column);
if(resultSet.wasNull())
{
return (null);
}
return (value);
- */
}
@@ -1397,15 +1397,12 @@ public class QueryManager
*******************************************************************************/
public static Timestamp getTimestamp(ResultSet resultSet, String column) throws SQLException
{
- throw (new NotImplementedException());
- /*
Timestamp value = resultSet.getTimestamp(column);
if(resultSet.wasNull())
{
return (null);
}
return (value);
- */
}
diff --git a/src/main/java/com/kingsrook/qqq/backend/module/rdbms/jdbc/SimpleEntity.java b/src/main/java/com/kingsrook/qqq/backend/module/rdbms/jdbc/SimpleEntity.java
index d49fb85a..8541d794 100755
--- a/src/main/java/com/kingsrook/qqq/backend/module/rdbms/jdbc/SimpleEntity.java
+++ b/src/main/java/com/kingsrook/qqq/backend/module/rdbms/jdbc/SimpleEntity.java
@@ -22,7 +22,6 @@
package com.kingsrook.qqq.backend.module.rdbms.jdbc;
-import java.math.BigDecimal;
import java.util.HashMap;
@@ -31,199 +30,199 @@ import java.util.HashMap;
*******************************************************************************/
public class SimpleEntity extends HashMap
{
- private String tableName;
+ // private String tableName;
- /*******************************************************************************
- **
- *******************************************************************************/
- public SimpleEntity()
- {
- super();
- }
+ // /*******************************************************************************
+ // **
+ // *******************************************************************************/
+ // public SimpleEntity()
+ // {
+ // super();
+ // }
- /*******************************************************************************
- **
- *******************************************************************************/
- public SimpleEntity with(String key, Object value)
- {
- put(key, value);
- return (this);
- }
+ // /*******************************************************************************
+ // **
+ // *******************************************************************************/
+ // public SimpleEntity with(String key, Object value)
+ // {
+ // put(key, value);
+ // return (this);
+ // }
- /*******************************************************************************
- ** Return the current value of tableName
- **
- ** @return tableName
- *******************************************************************************/
- public String getTableName()
- {
- return (tableName);
- }
+ // /*******************************************************************************
+ // ** Return the current value of tableName
+ // **
+ // ** @return tableName
+ // *******************************************************************************/
+ // public String getTableName()
+ // {
+ // return (tableName);
+ // }
- /*******************************************************************************
- ** Set the current value of tableName
- **
- ** @param tableName
- *******************************************************************************/
- public void setTableName(String tableName)
- {
- this.tableName = tableName;
- }
+ // /*******************************************************************************
+ // ** Set the current value of tableName
+ // **
+ // ** @param tableName
+ // *******************************************************************************/
+ // public void setTableName(String tableName)
+ // {
+ // this.tableName = tableName;
+ // }
- /*******************************************************************************
- **
- *******************************************************************************/
- public SimpleEntity withTableName(String tableName)
- {
- setTableName(tableName);
- return (this);
- }
+ // /*******************************************************************************
+ // **
+ // *******************************************************************************/
+ // public SimpleEntity withTableName(String tableName)
+ // {
+ // setTableName(tableName);
+ // return (this);
+ // }
- /*******************************************************************************
- **
- *******************************************************************************/
- public Boolean getBoolean(String columnName)
- {
- Object o = get(columnName);
- if(o == null)
- {
- return (null);
- }
+ // /*******************************************************************************
+ // **
+ // *******************************************************************************/
+ // public Boolean getBoolean(String columnName)
+ // {
+ // Object o = get(columnName);
+ // if(o == null)
+ // {
+ // return (null);
+ // }
- if(o instanceof Boolean)
- {
- return ((Boolean) o);
- }
- else if(o instanceof Number)
- {
- int i = ((Number) o).intValue();
- return (i != 0);
- }
- else if(o instanceof String)
- {
- String s = (String) o;
- return (s.equalsIgnoreCase("1") || s.equalsIgnoreCase("true") || s.equalsIgnoreCase("t"));
- }
- else
- {
- throw new IllegalArgumentException("Could not get value of object of type [" + o.getClass() + "] as Boolean.");
- }
+ // if(o instanceof Boolean)
+ // {
+ // return ((Boolean) o);
+ // }
+ // else if(o instanceof Number)
+ // {
+ // int i = ((Number) o).intValue();
+ // return (i != 0);
+ // }
+ // else if(o instanceof String)
+ // {
+ // String s = (String) o;
+ // return (s.equalsIgnoreCase("1") || s.equalsIgnoreCase("true") || s.equalsIgnoreCase("t"));
+ // }
+ // else
+ // {
+ // throw new IllegalArgumentException("Could not get value of object of type [" + o.getClass() + "] as Boolean.");
+ // }
- }
+ // }
- /*******************************************************************************
- **
- *******************************************************************************/
- public String getString(String columnName)
- {
- Object o = get(columnName);
- if(o == null)
- {
- return (null);
- }
- if(o instanceof String)
- {
- return ((String) o);
- }
- else if(o instanceof byte[])
- {
- return (new String((byte[]) o));
- }
+ // /*******************************************************************************
+ // **
+ // *******************************************************************************/
+ // public String getString(String columnName)
+ // {
+ // Object o = get(columnName);
+ // if(o == null)
+ // {
+ // return (null);
+ // }
+ // if(o instanceof String)
+ // {
+ // return ((String) o);
+ // }
+ // else if(o instanceof byte[])
+ // {
+ // return (new String((byte[]) o));
+ // }
- return String.valueOf(o);
- }
+ // return String.valueOf(o);
+ // }
- /*******************************************************************************
- **
- *******************************************************************************/
- public Integer getInteger(String columnName)
- {
- Object o = get(columnName);
- if(o instanceof Long)
- {
- return ((Long) o).intValue();
- }
- else if(o instanceof Short)
- {
- return ((Short) o).intValue();
- }
- else if(o instanceof String)
- {
- return (Integer.parseInt((String) o));
- }
+ // /*******************************************************************************
+ // **
+ // *******************************************************************************/
+ // public Integer getInteger(String columnName)
+ // {
+ // Object o = get(columnName);
+ // if(o instanceof Long)
+ // {
+ // return ((Long) o).intValue();
+ // }
+ // else if(o instanceof Short)
+ // {
+ // return ((Short) o).intValue();
+ // }
+ // else if(o instanceof String)
+ // {
+ // return (Integer.parseInt((String) o));
+ // }
- return ((Integer) o);
- }
+ // return ((Integer) o);
+ // }
- /*******************************************************************************
- **
- *******************************************************************************/
- public BigDecimal getBigDecimal(String columnName)
- {
- Object o = get(columnName);
- if(o == null)
- {
- return (null);
- }
+ // /*******************************************************************************
+ // **
+ // *******************************************************************************/
+ // public BigDecimal getBigDecimal(String columnName)
+ // {
+ // Object o = get(columnName);
+ // if(o == null)
+ // {
+ // return (null);
+ // }
- if(o instanceof BigDecimal)
- {
- return ((BigDecimal) o);
- }
- else
- {
- return new BigDecimal(String.valueOf(o));
- }
- }
+ // if(o instanceof BigDecimal)
+ // {
+ // return ((BigDecimal) o);
+ // }
+ // else
+ // {
+ // return new BigDecimal(String.valueOf(o));
+ // }
+ // }
- /*******************************************************************************
- **
- *******************************************************************************/
- public Long getLong(String columnName)
- {
- Object o = get(columnName);
- if(o instanceof Integer)
- {
- return ((Integer) o).longValue();
- }
+ // /*******************************************************************************
+ // **
+ // *******************************************************************************/
+ // public Long getLong(String columnName)
+ // {
+ // Object o = get(columnName);
+ // if(o instanceof Integer)
+ // {
+ // return ((Integer) o).longValue();
+ // }
- return ((Long) o);
- }
+ // return ((Long) o);
+ // }
- /*******************************************************************************
- **
- *******************************************************************************/
- public void trimStrings()
- {
- for(String key : keySet())
- {
- Object value = get(key);
- if(value != null && value instanceof String)
- {
- put(key, ((String) value).trim());
- }
- }
- }
+ // /*******************************************************************************
+ // **
+ // *******************************************************************************/
+ // public void trimStrings()
+ // {
+ // for(String key : keySet())
+ // {
+ // Object value = get(key);
+ // if(value != null && value instanceof String)
+ // {
+ // put(key, ((String) value).trim());
+ // }
+ // }
+ // }
}
diff --git a/src/test/java/com/kingsrook/qqq/backend/module/rdbms/jdbc/QueryManagerTest.java b/src/test/java/com/kingsrook/qqq/backend/module/rdbms/jdbc/QueryManagerTest.java
new file mode 100644
index 00000000..1d0cae91
--- /dev/null
+++ b/src/test/java/com/kingsrook/qqq/backend/module/rdbms/jdbc/QueryManagerTest.java
@@ -0,0 +1,227 @@
+/*
+ * QQQ - Low-code Application Framework for Engineers.
+ * Copyright (C) 2021-2022. Kingsrook, LLC
+ * 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
+ * contact@kingsrook.com
+ * https://github.com/Kingsrook/
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package com.kingsrook.qqq.backend.module.rdbms.jdbc;
+
+
+import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
+import java.sql.Connection;
+import java.sql.Date;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.OffsetDateTime;
+import java.util.GregorianCalendar;
+import com.kingsrook.qqq.backend.module.rdbms.TestUtils;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+
+/*******************************************************************************
+ **
+ *******************************************************************************/
+class QueryManagerTest
+{
+
+ /*******************************************************************************
+ **
+ *******************************************************************************/
+ @BeforeEach
+ void beforeEach() throws SQLException
+ {
+ Connection connection = getConnection();
+ QueryManager.executeUpdate(connection, "CREATE TABLE t (i INTEGER, dt DATETIME, c CHAR(1))");
+ }
+
+
+
+ /*******************************************************************************
+ **
+ *******************************************************************************/
+ @AfterEach
+ void afterEach() throws SQLException
+ {
+ Connection connection = getConnection();
+ QueryManager.executeUpdate(connection, "DROP TABLE t");
+ }
+
+
+
+ /*******************************************************************************
+ **
+ *******************************************************************************/
+ private Connection getConnection() throws SQLException
+ {
+ return new ConnectionManager().getConnection(TestUtils.defineBackend());
+ }
+
+
+
+ /*******************************************************************************
+ ** Test the various overloads that bind params
+ *******************************************************************************/
+ @Test
+ void testBindParams() throws SQLException
+ {
+ long ctMillis = System.currentTimeMillis();
+ Connection connection = getConnection();
+ PreparedStatement ps = connection.prepareStatement("UPDATE t SET i = ? WHERE i > 0");
+
+ ///////////////////////////////////////////////////////////////////////////////
+ // these calls - we just want to assert that they don't throw any exceptions //
+ ///////////////////////////////////////////////////////////////////////////////
+ QueryManager.bindParamObject(ps, 1, (short) 1);
+ QueryManager.bindParamObject(ps, 1, (long) 1);
+ QueryManager.bindParamObject(ps, 1, true);
+ QueryManager.bindParamObject(ps, 1, BigDecimal.ONE);
+ QueryManager.bindParamObject(ps, 1, "hello".getBytes(StandardCharsets.UTF_8));
+ QueryManager.bindParamObject(ps, 1, new Timestamp(ctMillis));
+ QueryManager.bindParamObject(ps, 1, new Date(ctMillis));
+ QueryManager.bindParamObject(ps, 1, new GregorianCalendar());
+ QueryManager.bindParamObject(ps, 1, LocalDate.now());
+ QueryManager.bindParamObject(ps, 1, OffsetDateTime.now());
+ QueryManager.bindParamObject(ps, 1, LocalDateTime.now());
+
+ assertThrows(SQLException.class, () ->
+ {
+ QueryManager.bindParamObject(ps, 1, new Object());
+ });
+
+ QueryManager.bindParam(ps, 1, (Integer) null);
+ QueryManager.bindParam(ps, 1, (Boolean) null);
+ QueryManager.bindParam(ps, 1, (BigDecimal) null);
+ QueryManager.bindParam(ps, 1, (byte[]) null);
+ QueryManager.bindParam(ps, 1, (Timestamp) null);
+ QueryManager.bindParam(ps, 1, (String) null);
+ QueryManager.bindParam(ps, 1, (Date) null);
+ QueryManager.bindParam(ps, 1, (GregorianCalendar) null);
+ QueryManager.bindParam(ps, 1, (LocalDate) null);
+ QueryManager.bindParam(ps, 1, (LocalDateTime) null);
+
+ QueryManager.bindParam(ps, 1, 1);
+ QueryManager.bindParam(ps, 1, true);
+ QueryManager.bindParam(ps, 1, BigDecimal.ONE);
+ QueryManager.bindParam(ps, 1, "hello".getBytes(StandardCharsets.UTF_8));
+ QueryManager.bindParam(ps, 1, new Timestamp(ctMillis));
+ QueryManager.bindParam(ps, 1, "hello");
+ QueryManager.bindParam(ps, 1, new Date(ctMillis));
+ QueryManager.bindParam(ps, 1, new GregorianCalendar());
+ QueryManager.bindParam(ps, 1, LocalDate.now());
+ QueryManager.bindParam(ps, 1, LocalDateTime.now());
+ }
+
+
+
+ /*******************************************************************************
+ ** Test the various getXXX methods from result sets
+ *******************************************************************************/
+ @Test
+ void testGetValueMethods() throws SQLException
+ {
+ Connection connection = getConnection();
+ QueryManager.executeUpdate(connection, "INSERT INTO t (i, dt, c) VALUES (1, now(), 'A')");
+ PreparedStatement preparedStatement = connection.prepareStatement("SELECT * from t");
+ preparedStatement.execute();
+ ResultSet rs = preparedStatement.getResultSet();
+ rs.next();
+
+ assertEquals(1, QueryManager.getInteger(rs, "i"));
+ assertEquals(1, QueryManager.getInteger(rs, 1));
+ assertEquals(1L, QueryManager.getLong(rs, "i"));
+ assertEquals(1L, QueryManager.getLong(rs, 1));
+ assertArrayEquals(new byte[] { 0, 0, 0, 1 }, QueryManager.getByteArray(rs, "i"));
+ assertArrayEquals(new byte[] { 0, 0, 0, 1 }, QueryManager.getByteArray(rs, 1));
+ assertEquals(1, QueryManager.getObject(rs, "i"));
+ assertEquals(1, QueryManager.getObject(rs, 1));
+ assertEquals(BigDecimal.ONE, QueryManager.getBigDecimal(rs, "i"));
+ assertEquals(BigDecimal.ONE, QueryManager.getBigDecimal(rs, 1));
+ assertEquals(true, QueryManager.getBoolean(rs, "i"));
+ assertEquals(true, QueryManager.getBoolean(rs, 1));
+ assertNotNull(QueryManager.getDate(rs, "dt"));
+ assertNotNull(QueryManager.getDate(rs, 2));
+ assertNotNull(QueryManager.getCalendar(rs, "dt"));
+ assertNotNull(QueryManager.getCalendar(rs, 2));
+ assertNotNull(QueryManager.getLocalDate(rs, "dt"));
+ assertNotNull(QueryManager.getLocalDate(rs, 2));
+ assertNotNull(QueryManager.getLocalDateTime(rs, "dt"));
+ assertNotNull(QueryManager.getLocalDateTime(rs, 2));
+ assertNotNull(QueryManager.getOffsetDateTime(rs, "dt"));
+ assertNotNull(QueryManager.getOffsetDateTime(rs, 2));
+ assertNotNull(QueryManager.getTimestamp(rs, "dt"));
+ assertNotNull(QueryManager.getTimestamp(rs, 2));
+ assertEquals("A", QueryManager.getObject(rs, "c"));
+ assertEquals("A", QueryManager.getObject(rs, 3));
+ }
+
+
+
+ /*******************************************************************************
+ ** Test the various getXXX methods from result sets, when they return null
+ *******************************************************************************/
+ @Test
+ void testGetValueMethodsReturningNull() throws SQLException
+ {
+ Connection connection = getConnection();
+ QueryManager.executeUpdate(connection, "INSERT INTO t (i, dt, c) VALUES (null, null, null)");
+ PreparedStatement preparedStatement = connection.prepareStatement("SELECT * from t");
+ preparedStatement.execute();
+ ResultSet rs = preparedStatement.getResultSet();
+ rs.next();
+
+ assertNull(QueryManager.getInteger(rs, "i"));
+ assertNull(QueryManager.getInteger(rs, 1));
+ assertNull(QueryManager.getLong(rs, "i"));
+ assertNull(QueryManager.getLong(rs, 1));
+ assertNull(QueryManager.getByteArray(rs, "i"));
+ assertNull(QueryManager.getByteArray(rs, 1));
+ assertNull(QueryManager.getObject(rs, "i"));
+ assertNull(QueryManager.getObject(rs, 1));
+ assertNull(QueryManager.getBigDecimal(rs, "i"));
+ assertNull(QueryManager.getBigDecimal(rs, 1));
+ assertNull(QueryManager.getBoolean(rs, "i"));
+ assertNull(QueryManager.getBoolean(rs, 1));
+ assertNull(QueryManager.getDate(rs, "dt"));
+ assertNull(QueryManager.getDate(rs, 2));
+ assertNull(QueryManager.getCalendar(rs, "dt"));
+ assertNull(QueryManager.getCalendar(rs, 2));
+ assertNull(QueryManager.getLocalDate(rs, "dt"));
+ assertNull(QueryManager.getLocalDate(rs, 2));
+ assertNull(QueryManager.getLocalDateTime(rs, "dt"));
+ assertNull(QueryManager.getLocalDateTime(rs, 2));
+ assertNull(QueryManager.getOffsetDateTime(rs, "dt"));
+ assertNull(QueryManager.getOffsetDateTime(rs, 2));
+ assertNull(QueryManager.getTimestamp(rs, "dt"));
+ assertNull(QueryManager.getTimestamp(rs, 2));
+ assertNull(QueryManager.getObject(rs, "c"));
+ assertNull(QueryManager.getObject(rs, 3));
+ }
+
+}
\ No newline at end of file