From 3f114eb4a2f3994b980aa607f2d4afc58e5aaa1d Mon Sep 17 00:00:00 2001 From: "Andrzej J.R. Hunt" Date: Tue, 10 Sep 2013 08:35:51 +0100 Subject: Implement firebird integer loading test. This is mainly in order to determine whether the firebird ODS is safely portable -- if testIntegerDatabase fails on non x64 / non Linux / non LE platforms then this isn't the case. Change-Id: I44eb7a774650cec27748b2058e9bb153f32742dc --- dbaccess/qa/unit/data/firebird_integer_x64le.odb | Bin 0 -> 43990 bytes dbaccess/qa/unit/firebird.cxx | 59 +++++++++++++++++++++-- 2 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 dbaccess/qa/unit/data/firebird_integer_x64le.odb (limited to 'dbaccess') diff --git a/dbaccess/qa/unit/data/firebird_integer_x64le.odb b/dbaccess/qa/unit/data/firebird_integer_x64le.odb new file mode 100644 index 000000000000..da2ec1499198 Binary files /dev/null and b/dbaccess/qa/unit/data/firebird_integer_x64le.odb differ diff --git a/dbaccess/qa/unit/firebird.cxx b/dbaccess/qa/unit/firebird.cxx index c1a72ffcfdcd..fb8234dc52c9 100644 --- a/dbaccess/qa/unit/firebird.cxx +++ b/dbaccess/qa/unit/firebird.cxx @@ -14,8 +14,12 @@ #include #include #include +#include #include #include +#include +#include +#include using namespace ::com::sun::star; using namespace ::com::sun::star::frame; @@ -31,16 +35,17 @@ public: virtual void setUp(); virtual void tearDown(); - /** - * Test that we connect to the database with an "empty" .odb file. - */ void testEmptyDBConnection(); + void testIntegerDatabase(); CPPUNIT_TEST_SUITE(FirebirdTest); CPPUNIT_TEST(testEmptyDBConnection); + CPPUNIT_TEST(testIntegerDatabase); 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). @@ -63,6 +68,54 @@ void FirebirdTest::testEmptyDBConnection() CPPUNIT_ASSERT(xConnection.is()); } +/** + * Test reading of integers from a known .odb to verify that the data + * can still be read on all systems. + */ +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< XConnection > xConnection = xDataSource->getConnection("",""); + CPPUNIT_ASSERT(xConnection.is()); + + uno::Reference< XStatement > xStatement = xConnection->createStatement(); + CPPUNIT_ASSERT(xStatement.is()); + + uno::Reference< XResultSet > xResultSet = xStatement->executeQuery( + "SELECT * FROM TESTTABLE"); + CPPUNIT_ASSERT(xResultSet.is()); + CPPUNIT_ASSERT(xResultSet->next()); + + uno::Reference< XRow > xRow(xResultSet, UNO_QUERY); + CPPUNIT_ASSERT(xRow.is()); + uno::Reference< XColumnLocate > xColumnLocate(xRow, UNO_QUERY); + CPPUNIT_ASSERT(xColumnLocate.is()); + + CPPUNIT_ASSERT(sal_Int16(-30000) == + xRow->getShort(xColumnLocate->findColumn("_SMALLINT"))); + CPPUNIT_ASSERT(sal_Int32(-2100000000) == + xRow->getInt(xColumnLocate->findColumn("_INT"))); + CPPUNIT_ASSERT(sal_Int64(-9000000000000000000) == + xRow->getLong(xColumnLocate->findColumn("_BIGINT"))); + CPPUNIT_ASSERT(OUString("5") == + xRow->getString(xColumnLocate->findColumn("_CHAR"))); + CPPUNIT_ASSERT(OUString("5") == + xRow->getString(xColumnLocate->findColumn("_VARCHAR"))); + + CPPUNIT_ASSERT(!xResultSet->next()); // Should only be one row +} + void FirebirdTest::setUp() { ::test::BootstrapFixture::setUp(); -- cgit ue='distro/collabora/lov-5.0'>distro/collabora/lov-5.0 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author