From f7fc6aaa09ffb1c6bf7802fa0aa65c9a6e5825a4 Mon Sep 17 00:00:00 2001 From: rusher Date: Thu, 10 Oct 2024 17:35:08 +0200 Subject: [PATCH] [misc] code coverage improvement --- .../java/org/mariadb/jdbc/BasePreparedStatement.java | 9 --------- .../mariadb/jdbc/integration/codec/LongCodecTest.java | 5 +++++ .../mariadb/jdbc/integration/codec/VarcharCodecTest.java | 7 +++++++ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/mariadb/jdbc/BasePreparedStatement.java b/src/main/java/org/mariadb/jdbc/BasePreparedStatement.java index 7899777f8..c3be4827e 100644 --- a/src/main/java/org/mariadb/jdbc/BasePreparedStatement.java +++ b/src/main/java/org/mariadb/jdbc/BasePreparedStatement.java @@ -155,15 +155,6 @@ public void updateMeta(ColumnDecoder[] ci) { public abstract ParameterMetaData getParameterMetaData() throws SQLException; - /** - * Set all parameters - * - * @param parameters parameters - */ - public void setParameters(Parameters parameters) { - this.parameters = parameters; - } - /** * Set parameter * diff --git a/src/test/java/org/mariadb/jdbc/integration/codec/LongCodecTest.java b/src/test/java/org/mariadb/jdbc/integration/codec/LongCodecTest.java index b51320436..2f41935a4 100644 --- a/src/test/java/org/mariadb/jdbc/integration/codec/LongCodecTest.java +++ b/src/test/java/org/mariadb/jdbc/integration/codec/LongCodecTest.java @@ -975,6 +975,8 @@ private void sendParam(Connection con) throws SQLException { prep.execute(); prep.setObject(1, 2L); prep.execute(); + prep.setObject(1, 3L, Types.DECIMAL); + prep.execute(); prep.setObject(1, BigInteger.TEN); prep.execute(); prep.setObject(1, null); @@ -985,6 +987,7 @@ private void sendParam(Connection con) throws SQLException { prep.execute(); prep.setObject(1, null, Types.BIGINT); prep.execute(); + assertThrowsContains(SQLSyntaxErrorException.class, () -> prep.setObject(1, 3L, Types.BLOB), "Could not convert"); } ResultSet rs = con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE) @@ -1000,6 +1003,7 @@ private void sendParam(Connection con) throws SQLException { rs.updateLong("t1", 60L); rs.updateRow(); assertEquals(60L, rs.getLong(2)); + assertTrue(rs.next()); assertTrue(rs.next()); assertEquals(10, rs.getLong(2)); @@ -1044,6 +1048,7 @@ private void sendParam(Connection con) throws SQLException { assertTrue(rs.next()); assertEquals(60L, rs.getLong(2)); + assertTrue(rs.next()); assertTrue(rs.next()); assertEquals(0L, rs.getLong(2)); diff --git a/src/test/java/org/mariadb/jdbc/integration/codec/VarcharCodecTest.java b/src/test/java/org/mariadb/jdbc/integration/codec/VarcharCodecTest.java index 439a299f2..64a8f02fe 100644 --- a/src/test/java/org/mariadb/jdbc/integration/codec/VarcharCodecTest.java +++ b/src/test/java/org/mariadb/jdbc/integration/codec/VarcharCodecTest.java @@ -896,6 +896,8 @@ private void sendParam(Connection con) throws SQLException { prep.execute(); prep.setObject(1, "e🌟2"); prep.execute(); + prep.setObject(1, '0', Types.BOOLEAN); + prep.execute(); prep.setObject(1, null); prep.execute(); prep.setObject(1, "e🌟3", Types.VARCHAR); @@ -922,6 +924,9 @@ private void sendParam(Connection con) throws SQLException { prep.execute(); prep.setNString(1, "e🌟12"); prep.execute(); + assertThrowsContains(SQLSyntaxErrorException.class, () -> prep.setObject(1, "e🌟12", Types.BLOB), "Cannot convert"); + assertThrowsContains(SQLSyntaxErrorException.class, () -> prep.setObject(1, "e🌟12", Types.OTHER), "Could not convert"); + } ResultSet rs = @@ -945,6 +950,7 @@ private void sendParam(Connection con) throws SQLException { rs.updateString(2, null); rs.updateRow(); assertNull(rs.getString(2)); + assertTrue(rs.next()); assertTrue(rs.next()); assertNull(rs.getString(2)); @@ -1020,6 +1026,7 @@ private void sendParam(Connection con) throws SQLException { assertTrue(rs.next()); assertNull(rs.getString(2)); + assertTrue(rs.next()); assertTrue(rs.next()); assertEquals("f🌟12", rs.getString(2));