diff options
author | David Ostrovsky <david@ostrovsky.org> | 2012-11-03 09:38:14 +0100 |
---|---|---|
committer | David Ostrovsky <david@ostrovsky.org> | 2012-11-03 10:42:15 +0100 |
commit | 1f02853eccd33585a4964c370b15fcd356dfef9d (patch) | |
tree | 6d29a746559daa5c951513eb202627a3ce78942c /connectivity | |
parent | msvc can't handle #if inside macro arguments (diff) | |
download | core-1f02853eccd33585a4964c370b15fcd356dfef9d.tar.gz core-1f02853eccd33585a4964c370b15fcd356dfef9d.zip |
fdo#53070 add complete unit test
Change-Id: I34f7a8ae58fa6af4c8cfdd13330420f1576fa2c9
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/CppunitTest_connectivity_ado.mk | 58 | ||||
-rw-r--r-- | connectivity/Module_connectivity.mk | 6 | ||||
-rwxr-xr-x | connectivity/qa/connectivity/ado/DriverTest.cxx | 147 | ||||
-rwxr-xr-x | connectivity/qa/connectivity/ado/TS001018407.mdb | bin | 0 -> 2789376 bytes |
4 files changed, 211 insertions, 0 deletions
diff --git a/connectivity/CppunitTest_connectivity_ado.mk b/connectivity/CppunitTest_connectivity_ado.mk new file mode 100644 index 000000000000..04706b743877 --- /dev/null +++ b/connectivity/CppunitTest_connectivity_ado.mk @@ -0,0 +1,58 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# 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/. +# + +$(eval $(call gb_CppunitTest_CppunitTest,connectivity_ado)) + +$(eval $(call gb_CppunitTest_set_include,connectivity_ado,\ + -I$(SRCDIR)/connectivity/source/inc \ + -I$(SRCDIR)/connectivity/source/drivers/ado \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_api,connectivity_ado,\ + udkapi \ + offapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,connectivity_ado)) + +$(eval $(call gb_CppunitTest_use_sdk_api,connectivity_mork)) + +$(eval $(call gb_CppunitTest_add_exception_objects,connectivity_ado, \ + connectivity/qa/connectivity/ado/DriverTest \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,connectivity_ado, \ + comphelper \ + cppu \ + cppuhelper \ + dbtools \ + i18nisolang1 \ + ado \ + sal \ + salhelper \ + sb \ + test \ + unotest \ + ucbhelper \ + utl \ + $(gb_UWINAPI) \ +)) + +$(eval $(call gb_CppunitTest_use_components,connectivity_ado,\ + configmgr/source/configmgr \ + i18npool/util/i18npool \ + connectivity/source/drivers/ado/ado \ + ucb/source/core/ucb1 \ + ucb/source/ucp/file/ucpfile1 \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,connectivity_ado)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Module_connectivity.mk b/connectivity/Module_connectivity.mk index ab3a4513094f..989bc81634d6 100644 --- a/connectivity/Module_connectivity.mk +++ b/connectivity/Module_connectivity.mk @@ -144,6 +144,12 @@ $(eval $(call gb_Module_add_check_targets,connectivity,\ endif +ifeq ($(GUI),WNT) +$(eval $(call gb_Module_add_check_targets,connectivity,\ + CppunitTest_connectivity_ado \ +)) +endif + ifneq ($(filter QADEVOOO,$(BUILD_TYPE)),) $(eval $(call gb_Module_add_subsequentcheck_targets,connectivity,\ Jar_ConnectivityTools \ diff --git a/connectivity/qa/connectivity/ado/DriverTest.cxx b/connectivity/qa/connectivity/ado/DriverTest.cxx new file mode 100755 index 000000000000..c2e357e4f73f --- /dev/null +++ b/connectivity/qa/connectivity/ado/DriverTest.cxx @@ -0,0 +1,147 @@ +/* -*- 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 "ado/ADriver.hxx" +//#include "ado/AConnection.hxx" +//#include <com/sun/star/sdbc/XDriver.hpp> + +#include "ado/AConnection.hxx" +#include "ado/ADatabaseMetaData.hxx" +#include "ado/ADriver.hxx" +#include "ado/AStatement.hxx" +#include "ado/ACallableStatement.hxx" +#include "ado/APreparedStatement.hxx" +#include "ado/ACatalog.hxx" +#include <com/sun/star/sdbc/ColumnValue.hpp> +#include <com/sun/star/sdbc/TransactionIsolation.hpp> +#include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/lang/DisposedException.hpp> +#include <cppuhelper/typeprovider.hxx> +#include "connectivity/dbexception.hxx" +#include <osl/file.hxx> +#include "resource/ado_res.hrc" + + +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::uno; + +namespace connectivity { namespace ado { + + +class AdoDriverTest: public test::BootstrapFixture +{ +public: + AdoDriverTest() : test::BootstrapFixture(false, false) {}; + + void test_metadata(); + void test_select_default_all(); + + virtual void setUp(); + virtual void tearDown(); + + CPPUNIT_TEST_SUITE(AdoDriverTest); + + CPPUNIT_TEST(test_metadata); + CPPUNIT_TEST(test_select_default_all); + CPPUNIT_TEST_SUITE_END(); + +private: + Reference<XInterface> m_xAdoComponent; + Reference<XConnection> m_xConnection; +}; + +void AdoDriverTest::setUp() +{ + test::BootstrapFixture::setUp(); + m_xAdoComponent = getMultiServiceFactory()->createInstance("com.sun.star.comp.sdbc.ado.ODriver"); + CPPUNIT_ASSERT_MESSAGE("no ado component!", m_xAdoComponent.is()); + + // is this the best way to pass test file through URL? + // may be take a custom Sequence< PropertyValue > route? + OUString url = OUString("sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=") + + getPathFromSrc("/connectivity/qa/connectivity/ado/TS001018407.mdb"); + + Sequence< PropertyValue > info; + Reference< XDriver> xDriver(m_xAdoComponent, UNO_QUERY); + if (!xDriver.is()) + { + CPPUNIT_ASSERT_MESSAGE("cannot connect to ado driver!", xDriver.is()); + } + + m_xConnection = xDriver->connect(url, info); + if (!m_xConnection.is()) + { + CPPUNIT_ASSERT_MESSAGE("cannot connect to students data soure!", m_xConnection.is()); + } +} + +void AdoDriverTest::tearDown() +{ + m_xAdoComponent = 0; + test::BootstrapFixture::tearDown(); +} + +void AdoDriverTest::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()); + } +} + +void AdoDriverTest::test_select_default_all() +{ + const OUString sql = "select \"FirstName\" from \"Students\" ORDER BY \"FirstName\""; + 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")); +*/ +} + +CPPUNIT_TEST_SUITE_REGISTRATION(AdoDriverTest); + +}} + +CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/connectivity/qa/connectivity/ado/TS001018407.mdb b/connectivity/qa/connectivity/ado/TS001018407.mdb Binary files differnew file mode 100755 index 000000000000..abe9f5ee33b3 --- /dev/null +++ b/connectivity/qa/connectivity/ado/TS001018407.mdb |