summaryrefslogtreecommitdiff
path: root/connectivity/qa
diff options
context:
space:
mode:
authorDavid Ostrovsky <david@ostrovsky.org>2012-09-30 19:53:40 +0200
committerMuthu Subramanian <sumuthu@suse.com>2012-10-10 13:35:13 +0530
commit36026a6ae5d2f42db5fa262a358a3bc8e33e036c (patch)
treeb27b7da466dde7e719f1c4db0fb50516470021dc /connectivity/qa
parentf6739073edc1b593035f25becbd0e9d6d536ef0c (diff)
mork driver: add list tables and unit test
Change-Id: I594b24341eb38c05523f578c1dc2e43d90544f30
Diffstat (limited to 'connectivity/qa')
-rw-r--r--connectivity/qa/connectivity/mork/DriverTest.cxx173
-rw-r--r--connectivity/qa/connectivity/mork/abook_10_john_does.mab159
2 files changed, 332 insertions, 0 deletions
diff --git a/connectivity/qa/connectivity/mork/DriverTest.cxx b/connectivity/qa/connectivity/mork/DriverTest.cxx
new file mode 100644
index 000000000000..1db1d9f7c1e0
--- /dev/null
+++ b/connectivity/qa/connectivity/mork/DriverTest.cxx
@@ -0,0 +1,173 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/bootstrapfixture.hxx>
+
+#include "MColumnAlias.hxx"
+#include "MQueryHelper.hxx"
+#include "MConnection.hxx"
+
+#include <com/sun/star/sdbc/XDriver.hpp>
+
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::uno;
+
+namespace connectivity { namespace mork {
+
+
+class MorkDriverTest: public test::BootstrapFixture
+{
+public:
+ MorkDriverTest() : test::BootstrapFixture(false, false) {};
+
+ void test_metadata();
+ void test_select_default_all();
+ void test_select_list_table_joe_doe_5();
+
+ virtual void setUp();
+ virtual void tearDown();
+
+ CPPUNIT_TEST_SUITE(MorkDriverTest);
+
+ CPPUNIT_TEST(test_metadata);
+ CPPUNIT_TEST(test_select_default_all);
+ CPPUNIT_TEST(test_select_list_table_joe_doe_5);
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+ Reference<XInterface> m_xMorkComponent;
+ Reference<XConnection> m_xConnection;
+};
+
+void MorkDriverTest::setUp()
+{
+ test::BootstrapFixture::setUp();
+ m_xMorkComponent = getMultiServiceFactory()->createInstance("com.sun.star.comp.sdbc.MorkDriver");
+ CPPUNIT_ASSERT_MESSAGE("no mork component!", m_xMorkComponent.is());
+
+ // is this the best way to pass test file through URL?
+ // may be take a custom Sequence< PropertyValue > route?
+ OUString url = OUString("sdbc:address:thunderbird:unittest:") +
+ getPathFromSrc("/connectivity/qa/connectivity/mork/abook_10_john_does.mab");
+
+ Sequence< PropertyValue > info;
+ Reference< XDriver> xDriver(m_xMorkComponent, UNO_QUERY);
+ if (!xDriver.is())
+ {
+ CPPUNIT_ASSERT_MESSAGE("cannot connect to mork driver!", xDriver.is());
+ }
+
+ m_xConnection = xDriver->connect(url, info);
+ if (!m_xConnection.is())
+ {
+ CPPUNIT_ASSERT_MESSAGE("cannot connect to address book data soure!", m_xConnection.is());
+ }
+}
+
+void MorkDriverTest::tearDown()
+{
+// how to make dispose() work?
+// Reference< com::sun::star::lang::XComponent >( m_xMorkComponent, UNO_QUERY_THROW )->dispose();
+ test::BootstrapFixture::tearDown();
+}
+
+void MorkDriverTest::test_metadata()
+{
+ Reference< XDatabaseMetaData > xDatabaseMetaData = m_xConnection->getMetaData();
+ if (!xDatabaseMetaData.is())
+ {
+ CPPUNIT_ASSERT_MESSAGE("cannot retrieve meta data!", xDatabaseMetaData.is());
+ }
+
+ const Any catalog;
+ const OUString schemaPattern = "%";
+ const OUString tableNamePattern = "%";
+ const Sequence< OUString > types;
+
+ Reference< XResultSet > xResultSet =
+ xDatabaseMetaData->getTables(catalog, schemaPattern, tableNamePattern, types);
+ if (!xResultSet.is())
+ {
+ CPPUNIT_ASSERT_MESSAGE("cannot retrieve tables!", xResultSet.is());
+ }
+
+ // TODO: how to access that result set and check the tables?
+ // it should be 3 tables inside: AddressBook, does_5 and does_10
+}
+
+void MorkDriverTest::test_select_default_all()
+{
+ const OUString sql = "select \"E-mail\" from \"AddressBook\" ORDER BY \"E-mail\"";
+ Reference< XPreparedStatement > xStatement = m_xConnection->prepareStatement(sql);
+ if (!xStatement.is())
+ {
+ CPPUNIT_ASSERT_MESSAGE("cannot create prepared statement!", xStatement.is());
+ }
+
+ Reference< XResultSet > xResultSet = xStatement->executeQuery();
+ if (!xResultSet.is())
+ {
+ CPPUNIT_ASSERT_MESSAGE("cannot execure sql statement!", xResultSet.is());
+ }
+
+ Reference< XRow > xDelegatorRow(xResultSet, UNO_QUERY);
+ if (!xDelegatorRow.is())
+ {
+ CPPUNIT_ASSERT_MESSAGE("cannot extract row from result set!", xDelegatorRow.is());
+ }
+
+ sal_Bool result = xResultSet->first();
+ CPPUNIT_ASSERT_MESSAGE("fetch first row failed!", result);
+ OUString mail = xDelegatorRow->getString(1);
+ CPPUNIT_ASSERT_MESSAGE("first row is not john@doe.org!", mail.equalsAscii("john@doe.org"));
+
+ result = xResultSet->next();
+ CPPUNIT_ASSERT_MESSAGE("fetch second row failed!", result);
+ mail = xDelegatorRow->getString(1);
+ CPPUNIT_ASSERT_MESSAGE("second row is not john@doe10.org!", mail.equalsAscii("john@doe10.org"));
+
+ result = xResultSet->last();
+ CPPUNIT_ASSERT_MESSAGE("fetch last row failed!", result);
+ mail = xDelegatorRow->getString(1);
+ CPPUNIT_ASSERT_MESSAGE("last row is not john@doe9.org!", mail.equalsAscii("john@doe9.org"));
+}
+
+void MorkDriverTest::test_select_list_table_joe_doe_5()
+{
+ const OUString sql = "select \"E-mail\" from \"does_5\" where \"E-mail\" LIKE '%doe5.org' ";
+ Reference< XPreparedStatement > xStatement = m_xConnection->prepareStatement(sql);
+ if (!xStatement.is())
+ {
+ CPPUNIT_ASSERT_MESSAGE("cannot create prepared statement!", xStatement.is());
+ }
+
+ Reference< XResultSet > xResultSet = xStatement->executeQuery();
+ if (!xResultSet.is())
+ {
+ CPPUNIT_ASSERT_MESSAGE("cannot execure sql statement!", xResultSet.is());
+ }
+
+ Reference< XRow > xDelegatorRow(xResultSet, UNO_QUERY);
+ if (!xDelegatorRow.is())
+ {
+ CPPUNIT_ASSERT_MESSAGE("cannot extract row from result set!", xDelegatorRow.is());
+ }
+
+ sal_Bool result = xResultSet->first();
+ CPPUNIT_ASSERT_MESSAGE("fetch first row failed!", result);
+ OUString mail = xDelegatorRow->getString(1);
+ CPPUNIT_ASSERT_MESSAGE("last row is not john@doe5.org!", mail.equalsAscii("john@doe5.org"));
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(MorkDriverTest);
+
+}}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/connectivity/qa/connectivity/mork/abook_10_john_does.mab b/connectivity/qa/connectivity/mork/abook_10_john_does.mab
new file mode 100644
index 000000000000..41aac4c3e42c
--- /dev/null
+++ b/connectivity/qa/connectivity/mork/abook_10_john_does.mab
@@ -0,0 +1,159 @@
+// <!-- <mdb:mork:z v="1.4"/> -->
+< <(a=c)> // (f=iso-8859-1)
+ (B8=LastModifiedDate)(B9=RecordKey)(BA=AddrCharSet)(BB=LastRecordKey)
+ (BC=ns:addrbk:db:table:kind:pab)(BD=ListName)(BE=ListNickName)
+ (BF=ListDescription)(C0=ListTotalAddresses)(C1=LowercaseListName)
+ (C2=ns:addrbk:db:table:kind:deleted)(C3=_Yahoo)(C4=_MSN)
+ (C5=_GoogleTalk)(C6=_Skype)(C7=_JabberId)(C8=PreferDisplayName)
+ (C9=PhotoURI)(CA=PhotoType)(CB=PhotoName)(CC=DbRowID)(CD=_QQ)(CE=_ICQ)
+ (80=ns:addrbk:db:row:scope:card:all)
+ (81=ns:addrbk:db:row:scope:list:all)
+ (82=ns:addrbk:db:row:scope:data:all)(83=FirstName)(84=LastName)
+ (85=PhoneticFirstName)(86=PhoneticLastName)(87=DisplayName)
+ (88=NickName)(89=PrimaryEmail)(8A=LowercasePrimaryEmail)
+ (8B=SecondEmail)(8C=PreferMailFormat)(8D=PopularityIndex)
+ (8E=AllowRemoteContent)(8F=WorkPhone)(90=HomePhone)(91=FaxNumber)
+ (92=PagerNumber)(93=CellularNumber)(94=WorkPhoneType)(95=HomePhoneType)
+ (96=FaxNumberType)(97=PagerNumberType)(98=CellularNumberType)
+ (99=HomeAddress)(9A=HomeAddress2)(9B=HomeCity)(9C=HomeState)
+ (9D=HomeZipCode)(9E=HomeCountry)(9F=WorkAddress)(A0=WorkAddress2)
+ (A1=WorkCity)(A2=WorkState)(A3=WorkZipCode)(A4=WorkCountry)
+ (A5=JobTitle)(A6=Department)(A7=Company)(A8=_AimScreenName)
+ (A9=AnniversaryYear)(AA=AnniversaryMonth)(AB=AnniversaryDay)
+ (AC=SpouseName)(AD=FamilyName)(AE=WebPage1)(AF=WebPage2)(B0=BirthYear)
+ (B1=BirthMonth)(B2=BirthDay)(B3=Custom1)(B4=Custom2)(B5=Custom3)
+ (B6=Custom4)(B7=Notes)>
+
+<(AF=b)(81=John Doe)(82=)(80=0)(83=John)(84=1)(85=Doe)(86=john@doe.org)
+ (87=generic)(88=John Doe2)(89=Doe2)(8A=john@doe2.org)(8B=2)(8C=John Doe3)
+ (8D=Doe3)(8E=john@doe3.org)(8F=3)(90=John Doe4)(91=Doe4)(92
+ =john@doe4.org)(93=4)(94=John Doe5)(95=Doe5)(96=john@doe5.org)(97=5)
+ (98=John Doe6)(99=Doe6)(9A=john@doe6.org)(9B=6)(9C=John Doe7)(9D=Doe7)
+ (9E=john@doe7.org)(9F=7)(A0=John Doe8)(A1=Doe8)(A2=john@doe8.org)
+ (A3=8)(A4=John Doe9)(A5=Doe9)(A6=john@doe9.org)(A7=9)(A8=John Doe10)
+ (A9=Doe10)(AA=john@doe10.org)(AB=10)(AC=a)(AD=Does_5)(AE=does_5)>
+{1:^80 {(k^BC:c)(s=9)}
+ [1:^82(^B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