diff options
author | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2013-09-10 08:35:51 +0100 |
---|---|---|
committer | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2013-09-10 08:44:23 +0100 |
commit | 3f114eb4a2f3994b980aa607f2d4afc58e5aaa1d (patch) | |
tree | 906a788ae691a6e19cc8df249f924ba7640865e2 /dbaccess/qa/unit | |
parent | 65fc052b89b029ad1e853a139f6b3817ac24452a (diff) |
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
Diffstat (limited to 'dbaccess/qa/unit')
-rw-r--r-- | dbaccess/qa/unit/data/firebird_integer_x64le.odb | bin | 0 -> 43990 bytes | |||
-rw-r--r-- | dbaccess/qa/unit/firebird.cxx | 59 |
2 files changed, 56 insertions, 3 deletions
diff --git a/dbaccess/qa/unit/data/firebird_integer_x64le.odb b/dbaccess/qa/unit/data/firebird_integer_x64le.odb Binary files differnew file mode 100644 index 000000000000..da2ec1499198 --- /dev/null +++ b/dbaccess/qa/unit/data/firebird_integer_x64le.odb 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 <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; @@ -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(); |