diff --git a/driver/src/main/java/com/consol/citrus/db/driver/JdbcResultSet.java b/driver/src/main/java/com/consol/citrus/db/driver/JdbcResultSet.java index 92bfc27..cfa15dd 100644 --- a/driver/src/main/java/com/consol/citrus/db/driver/JdbcResultSet.java +++ b/driver/src/main/java/com/consol/citrus/db/driver/JdbcResultSet.java @@ -67,7 +67,6 @@ public JdbcResultSet(final DataSet dataSet, final JdbcStatement statement) { @Override public boolean next() throws SQLException { - ensureNotClosed(); row = dataSet.getNextRow(); return row != null; } @@ -78,57 +77,46 @@ public void close() throws SQLException { } public String getString(final int columnIndex) throws SQLException { - validateAccess(); return (String) row.getValue(columnIndex-1, String.class); } public String getString(final String columnName) throws SQLException { - validateAccess(); return (String) row.getValue(columnName, String.class); } public float getFloat(final int columnIndex) throws SQLException { - validateAccess(); return (float) row.getValue(columnIndex-1, float.class); } public float getFloat(final String columnName) throws SQLException { - validateAccess(); return (float) row.getValue(columnName, float.class); } public int getInt(final int columnIndex) throws SQLException { - validateAccess(); return (int) row.getValue(columnIndex-1, int.class); } public int getInt(final String columnName) throws SQLException { - validateAccess(); return (int) row.getValue(columnName, int.class); } public boolean getBoolean(final int columnIndex) throws SQLException { - validateAccess(); return (boolean) row.getValue(columnIndex-1, boolean.class); } public byte getByte(final int columnIndex) throws SQLException { - validateAccess(); return (byte) row.getValue(columnIndex-1, byte.class); } public short getShort(final int columnIndex) throws SQLException { - validateAccess(); return (short) row.getValue(columnIndex-1, short.class); } public long getLong(final int columnIndex) throws SQLException { - validateAccess(); return (long) row.getValue(columnIndex-1, long.class); } public double getDouble(final int columnIndex) throws SQLException { - validateAccess(); return (double) row.getValue(columnIndex-1, double.class); } @@ -137,22 +125,18 @@ public BigDecimal getBigDecimal(final int columnIndex, final int scale) throws S } public byte[] getBytes(final int columnIndex) throws SQLException { - validateAccess(); return (byte[]) row.getValue(columnIndex-1, byte[].class); } public Date getDate(final int columnIndex) throws SQLException { - validateAccess(); return (Date) row.getValue(columnIndex-1, Date.class); } public Time getTime(final int columnIndex) throws SQLException { - validateAccess(); return (Time) row.getValue(columnIndex-1, Time.class); } public Timestamp getTimestamp(final int columnIndex) throws SQLException { - validateAccess(); return (Timestamp) row.getValue(columnIndex-1, Timestamp.class); } @@ -169,37 +153,30 @@ public InputStream getBinaryStream(final int columnIndex) throws SQLException { } public Object getObject(final int columnIndex) throws SQLException { - validateAccess(); return row.getValue(columnIndex-1); } public BigDecimal getBigDecimal(final int columnIndex) throws SQLException { - validateAccess(); return (BigDecimal) row.getValue(columnIndex-1, BigDecimal.class); } public boolean getBoolean(final String columnName) throws SQLException { - validateAccess(); return (boolean) row.getValue(columnName, boolean.class); } public byte getByte(final String columnName) throws SQLException { - validateAccess(); return (byte) row.getValue(columnName, byte.class); } public short getShort(final String columnName) throws SQLException { - validateAccess(); return (short) row.getValue(columnName, short.class); } public long getLong(final String columnName) throws SQLException { - validateAccess(); return (long) row.getValue(columnName, long.class); } public double getDouble(final String columnName) throws SQLException { - validateAccess(); return (double) row.getValue(columnName, double.class); } @@ -208,32 +185,26 @@ public BigDecimal getBigDecimal(final String columnName, final int scale) throws } public byte[] getBytes(final String columnName) throws SQLException { - validateAccess(); return (byte[]) row.getValue(columnName, byte[].class); } public Date getDate(final String columnName) throws SQLException { - validateAccess(); return (Date) row.getValue(columnName, Date.class); } public Time getTime(final String columnName) throws SQLException { - validateAccess(); return (Time) row.getValue(columnName, Time.class); } public Timestamp getTimestamp(final String columnName) throws SQLException { - validateAccess(); return (Timestamp) row.getValue(columnName, Timestamp.class); } public Object getObject(final String columnName) throws SQLException { - validateAccess(); return row.getValue(columnName); } public BigDecimal getBigDecimal(final String columnName) throws SQLException { - validateAccess(); return (BigDecimal) row.getValue(columnName, BigDecimal.class); } @@ -266,7 +237,6 @@ public ResultSetMetaData getMetaData() throws SQLException { } public int findColumn(final String columnName) throws SQLException { - validateAccess(); return row.getColumns().indexOf(columnName)+1; } @@ -311,7 +281,6 @@ public boolean last() throws SQLException { } public int getRow() throws SQLException { - ensureNotClosed(); return dataSet.getCursor(); } @@ -536,7 +505,6 @@ public void moveToCurrentRow() throws SQLException { } public Statement getStatement() throws SQLException { - ensureNotClosed(); return statement; } @@ -866,7 +834,6 @@ public T getObject(final String columnLabel, final Class type) throws SQL } public boolean wasNull()throws SQLException { - validateAccess(); return row.getLastValue() == null; } @@ -918,25 +885,7 @@ public Array getArray(final String colName) throws SQLException { throw new SQLException("Not supported JDBC result set function 'getArray'"); } - private void validateAccess() throws SQLException { - ensureValidCursor(); - ensureNotClosed(); - } - - private void ensureValidCursor() throws SQLException { - if(row == null){ - throw new SQLException("No further data - Cursor position is after last row"); - } - } - - private void ensureNotClosed() throws SQLException { - if(isClosed()){ - throw new SQLException("Result set already closed"); - } - } - - private boolean rowModified() throws SQLException { - ensureNotClosed(); + private boolean rowModified() { return !dataSet.getRows().isEmpty(); } diff --git a/driver/src/test/java/com/consol/citrus/db/driver/JdbcResultSetTest.java b/driver/src/test/java/com/consol/citrus/db/driver/JdbcResultSetTest.java index 38cfd99..87036df 100644 --- a/driver/src/test/java/com/consol/citrus/db/driver/JdbcResultSetTest.java +++ b/driver/src/test/java/com/consol/citrus/db/driver/JdbcResultSetTest.java @@ -661,1020 +661,6 @@ void testRowDeleted() throws SQLException { assertTrue(updated); } - @Test(expectedExceptions = SQLException.class) - void nextThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.next(); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getStringByNameThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getString(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getStringByNameThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getString(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getStringByIndexThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getString(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getStringByIndexThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getString(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getFloatByNameThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getFloat(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getFloatByNameThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getFloat(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getFloatByIndexThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getFloat(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getFloatByIndexThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getFloat(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getIntByNameThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getInt(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getIntByNameThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getInt(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getIntByIndexThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getInt(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getIntByIndexThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getInt(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getBooleanByNameThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getBoolean(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getBooleanByNameThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getBoolean(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getBooleanByIndexThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getBoolean(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getBooleanByIndexThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getBoolean(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getByteByNameThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getBytes(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getByteByNameThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getBytes(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getByteByIndexThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getBytes(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getByteByIndexThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getBytes(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getShortByNameThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getShort(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getShortByNameThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getShort(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getShortByIndexThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getShort(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getShortByIndexThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getShort(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getLongByNameThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getLong(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getLongByNameThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getLong(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getLongByIndexThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getLong(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getLongByIndexThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getLong(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getDoubleByNameThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getDouble(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getDoubleByNameThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getDouble(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getDoubleByIndexThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getDouble(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getBigDecimalByNameThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getBigDecimal(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getBigDecimalByNameThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getBigDecimal(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getBigDecimalByIndexThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getBigDecimal(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getBigDecimalByIndexThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getBigDecimal(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getBytesByNameThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getBytes(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getBytesByNameThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getBytes(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getBytesByIndexThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getBytes(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getBytesByIndexThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getBytes(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getDateByNameThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getDate(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getDateByNameThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getDate(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getDateByIndexThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getDate(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getDateByIndexThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getDate(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getTimeByNameThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getTime(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getTimeByNameThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getTime(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getTimeByIndexThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getTime(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getTimeByIndexThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getTime(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getTimestampByNameThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getTimestamp(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getTimestampByNameThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getTimestamp(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getTimestampByIndexThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getTimestamp(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getTimestampByIndexThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getTimestamp(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getAsciiStreamByNameThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getAsciiStream(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getAsciiStreamByNameThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getAsciiStream(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getAsciiStreamByIndexThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getAsciiStream(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getAsciiStreamByIndexThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getAsciiStream(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getUnicodeStreamByNameThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getUnicodeStream(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getUnicodeStreamByNameThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getUnicodeStream(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getUnicodeStreamByIndexThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getUnicodeStream(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getUnicodeStreamByIndexThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getUnicodeStream(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getBinaryStreamByNameThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getBinaryStream(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getBinaryStreamByNameThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getBinaryStream(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getBinaryStreamByIndexThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getBinaryStream(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getBinaryStreamByIndexThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getBinaryStream(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getObjectByNameThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getObject(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getObjectByNameThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getObject(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getObjectByIndexThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getObject(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void getObjectByIndexThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.getObject(TEST_VALUE_INDEX_JDBC); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void findColumnThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.findColumn(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void findColumnThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.findColumn(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void testGetRowThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.findColumn(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void testGetRowThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.findColumn(TEST_VALUE_NAME); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void testRowUpdatedThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.rowUpdated(); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void testRowInsertedThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.rowInserted(); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void testRowDeletedThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.rowDeleted(); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void testGetStatementThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.getStatement(); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void testWasNullThrowsExceptionIfCalledOnClosedResultSet() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateClosedResultSet(); - - //WHEN - resultSet.wasNull(); - - //THEN - //exception - } - - @Test(expectedExceptions = SQLException.class) - void testWasNullThrowsExceptionIfCalledWithInvalidCursor() throws SQLException { - - //GIVEN - final JdbcResultSet resultSet = generateResultSetWithInvalidCursor(); - - //WHEN - resultSet.wasNull(); - - //THEN - //exception - } - @Test void testWasNullIsFalse() throws SQLException { @@ -1749,19 +735,6 @@ public void equalsContract(){ .verify(); } - private JdbcResultSet generateClosedResultSet() throws SQLException { - final JdbcResultSet jdbcResultSet = new JdbcResultSet(generateTestDataSet(), null); - jdbcResultSet.next(); - jdbcResultSet.close(); - return jdbcResultSet; - } - - private JdbcResultSet generateResultSetWithInvalidCursor() { - final DataSet dataSet = new DataSet(); - dataSet.getRows().add(null); - return new JdbcResultSet(dataSet, null); - } - private JdbcResultSet generateResultSet(final Object testValue) throws SQLException { return new JdbcResultSet(generateTestDataSet(testValue), null); }