LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / dbaccess / qa / unit / firebird.cxx
blobe67a4d10c09717dbf4b78eb7be31eca57248afb6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include "dbtest_base.cxx"
12 #include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
13 #include <com/sun/star/sdbc/XColumnLocate.hpp>
14 #include <com/sun/star/sdbc/XConnection.hpp>
15 #include <com/sun/star/sdbc/XResultSet.hpp>
16 #include <com/sun/star/sdbc/XRow.hpp>
17 #include <com/sun/star/sdbc/XStatement.hpp>
19 using namespace ::com::sun::star;
20 using namespace ::com::sun::star::sdb;
21 using namespace ::com::sun::star::sdbc;
22 using namespace ::com::sun::star::uno;
24 class FirebirdTest
25 : public DBTestBase
27 public:
28 void testEmptyDBConnection();
29 void testIntegerDatabase();
31 CPPUNIT_TEST_SUITE(FirebirdTest);
32 CPPUNIT_TEST(testEmptyDBConnection);
33 CPPUNIT_TEST(testIntegerDatabase);
34 CPPUNIT_TEST_SUITE_END();
37 /**
38 * Test the loading of an "empty" file, i.e. the embedded database has not yet
39 * been initialised (as occurs when a new .odb is created and opened by base).
41 void FirebirdTest::testEmptyDBConnection()
43 auto const tmp = createTempCopy(u"firebird_empty.odb");
44 uno::Reference< XOfficeDatabaseDocument > xDocument =
45 getDocumentForUrl(tmp.GetURL());
47 getConnectionForDocument(xDocument);
49 closeDocument(uno::Reference<lang::XComponent>(xDocument, uno::UNO_QUERY));
52 /**
53 * Test reading of integers from a known .odb to verify that the data
54 * can still be read on all systems.
56 void FirebirdTest::testIntegerDatabase()
58 uno::Reference< XOfficeDatabaseDocument > xDocument =
59 getDocumentForFileName(u"firebird_integer_ods12.odb");
61 uno::Reference< XConnection > xConnection =
62 getConnectionForDocument(xDocument);
64 uno::Reference< XStatement > xStatement = xConnection->createStatement();
65 CPPUNIT_ASSERT(xStatement.is());
67 uno::Reference< XResultSet > xResultSet = xStatement->executeQuery(
68 "SELECT * FROM TESTTABLE");
69 CPPUNIT_ASSERT(xResultSet.is());
70 CPPUNIT_ASSERT(xResultSet->next());
72 uno::Reference< XRow > xRow(xResultSet, UNO_QUERY);
73 CPPUNIT_ASSERT(xRow.is());
74 uno::Reference< XColumnLocate > xColumnLocate(xRow, UNO_QUERY);
75 CPPUNIT_ASSERT(xColumnLocate.is());
77 CPPUNIT_ASSERT_EQUAL(sal_Int16(-30000),
78 xRow->getShort(xColumnLocate->findColumn("_SMALLINT")));
79 CPPUNIT_ASSERT_EQUAL(sal_Int32(-2100000000),
80 xRow->getInt(xColumnLocate->findColumn("_INT")));
81 CPPUNIT_ASSERT_EQUAL(SAL_CONST_INT64(-9000000000000000000),
82 xRow->getLong(xColumnLocate->findColumn("_BIGINT")));
83 CPPUNIT_ASSERT_EQUAL(OUString("5"),
84 xRow->getString(xColumnLocate->findColumn("_CHAR")));
85 CPPUNIT_ASSERT_EQUAL(OUString("5"),
86 xRow->getString(xColumnLocate->findColumn("_VARCHAR")));
88 CPPUNIT_ASSERT(!xResultSet->next()); // Should only be one row
90 closeDocument(uno::Reference<lang::XComponent>(xDocument, uno::UNO_QUERY));
93 CPPUNIT_TEST_SUITE_REGISTRATION(FirebirdTest);
95 CPPUNIT_PLUGIN_IMPLEMENT();
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */