From 4a37e2edd99e45c029c1374b960d6ecf36a41669 Mon Sep 17 00:00:00 2001 From: rusher Date: Tue, 10 Oct 2017 10:54:34 +0200 Subject: [PATCH] [misc] improve some test --- .../jdbc/ServerPrepareStatementTest.java | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/test/java/org/mariadb/jdbc/ServerPrepareStatementTest.java b/src/test/java/org/mariadb/jdbc/ServerPrepareStatementTest.java index 94491ff44..dc4c65a08 100644 --- a/src/test/java/org/mariadb/jdbc/ServerPrepareStatementTest.java +++ b/src/test/java/org/mariadb/jdbc/ServerPrepareStatementTest.java @@ -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