[Libreoffice-commits] core.git: connectivity/qa

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sun Dec 9 00:06:46 UTC 2018


 connectivity/qa/connectivity/mysql/mysql.cxx |   51 +++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

New commits:
commit adc10258c7ab263ed8f7f44de3119aab6ea00187
Author:     Tamas Bunth <tamas.bunth at collabora.co.uk>
AuthorDate: Sat Dec 1 21:51:45 2018 +0100
Commit:     Tamás Bunth <btomi96 at gmail.com>
CommitDate: Sun Dec 9 01:06:25 2018 +0100

    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 at gmail.com>

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();


More information about the Libreoffice-commits mailing list