diff --git a/src/main/java/com/alibaba/druid/mock/MockResultSet.java b/src/main/java/com/alibaba/druid/mock/MockResultSet.java index 726548924d..108f715484 100644 --- a/src/main/java/com/alibaba/druid/mock/MockResultSet.java +++ b/src/main/java/com/alibaba/druid/mock/MockResultSet.java @@ -823,42 +823,42 @@ public class MockResultSet implements ResultSet { @Override public void updateRef(int columnIndex, Ref x) throws SQLException { - + updateObject(columnIndex, x); } @Override public void updateRef(String columnLabel, Ref x) throws SQLException { - + updateObject(columnLabel, x); } @Override public void updateBlob(int columnIndex, Blob x) throws SQLException { - + updateObject(columnIndex, x); } @Override public void updateBlob(String columnLabel, Blob x) throws SQLException { - + updateObject(columnLabel, x); } @Override public void updateClob(int columnIndex, Clob x) throws SQLException { - + updateObject(columnIndex, x); } @Override public void updateClob(String columnLabel, Clob x) throws SQLException { - + updateObject(columnLabel, x); } @Override public void updateArray(int columnIndex, Array x) throws SQLException { - + updateObject(columnIndex, x); } @Override public void updateArray(String columnLabel, Array x) throws SQLException { - + updateObject(columnLabel, x); } @Override @@ -875,12 +875,12 @@ public class MockResultSet implements ResultSet { @Override public void updateRowId(int columnIndex, RowId x) throws SQLException { - + updateObject(columnIndex, x); } @Override public void updateRowId(String columnLabel, RowId x) throws SQLException { - + updateObject(columnLabel, x); } @Override @@ -975,7 +975,7 @@ public class MockResultSet implements ResultSet { @Override public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException { - + updateObject(columnIndex, x); } @Override @@ -985,17 +985,17 @@ public class MockResultSet implements ResultSet { @Override public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException { - + updateObject(columnIndex, x); } @Override public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException { - + updateObject(columnIndex, x); } @Override public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException { - + updateObject(columnIndex, x); } @Override @@ -1005,7 +1005,7 @@ public class MockResultSet implements ResultSet { @Override public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException { - + updateObject(columnLabel, x); } @Override @@ -1014,8 +1014,8 @@ public class MockResultSet implements ResultSet { } @Override - public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException { - + public void updateBlob(int columnIndex, InputStream x, long length) throws SQLException { + updateObject(columnIndex, x); } @Override @@ -1024,8 +1024,8 @@ public class MockResultSet implements ResultSet { } @Override - public void updateClob(int columnIndex, Reader reader, long length) throws SQLException { - + public void updateClob(int columnIndex, Reader x, long length) throws SQLException { + updateObject(columnIndex, x); } @Override @@ -1034,8 +1034,8 @@ public class MockResultSet implements ResultSet { } @Override - public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException { - + public void updateNClob(int columnIndex, Reader x, long length) throws SQLException { + updateObject(columnIndex, x); } @Override @@ -1045,7 +1045,7 @@ public class MockResultSet implements ResultSet { @Override public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException { - + updateObject(columnIndex, x); } @Override @@ -1055,17 +1055,17 @@ public class MockResultSet implements ResultSet { @Override public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException { - + updateObject(columnIndex, x); } @Override public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException { - + updateObject(columnIndex, x); } @Override public void updateCharacterStream(int columnIndex, Reader x) throws SQLException { - + updateObject(columnIndex, x); } @Override @@ -1075,42 +1075,42 @@ public class MockResultSet implements ResultSet { @Override public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException { - + updateObject(columnLabel, x); } @Override - public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException { - + public void updateCharacterStream(String columnLabel, Reader x) throws SQLException { + updateObject(columnLabel, x); } @Override - public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException { - + public void updateBlob(int columnIndex, InputStream x) throws SQLException { + updateObject(columnIndex, x); } @Override - public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException { - + public void updateBlob(String columnLabel, InputStream x) throws SQLException { + updateObject(columnLabel, x); } @Override - public void updateClob(int columnIndex, Reader reader) throws SQLException { - + public void updateClob(int columnIndex, Reader x) throws SQLException { + updateObject(columnIndex, x); } @Override - public void updateClob(String columnLabel, Reader reader) throws SQLException { - + public void updateClob(String columnLabel, Reader x) throws SQLException { + updateObject(columnLabel, x); } @Override - public void updateNClob(int columnIndex, Reader reader) throws SQLException { - + public void updateNClob(int columnIndex, Reader x) throws SQLException { + updateObject(columnIndex, x); } @Override - public void updateNClob(String columnLabel, Reader reader) throws SQLException { - + public void updateNClob(String columnLabel, Reader x) throws SQLException { + updateObject(columnLabel, x); } } diff --git a/src/test/java/com/alibaba/druid/bvt/pool/basic/ResultSetTest.java b/src/test/java/com/alibaba/druid/bvt/pool/basic/ResultSetTest.java index 1df0e78b12..03b73d0bf0 100644 --- a/src/test/java/com/alibaba/druid/bvt/pool/basic/ResultSetTest.java +++ b/src/test/java/com/alibaba/druid/bvt/pool/basic/ResultSetTest.java @@ -1,5 +1,7 @@ package com.alibaba.druid.bvt.pool.basic; +import java.io.InputStream; +import java.io.Reader; import java.math.BigDecimal; import java.sql.SQLException; @@ -321,8 +323,8 @@ public class ResultSetTest extends TestCase { resultSet.updateTimestamp("1", new java.sql.Timestamp(currentMillis)); Assert.assertEquals(new java.sql.Timestamp(currentMillis), resultSet.getTimestamp("1")); } - - public void test_setByLabel_error() throws Exception { + + public void test_updateByLabel_error() throws Exception { long currentMillis = System.currentTimeMillis(); Assert.assertTrue(resultSet.next()); @@ -468,6 +470,141 @@ public class ResultSetTest extends TestCase { } } + + public void test_updateBinaryStream() throws Exception { + resultSet.next(); + + resultSet.updateBinaryStream(1, (InputStream) null); + resultSet.updateBinaryStream("1", (InputStream) null); + + { + SQLException error = null; + try { + resultSet.updateBinaryStream("0", (InputStream) null); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + { + SQLException error = null; + try { + resultSet.updateBinaryStream(0, (InputStream) null); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + } + + public void test_updateCharacterStream() throws Exception { + resultSet.next(); + + resultSet.updateCharacterStream(1, (Reader) null); + resultSet.updateCharacterStream("1", (Reader) null); + + { + SQLException error = null; + try { + resultSet.updateCharacterStream("0", (Reader) null); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + { + SQLException error = null; + try { + resultSet.updateCharacterStream(0, (Reader) null); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + } + + public void test_update_blob() throws Exception { + resultSet.next(); + + resultSet.updateBlob(1, (InputStream) null); + resultSet.updateBlob("1", (InputStream) null); + + { + SQLException error = null; + try { + resultSet.updateBlob("0", (InputStream) null); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + { + SQLException error = null; + try { + resultSet.updateBlob(0, (InputStream) null); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + } + + public void test_update_clob() throws Exception { + resultSet.next(); + + resultSet.updateClob(1, (Reader) null); + resultSet.updateClob("1", (Reader) null); + + { + SQLException error = null; + try { + resultSet.updateClob("0", (Reader) null); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + { + SQLException error = null; + try { + resultSet.updateClob(0, (Reader) null); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + } + + public void test_update_nclob() throws Exception { + resultSet.next(); + + resultSet.updateNClob(1, (Reader) null); + resultSet.updateNClob("1", (Reader) null); + + { + SQLException error = null; + try { + resultSet.updateNClob("0", (Reader) null); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + { + SQLException error = null; + try { + resultSet.updateNClob(0, (Reader) null); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + } public void test_get_error() throws Exception { {