sptk2 logo
SPTK Home Page
DatabaseTests.h
1/*
2╔══════════════════════════════════════════════════════════════════════════════╗
3║ SIMPLY POWERFUL TOOLKIT (SPTK) ║
4╟──────────────────────────────────────────────────────────────────────────────╢
5║ copyright © 1999-2022 Alexey Parshin. All rights reserved. ║
6║ email alexeyp@gmail.com ║
7╚══════════════════════════════════════════════════════════════════════════════╝
8┌──────────────────────────────────────────────────────────────────────────────┐
9│ This library is free software; you can redistribute it and/or modify it │
10│ under the terms of the GNU Library General Public License as published by │
11│ the Free Software Foundation; either version 2 of the License, or (at your │
12│ option) any later version. │
13│ │
14│ This library is distributed in the hope that it will be useful, but │
15│ WITHOUT ANY WARRANTY; without even the implied warranty of │
16│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library │
17│ General Public License for more details. │
18│ │
19│ You should have received a copy of the GNU Library General Public License │
20│ along with this library; if not, write to the Free Software Foundation, │
21│ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. │
22│ │
23│ Please report all bugs and problems to alexeyp@gmail.com. │
24└──────────────────────────────────────────────────────────────────────────────┘
25*/
26
27#pragma once
28
29#include "AutoDatabaseConnection.h"
30#include "DatabaseConnectionString.h"
31
32namespace sptk {
33
37class SP_EXPORT DatabaseTests
38{
39public:
44
50 void addDatabaseConnection(const DatabaseConnectionString& connectionString);
51
56 std::vector<DatabaseConnectionString> connectionStrings() const;
57
64
69 static void testConnect(const DatabaseConnectionString& connectionString);
70
75 static void testSelect(const DatabaseConnectionString& connectionString);
76
81 static void testSelect(DatabaseConnectionPool& connectionPool);
82
87 static void testDDL(const DatabaseConnectionString& connectionString);
88
93 static void testQueryInsertDate(const DatabaseConnectionString& connectionString);
94
99 static void testQueryInsertDateTime(const DatabaseConnectionString& connectionString);
100
105 static void testQueryParameters(const DatabaseConnectionString& connectionString);
106
111 static void testInsertQuery(const DatabaseConnectionString& connectionString);
112
117 static void testInsertQueryDirect(const DatabaseConnectionString& connectionString);
118
123 static void testTransaction(const DatabaseConnectionString& connectionString);
124
129 static void testBulkInsert(const DatabaseConnectionString& connectionString);
130
136 static void testBulkInsertPerformance(const DatabaseConnectionString& connectionString, size_t recordCount);
137
142 static void testBatchSQL(const DatabaseConnectionString& connectionString);
143
144
149 static void testBLOB(const DatabaseConnectionString& connectionString);
150
155
156private:
160 static DatabaseTests _databaseTests;
161
165 std::map<String, DatabaseConnectionString> m_connectionStrings;
166
173 static size_t countRowsInTable(const DatabaseConnection& db, const String& table);
174
180 static void testTransaction(DatabaseConnection db, bool commit);
181
188 static void createTestTable(DatabaseConnection db, bool autoPrepare = true, bool withBlob = false);
189
194 static void createTestTableWithSerial(DatabaseConnection db);
195
202 static void createOracleAutoIncrement(const DatabaseConnection& db, const String& tableName, const String& columnName);
203};
204
205} // namespace sptk
Definition: DatabaseConnectionPool.h:96
Definition: DatabaseConnectionString.h:56
Definition: DatabaseTests.h:38
static void testInsertQuery(const DatabaseConnectionString &connectionString)
static void testSelect(const DatabaseConnectionString &connectionString)
static void testQueryInsertDate(const DatabaseConnectionString &connectionString)
static void testBLOB(const DatabaseConnectionString &connectionString)
static void testQueryInsertDateTime(const DatabaseConnectionString &connectionString)
static void testBulkInsert(const DatabaseConnectionString &connectionString)
void addDatabaseConnection(const DatabaseConnectionString &connectionString)
static void testBatchSQL(const DatabaseConnectionString &connectionString)
static void testTransaction(const DatabaseConnectionString &connectionString)
static DatabaseTests & tests()
std::vector< DatabaseConnectionString > connectionStrings() const
static void testDDL(const DatabaseConnectionString &connectionString)
DatabaseConnectionString connectionString(const String &driverName) const
static void testBulkInsertPerformance(const DatabaseConnectionString &connectionString, size_t recordCount)
static void testQueryParameters(const DatabaseConnectionString &connectionString)
static void testInsertQueryDirect(const DatabaseConnectionString &connectionString)
static void testSelect(DatabaseConnectionPool &connectionPool)
static void testConnect(const DatabaseConnectionString &connectionString)
Definition: String.h:49

Fri Oct 14 2022 09:58:31: SPTK 5.4.1