Mercurial > hg > orthanc
annotate OrthancFramework/UnitTestsSources/FileStorageTests.cpp @ 4094:1c89208fbba9
fix build of orthanc framework
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 30 Jun 2020 17:00:18 +0200 |
parents | e00f3d089991 |
children | bf7b9edf6b81 |
rev | line source |
---|---|
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
1 /** |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
3640
94f4a18a79cc
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
6 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
8 * modify it under the terms of the GNU General Public License as |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
9 * published by the Free Software Foundation, either version 3 of the |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
10 * License, or (at your option) any later version. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
11 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
12 * In addition, as a special exception, the copyright holders of this |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
13 * program give permission to link the code of its release with the |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
15 * that use the same license as the "OpenSSL" library), and distribute |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
16 * the linked executables. You must obey the GNU General Public License |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
17 * in all respects for all of the code used other than "OpenSSL". If you |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
18 * modify file(s) with this exception, you may extend this exception to |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
19 * your version of the file(s), but you are not obligated to do so. If |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
20 * you do not wish to do so, delete this exception statement from your |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
21 * version. If you delete this exception statement from all source files |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
22 * in the program, then also delete it here. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
23 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
24 * This program is distributed in the hope that it will be useful, but |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
25 * WITHOUT ANY WARRANTY; without even the implied warranty of |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
27 * General Public License for more details. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
28 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
29 * You should have received a copy of the GNU General Public License |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
31 **/ |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
32 |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
811
diff
changeset
|
33 |
4058
2a8bf0991be0
moved FileStorageTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
34 #if ORTHANC_UNIT_TESTS_LINK_FRAMEWORK == 1 |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
35 // Must be the first to be sure to use the Orthanc framework shared library |
4058
2a8bf0991be0
moved FileStorageTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
36 # include <OrthancFramework.h> |
2a8bf0991be0
moved FileStorageTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
37 #endif |
2a8bf0991be0
moved FileStorageTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
38 |
4062 | 39 #include <gtest/gtest.h> |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 |
4058
2a8bf0991be0
moved FileStorageTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
41 #include "../Sources/FileStorage/FilesystemStorage.h" |
2a8bf0991be0
moved FileStorageTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
42 #include "../Sources/FileStorage/StorageAccessor.h" |
2a8bf0991be0
moved FileStorageTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
43 #include "../Sources/HttpServer/BufferHttpSender.h" |
2a8bf0991be0
moved FileStorageTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
44 #include "../Sources/HttpServer/FilesystemHttpSender.h" |
2a8bf0991be0
moved FileStorageTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
45 #include "../Sources/Logging.h" |
2a8bf0991be0
moved FileStorageTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
46 #include "../Sources/OrthancException.h" |
2a8bf0991be0
moved FileStorageTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
47 #include "../Sources/Toolbox.h" |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 |
4062 | 49 #include <ctype.h> |
50 | |
51 | |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 using namespace Orthanc; |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 |
712 | 54 |
55 static void StringToVector(std::vector<uint8_t>& v, | |
56 const std::string& s) | |
57 { | |
58 v.resize(s.size()); | |
59 for (size_t i = 0; i < s.size(); i++) | |
60 v[i] = s[i]; | |
61 } | |
62 | |
63 | |
1123 | 64 TEST(FilesystemStorage, Basic) |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 { |
1123 | 66 FilesystemStorage s("UnitTestsStorage"); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 |
2512
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
68 std::string data = Toolbox::GenerateUuid(); |
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
69 std::string uid = Toolbox::GenerateUuid(); |
1135
67c3c1e4a6e0
index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1126
diff
changeset
|
70 s.Create(uid.c_str(), &data[0], data.size(), FileContentType_Unknown); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 std::string d; |
1126
bf67431a7383
handling of file content type in IStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1124
diff
changeset
|
72 s.Read(d, uid, FileContentType_Unknown); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 ASSERT_EQ(d.size(), data.size()); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 ASSERT_FALSE(memcmp(&d[0], &data[0], data.size())); |
1122
1d60316c3618
simplifications in FileStorage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
75 ASSERT_EQ(s.GetSize(uid), data.size()); |
712 | 76 } |
77 | |
1123 | 78 TEST(FilesystemStorage, Basic2) |
712 | 79 { |
1123 | 80 FilesystemStorage s("UnitTestsStorage"); |
712 | 81 |
82 std::vector<uint8_t> data; | |
2512
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
83 StringToVector(data, Toolbox::GenerateUuid()); |
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
84 std::string uid = Toolbox::GenerateUuid(); |
1135
67c3c1e4a6e0
index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1126
diff
changeset
|
85 s.Create(uid.c_str(), &data[0], data.size(), FileContentType_Unknown); |
712 | 86 std::string d; |
1126
bf67431a7383
handling of file content type in IStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1124
diff
changeset
|
87 s.Read(d, uid, FileContentType_Unknown); |
712 | 88 ASSERT_EQ(d.size(), data.size()); |
89 ASSERT_FALSE(memcmp(&d[0], &data[0], data.size())); | |
1122
1d60316c3618
simplifications in FileStorage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
90 ASSERT_EQ(s.GetSize(uid), data.size()); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 } |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 |
1123 | 93 TEST(FilesystemStorage, EndToEnd) |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 { |
1123 | 95 FilesystemStorage s("UnitTestsStorage"); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 s.Clear(); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 std::list<std::string> u; |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 for (unsigned int i = 0; i < 10; i++) |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 { |
2512
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
101 std::string t = Toolbox::GenerateUuid(); |
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
102 std::string uid = Toolbox::GenerateUuid(); |
1135
67c3c1e4a6e0
index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1126
diff
changeset
|
103 s.Create(uid.c_str(), &t[0], t.size(), FileContentType_Unknown); |
67c3c1e4a6e0
index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1126
diff
changeset
|
104 u.push_back(uid); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 } |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 std::set<std::string> ss; |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 s.ListAllFiles(ss); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 ASSERT_EQ(10u, ss.size()); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 unsigned int c = 0; |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 for (std::list<std::string>::iterator |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 i = u.begin(); i != u.end(); i++, c++) |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 { |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 ASSERT_TRUE(ss.find(*i) != ss.end()); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 if (c < 5) |
1126
bf67431a7383
handling of file content type in IStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1124
diff
changeset
|
117 s.Remove(*i, FileContentType_Unknown); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 } |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 s.ListAllFiles(ss); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 ASSERT_EQ(5u, ss.size()); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 s.Clear(); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 s.ListAllFiles(ss); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 ASSERT_EQ(0u, ss.size()); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 } |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1514
diff
changeset
|
129 TEST(StorageAccessor, NoCompression) |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 { |
1123 | 131 FilesystemStorage s("UnitTestsStorage"); |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1514
diff
changeset
|
132 StorageAccessor accessor(s); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 std::string data = "Hello world"; |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1514
diff
changeset
|
135 FileInfo info = accessor.Write(data, FileContentType_Dicom, CompressionType_None, true); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 std::string r; |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1514
diff
changeset
|
138 accessor.Read(r, info); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 ASSERT_EQ(data, r); |
232
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
141 ASSERT_EQ(CompressionType_None, info.GetCompressionType()); |
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
142 ASSERT_EQ(11u, info.GetUncompressedSize()); |
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
143 ASSERT_EQ(11u, info.GetCompressedSize()); |
233 | 144 ASSERT_EQ(FileContentType_Dicom, info.GetContentType()); |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1514
diff
changeset
|
145 ASSERT_EQ("3e25960a79dbc69b674cd4ec67a72c62", info.GetUncompressedMD5()); |
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1514
diff
changeset
|
146 ASSERT_EQ(info.GetUncompressedMD5(), info.GetCompressedMD5()); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 } |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1514
diff
changeset
|
150 TEST(StorageAccessor, Compression) |
712 | 151 { |
1123 | 152 FilesystemStorage s("UnitTestsStorage"); |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1514
diff
changeset
|
153 StorageAccessor accessor(s); |
712 | 154 |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1514
diff
changeset
|
155 std::string data = "Hello world"; |
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1514
diff
changeset
|
156 FileInfo info = accessor.Write(data, FileContentType_DicomAsJson, CompressionType_ZlibWithSize, true); |
712 | 157 |
158 std::string r; | |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1514
diff
changeset
|
159 accessor.Read(r, info); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 ASSERT_EQ(data, r); |
1514
d73a2178b319
support of deflate and gzip content-types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
162 ASSERT_EQ(CompressionType_ZlibWithSize, info.GetCompressionType()); |
232
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
163 ASSERT_EQ(11u, info.GetUncompressedSize()); |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1514
diff
changeset
|
164 ASSERT_EQ(FileContentType_DicomAsJson, info.GetContentType()); |
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1514
diff
changeset
|
165 ASSERT_EQ("3e25960a79dbc69b674cd4ec67a72c62", info.GetUncompressedMD5()); |
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1514
diff
changeset
|
166 ASSERT_NE(info.GetUncompressedMD5(), info.GetCompressedMD5()); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 } |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1514
diff
changeset
|
170 TEST(StorageAccessor, Mix) |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 { |
1123 | 172 FilesystemStorage s("UnitTestsStorage"); |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1514
diff
changeset
|
173 StorageAccessor accessor(s); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 std::string r; |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 std::string compressedData = "Hello"; |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
177 std::string uncompressedData = "HelloWorld"; |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
178 |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1514
diff
changeset
|
179 FileInfo compressedInfo = accessor.Write(compressedData, FileContentType_Dicom, CompressionType_ZlibWithSize, false); |
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1514
diff
changeset
|
180 FileInfo uncompressedInfo = accessor.Write(uncompressedData, FileContentType_Dicom, CompressionType_None, false); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1514
diff
changeset
|
182 accessor.Read(r, compressedInfo); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
183 ASSERT_EQ(compressedData, r); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 |
1549
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1514
diff
changeset
|
185 accessor.Read(r, uncompressedInfo); |
e5e975e9b738
refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1514
diff
changeset
|
186 ASSERT_EQ(uncompressedData, r); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 ASSERT_NE(compressedData, r); |
232
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
188 |
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
189 /* |
224
4eb0c7ce86c9
refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
190 // This test is too slow on Windows |
1514
d73a2178b319
support of deflate and gzip content-types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
191 accessor.SetCompressionForNextOperations(CompressionType_ZlibWithSize); |
1126
bf67431a7383
handling of file content type in IStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1124
diff
changeset
|
192 ASSERT_THROW(accessor.Read(r, uncompressedInfo.GetUuid(), FileContentType_Unknown), OrthancException); |
232
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
193 */ |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 } |