2013-09-07 17:32:20 +01:00
|
|
|
/* -*- 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/.
|
|
|
|
*/
|
|
|
|
|
2013-09-10 10:19:26 +01:00
|
|
|
#include "dbtest_base.cxx"
|
2013-09-07 17:32:20 +01:00
|
|
|
|
|
|
|
#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
|
2013-09-10 08:35:51 +01:00
|
|
|
#include <com/sun/star/sdbc/XColumnLocate.hpp>
|
2013-09-07 17:32:20 +01:00
|
|
|
#include <com/sun/star/sdbc/XConnection.hpp>
|
2013-09-10 08:35:51 +01:00
|
|
|
#include <com/sun/star/sdbc/XResultSet.hpp>
|
|
|
|
#include <com/sun/star/sdbc/XRow.hpp>
|
|
|
|
#include <com/sun/star/sdbc/XStatement.hpp>
|
2013-09-07 17:32:20 +01:00
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::sdb;
|
|
|
|
using namespace ::com::sun::star::sdbc;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
|
|
|
|
class FirebirdTest
|
2013-09-10 10:19:26 +01:00
|
|
|
: public DBTestBase
|
2013-09-07 17:32:20 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
void testEmptyDBConnection();
|
2013-09-10 08:35:51 +01:00
|
|
|
void testIntegerDatabase();
|
2013-09-07 17:32:20 +01:00
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE(FirebirdTest);
|
|
|
|
CPPUNIT_TEST(testEmptyDBConnection);
|
2013-09-10 08:35:51 +01:00
|
|
|
CPPUNIT_TEST(testIntegerDatabase);
|
2013-09-07 17:32:20 +01:00
|
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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()
|
|
|
|
{
|
2013-09-10 10:19:26 +01:00
|
|
|
uno::Reference< XOfficeDatabaseDocument > xDocument =
|
|
|
|
getDocumentForFileName("firebird_empty.odb");
|
2013-09-07 17:32:20 +01:00
|
|
|
|
2013-09-10 10:19:26 +01:00
|
|
|
getConnectionForDocument(xDocument);
|
2013-09-07 17:32:20 +01:00
|
|
|
}
|
|
|
|
|
2013-09-10 08:35:51 +01:00
|
|
|
/**
|
|
|
|
* Test reading of integers from a known .odb to verify that the data
|
|
|
|
* can still be read on all systems.
|
|
|
|
*/
|
|
|
|
void FirebirdTest::testIntegerDatabase()
|
|
|
|
{
|
2013-09-10 10:19:26 +01:00
|
|
|
uno::Reference< XOfficeDatabaseDocument > xDocument =
|
|
|
|
getDocumentForFileName("firebird_integer_x64le.odb");
|
2013-09-10 08:35:51 +01:00
|
|
|
|
2013-09-10 10:19:26 +01:00
|
|
|
uno::Reference< XConnection > xConnection =
|
|
|
|
getConnectionForDocument(xDocument);
|
2013-09-10 08:35:51 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2013-09-07 17:32:20 +01:00
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION(FirebirdTest);
|
|
|
|
|
|
|
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|