summaryrefslogtreecommitdiff
path: root/connectivity/qa
diff options
context:
space:
mode:
authorTamas Bunth <tamas.bunth@collabora.co.uk>2018-12-01 21:51:45 +0100
committerTamás Bunth <btomi96@gmail.com>2018-12-09 01:06:25 +0100
commitadc10258c7ab263ed8f7f44de3119aab6ea00187 (patch)
tree0f59c2e0bb4513a5ce6aaa21fd459bf6dd6c0e04 /connectivity/qa
parentb297193296e6afd0a6045ab7cd9daf2374b3fb3a (diff)
mysql_jdbc: test simultaneously opened result sets
Change-Id: I413fa17ee0fc264526133eca12ee747d40d6ac6a Reviewed-on: https://gerrit.libreoffice.org/64412 Tested-by: Jenkins Reviewed-by: Tamás Bunth <btomi96@gmail.com>
Diffstat (limited to 'connectivity/qa')
-rw-r--r--connectivity/qa/connectivity/mysql/mysql.cxx51
1 files changed, 51 insertions, 0 deletions
diff --git a/connectivity/qa/connectivity/mysql/mysql.cxx b/connectivity/qa/connectivity/mysql/mysql.cxx
index 16172439df0f..ee502ed286b7 100644
--- a/connectivity/qa/connectivity/mysql/mysql.cxx
+++ b/connectivity/qa/connectivity/mysql/mysql.cxx
@@ -40,18 +40,35 @@ public:
{
}
virtual void setUp() override;
+ virtual void tearDown() override;
void testDBConnection();
void testCreateAndDropTable();
void testIntegerInsertAndQuery();
void testDBPositionChange();
+ void testMultipleResultsets();
CPPUNIT_TEST_SUITE(MysqlTestDriver);
CPPUNIT_TEST(testDBConnection);
CPPUNIT_TEST(testCreateAndDropTable);
CPPUNIT_TEST(testIntegerInsertAndQuery);
+ CPPUNIT_TEST(testMultipleResultsets);
CPPUNIT_TEST_SUITE_END();
};
+void MysqlTestDriver::tearDown()
+{
+ Reference<XConnection> xConnection = m_xDriver->connect(m_sUrl, m_infos);
+ if (!xConnection.is())
+ {
+ CPPUNIT_ASSERT_MESSAGE("cannot connect to data source!", xConnection.is());
+ }
+ uno::Reference<XStatement> xStatement = xConnection->createStatement();
+ CPPUNIT_ASSERT(xStatement.is());
+ xStatement->executeUpdate("DROP TABLE IF EXISTS myTestTable");
+ xStatement->executeUpdate("DROP TABLE IF EXISTS otherTable");
+ test::BootstrapFixture::tearDown();
+}
+
void MysqlTestDriver::setUp()
{
test::BootstrapFixture::setUp();
@@ -236,6 +253,40 @@ void MysqlTestDriver::testDBPositionChange()
CPPUNIT_ASSERT_EQUAL(0, nUpdateCount); // it's a DDL statement
}
+void MysqlTestDriver::testMultipleResultsets()
+{
+ Reference<XConnection> xConnection = m_xDriver->connect(m_sUrl, m_infos);
+ CPPUNIT_ASSERT(xConnection.is());
+ Reference<XStatement> xStatement = xConnection->createStatement();
+ CPPUNIT_ASSERT(xStatement.is());
+ // create two tables
+ xStatement->executeUpdate("DROP TABLE IF EXISTS myTestTable");
+ xStatement->executeUpdate("DROP TABLE IF EXISTS otherTable");
+ xStatement->executeUpdate("CREATE TABLE myTestTable (id INTEGER PRIMARY KEY)");
+ xStatement->executeUpdate("INSERT INTO myTestTable VALUES (1)");
+ xStatement->executeUpdate("CREATE TABLE otherTable (id INTEGER PRIMARY KEY)");
+ xStatement->executeUpdate("INSERT INTO otherTable VALUES (2)");
+
+ // create first result set
+ Reference<XResultSet> xResultSet = xStatement->executeQuery("SELECT id from myTestTable");
+ CPPUNIT_ASSERT_MESSAGE("result set cannot be instantiated after query", xResultSet.is());
+ // use it
+ xResultSet->next();
+ Reference<XRow> xRowFirst(xResultSet, UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(1l, xRowFirst->getLong(1));
+ // create second result set
+ Reference<XResultSet> xResultSet2 = xStatement->executeQuery("SELECT id from otherTable");
+ // use second result set
+ xResultSet2->next();
+ Reference<XRow> xRowSecond(xResultSet2, UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(2l, xRowSecond->getLong(1));
+ // now use the first result set again
+ CPPUNIT_ASSERT_EQUAL(1l, xRowFirst->getLong(1));
+
+ xStatement->executeUpdate("DROP TABLE myTestTable");
+ xStatement->executeUpdate("DROP TABLE otherTable");
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(MysqlTestDriver);
CPPUNIT_PLUGIN_IMPLEMENT();