tdf#172935: Add test

Change-Id: I8144105e2135e541beb7c39ebe65afd534a883b9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208885
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
Xisco Fauli
2026-09-03 19:35:30 +02:00
parent 84129dd550
commit 029d309787
3 changed files with 147 additions and 0 deletions
@@ -0,0 +1,51 @@
# -*- 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_firebird_test))
$(eval $(call gb_CppunitTest_use_externals,connectivity_firebird_test,\
boost_headers \
libxml2 \
))
$(eval $(call gb_CppunitTest_add_exception_objects,connectivity_firebird_test, \
connectivity/qa/connectivity/firebird/firebird \
))
$(eval $(call gb_CppunitTest_use_libraries,connectivity_firebird_test, \
comphelper \
cppu \
cppuhelper \
editeng \
sal \
sfx \
subsequenttest \
svl \
test \
tl \
unotest \
utl \
vcl \
))
$(eval $(call gb_CppunitTest_use_api,connectivity_firebird_test,\
offapi \
oovbaapi \
udkapi \
))
$(eval $(call gb_CppunitTest_use_ure,connectivity_firebird_test))
$(eval $(call gb_CppunitTest_use_vcl,connectivity_firebird_test))
$(eval $(call gb_CppunitTest_use_rdb,connectivity_firebird_test,services))
$(eval $(call gb_CppunitTest_use_configuration,connectivity_firebird_test))
# vim: set noet sw=4 ts=4:
+3
View File
@@ -83,6 +83,9 @@ $(eval $(call gb_Module_add_targets,connectivity,\
Configuration_firebird \
Library_firebird_sdbc \
))
$(eval $(call gb_Module_add_check_targets,connectivity,\
CppunitTest_connectivity_firebird_test \
))
endif
ifeq ($(ENABLE_MARIADBC),TRUE)
@@ -0,0 +1,93 @@
/* -*- 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/unoapi_test.hxx>
#include <osl/file.hxx>
#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/XResultSet.hpp>
#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/sdbc/XParameters.hpp>
#include <com/sun/star/sdbc/XStatement.hpp>
#include <com/sun/star/sdbc/XDriver.hpp>
using namespace ::com::sun::star;
using namespace ::com::sun::star::sdb;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
class FirebirdTestDriver : public UnoApiTest
{
private:
Reference<XInterface> m_xFirebirdComponent;
Reference<XDriver> m_xDriver;
Sequence<PropertyValue> m_infos;
public:
FirebirdTestDriver()
: UnoApiTest(u"/connectivity/qa/connectivity/firebird/data"_ustr)
{
}
virtual void setUp() override;
void testDBConnection();
CPPUNIT_TEST_SUITE(FirebirdTestDriver);
CPPUNIT_TEST(testDBConnection);
CPPUNIT_TEST_SUITE_END();
};
void FirebirdTestDriver::setUp()
{
UnoApiTest::setUp();
m_xFirebirdComponent
= getMultiServiceFactory()->createInstance(u"com.sun.star.comp.sdbc.firebird.Driver"_ustr);
CPPUNIT_ASSERT_MESSAGE("no firebird component!", m_xFirebirdComponent.is());
m_xDriver.set(m_xFirebirdComponent, UNO_QUERY);
CPPUNIT_ASSERT_MESSAGE("cannot connect to firebird driver!", m_xDriver.is());
}
void FirebirdTestDriver::testDBConnection()
{
// Use existing database inside the firebird tarball
const OUString sDocPath(
m_directories.getURLFromWorkdir(u"/UnpackedTarball/firebird/gen/examples/employee.fdb"));
// and create a copy of it
auto const e = osl::File::copy(sDocPath, maTempFile.GetURL());
CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, e);
Reference<XConnection> xConnection
= m_xDriver->connect("sdbc:firebird:" + maTempFile.GetURL(), m_infos);
CPPUNIT_ASSERT_MESSAGE("cannot connect to data source!", xConnection.is());
uno::Reference<XStatement> xStatement = xConnection->createStatement();
CPPUNIT_ASSERT(xStatement.is());
uno::Reference<XResultSet> xRes
= xStatement->executeQuery(u"SELECT COUNTRY, CURRENCY FROM COUNTRY ORDER BY COUNTRY"_ustr);
uno::Reference<XRow> xRow(xRes, UNO_QUERY_THROW);
// assert first row
CPPUNIT_ASSERT(xRes->next());
CPPUNIT_ASSERT_EQUAL(u"Australia"_ustr, xRow->getString(1));
CPPUNIT_ASSERT_EQUAL(u"ADollar"_ustr, xRow->getString(2));
}
CPPUNIT_TEST_SUITE_REGISTRATION(FirebirdTestDriver);
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */