Skip to content

Commit

Permalink
[misc] improve some test
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Oct 10, 2017
1 parent 8c96b62 commit 4a37e2e
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/test/java/org/mariadb/jdbc/ServerPrepareStatementTest.java
Expand Up @@ -131,23 +131,19 @@ public void serverExecutionTest() throws SQLException {
public void serverCacheStatementTest() throws Throwable {
Assume.assumeTrue(sharedUsePrepare());
try (Connection connection = setConnection()) {
PreparedStatement ps = connection.prepareStatement("INSERT INTO ServerPrepareStatementTestCache(test) VALUES (?) ");
ps.setBoolean(1, true);
ps.addBatch();
ps.executeBatch();
}
Protocol protocol = getProtocolFromConnection(connection);
int cacheSize = protocol.prepareStatementCache().size();

PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO ServerPrepareStatementTestCache(test) VALUES (?)");
preparedStatement.setBoolean(1, true);
preparedStatement.execute();
assertTrue(cacheSize + 1 == protocol.prepareStatementCache().size());

Protocol protocol = getProtocolFromConnection(sharedConnection);
int cacheSize = protocol.prepareStatementCache().size();
PreparedStatement preparedStatement = sharedConnection.prepareStatement("INSERT INTO ServerPrepareStatementTestCache(test) VALUES (?)");
preparedStatement.setBoolean(1, true);
preparedStatement.execute();
assertTrue(cacheSize + 1 == protocol.prepareStatementCache().size());

PreparedStatement preparedStatement2 = sharedConnection.prepareStatement("INSERT INTO ServerPrepareStatementTestCache(test) VALUES (?)");
preparedStatement2.setBoolean(1, true);
preparedStatement2.execute();
assertTrue(cacheSize + 1 == protocol.prepareStatementCache().size());
PreparedStatement preparedStatement2 = connection.prepareStatement("INSERT INTO ServerPrepareStatementTestCache(test) VALUES (?)");
preparedStatement2.setBoolean(1, true);
preparedStatement2.execute();
assertTrue(cacheSize + 1 == protocol.prepareStatementCache().size());
}
}

@Test
Expand Down

0 comments on commit 4a37e2e

Please sign in to comment.