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
This commit is contained in:
Andrzej J.R. Hunt
2013-09-10 08:44:23 +01:00
parent 65fc052b89
commit 3f114eb4a2
2 changed files with 56 additions and 3 deletions
Binary file not shown.
+56 -3
View File
@@ -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();