[Libreoffice-commits] core.git: 2 commits - dbaccess/CppunitTest_dbaccess_firebird_test.mk dbaccess/qa
Andrzej J.R. Hunt
andrzej at ahunt.org
Tue Sep 10 03:29:09 PDT 2013
dbaccess/CppunitTest_dbaccess_firebird_test.mk | 1
dbaccess/qa/unit/dbtest_base.cxx | 86 +++++++++++++++++++++++++
dbaccess/qa/unit/firebird.cxx | 63 ++----------------
3 files changed, 96 insertions(+), 54 deletions(-)
New commits:
commit e4b07b2917154d68019e37b4eadf81a8b73d666b
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Tue Sep 10 11:27:15 2013 +0100
Add missing component to firebird unit test.
(Windows throws an Error on this.)
Change-Id: Ica3aeac294d3a32a4faa6837309a0fb5d8d15b92
diff --git a/dbaccess/CppunitTest_dbaccess_firebird_test.mk b/dbaccess/CppunitTest_dbaccess_firebird_test.mk
index 3f5df09..4237e0d 100644
--- a/dbaccess/CppunitTest_dbaccess_firebird_test.mk
+++ b/dbaccess/CppunitTest_dbaccess_firebird_test.mk
@@ -48,6 +48,7 @@ $(eval $(call gb_CppunitTest_use_components,dbaccess_firebird_test,\
filter/source/config/cache/filterconfig1 \
framework/util/fwk \
i18npool/util/i18npool \
+ linguistic/source/lng \
package/source/xstor/xstor \
package/util/package2 \
sax/source/expatwrap/expwrap \
commit f7383e8b58903410210ff72348636976f9229be2
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Tue Sep 10 10:19:26 2013 +0100
Split reusable parts of Firebird unit test into DBTestBase.
Change-Id: I6b2d131e0e4b53bb6b4cec69c5b0e99b8b9e74a7
diff --git a/dbaccess/qa/unit/dbtest_base.cxx b/dbaccess/qa/unit/dbtest_base.cxx
new file mode 100644
index 0000000..4b4e3a3
--- /dev/null
+++ b/dbaccess/qa/unit/dbtest_base.cxx
@@ -0,0 +1,86 @@
+/* -*- 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 <comphelper/processfactory.hxx>
+#include <test/bootstrapfixture.hxx>
+#include <unotest/macros_test.hxx>
+
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::uno;
+
+class DBTestBase
+ : public ::test::BootstrapFixture
+ , public ::unotest::MacrosTest
+{
+private:
+ static OUString our_sFilePath;
+public:
+ virtual void setUp();
+ virtual void tearDown();
+
+ uno::Reference< XOfficeDatabaseDocument >
+ getDocumentForFileName(OUString sFileName);
+
+ uno::Reference< XConnection >
+ getConnectionForDocument(
+ uno::Reference< XOfficeDatabaseDocument >& xDocument);
+};
+
+OUString DBTestBase::our_sFilePath("/dbaccess/qa/unit/data/");
+
+uno::Reference< XOfficeDatabaseDocument >
+ DBTestBase::getDocumentForFileName(OUString sFileName)
+{
+ uno::Reference< lang::XComponent > xComponent =
+ loadFromDesktop(getSrcRootURL() + our_sFilePath + sFileName);
+ CPPUNIT_ASSERT(xComponent.is());
+
+ uno::Reference< XOfficeDatabaseDocument > xDocument(xComponent, UNO_QUERY);
+ CPPUNIT_ASSERT(xDocument.is());
+
+ return xDocument;
+}
+
+uno::Reference< XConnection > DBTestBase::getConnectionForDocument(
+ uno::Reference< XOfficeDatabaseDocument >& xDocument)
+{
+ uno::Reference< XDataSource > xDataSource = xDocument->getDataSource();
+ CPPUNIT_ASSERT(xDataSource.is());
+
+ uno::Reference< XConnection > xConnection = xDataSource->getConnection("","");
+ CPPUNIT_ASSERT(xConnection.is());
+
+ return xConnection;
+}
+
+
+void DBTestBase::setUp()
+{
+ ::test::BootstrapFixture::setUp();
+
+ mxDesktop = ::com::sun::star::frame::Desktop::create(
+ ::comphelper::getProcessComponentContext());
+ CPPUNIT_ASSERT(mxDesktop.is());
+}
+
+void DBTestBase::tearDown()
+{
+ test::BootstrapFixture::tearDown();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/qa/unit/firebird.cxx b/dbaccess/qa/unit/firebird.cxx
index fb8234d..183d83d 100644
--- a/dbaccess/qa/unit/firebird.cxx
+++ b/dbaccess/qa/unit/firebird.cxx
@@ -7,34 +7,24 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include <comphelper/processfactory.hxx>
-#include <test/bootstrapfixture.hxx>
-#include <unotest/macros_test.hxx>
+#include "dbtest_base.cxx"
-#include <com/sun/star/frame/XModel.hpp>
-#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
#include <com/sun/star/sdbc/XColumnLocate.hpp>
#include <com/sun/star/sdbc/XConnection.hpp>
-#include <com/sun/star/sdbc/XDataSource.hpp>
#include <com/sun/star/sdbc/XResultSet.hpp>
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/sdbc/XStatement.hpp>
using namespace ::com::sun::star;
-using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::sdb;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::uno;
class FirebirdTest
- : public ::test::BootstrapFixture
- , public ::unotest::MacrosTest
+ : public DBTestBase
{
public:
- virtual void setUp();
- virtual void tearDown();
-
void testEmptyDBConnection();
void testIntegerDatabase();
@@ -44,28 +34,16 @@ public:
CPPUNIT_TEST_SUITE_END();
};
-// TODO: refactor the load file -> get Connection stuff into a separate class
-
/**
* Test the loading of an "empty" file, i.e. the embedded database has not yet
* been initialised (as occurs when a new .odb is created and opened by base).
*/
void FirebirdTest::testEmptyDBConnection()
{
- const OUString sFileName("/dbaccess/qa/unit/data/firebird_empty.odb");
-
- uno::Reference< lang::XComponent > xComponent = loadFromDesktop(
- getSrcRootURL() + sFileName);
- CPPUNIT_ASSERT(xComponent.is());
-
- uno::Reference< XOfficeDatabaseDocument > xDocument(xComponent, UNO_QUERY);
- CPPUNIT_ASSERT(xDocument.is());
+ uno::Reference< XOfficeDatabaseDocument > xDocument =
+ getDocumentForFileName("firebird_empty.odb");
- uno::Reference< XDataSource > xDataSource = xDocument->getDataSource();
- CPPUNIT_ASSERT(xDataSource.is());
-
- uno::Reference< XConnection > xConnection = xDataSource->getConnection("","");
- CPPUNIT_ASSERT(xConnection.is());
+ getConnectionForDocument(xDocument);
}
/**
@@ -74,20 +52,11 @@ void FirebirdTest::testEmptyDBConnection()
*/
void FirebirdTest::testIntegerDatabase()
{
- const OUString sFileName("/dbaccess/qa/unit/data/firebird_integer_x64le.odb");
-
- uno::Reference< lang::XComponent > xComponent = loadFromDesktop(
- getSrcRootURL() + sFileName);
- CPPUNIT_ASSERT(xComponent.is());
-
- uno::Reference< XOfficeDatabaseDocument > xDocument(xComponent, UNO_QUERY);
- CPPUNIT_ASSERT(xDocument.is());
-
- uno::Reference< XDataSource > xDataSource = xDocument->getDataSource();
- CPPUNIT_ASSERT(xDataSource.is());
+ uno::Reference< XOfficeDatabaseDocument > xDocument =
+ getDocumentForFileName("firebird_integer_x64le.odb");
- uno::Reference< XConnection > xConnection = xDataSource->getConnection("","");
- CPPUNIT_ASSERT(xConnection.is());
+ uno::Reference< XConnection > xConnection =
+ getConnectionForDocument(xDocument);
uno::Reference< XStatement > xStatement = xConnection->createStatement();
CPPUNIT_ASSERT(xStatement.is());
@@ -116,20 +85,6 @@ void FirebirdTest::testIntegerDatabase()
CPPUNIT_ASSERT(!xResultSet->next()); // Should only be one row
}
-void FirebirdTest::setUp()
-{
- ::test::BootstrapFixture::setUp();
-
- mxDesktop = ::com::sun::star::frame::Desktop::create(
- ::comphelper::getProcessComponentContext());
- CPPUNIT_ASSERT(mxDesktop.is());
-}
-
-void FirebirdTest::tearDown()
-{
- test::BootstrapFixture::tearDown();
-}
-
CPPUNIT_TEST_SUITE_REGISTRATION(FirebirdTest);
CPPUNIT_PLUGIN_IMPLEMENT();
More information about the Libreoffice-commits
mailing list