diff --git a/driver/src/main/java/com/consol/citrus/db/driver/JdbcCallableStatement.java b/driver/src/main/java/com/consol/citrus/db/driver/JdbcCallableStatement.java index 58c5a18..7828ee9 100644 --- a/driver/src/main/java/com/consol/citrus/db/driver/JdbcCallableStatement.java +++ b/driver/src/main/java/com/consol/citrus/db/driver/JdbcCallableStatement.java @@ -186,9 +186,9 @@ public Blob getBlob(final int parameterIndex) throws SQLException { } @Override - public Clob getClob(final int parameterIndex) throws SQLException { - notSupported("getClob(int parameterIndex)"); - return null; + public Clob getClob(final int parameterIndex) { + prepareResultSet(); + return resultSet.getClob(parameterIndex); } @Override @@ -626,7 +626,7 @@ public void setBlob(final String parameterName, final Blob x) throws SQLExceptio } @Override - public void setClob(final String parameterName, final Clob x) throws SQLException { + public void setClob(final String parameterName, final Clob x) { setParameter(parameterName, x); } @@ -731,7 +731,7 @@ private void setOutParameter(final String parameterName) { setParameter(parameterName, "?"); } - private void prepareResultSet() throws SQLException { + private void prepareResultSet() { if(resultSet.getRow() == 0){ resultSet.next(); } diff --git a/driver/src/test/java/com/consol/citrus/db/driver/JdbcCallableStatementTest.java b/driver/src/test/java/com/consol/citrus/db/driver/JdbcCallableStatementTest.java index 27d41e0..512bc75 100644 --- a/driver/src/test/java/com/consol/citrus/db/driver/JdbcCallableStatementTest.java +++ b/driver/src/test/java/com/consol/citrus/db/driver/JdbcCallableStatementTest.java @@ -446,6 +446,7 @@ public void testGetStringByIndex() throws SQLException { callableStatement.getString(TEST_VALUE_INDEX); //THEN + verify(resultSetSpy).next(); verify(resultSetSpy).getString(TEST_VALUE_INDEX); } @@ -456,6 +457,7 @@ public void testGetBooleanByIndex() throws SQLException { callableStatement.getBoolean(TEST_VALUE_INDEX); //THEN + verify(resultSetSpy).next(); verify(resultSetSpy).getBoolean(TEST_VALUE_INDEX); } @@ -466,6 +468,7 @@ public void testGetByteByIndex() throws SQLException { callableStatement.getByte(TEST_VALUE_INDEX); //THEN + verify(resultSetSpy).next(); verify(resultSetSpy).getByte(TEST_VALUE_INDEX); } @@ -476,6 +479,7 @@ public void testGetBytesByIndex() throws SQLException { callableStatement.getBytes(TEST_VALUE_INDEX); //THEN + verify(resultSetSpy).next(); verify(resultSetSpy).getBytes(TEST_VALUE_INDEX); } @@ -486,6 +490,7 @@ public void testGetShortByIndex() throws SQLException { callableStatement.getShort(TEST_VALUE_INDEX); //THEN + verify(resultSetSpy).next(); verify(resultSetSpy).getShort(TEST_VALUE_INDEX); } @@ -496,6 +501,7 @@ public void testGetIntByIndex() throws SQLException { callableStatement.getInt(TEST_VALUE_INDEX); //THEN + verify(resultSetSpy).next(); verify(resultSetSpy).getInt(TEST_VALUE_INDEX); } @@ -506,6 +512,7 @@ public void testGetLongByIndex() throws SQLException { callableStatement.getLong(TEST_VALUE_INDEX); //THEN + verify(resultSetSpy).next(); verify(resultSetSpy).getLong(TEST_VALUE_INDEX); } @@ -516,6 +523,7 @@ public void testGetFloatByIndex() throws SQLException { callableStatement.getFloat(TEST_VALUE_INDEX); //THEN + verify(resultSetSpy).next(); verify(resultSetSpy).getFloat(TEST_VALUE_INDEX); } @@ -526,6 +534,7 @@ public void testGetDoubleByIndex() throws SQLException { callableStatement.getDouble(TEST_VALUE_INDEX); //THEN + verify(resultSetSpy).next(); verify(resultSetSpy).getDouble(TEST_VALUE_INDEX); } @@ -540,6 +549,7 @@ public void testGetBigDecimalByIndexWithScale() throws Exception { callableStatement.getBigDecimal(TEST_VALUE_INDEX, 2); //THEN + verify(resultSetSpy).next(); //noinspection ResultOfMethodCallIgnored verify(bigDecimalMock).setScale(2, RoundingMode.HALF_UP); } @@ -551,6 +561,7 @@ public void testGetStringByName() throws SQLException { callableStatement.getString(TEST_VALUE_NAME); //THEN + verify(resultSetSpy).next(); verify(resultSetSpy).getString(TEST_VALUE_NAME); } @@ -561,6 +572,7 @@ public void testGetBooleanByName() throws SQLException { callableStatement.getBoolean(TEST_VALUE_NAME); //THEN + verify(resultSetSpy).next(); verify(resultSetSpy).getBoolean(TEST_VALUE_NAME); } @@ -581,6 +593,7 @@ public void testGetShortByName() throws SQLException { callableStatement.getShort(TEST_VALUE_NAME); //THEN + verify(resultSetSpy).next(); verify(resultSetSpy).getShort(TEST_VALUE_NAME); } @@ -591,6 +604,7 @@ public void testGetIntByName() throws SQLException { callableStatement.getInt(TEST_VALUE_NAME); //THEN + verify(resultSetSpy).next(); verify(resultSetSpy).getInt(TEST_VALUE_NAME); } @@ -601,6 +615,7 @@ public void testGetLongByName() throws SQLException { callableStatement.getLong(TEST_VALUE_NAME); //THEN + verify(resultSetSpy).next(); verify(resultSetSpy).getLong(TEST_VALUE_NAME); } @@ -611,6 +626,7 @@ public void testGetFloatByName() throws SQLException { callableStatement.getFloat(TEST_VALUE_NAME); //THEN + verify(resultSetSpy).next(); verify(resultSetSpy).getFloat(TEST_VALUE_NAME); } @@ -621,6 +637,7 @@ public void testGetDoubleByName() throws SQLException { callableStatement.getDouble(TEST_VALUE_NAME); //THEN + verify(resultSetSpy).next(); verify(resultSetSpy).getDouble(TEST_VALUE_NAME); } @@ -631,6 +648,7 @@ public void testGetBytesByName() throws SQLException { callableStatement.getBytes(TEST_VALUE_NAME); //THEN + verify(resultSetSpy).next(); verify(resultSetSpy).getBytes(TEST_VALUE_NAME); } @@ -641,6 +659,7 @@ public void testGetObjectByName() throws SQLException { callableStatement.getObject(TEST_VALUE_NAME); //THEN + verify(resultSetSpy).next(); verify(resultSetSpy).getObject(TEST_VALUE_NAME); } @@ -651,6 +670,7 @@ public void testGetBigDecimalByName() throws SQLException { callableStatement.getBigDecimal(TEST_VALUE_NAME); //THEN + verify(resultSetSpy).next(); verify(resultSetSpy).getBigDecimal(TEST_VALUE_NAME); } @@ -672,6 +692,7 @@ public void testGetDateByIndex() throws SQLException { callableStatement.getDate(TEST_VALUE_INDEX); //THEN + verify(resultSetSpy).next(); verify(resultSetSpy).getDate(TEST_VALUE_INDEX); } @@ -682,6 +703,7 @@ public void testGetTimeByIndex() throws SQLException { callableStatement.getTime(TEST_VALUE_INDEX); //THEN + verify(resultSetSpy).next(); verify(resultSetSpy).getTime(TEST_VALUE_INDEX); } @@ -692,6 +714,7 @@ public void testGetTimestampByIndex() throws SQLException { callableStatement.getTimestamp(TEST_VALUE_INDEX); //THEN + verify(resultSetSpy).next(); verify(resultSetSpy).getTimestamp(TEST_VALUE_INDEX); } @@ -702,6 +725,7 @@ public void testGetObjectByIndex() throws SQLException { callableStatement.getObject(TEST_VALUE_INDEX); //THEN + verify(resultSetSpy).next(); verify(resultSetSpy).getObject(TEST_VALUE_INDEX); } @@ -712,6 +736,7 @@ public void testGetDateByName() throws SQLException { callableStatement.getDate(TEST_VALUE_NAME); //THEN + verify(resultSetSpy).next(); verify(resultSetSpy).getDate(TEST_VALUE_NAME); } @@ -722,6 +747,7 @@ public void testGetTimeByName() throws SQLException { callableStatement.getTime(TEST_VALUE_NAME); //THEN + verify(resultSetSpy).next(); verify(resultSetSpy).getTime(TEST_VALUE_NAME); } @@ -732,6 +758,7 @@ public void testGetTimestampByName() throws SQLException { callableStatement.getTimestamp(TEST_VALUE_NAME); //THEN + verify(resultSetSpy).next(); verify(resultSetSpy).getTimestamp(TEST_VALUE_NAME); } @@ -774,7 +801,7 @@ public void testSetLimitedClobFromReader() throws Exception { } @Test - public void TestNoopIfLengthExceedsInt() throws Exception { + public void testNoopIfLengthExceedsInt() throws Exception { //GIVEN when(lobUtils.fitsInInt(anyLong())).thenReturn(false); @@ -787,7 +814,7 @@ public void TestNoopIfLengthExceedsInt() throws Exception { } @Test - public void testSetClob() throws Exception { + public void testSetClob() { //GIVEN final String parameterName = "myClob"; @@ -802,7 +829,7 @@ public void testSetClob() throws Exception { } @Test - public void setClobFromReader() throws Exception { + public void testSetClobFromReader() throws Exception { //GIVEN final String parameterName = "myClob"; @@ -818,6 +845,17 @@ public void setClobFromReader() throws Exception { assertEquals(storedClob, expectedClob); } + @Test + public void testGetClobByIndex() throws Exception { + + //WHEN + callableStatement.getClob(TEST_VALUE_INDEX); + + //THEN + verify(resultSetSpy).next(); + verify(resultSetSpy).getClob(TEST_VALUE_INDEX); + } + @Test public void testToString(){ ToStringVerifier