Skip to content
Permalink
Browse files

[misc] adding coverage tests, correcting test if using "useServerPrep…

…Stmts" option

(cherry picked from commit f445006)
  • Loading branch information...
rusher committed Jan 24, 2019
1 parent 03046d8 commit e1266f3de595562bdec2108ac16082b864d03ac7
Showing with 6 additions and 2 deletions.
  1. +6 −2 src/test/java/org/mariadb/jdbc/ClientPreparedStatementTest.java
@@ -56,6 +56,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import org.junit.Assume;
import org.junit.Test;

import java.sql.Connection;
@@ -163,7 +164,8 @@ public void batchParamNumber() throws SQLException {
preparedStatement.addBatch();
fail();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("You need to set exactly 2 parameters on the prepared statement"));
assertTrue(e.getMessage().contains("You need to set exactly 2 parameters on the prepared statement")
|| e.getMessage().contains("Parameter at position 2 is not set"));
}

try {
@@ -184,14 +186,16 @@ public void batchParamNumber() throws SQLException {
preparedStatement.addBatch();
fail();
} catch (SQLException e) {
assertTrue(e.getMessage().contains("You need to set exactly 2 parameters on the prepared statement"));
assertTrue(e.getMessage().contains("You need to set exactly 2 parameters on the prepared statement")
|| e.getMessage().contains("Parameter at position 1 is not set"));
}

}


@Test
public void setParameterError() throws SQLException {
Assume.assumeFalse(sharedOptions().useServerPrepStmts);
PreparedStatement preparedStatement = sharedConnection.prepareStatement("SELECT ?, ?");
preparedStatement.setString(1, "a");
preparedStatement.setString(2, "a");

0 comments on commit e1266f3

Please sign in to comment.
You can’t perform that action at this time.