Mercurial > hg > orthanc-databases
annotate MySQL/UnitTests/UnitTestsMain.cpp @ 124:a981ef52bcf6
fix build with postgresql 11
author | jodogne |
---|---|
date | Fri, 08 Feb 2019 18:10:41 +0100 |
parents | 714c5d2bee76 |
children | e26690365c25 |
rev | line source |
---|---|
0 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
67 | 5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #include "../Plugins/MySQLIndex.h" | |
17 | 23 #include "../Plugins/MySQLStorageArea.h" |
0 | 24 |
25 OrthancDatabases::MySQLParameters globalParameters_; | |
26 | |
17 | 27 #include "../../Framework/Common/Integer64Value.h" |
28 #include "../../Framework/MySQL/MySQLDatabase.h" | |
29 #include "../../Framework/MySQL/MySQLResult.h" | |
30 #include "../../Framework/MySQL/MySQLStatement.h" | |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
31 #include "../../Framework/MySQL/MySQLTransaction.h" |
0 | 32 #include "../../Framework/Plugins/IndexUnitTests.h" |
33 | |
40
5600949bfb12
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
34 #include <Core/HttpClient.h> |
0 | 35 #include <Core/Logging.h> |
42 | 36 #include <Core/Toolbox.h> |
0 | 37 |
38 #include <gtest/gtest.h> | |
39 | |
40 | |
41 TEST(MySQLIndex, Lock) | |
42 { | |
43 OrthancDatabases::MySQLParameters noLock = globalParameters_; | |
44 noLock.SetLock(false); | |
45 | |
46 OrthancDatabases::MySQLParameters lock = globalParameters_; | |
47 lock.SetLock(true); | |
48 | |
49 OrthancDatabases::MySQLIndex db1(noLock); | |
50 db1.SetClearAll(true); | |
51 db1.Open(); | |
52 | |
53 { | |
54 OrthancDatabases::MySQLIndex db2(lock); | |
55 db2.Open(); | |
56 | |
57 OrthancDatabases::MySQLIndex db3(lock); | |
58 ASSERT_THROW(db3.Open(), Orthanc::OrthancException); | |
59 } | |
60 | |
61 OrthancDatabases::MySQLIndex db4(lock); | |
62 db4.Open(); | |
63 } | |
64 | |
65 | |
17 | 66 static int64_t CountFiles(OrthancDatabases::MySQLDatabase& db) |
67 { | |
68 OrthancDatabases::Query query("SELECT COUNT(*) FROM StorageArea", true); | |
69 OrthancDatabases::MySQLStatement s(db, query); | |
70 OrthancDatabases::MySQLTransaction t(db); | |
71 OrthancDatabases::Dictionary d; | |
72 std::auto_ptr<OrthancDatabases::IResult> result(s.Execute(t, d)); | |
73 return dynamic_cast<const OrthancDatabases::Integer64Value&>(result->GetField(0)).GetValue(); | |
74 } | |
75 | |
76 | |
77 TEST(MySQL, StorageArea) | |
78 { | |
79 OrthancDatabases::MySQLStorageArea storageArea(globalParameters_); | |
80 storageArea.SetClearAll(true); | |
81 | |
82 { | |
83 OrthancDatabases::DatabaseManager::Transaction transaction(storageArea.GetManager()); | |
84 OrthancDatabases::MySQLDatabase& db = | |
85 dynamic_cast<OrthancDatabases::MySQLDatabase&>(transaction.GetDatabase()); | |
86 | |
87 ASSERT_EQ(0, CountFiles(db)); | |
88 | |
89 for (int i = 0; i < 10; i++) | |
90 { | |
91 std::string uuid = boost::lexical_cast<std::string>(i); | |
92 std::string value = "Value " + boost::lexical_cast<std::string>(i * 2); | |
93 storageArea.Create(transaction, uuid, value.c_str(), value.size(), OrthancPluginContentType_Unknown); | |
94 } | |
95 | |
96 std::string tmp; | |
97 ASSERT_THROW(storageArea.ReadToString(tmp, transaction, "nope", OrthancPluginContentType_Unknown), | |
98 Orthanc::OrthancException); | |
99 | |
100 ASSERT_EQ(10, CountFiles(db)); | |
101 storageArea.Remove(transaction, "5", OrthancPluginContentType_Unknown); | |
102 | |
103 ASSERT_EQ(9, CountFiles(db)); | |
104 | |
105 for (int i = 0; i < 10; i++) | |
106 { | |
107 std::string uuid = boost::lexical_cast<std::string>(i); | |
108 std::string expected = "Value " + boost::lexical_cast<std::string>(i * 2); | |
109 std::string content; | |
110 | |
111 if (i == 5) | |
112 { | |
113 ASSERT_THROW(storageArea.ReadToString(content, transaction, uuid, OrthancPluginContentType_Unknown), | |
114 Orthanc::OrthancException); | |
115 } | |
116 else | |
117 { | |
118 storageArea.ReadToString(content, transaction, uuid, OrthancPluginContentType_Unknown); | |
119 ASSERT_EQ(expected, content); | |
120 } | |
121 } | |
122 | |
123 for (int i = 0; i < 10; i++) | |
124 { | |
125 storageArea.Remove(transaction, boost::lexical_cast<std::string>(i), | |
126 OrthancPluginContentType_Unknown); | |
127 } | |
128 | |
129 ASSERT_EQ(0, CountFiles(db)); | |
130 | |
131 transaction.Commit(); | |
132 } | |
133 } | |
134 | |
135 | |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
136 TEST(MySQL, ImplicitTransaction) |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
137 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
138 OrthancDatabases::MySQLDatabase::ClearDatabase(globalParameters_); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
139 OrthancDatabases::MySQLDatabase db(globalParameters_); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
140 db.Open(); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
141 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
142 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
143 OrthancDatabases::MySQLTransaction t(db); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
144 ASSERT_FALSE(db.DoesTableExist(t, "test")); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
145 ASSERT_FALSE(db.DoesTableExist(t, "test2")); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
146 } |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
147 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
148 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
149 std::auto_ptr<OrthancDatabases::ITransaction> t(db.CreateTransaction(false)); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
150 ASSERT_FALSE(t->IsImplicit()); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
151 } |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
152 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
153 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
154 OrthancDatabases::Query query("CREATE TABLE test(id INT)", false); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
155 std::auto_ptr<OrthancDatabases::IPrecompiledStatement> s(db.Compile(query)); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
156 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
157 std::auto_ptr<OrthancDatabases::ITransaction> t(db.CreateTransaction(true)); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
158 ASSERT_TRUE(t->IsImplicit()); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
159 ASSERT_THROW(t->Commit(), Orthanc::OrthancException); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
160 ASSERT_THROW(t->Rollback(), Orthanc::OrthancException); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
161 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
162 OrthancDatabases::Dictionary args; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
163 t->ExecuteWithoutResult(*s, args); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
164 ASSERT_THROW(t->Rollback(), Orthanc::OrthancException); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
165 t->Commit(); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
166 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
167 ASSERT_THROW(t->Commit(), Orthanc::OrthancException); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
168 } |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
169 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
170 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
171 // An implicit transaction does not need to be explicitely committed |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
172 OrthancDatabases::Query query("CREATE TABLE test2(id INT)", false); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
173 std::auto_ptr<OrthancDatabases::IPrecompiledStatement> s(db.Compile(query)); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
174 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
175 std::auto_ptr<OrthancDatabases::ITransaction> t(db.CreateTransaction(true)); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
176 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
177 OrthancDatabases::Dictionary args; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
178 t->ExecuteWithoutResult(*s, args); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
179 } |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
180 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
181 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
182 OrthancDatabases::MySQLTransaction t(db); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
183 ASSERT_TRUE(db.DoesTableExist(t, "test")); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
184 ASSERT_TRUE(db.DoesTableExist(t, "test2")); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
185 } |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
186 } |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
187 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
188 |
0 | 189 int main(int argc, char **argv) |
190 { | |
191 if (argc < 5) | |
192 { | |
46
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
42
diff
changeset
|
193 std::cerr |
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
42
diff
changeset
|
194 #if !defined(_WIN32) |
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
42
diff
changeset
|
195 << "Usage (UNIX socket): " << argv[0] << " <socket> <username> <password> <database>" |
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
42
diff
changeset
|
196 << std::endl |
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
42
diff
changeset
|
197 #endif |
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
42
diff
changeset
|
198 << "Usage (TCP connection): " << argv[0] << " <host> <port> <username> <password> <database>" |
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
42
diff
changeset
|
199 << std::endl << std::endl |
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
42
diff
changeset
|
200 #if !defined(_WIN32) |
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
42
diff
changeset
|
201 << "Example (UNIX socket): " << argv[0] << " /var/run/mysqld/mysqld.sock root root orthanctest" |
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
42
diff
changeset
|
202 << std::endl |
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
42
diff
changeset
|
203 #endif |
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
42
diff
changeset
|
204 << "Example (TCP connection): " << argv[0] << " localhost 3306 root root orthanctest" |
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
42
diff
changeset
|
205 << std::endl << std::endl; |
0 | 206 return -1; |
207 } | |
208 | |
22
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
209 std::vector<std::string> args; |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
210 for (int i = 1; i < argc; i++) |
16
9e419261f1c9
mysql storage area working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
211 { |
22
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
212 // Ignore arguments beginning with "-" to allow passing arguments |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
213 // to Google Test such as "--gtest_filter=" |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
214 if (argv[i] != NULL && |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
215 argv[i][0] != '-') |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
216 { |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
217 args.push_back(std::string(argv[i])); |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
218 } |
16
9e419261f1c9
mysql storage area working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
219 } |
22
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
220 |
0 | 221 ::testing::InitGoogleTest(&argc, argv); |
222 Orthanc::Logging::Initialize(); | |
223 Orthanc::Logging::EnableInfoLevel(true); | |
224 Orthanc::Logging::EnableTraceLevel(true); | |
42 | 225 Orthanc::Toolbox::InitializeOpenSsl(); |
40
5600949bfb12
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
226 Orthanc::HttpClient::GlobalInitialize(); |
22
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
227 |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
228 if (args.size() == 4) |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
229 { |
46
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
42
diff
changeset
|
230 // UNIX socket flavor |
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
42
diff
changeset
|
231 globalParameters_.SetHost(""); |
22
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
232 globalParameters_.SetUnixSocket(args[0]); |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
233 globalParameters_.SetUsername(args[1]); |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
234 globalParameters_.SetPassword(args[2]); |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
235 globalParameters_.SetDatabase(args[3]); |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
236 } |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
237 else if (args.size() == 5) |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
238 { |
46
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
42
diff
changeset
|
239 // TCP connection flavor |
22
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
240 globalParameters_.SetHost(args[0]); |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
241 globalParameters_.SetPort(boost::lexical_cast<unsigned int>(args[1])); |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
242 globalParameters_.SetUsername(args[2]); |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
243 globalParameters_.SetPassword(args[3]); |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
244 globalParameters_.SetDatabase(args[4]); |
46
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
42
diff
changeset
|
245 |
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
42
diff
changeset
|
246 // Force the use of TCP on localhost, even if UNIX sockets are available |
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
42
diff
changeset
|
247 globalParameters_.SetUnixSocket(""); |
22
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
248 } |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
249 else |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
250 { |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
251 LOG(ERROR) << "Bad number of arguments"; |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
252 return -1; |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
253 } |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
254 |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
255 Json::Value config; |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
256 globalParameters_.Format(config); |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
257 std::cout << "Parameters of the MySQL connection: " << std::endl |
1e9bad493475
prevent running unit tests on a non-existing db
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
17
diff
changeset
|
258 << config.toStyledString() << std::endl; |
0 | 259 |
260 int result = RUN_ALL_TESTS(); | |
261 | |
40
5600949bfb12
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
262 Orthanc::HttpClient::GlobalFinalize(); |
42 | 263 Orthanc::Toolbox::FinalizeOpenSsl(); |
264 OrthancDatabases::MySQLDatabase::GlobalFinalization(); | |
0 | 265 Orthanc::Logging::Finalize(); |
266 | |
267 return result; | |
268 } |