Mercurial > hg > orthanc
annotate OrthancFramework/UnitTestsSources/JobsTests.cpp @ 5853:4d932683049d get-scu tip
very first implementation of C-Get SCU
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Tue, 29 Oct 2024 17:25:49 +0100 |
parents | f7adfb22e20e |
children |
rev | line source |
---|---|
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
1 /** |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
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:
1009
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
5640
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5310
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
8 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
9 * This program is free software: you can redistribute it and/or |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
10 * modify it under the terms of the GNU Lesser General Public License |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
11 * as published by the Free Software Foundation, either version 3 of |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
12 * the License, or (at your option) any later version. |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
13 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
14 * 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:
776
diff
changeset
|
15 * WITHOUT ANY WARRANTY; without even the implied warranty of |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
17 * Lesser General Public License for more details. |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
18 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
19 * You should have received a copy of the GNU Lesser General Public |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
20 * License along with this program. If not, see |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
21 * <http://www.gnu.org/licenses/>. |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
22 **/ |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
23 |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
24 |
4060
149172a06b4d
splitting MultiThreadingTests.cpp into JobsTests.cpp and ServerJobsTests.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
25 #if ORTHANC_UNIT_TESTS_LINK_FRAMEWORK == 1 |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
26 // Must be the first to be sure to use the Orthanc framework shared library |
4060
149172a06b4d
splitting MultiThreadingTests.cpp into JobsTests.cpp and ServerJobsTests.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
27 # include <OrthancFramework.h> |
149172a06b4d
splitting MultiThreadingTests.cpp into JobsTests.cpp and ServerJobsTests.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
28 #endif |
149172a06b4d
splitting MultiThreadingTests.cpp into JobsTests.cpp and ServerJobsTests.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
29 |
4062 | 30 #include <gtest/gtest.h> |
723 | 31 |
4045 | 32 #include "../../OrthancFramework/Sources/Compatibility.h" |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
33 #include "../../OrthancFramework/Sources/DicomNetworking/DicomAssociationParameters.h" |
4060
149172a06b4d
splitting MultiThreadingTests.cpp into JobsTests.cpp and ServerJobsTests.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
34 #include "../../OrthancFramework/Sources/DicomNetworking/RemoteModalityParameters.h" |
149172a06b4d
splitting MultiThreadingTests.cpp into JobsTests.cpp and ServerJobsTests.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
35 #include "../../OrthancFramework/Sources/DicomParsing/DicomModification.h" |
149172a06b4d
splitting MultiThreadingTests.cpp into JobsTests.cpp and ServerJobsTests.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
36 #include "../../OrthancFramework/Sources/DicomParsing/ParsedDicomFile.h" |
149172a06b4d
splitting MultiThreadingTests.cpp into JobsTests.cpp and ServerJobsTests.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
37 #include "../../OrthancFramework/Sources/JobsEngine/GenericJobUnserializer.h" |
4045 | 38 #include "../../OrthancFramework/Sources/JobsEngine/JobsEngine.h" |
4060
149172a06b4d
splitting MultiThreadingTests.cpp into JobsTests.cpp and ServerJobsTests.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
39 #include "../../OrthancFramework/Sources/JobsEngine/Operations/JobOperationValues.h" |
149172a06b4d
splitting MultiThreadingTests.cpp into JobsTests.cpp and ServerJobsTests.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
40 #include "../../OrthancFramework/Sources/JobsEngine/Operations/LogJobOperation.h" |
149172a06b4d
splitting MultiThreadingTests.cpp into JobsTests.cpp and ServerJobsTests.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
41 #include "../../OrthancFramework/Sources/JobsEngine/Operations/NullOperationValue.h" |
149172a06b4d
splitting MultiThreadingTests.cpp into JobsTests.cpp and ServerJobsTests.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
42 #include "../../OrthancFramework/Sources/JobsEngine/Operations/SequenceOfOperationsJob.h" |
149172a06b4d
splitting MultiThreadingTests.cpp into JobsTests.cpp and ServerJobsTests.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
43 #include "../../OrthancFramework/Sources/JobsEngine/Operations/StringOperationValue.h" |
149172a06b4d
splitting MultiThreadingTests.cpp into JobsTests.cpp and ServerJobsTests.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
44 #include "../../OrthancFramework/Sources/JobsEngine/SetOfInstancesJob.h" |
4045 | 45 #include "../../OrthancFramework/Sources/Logging.h" |
46 #include "../../OrthancFramework/Sources/MultiThreading/SharedMessageQueue.h" | |
47 #include "../../OrthancFramework/Sources/OrthancException.h" | |
48 #include "../../OrthancFramework/Sources/SerializationToolbox.h" | |
2655 | 49 |
723 | 50 |
51 using namespace Orthanc; | |
52 | |
53 namespace | |
54 { | |
2652 | 55 class DummyJob : public IJob |
56 { | |
57 private: | |
58 bool fails_; | |
59 unsigned int count_; | |
60 unsigned int steps_; | |
61 | |
62 public: | |
63 DummyJob() : | |
64 fails_(false), | |
65 count_(0), | |
66 steps_(4) | |
67 { | |
68 } | |
69 | |
70 explicit DummyJob(bool fails) : | |
71 fails_(fails), | |
72 count_(0), | |
73 steps_(4) | |
74 { | |
75 } | |
76 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2872
diff
changeset
|
77 virtual void Start() ORTHANC_OVERRIDE |
2652 | 78 { |
79 } | |
80 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2872
diff
changeset
|
81 virtual void Reset() ORTHANC_OVERRIDE |
2652 | 82 { |
83 } | |
84 | |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
85 virtual JobStepResult Step(const std::string& jobId) ORTHANC_OVERRIDE |
2652 | 86 { |
87 if (fails_) | |
88 { | |
3240
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3093
diff
changeset
|
89 return JobStepResult::Failure(ErrorCode_ParameterOutOfRange, NULL); |
2652 | 90 } |
91 else if (count_ == steps_ - 1) | |
92 { | |
93 return JobStepResult::Success(); | |
94 } | |
95 else | |
96 { | |
97 count_++; | |
98 return JobStepResult::Continue(); | |
99 } | |
100 } | |
101 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2872
diff
changeset
|
102 virtual void Stop(JobStopReason reason) ORTHANC_OVERRIDE |
2652 | 103 { |
104 } | |
105 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2872
diff
changeset
|
106 virtual float GetProgress() ORTHANC_OVERRIDE |
2652 | 107 { |
108 return static_cast<float>(count_) / static_cast<float>(steps_ - 1); | |
109 } | |
110 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2872
diff
changeset
|
111 virtual void GetJobType(std::string& type) ORTHANC_OVERRIDE |
2652 | 112 { |
113 type = "DummyJob"; | |
114 } | |
115 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2872
diff
changeset
|
116 virtual bool Serialize(Json::Value& value) ORTHANC_OVERRIDE |
2652 | 117 { |
2667
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
118 value = Json::objectValue; |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
119 value["Type"] = "DummyJob"; |
2663
228e2783ce83
some jobs might not be serializable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2662
diff
changeset
|
120 return true; |
2652 | 121 } |
122 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2872
diff
changeset
|
123 virtual void GetPublicContent(Json::Value& value) ORTHANC_OVERRIDE |
2652 | 124 { |
125 value["hello"] = "world"; | |
126 } | |
2976
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2966
diff
changeset
|
127 |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2966
diff
changeset
|
128 virtual bool GetOutput(std::string& output, |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2966
diff
changeset
|
129 MimeType& mime, |
4805
0a38000b086d
Archive jobs response now contains a header Content-Disposition:filename='archive.zip'
Alain Mazy <am@osimis.io>
parents:
4779
diff
changeset
|
130 std::string& filename, |
2976
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2966
diff
changeset
|
131 const std::string& key) ORTHANC_OVERRIDE |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2966
diff
changeset
|
132 { |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2966
diff
changeset
|
133 return false; |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2966
diff
changeset
|
134 } |
5310
b5c502bcaf99
added a route to DELETE /jobs/../archive
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
135 |
b5c502bcaf99
added a route to DELETE /jobs/../archive
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
136 virtual bool DeleteOutput(const std::string& key) ORTHANC_OVERRIDE |
b5c502bcaf99
added a route to DELETE /jobs/../archive
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
137 { |
b5c502bcaf99
added a route to DELETE /jobs/../archive
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
138 return false; |
b5c502bcaf99
added a route to DELETE /jobs/../archive
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
139 } |
2652 | 140 }; |
141 | |
142 | |
143 class DummyInstancesJob : public SetOfInstancesJob | |
144 { | |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
145 private: |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
146 bool trailingStepDone_; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
147 |
2652 | 148 protected: |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2872
diff
changeset
|
149 virtual bool HandleInstance(const std::string& instance) ORTHANC_OVERRIDE |
2652 | 150 { |
2657
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
151 return (instance != "nope"); |
2652 | 152 } |
153 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2872
diff
changeset
|
154 virtual bool HandleTrailingStep() ORTHANC_OVERRIDE |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
155 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
156 if (HasTrailingStep()) |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
157 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
158 if (trailingStepDone_) |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
159 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
160 throw OrthancException(ErrorCode_InternalError); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
161 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
162 else |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
163 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
164 trailingStepDone_ = true; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
165 return true; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
166 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
167 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
168 else |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
169 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
170 throw OrthancException(ErrorCode_InternalError); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
171 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
172 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
173 |
2652 | 174 public: |
2860 | 175 DummyInstancesJob() : |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
176 trailingStepDone_(false) |
2652 | 177 { |
178 } | |
179 | |
4204 | 180 explicit DummyInstancesJob(const Json::Value& value) : |
2652 | 181 SetOfInstancesJob(value) |
182 { | |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
183 if (HasTrailingStep()) |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
184 { |
2860 | 185 trailingStepDone_ = (GetPosition() == GetCommandsCount()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
186 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
187 else |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
188 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
189 trailingStepDone_ = false; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
190 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
191 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
192 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
193 bool IsTrailingStepDone() const |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
194 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
195 return trailingStepDone_; |
2652 | 196 } |
197 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2872
diff
changeset
|
198 virtual void Stop(JobStopReason reason) ORTHANC_OVERRIDE |
2652 | 199 { |
200 } | |
201 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2872
diff
changeset
|
202 virtual void GetJobType(std::string& s) ORTHANC_OVERRIDE |
2652 | 203 { |
204 s = "DummyInstancesJob"; | |
205 } | |
206 }; | |
207 | |
208 | |
209 class DummyUnserializer : public GenericJobUnserializer | |
210 { | |
211 public: | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2872
diff
changeset
|
212 virtual IJob* UnserializeJob(const Json::Value& value) ORTHANC_OVERRIDE |
2652 | 213 { |
2656
a6d3e45eeff5
SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2655
diff
changeset
|
214 if (SerializationToolbox::ReadString(value, "Type") == "DummyInstancesJob") |
2652 | 215 { |
216 return new DummyInstancesJob(value); | |
217 } | |
2667
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
218 else if (SerializationToolbox::ReadString(value, "Type") == "DummyJob") |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
219 { |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
220 return new DummyJob; |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
221 } |
2652 | 222 else |
223 { | |
224 return GenericJobUnserializer::UnserializeJob(value); | |
225 } | |
226 } | |
227 }; | |
228 | |
229 | |
1396
ac4efabeb80c
Migration of the orthanc-client as a separate project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1304
diff
changeset
|
230 class DynamicInteger : public IDynamicObject |
723 | 231 { |
232 private: | |
233 int value_; | |
234 std::set<int>& target_; | |
235 | |
236 public: | |
237 DynamicInteger(int value, std::set<int>& target) : | |
238 value_(value), target_(target) | |
239 { | |
240 } | |
241 | |
242 int GetValue() const | |
243 { | |
244 return value_; | |
245 } | |
246 }; | |
247 } | |
248 | |
249 | |
250 TEST(MultiThreading, SharedMessageQueueBasic) | |
251 { | |
252 std::set<int> s; | |
253 | |
254 SharedMessageQueue q; | |
255 ASSERT_TRUE(q.WaitEmpty(0)); | |
256 q.Enqueue(new DynamicInteger(10, s)); | |
257 ASSERT_FALSE(q.WaitEmpty(1)); | |
258 q.Enqueue(new DynamicInteger(20, s)); | |
259 q.Enqueue(new DynamicInteger(30, s)); | |
260 q.Enqueue(new DynamicInteger(40, s)); | |
261 | |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
262 std::unique_ptr<DynamicInteger> i; |
723 | 263 i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(10, i->GetValue()); |
264 i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(20, i->GetValue()); | |
265 i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(30, i->GetValue()); | |
266 ASSERT_FALSE(q.WaitEmpty(1)); | |
267 i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(40, i->GetValue()); | |
268 ASSERT_TRUE(q.WaitEmpty(0)); | |
269 ASSERT_EQ(NULL, q.Dequeue(1)); | |
270 } | |
271 | |
272 | |
273 TEST(MultiThreading, SharedMessageQueueClean) | |
274 { | |
275 std::set<int> s; | |
276 | |
277 try | |
278 { | |
279 SharedMessageQueue q; | |
280 q.Enqueue(new DynamicInteger(10, s)); | |
281 q.Enqueue(new DynamicInteger(20, s)); | |
1583
9ea3d082b064
got rid of custom exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
282 throw OrthancException(ErrorCode_InternalError); |
723 | 283 } |
284 catch (OrthancException&) | |
285 { | |
286 } | |
287 } | |
288 | |
289 | |
769
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
290 |
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
291 |
2652 | 292 static bool CheckState(JobsRegistry& registry, |
293 const std::string& id, | |
294 JobState state) | |
2557 | 295 { |
2652 | 296 JobState s; |
2558 | 297 if (registry.GetState(s, id)) |
2557 | 298 { |
299 return state == s; | |
300 } | |
301 else | |
302 { | |
303 return false; | |
304 } | |
305 } | |
306 | |
307 | |
2652 | 308 static bool CheckErrorCode(JobsRegistry& registry, |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
309 const std::string& id, |
2652 | 310 ErrorCode code) |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
311 { |
2652 | 312 JobInfo s; |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
313 if (registry.GetJobInfo(s, id)) |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
314 { |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
315 return code == s.GetStatus().GetErrorCode(); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
316 } |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
317 else |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
318 { |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
319 return false; |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
320 } |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
321 } |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
322 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
323 |
2558 | 324 TEST(JobsRegistry, Priority) |
2557 | 325 { |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
326 JobsRegistry registry(10); |
2557 | 327 |
328 std::string i1, i2, i3, i4; | |
2558 | 329 registry.Submit(i1, new DummyJob(), 10); |
330 registry.Submit(i2, new DummyJob(), 30); | |
331 registry.Submit(i3, new DummyJob(), 20); | |
332 registry.Submit(i4, new DummyJob(), 5); | |
2557 | 333 |
2558 | 334 registry.SetMaxCompletedJobs(2); |
2557 | 335 |
336 std::set<std::string> id; | |
2558 | 337 registry.ListJobs(id); |
2557 | 338 |
339 ASSERT_EQ(4u, id.size()); | |
340 ASSERT_TRUE(id.find(i1) != id.end()); | |
341 ASSERT_TRUE(id.find(i2) != id.end()); | |
342 ASSERT_TRUE(id.find(i3) != id.end()); | |
343 ASSERT_TRUE(id.find(i4) != id.end()); | |
344 | |
2652 | 345 ASSERT_TRUE(CheckState(registry, i2, JobState_Pending)); |
2557 | 346 |
347 { | |
2558 | 348 JobsRegistry::RunningJob job(registry, 0); |
2557 | 349 ASSERT_TRUE(job.IsValid()); |
350 ASSERT_EQ(30, job.GetPriority()); | |
351 ASSERT_EQ(i2, job.GetId()); | |
352 | |
2652 | 353 ASSERT_TRUE(CheckState(registry, i2, JobState_Running)); |
2557 | 354 } |
355 | |
2652 | 356 ASSERT_TRUE(CheckState(registry, i2, JobState_Failure)); |
357 ASSERT_TRUE(CheckState(registry, i3, JobState_Pending)); | |
2557 | 358 |
359 { | |
2558 | 360 JobsRegistry::RunningJob job(registry, 0); |
2557 | 361 ASSERT_TRUE(job.IsValid()); |
362 ASSERT_EQ(20, job.GetPriority()); | |
363 ASSERT_EQ(i3, job.GetId()); | |
364 | |
365 job.MarkSuccess(); | |
366 | |
2652 | 367 ASSERT_TRUE(CheckState(registry, i3, JobState_Running)); |
2557 | 368 } |
369 | |
2652 | 370 ASSERT_TRUE(CheckState(registry, i3, JobState_Success)); |
2557 | 371 |
372 { | |
2558 | 373 JobsRegistry::RunningJob job(registry, 0); |
2557 | 374 ASSERT_TRUE(job.IsValid()); |
375 ASSERT_EQ(10, job.GetPriority()); | |
376 ASSERT_EQ(i1, job.GetId()); | |
377 } | |
378 | |
379 { | |
2558 | 380 JobsRegistry::RunningJob job(registry, 0); |
2557 | 381 ASSERT_TRUE(job.IsValid()); |
382 ASSERT_EQ(5, job.GetPriority()); | |
383 ASSERT_EQ(i4, job.GetId()); | |
384 } | |
385 | |
386 { | |
2558 | 387 JobsRegistry::RunningJob job(registry, 1); |
2557 | 388 ASSERT_FALSE(job.IsValid()); |
389 } | |
390 | |
2652 | 391 JobState s; |
2558 | 392 ASSERT_TRUE(registry.GetState(s, i1)); |
393 ASSERT_FALSE(registry.GetState(s, i2)); // Removed because oldest | |
394 ASSERT_FALSE(registry.GetState(s, i3)); // Removed because second oldest | |
395 ASSERT_TRUE(registry.GetState(s, i4)); | |
2557 | 396 |
2558 | 397 registry.SetMaxCompletedJobs(1); // (*) |
398 ASSERT_FALSE(registry.GetState(s, i1)); // Just discarded by (*) | |
399 ASSERT_TRUE(registry.GetState(s, i4)); | |
2557 | 400 } |
401 | |
402 | |
2558 | 403 TEST(JobsRegistry, Simultaneous) |
2557 | 404 { |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
405 JobsRegistry registry(10); |
2558 | 406 |
407 std::string i1, i2; | |
408 registry.Submit(i1, new DummyJob(), 20); | |
409 registry.Submit(i2, new DummyJob(), 10); | |
410 | |
2652 | 411 ASSERT_TRUE(CheckState(registry, i1, JobState_Pending)); |
412 ASSERT_TRUE(CheckState(registry, i2, JobState_Pending)); | |
2558 | 413 |
414 { | |
415 JobsRegistry::RunningJob job1(registry, 0); | |
416 JobsRegistry::RunningJob job2(registry, 0); | |
417 | |
418 ASSERT_TRUE(job1.IsValid()); | |
419 ASSERT_TRUE(job2.IsValid()); | |
420 | |
421 job1.MarkFailure(); | |
422 job2.MarkSuccess(); | |
423 | |
2652 | 424 ASSERT_TRUE(CheckState(registry, i1, JobState_Running)); |
425 ASSERT_TRUE(CheckState(registry, i2, JobState_Running)); | |
2558 | 426 } |
427 | |
2652 | 428 ASSERT_TRUE(CheckState(registry, i1, JobState_Failure)); |
429 ASSERT_TRUE(CheckState(registry, i2, JobState_Success)); | |
2558 | 430 } |
431 | |
432 | |
433 TEST(JobsRegistry, Resubmit) | |
434 { | |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
435 JobsRegistry registry(10); |
2557 | 436 |
437 std::string id; | |
2558 | 438 registry.Submit(id, new DummyJob(), 10); |
2557 | 439 |
2652 | 440 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2557 | 441 |
2558 | 442 registry.Resubmit(id); |
2652 | 443 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2557 | 444 |
445 { | |
2558 | 446 JobsRegistry::RunningJob job(registry, 0); |
2557 | 447 ASSERT_TRUE(job.IsValid()); |
448 job.MarkFailure(); | |
449 | |
2652 | 450 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2557 | 451 |
2558 | 452 registry.Resubmit(id); |
2652 | 453 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2557 | 454 } |
455 | |
2652 | 456 ASSERT_TRUE(CheckState(registry, id, JobState_Failure)); |
2557 | 457 |
2558 | 458 registry.Resubmit(id); |
2652 | 459 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2557 | 460 |
461 { | |
2558 | 462 JobsRegistry::RunningJob job(registry, 0); |
2557 | 463 ASSERT_TRUE(job.IsValid()); |
464 ASSERT_EQ(id, job.GetId()); | |
465 | |
466 job.MarkSuccess(); | |
2652 | 467 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2558 | 468 } |
469 | |
2652 | 470 ASSERT_TRUE(CheckState(registry, id, JobState_Success)); |
2558 | 471 |
472 registry.Resubmit(id); | |
2652 | 473 ASSERT_TRUE(CheckState(registry, id, JobState_Success)); |
2558 | 474 } |
475 | |
476 | |
477 TEST(JobsRegistry, Retry) | |
478 { | |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
479 JobsRegistry registry(10); |
2558 | 480 |
481 std::string id; | |
482 registry.Submit(id, new DummyJob(), 10); | |
483 | |
2652 | 484 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2558 | 485 |
486 { | |
487 JobsRegistry::RunningJob job(registry, 0); | |
488 ASSERT_TRUE(job.IsValid()); | |
489 job.MarkRetry(0); | |
490 | |
2652 | 491 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2558 | 492 } |
493 | |
2652 | 494 ASSERT_TRUE(CheckState(registry, id, JobState_Retry)); |
2558 | 495 |
496 registry.Resubmit(id); | |
2652 | 497 ASSERT_TRUE(CheckState(registry, id, JobState_Retry)); |
2558 | 498 |
499 registry.ScheduleRetries(); | |
2652 | 500 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2558 | 501 |
502 { | |
503 JobsRegistry::RunningJob job(registry, 0); | |
504 ASSERT_TRUE(job.IsValid()); | |
505 job.MarkSuccess(); | |
506 | |
2652 | 507 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2557 | 508 } |
509 | |
2652 | 510 ASSERT_TRUE(CheckState(registry, id, JobState_Success)); |
2558 | 511 } |
512 | |
513 | |
514 TEST(JobsRegistry, PausePending) | |
515 { | |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
516 JobsRegistry registry(10); |
2558 | 517 |
518 std::string id; | |
519 registry.Submit(id, new DummyJob(), 10); | |
520 | |
2652 | 521 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2558 | 522 |
523 registry.Pause(id); | |
2652 | 524 ASSERT_TRUE(CheckState(registry, id, JobState_Paused)); |
2558 | 525 |
526 registry.Pause(id); | |
2652 | 527 ASSERT_TRUE(CheckState(registry, id, JobState_Paused)); |
2558 | 528 |
529 registry.Resubmit(id); | |
2652 | 530 ASSERT_TRUE(CheckState(registry, id, JobState_Paused)); |
2558 | 531 |
532 registry.Resume(id); | |
2652 | 533 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2557 | 534 } |
2558 | 535 |
536 | |
537 TEST(JobsRegistry, PauseRunning) | |
538 { | |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
539 JobsRegistry registry(10); |
2558 | 540 |
541 std::string id; | |
542 registry.Submit(id, new DummyJob(), 10); | |
543 | |
2652 | 544 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2558 | 545 |
546 { | |
547 JobsRegistry::RunningJob job(registry, 0); | |
548 ASSERT_TRUE(job.IsValid()); | |
549 | |
550 registry.Resubmit(id); | |
2562 | 551 job.MarkPause(); |
2652 | 552 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2558 | 553 } |
554 | |
2652 | 555 ASSERT_TRUE(CheckState(registry, id, JobState_Paused)); |
2558 | 556 |
557 registry.Resubmit(id); | |
2652 | 558 ASSERT_TRUE(CheckState(registry, id, JobState_Paused)); |
2558 | 559 |
560 registry.Resume(id); | |
2652 | 561 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2558 | 562 |
563 { | |
564 JobsRegistry::RunningJob job(registry, 0); | |
565 ASSERT_TRUE(job.IsValid()); | |
566 | |
567 job.MarkSuccess(); | |
2652 | 568 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2558 | 569 } |
570 | |
2652 | 571 ASSERT_TRUE(CheckState(registry, id, JobState_Success)); |
2558 | 572 } |
573 | |
574 | |
575 TEST(JobsRegistry, PauseRetry) | |
576 { | |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
577 JobsRegistry registry(10); |
2558 | 578 |
579 std::string id; | |
580 registry.Submit(id, new DummyJob(), 10); | |
581 | |
2652 | 582 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2558 | 583 |
584 { | |
585 JobsRegistry::RunningJob job(registry, 0); | |
586 ASSERT_TRUE(job.IsValid()); | |
587 | |
588 job.MarkRetry(0); | |
2652 | 589 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2558 | 590 } |
591 | |
2652 | 592 ASSERT_TRUE(CheckState(registry, id, JobState_Retry)); |
2558 | 593 |
594 registry.Pause(id); | |
2652 | 595 ASSERT_TRUE(CheckState(registry, id, JobState_Paused)); |
2558 | 596 |
597 registry.Resume(id); | |
2652 | 598 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2558 | 599 |
600 { | |
601 JobsRegistry::RunningJob job(registry, 0); | |
602 ASSERT_TRUE(job.IsValid()); | |
603 | |
604 job.MarkSuccess(); | |
2652 | 605 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2558 | 606 } |
607 | |
2652 | 608 ASSERT_TRUE(CheckState(registry, id, JobState_Success)); |
2558 | 609 } |
2565 | 610 |
611 | |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
612 TEST(JobsRegistry, Cancel) |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
613 { |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
614 JobsRegistry registry(10); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
615 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
616 std::string id; |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
617 registry.Submit(id, new DummyJob(), 10); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
618 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
619 ASSERT_FALSE(registry.Cancel("nope")); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
620 |
2652 | 621 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
622 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_Success)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
623 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
624 ASSERT_TRUE(registry.Cancel(id)); |
2652 | 625 ASSERT_TRUE(CheckState(registry, id, JobState_Failure)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
626 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_CanceledJob)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
627 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
628 ASSERT_TRUE(registry.Cancel(id)); |
2652 | 629 ASSERT_TRUE(CheckState(registry, id, JobState_Failure)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
630 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_CanceledJob)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
631 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
632 ASSERT_TRUE(registry.Resubmit(id)); |
2652 | 633 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
634 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_CanceledJob)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
635 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
636 { |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
637 JobsRegistry::RunningJob job(registry, 0); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
638 ASSERT_TRUE(job.IsValid()); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
639 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
640 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_Success)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
641 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
642 job.MarkSuccess(); |
2652 | 643 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
644 } |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
645 |
2652 | 646 ASSERT_TRUE(CheckState(registry, id, JobState_Success)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
647 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_Success)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
648 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
649 ASSERT_TRUE(registry.Cancel(id)); |
2652 | 650 ASSERT_TRUE(CheckState(registry, id, JobState_Success)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
651 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_Success)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
652 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
653 registry.Submit(id, new DummyJob(), 10); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
654 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
655 { |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
656 JobsRegistry::RunningJob job(registry, 0); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
657 ASSERT_TRUE(job.IsValid()); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
658 ASSERT_EQ(id, job.GetId()); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
659 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
660 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_Success)); |
2652 | 661 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
662 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
663 job.MarkCanceled(); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
664 } |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
665 |
2652 | 666 ASSERT_TRUE(CheckState(registry, id, JobState_Failure)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
667 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_CanceledJob)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
668 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
669 ASSERT_TRUE(registry.Resubmit(id)); |
2652 | 670 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
671 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_CanceledJob)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
672 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
673 ASSERT_TRUE(registry.Pause(id)); |
2652 | 674 ASSERT_TRUE(CheckState(registry, id, JobState_Paused)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
675 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_CanceledJob)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
676 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
677 ASSERT_TRUE(registry.Cancel(id)); |
2652 | 678 ASSERT_TRUE(CheckState(registry, id, JobState_Failure)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
679 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_CanceledJob)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
680 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
681 ASSERT_TRUE(registry.Resubmit(id)); |
2652 | 682 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
683 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_CanceledJob)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
684 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
685 { |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
686 JobsRegistry::RunningJob job(registry, 0); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
687 ASSERT_TRUE(job.IsValid()); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
688 ASSERT_EQ(id, job.GetId()); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
689 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
690 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_Success)); |
2652 | 691 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
692 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
693 job.MarkRetry(500); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
694 } |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
695 |
2652 | 696 ASSERT_TRUE(CheckState(registry, id, JobState_Retry)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
697 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_Success)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
698 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
699 ASSERT_TRUE(registry.Cancel(id)); |
2652 | 700 ASSERT_TRUE(CheckState(registry, id, JobState_Failure)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
701 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_CanceledJob)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
702 } |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
703 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
704 |
2570
2e879c796ec7
JobsRegistry::SubmitAndWait(), StoreScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2569
diff
changeset
|
705 |
2599 | 706 TEST(JobsEngine, SubmitAndWait) |
2565 | 707 { |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
708 JobsEngine engine(10); |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
709 engine.SetThreadSleep(10); |
2565 | 710 engine.SetWorkersCount(3); |
711 engine.Start(); | |
712 | |
2867 | 713 Json::Value content = Json::nullValue; |
3240
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3093
diff
changeset
|
714 engine.GetRegistry().SubmitAndWait(content, new DummyJob(), rand() % 10); |
2867 | 715 ASSERT_EQ(Json::objectValue, content.type()); |
716 ASSERT_EQ("world", content["hello"].asString()); | |
717 | |
718 content = Json::nullValue; | |
3240
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3093
diff
changeset
|
719 ASSERT_THROW(engine.GetRegistry().SubmitAndWait(content, new DummyJob(true), rand() % 10), OrthancException); |
2867 | 720 ASSERT_EQ(Json::nullValue, content.type()); |
2599 | 721 |
722 engine.Stop(); | |
723 } | |
724 | |
725 | |
2600
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
726 TEST(JobsEngine, DISABLED_SequenceOfOperationsJob) |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
727 { |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
728 JobsEngine engine(10); |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
729 engine.SetThreadSleep(10); |
2600
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
730 engine.SetWorkersCount(3); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
731 engine.Start(); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
732 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
733 std::string id; |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
734 SequenceOfOperationsJob* job = NULL; |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
735 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
736 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
737 std::unique_ptr<SequenceOfOperationsJob> a(new SequenceOfOperationsJob); |
2600
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
738 job = a.get(); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
739 engine.GetRegistry().Submit(id, a.release(), 0); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
740 } |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
741 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
742 boost::this_thread::sleep(boost::posix_time::milliseconds(500)); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
743 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
744 { |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
745 SequenceOfOperationsJob::Lock lock(*job); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
746 size_t i = lock.AddOperation(new LogJobOperation); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
747 size_t j = lock.AddOperation(new LogJobOperation); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
748 size_t k = lock.AddOperation(new LogJobOperation); |
2730 | 749 |
750 StringOperationValue a("Hello"); | |
751 StringOperationValue b("World"); | |
752 lock.AddInput(i, a); | |
753 lock.AddInput(i, b); | |
754 | |
2600
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
755 lock.Connect(i, j); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
756 lock.Connect(j, k); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
757 } |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
758 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
759 boost::this_thread::sleep(boost::posix_time::milliseconds(2000)); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
760 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
761 engine.Stop(); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
762 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
763 } |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
764 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
765 |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
766 static bool CheckSameJson(const Json::Value& a, |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
767 const Json::Value& b) |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
768 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
769 std::string s = a.toStyledString(); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
770 std::string t = b.toStyledString(); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
771 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
772 if (s == t) |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
773 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
774 return true; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
775 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
776 else |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
777 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
778 LOG(ERROR) << "Expected serialization: " << s; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
779 LOG(ERROR) << "Actual serialization: " << t; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
780 return false; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
781 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
782 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
783 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
784 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
785 static bool CheckIdempotentSerialization(IJobUnserializer& unserializer, |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
786 IJob& job) |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
787 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
788 Json::Value a = 42; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
789 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
790 if (!job.Serialize(a)) |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
791 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
792 return false; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
793 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
794 else |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
795 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
796 std::unique_ptr<IJob> unserialized(unserializer.UnserializeJob(a)); |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
797 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
798 Json::Value b = 43; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
799 if (unserialized->Serialize(b)) |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
800 { |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
801 return (CheckSameJson(a, b)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
802 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
803 else |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
804 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
805 return false; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
806 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
807 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
808 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
809 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
810 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
811 static bool CheckIdempotentSetOfInstances(IJobUnserializer& unserializer, |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
812 SetOfInstancesJob& job) |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
813 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
814 Json::Value a = 42; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
815 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
816 if (!job.Serialize(a)) |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
817 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
818 return false; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
819 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
820 else |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
821 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
822 std::unique_ptr<SetOfInstancesJob> unserialized |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
823 (dynamic_cast<SetOfInstancesJob*>(unserializer.UnserializeJob(a))); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
824 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
825 Json::Value b = 43; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
826 if (unserialized->Serialize(b)) |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
827 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
828 return (CheckSameJson(a, b) && |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
829 job.HasTrailingStep() == unserialized->HasTrailingStep() && |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
830 job.GetPosition() == unserialized->GetPosition() && |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
831 job.GetInstancesCount() == unserialized->GetInstancesCount() && |
2860 | 832 job.GetCommandsCount() == unserialized->GetCommandsCount()); |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
833 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
834 else |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
835 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
836 return false; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
837 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
838 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
839 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
840 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
841 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
842 static bool CheckIdempotentSerialization(IJobUnserializer& unserializer, |
4310
2ae905070221
renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
843 const IJobOperationValue& value) |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
844 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
845 Json::Value a = 42; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
846 value.Serialize(a); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
847 |
4310
2ae905070221
renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
848 std::unique_ptr<IJobOperationValue> unserialized(unserializer.UnserializeValue(a)); |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
849 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
850 Json::Value b = 43; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
851 unserialized->Serialize(b); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
852 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
853 return CheckSameJson(a, b); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
854 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
855 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
856 |
2655 | 857 TEST(JobsSerialization, BadFileFormat) |
858 { | |
859 GenericJobUnserializer unserializer; | |
860 | |
861 Json::Value s; | |
862 | |
863 s = Json::objectValue; | |
864 ASSERT_THROW(unserializer.UnserializeValue(s), OrthancException); | |
865 ASSERT_THROW(unserializer.UnserializeJob(s), OrthancException); | |
866 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); | |
867 | |
868 s = Json::arrayValue; | |
869 ASSERT_THROW(unserializer.UnserializeValue(s), OrthancException); | |
870 ASSERT_THROW(unserializer.UnserializeJob(s), OrthancException); | |
871 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); | |
872 | |
873 s = "hello"; | |
874 ASSERT_THROW(unserializer.UnserializeValue(s), OrthancException); | |
875 ASSERT_THROW(unserializer.UnserializeJob(s), OrthancException); | |
876 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); | |
877 | |
878 s = 42; | |
879 ASSERT_THROW(unserializer.UnserializeValue(s), OrthancException); | |
880 ASSERT_THROW(unserializer.UnserializeJob(s), OrthancException); | |
881 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); | |
882 } | |
883 | |
884 | |
2657
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
885 TEST(JobsSerialization, JobOperationValues) |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
886 { |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
887 Json::Value s; |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
888 |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
889 { |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
890 JobOperationValues values; |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
891 values.Append(new NullOperationValue); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
892 values.Append(new StringOperationValue("hello")); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
893 values.Append(new StringOperationValue("world")); |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
894 |
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
895 s = 42; |
2657
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
896 values.Serialize(s); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
897 } |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
898 |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
899 { |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
900 GenericJobUnserializer unserializer; |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
901 std::unique_ptr<JobOperationValues> values(JobOperationValues::Unserialize(unserializer, s)); |
2657
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
902 ASSERT_EQ(3u, values->GetSize()); |
4310
2ae905070221
renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
903 ASSERT_EQ(IJobOperationValue::Type_Null, values->GetValue(0).GetType()); |
2ae905070221
renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
904 ASSERT_EQ(IJobOperationValue::Type_String, values->GetValue(1).GetType()); |
2ae905070221
renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
905 ASSERT_EQ(IJobOperationValue::Type_String, values->GetValue(2).GetType()); |
2657
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
906 |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
907 ASSERT_EQ("hello", dynamic_cast<const StringOperationValue&>(values->GetValue(1)).GetContent()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
908 ASSERT_EQ("world", dynamic_cast<const StringOperationValue&>(values->GetValue(2)).GetContent()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
909 } |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
910 } |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
911 |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
912 |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
913 TEST(JobsSerialization, GenericValues) |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
914 { |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
915 GenericJobUnserializer unserializer; |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
916 Json::Value s; |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
917 |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
918 { |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
919 NullOperationValue null; |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
920 |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
921 ASSERT_TRUE(CheckIdempotentSerialization(unserializer, null)); |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
922 null.Serialize(s); |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
923 } |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
924 |
2652 | 925 ASSERT_THROW(unserializer.UnserializeJob(s), OrthancException); |
926 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); | |
2655 | 927 |
4310
2ae905070221
renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
928 std::unique_ptr<IJobOperationValue> value; |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
929 value.reset(unserializer.UnserializeValue(s)); |
2652 | 930 |
4310
2ae905070221
renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
931 ASSERT_EQ(IJobOperationValue::Type_Null, value->GetType()); |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
932 |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
933 { |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
934 StringOperationValue str("Hello"); |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
935 |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
936 ASSERT_TRUE(CheckIdempotentSerialization(unserializer, str)); |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
937 str.Serialize(s); |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
938 } |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
939 |
2652 | 940 ASSERT_THROW(unserializer.UnserializeJob(s), OrthancException); |
941 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); | |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
942 value.reset(unserializer.UnserializeValue(s)); |
2652 | 943 |
4310
2ae905070221
renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
944 ASSERT_EQ(IJobOperationValue::Type_String, value->GetType()); |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
945 ASSERT_EQ("Hello", dynamic_cast<StringOperationValue&>(*value).GetContent()); |
2600
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
946 } |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
947 |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
948 |
2655 | 949 TEST(JobsSerialization, GenericJobs) |
950 { | |
2652 | 951 Json::Value s; |
952 | |
2658 | 953 // This tests SetOfInstancesJob |
954 | |
2652 | 955 { |
2860 | 956 DummyInstancesJob job; |
2652 | 957 job.SetDescription("description"); |
2657
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
958 job.AddInstance("hello"); |
2652 | 959 job.AddInstance("nope"); |
2657
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
960 job.AddInstance("world"); |
2652 | 961 job.SetPermissive(true); |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
962 ASSERT_THROW(job.Step("jobId"), OrthancException); // Not started yet |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
963 ASSERT_FALSE(job.HasTrailingStep()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
964 ASSERT_FALSE(job.IsTrailingStepDone()); |
2657
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
965 job.Start(); |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
966 ASSERT_EQ(JobStepCode_Continue, job.Step("jobId").GetCode()); |
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
967 ASSERT_EQ(JobStepCode_Continue, job.Step("jobId").GetCode()); |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
968 |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
969 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
970 DummyUnserializer unserializer; |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
971 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
972 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
973 |
2663
228e2783ce83
some jobs might not be serializable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2662
diff
changeset
|
974 ASSERT_TRUE(job.Serialize(s)); |
2652 | 975 } |
976 | |
2655 | 977 { |
978 DummyUnserializer unserializer; | |
979 ASSERT_THROW(unserializer.UnserializeValue(s), OrthancException); | |
980 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); | |
2652 | 981 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
982 std::unique_ptr<IJob> job; |
2655 | 983 job.reset(unserializer.UnserializeJob(s)); |
2657
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
984 |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
985 const DummyInstancesJob& tmp = dynamic_cast<const DummyInstancesJob&>(*job); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
986 ASSERT_FALSE(tmp.IsStarted()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
987 ASSERT_TRUE(tmp.IsPermissive()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
988 ASSERT_EQ("description", tmp.GetDescription()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
989 ASSERT_EQ(3u, tmp.GetInstancesCount()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
990 ASSERT_EQ(2u, tmp.GetPosition()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
991 ASSERT_EQ(1u, tmp.GetFailedInstances().size()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
992 ASSERT_EQ("hello", tmp.GetInstance(0)); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
993 ASSERT_EQ("nope", tmp.GetInstance(1)); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
994 ASSERT_EQ("world", tmp.GetInstance(2)); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
995 ASSERT_TRUE(tmp.IsFailedInstance("nope")); |
2655 | 996 } |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
997 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
998 // SequenceOfOperationsJob |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
999 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1000 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1001 SequenceOfOperationsJob job; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1002 job.SetDescription("hello"); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1003 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1004 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1005 SequenceOfOperationsJob::Lock lock(job); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1006 size_t a = lock.AddOperation(new LogJobOperation); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1007 size_t b = lock.AddOperation(new LogJobOperation); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1008 lock.Connect(a, b); |
2730 | 1009 |
1010 StringOperationValue s1("hello"); | |
1011 StringOperationValue s2("world"); | |
1012 lock.AddInput(a, s1); | |
1013 lock.AddInput(a, s2); | |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1014 lock.SetTrailingOperationTimeout(300); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1015 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1016 |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
1017 ASSERT_EQ(JobStepCode_Continue, job.Step("jobId").GetCode()); |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1018 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1019 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1020 GenericJobUnserializer unserializer; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1021 ASSERT_TRUE(CheckIdempotentSerialization(unserializer, job)); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1022 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1023 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1024 ASSERT_TRUE(job.Serialize(s)); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1025 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1026 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1027 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1028 GenericJobUnserializer unserializer; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1029 ASSERT_THROW(unserializer.UnserializeValue(s), OrthancException); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1030 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1031 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
1032 std::unique_ptr<IJob> job; |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1033 job.reset(unserializer.UnserializeJob(s)); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1034 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1035 std::string tmp; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1036 dynamic_cast<SequenceOfOperationsJob&>(*job).GetDescription(tmp); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1037 ASSERT_EQ("hello", tmp); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1038 } |
2658 | 1039 } |
1040 | |
1041 | |
4204 | 1042 static bool IsSameTagValue(const ParsedDicomFile& dicom1, |
1043 const ParsedDicomFile& dicom2, | |
2662
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1044 DicomTag tag) |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1045 { |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1046 std::string a, b; |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1047 return (dicom1.GetTagValue(a, tag) && |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1048 dicom2.GetTagValue(b, tag) && |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1049 (a == b)); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1050 } |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1051 |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1052 |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1053 |
2660 | 1054 TEST(JobsSerialization, DicomModification) |
1055 { | |
2662
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1056 Json::Value s; |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1057 |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1058 ParsedDicomFile source(true); |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
1059 source.Insert(DICOM_TAG_STUDY_DESCRIPTION, "Test 1", false, ""); |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
1060 source.Insert(DICOM_TAG_SERIES_DESCRIPTION, "Test 2", false, ""); |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
1061 source.Insert(DICOM_TAG_PATIENT_NAME, "Test 3", false, ""); |
2662
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1062 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
1063 std::unique_ptr<ParsedDicomFile> modified(source.Clone(true)); |
2662
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1064 |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1065 { |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1066 DicomModification modification; |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1067 modification.SetLevel(ResourceType_Series); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1068 modification.Clear(DICOM_TAG_STUDY_DESCRIPTION); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1069 modification.Remove(DICOM_TAG_SERIES_DESCRIPTION); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1070 modification.Replace(DICOM_TAG_PATIENT_NAME, "Test 4", true); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1071 |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1072 modification.Apply(*modified); |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
1073 |
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
1074 s = 42; |
2662
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1075 modification.Serialize(s); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1076 } |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1077 |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1078 { |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1079 DicomModification modification(s); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1080 ASSERT_EQ(ResourceType_Series, modification.GetLevel()); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1081 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
1082 std::unique_ptr<ParsedDicomFile> second(source.Clone(true)); |
2662
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1083 modification.Apply(*second); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1084 |
4204 | 1085 std::string t; |
1086 ASSERT_TRUE(second->GetTagValue(t, DICOM_TAG_STUDY_DESCRIPTION)); | |
1087 ASSERT_TRUE(t.empty()); | |
1088 ASSERT_FALSE(second->GetTagValue(t, DICOM_TAG_SERIES_DESCRIPTION)); | |
1089 ASSERT_TRUE(second->GetTagValue(t, DICOM_TAG_PATIENT_NAME)); | |
1090 ASSERT_EQ("Test 4", t); | |
2662
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1091 |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1092 ASSERT_TRUE(IsSameTagValue(source, *modified, DICOM_TAG_STUDY_INSTANCE_UID)); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1093 ASSERT_TRUE(IsSameTagValue(source, *second, DICOM_TAG_STUDY_INSTANCE_UID)); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1094 |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1095 ASSERT_FALSE(IsSameTagValue(source, *second, DICOM_TAG_SERIES_INSTANCE_UID)); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1096 ASSERT_TRUE(IsSameTagValue(*modified, *second, DICOM_TAG_SERIES_INSTANCE_UID)); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1097 } |
2660 | 1098 } |
1099 | |
1100 | |
4687
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4656
diff
changeset
|
1101 TEST(JobsSerialization, DicomModification2) |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4656
diff
changeset
|
1102 { |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4656
diff
changeset
|
1103 Json::Value s; |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4656
diff
changeset
|
1104 |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4656
diff
changeset
|
1105 { |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4656
diff
changeset
|
1106 DicomModification modification; |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4656
diff
changeset
|
1107 modification.SetupAnonymization(DicomVersion_2017c); |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4656
diff
changeset
|
1108 modification.Remove(DicomPath(DICOM_TAG_REFERENCED_IMAGE_SEQUENCE, 1, DICOM_TAG_SOP_INSTANCE_UID)); |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4656
diff
changeset
|
1109 modification.Replace(DicomPath(DICOM_TAG_REFERENCED_IMAGE_SEQUENCE, 1, DICOM_TAG_SOP_CLASS_UID), "Hello", true); |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4656
diff
changeset
|
1110 modification.Keep(DicomPath(DICOM_TAG_REFERENCED_IMAGE_SEQUENCE, 1, DICOM_TAG_PATIENT_NAME)); |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4656
diff
changeset
|
1111 |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4656
diff
changeset
|
1112 s = 42; |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4656
diff
changeset
|
1113 modification.Serialize(s); |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4656
diff
changeset
|
1114 } |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4656
diff
changeset
|
1115 |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4656
diff
changeset
|
1116 { |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4656
diff
changeset
|
1117 DicomModification modification(s); |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4656
diff
changeset
|
1118 |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4656
diff
changeset
|
1119 // Check idempotent serialization |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4656
diff
changeset
|
1120 Json::Value ss; |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4656
diff
changeset
|
1121 modification.Serialize(ss); |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4656
diff
changeset
|
1122 ASSERT_EQ(s.toStyledString(), ss.toStyledString()); |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4656
diff
changeset
|
1123 } |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4656
diff
changeset
|
1124 } |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4656
diff
changeset
|
1125 |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4656
diff
changeset
|
1126 |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1127 TEST(JobsSerialization, Registry) |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1128 { |
2667
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1129 Json::Value s; |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1130 std::string i1, i2; |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1131 |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1132 { |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
1133 JobsRegistry registry(10); |
2667
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1134 registry.Submit(i1, new DummyJob(), 10); |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1135 registry.Submit(i2, new SequenceOfOperationsJob(), 30); |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1136 registry.Serialize(s); |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1137 } |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1138 |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1139 { |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1140 DummyUnserializer unserializer; |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
1141 JobsRegistry registry(unserializer, s, 10); |
2667
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1142 |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1143 Json::Value t; |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1144 registry.Serialize(t); |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1145 ASSERT_TRUE(CheckSameJson(s, t)); |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1146 } |
2658 | 1147 } |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1148 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1149 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1150 TEST(JobsSerialization, TrailingStep) |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1151 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1152 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1153 Json::Value s; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1154 |
2860 | 1155 DummyInstancesJob job; |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1156 ASSERT_EQ(0u, job.GetCommandsCount()); |
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1157 ASSERT_EQ(0u, job.GetInstancesCount()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1158 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1159 job.Start(); |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1160 ASSERT_EQ(0u, job.GetPosition()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1161 ASSERT_FALSE(job.HasTrailingStep()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1162 ASSERT_FALSE(job.IsTrailingStepDone()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1163 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1164 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1165 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1166 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1167 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1168 |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
1169 ASSERT_EQ(JobStepCode_Success, job.Step("jobId").GetCode()); |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1170 ASSERT_EQ(1u, job.GetPosition()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1171 ASSERT_FALSE(job.IsTrailingStepDone()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1172 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1173 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1174 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1175 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1176 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1177 |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
1178 ASSERT_THROW(job.Step("jobId"), OrthancException); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1179 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1180 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1181 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1182 Json::Value s; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1183 |
2860 | 1184 DummyInstancesJob job; |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1185 job.AddInstance("hello"); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1186 job.AddInstance("world"); |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1187 ASSERT_EQ(2u, job.GetCommandsCount()); |
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1188 ASSERT_EQ(2u, job.GetInstancesCount()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1189 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1190 job.Start(); |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1191 ASSERT_EQ(0u, job.GetPosition()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1192 ASSERT_FALSE(job.HasTrailingStep()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1193 ASSERT_FALSE(job.IsTrailingStepDone()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1194 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1195 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1196 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1197 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1198 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1199 |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
1200 ASSERT_EQ(JobStepCode_Continue, job.Step("jobId").GetCode()); |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1201 ASSERT_EQ(1u, job.GetPosition()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1202 ASSERT_FALSE(job.IsTrailingStepDone()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1203 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1204 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1205 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1206 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1207 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1208 |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
1209 ASSERT_EQ(JobStepCode_Success, job.Step("jobId").GetCode()); |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1210 ASSERT_EQ(2u, job.GetPosition()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1211 ASSERT_FALSE(job.IsTrailingStepDone()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1212 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1213 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1214 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1215 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1216 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1217 |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
1218 ASSERT_THROW(job.Step("jobId"), OrthancException); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1219 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1220 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1221 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1222 Json::Value s; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1223 |
2860 | 1224 DummyInstancesJob job; |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1225 ASSERT_EQ(0u, job.GetInstancesCount()); |
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1226 ASSERT_EQ(0u, job.GetCommandsCount()); |
2860 | 1227 job.AddTrailingStep(); |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1228 ASSERT_EQ(0u, job.GetInstancesCount()); |
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1229 ASSERT_EQ(1u, job.GetCommandsCount()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1230 |
2860 | 1231 job.Start(); // This adds the trailing step |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1232 ASSERT_EQ(0u, job.GetPosition()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1233 ASSERT_TRUE(job.HasTrailingStep()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1234 ASSERT_FALSE(job.IsTrailingStepDone()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1235 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1236 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1237 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1238 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1239 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1240 |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
1241 ASSERT_EQ(JobStepCode_Success, job.Step("jobId").GetCode()); |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1242 ASSERT_EQ(1u, job.GetPosition()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1243 ASSERT_TRUE(job.IsTrailingStepDone()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1244 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1245 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1246 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1247 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1248 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1249 |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
1250 ASSERT_THROW(job.Step("jobId"), OrthancException); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1251 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1252 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1253 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1254 Json::Value s; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1255 |
2860 | 1256 DummyInstancesJob job; |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1257 job.AddInstance("hello"); |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1258 ASSERT_EQ(1u, job.GetInstancesCount()); |
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1259 ASSERT_EQ(1u, job.GetCommandsCount()); |
2860 | 1260 job.AddTrailingStep(); |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1261 ASSERT_EQ(1u, job.GetInstancesCount()); |
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1262 ASSERT_EQ(2u, job.GetCommandsCount()); |
2860 | 1263 |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1264 job.Start(); |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1265 ASSERT_EQ(2u, job.GetCommandsCount()); |
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1266 ASSERT_EQ(0u, job.GetPosition()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1267 ASSERT_TRUE(job.HasTrailingStep()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1268 ASSERT_FALSE(job.IsTrailingStepDone()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1269 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1270 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1271 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1272 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1273 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1274 |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
1275 ASSERT_EQ(JobStepCode_Continue, job.Step("jobId").GetCode()); |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1276 ASSERT_EQ(1u, job.GetPosition()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1277 ASSERT_FALSE(job.IsTrailingStepDone()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1278 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1279 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1280 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1281 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1282 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1283 |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
1284 ASSERT_EQ(JobStepCode_Success, job.Step("jobId").GetCode()); |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1285 ASSERT_EQ(2u, job.GetPosition()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1286 ASSERT_TRUE(job.IsTrailingStepDone()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1287 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1288 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1289 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1290 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1291 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1292 |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
1293 ASSERT_THROW(job.Step("jobId"), OrthancException); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1294 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1295 } |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1296 |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1297 |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1298 TEST(JobsSerialization, RemoteModalityParameters) |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1299 { |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1300 Json::Value s; |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1301 |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1302 { |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1303 RemoteModalityParameters modality; |
2872
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1304 ASSERT_FALSE(modality.IsAdvancedFormatNeeded()); |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1305 modality.Serialize(s, false); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1306 ASSERT_EQ(Json::arrayValue, s.type()); |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1307 ASSERT_FALSE(modality.IsDicomTlsEnabled()); |
4518
cb8fcecf1b02
new option "Timeout" in "DicomModalities" to set DICOM SCU timeout on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4463
diff
changeset
|
1308 ASSERT_FALSE(modality.HasTimeout()); |
cb8fcecf1b02
new option "Timeout" in "DicomModalities" to set DICOM SCU timeout on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4463
diff
changeset
|
1309 ASSERT_EQ(0u, modality.GetTimeout()); |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1310 } |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1311 |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1312 { |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1313 RemoteModalityParameters modality(s); |
4463
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1314 ASSERT_FALSE(modality.IsAdvancedFormatNeeded()); |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1315 ASSERT_EQ("ORTHANC", modality.GetApplicationEntityTitle()); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1316 ASSERT_EQ("127.0.0.1", modality.GetHost()); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1317 ASSERT_EQ(104u, modality.GetPortNumber()); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1318 ASSERT_EQ(ModalityManufacturer_Generic, modality.GetManufacturer()); |
2872
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1319 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Echo)); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1320 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Find)); |
4888
8523078f3f4b
added new configuration to authorize C-Find for worklist independently from other C-Find
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
1321 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_FindWorklist)); |
2872
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1322 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Get)); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1323 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Store)); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1324 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Move)); |
3602
085283445db0
AllowNAction in remote modality parameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3561
diff
changeset
|
1325 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_NAction)); |
3613
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1326 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_NEventReport)); |
3894
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3878
diff
changeset
|
1327 ASSERT_TRUE(modality.IsTranscodingAllowed()); |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1328 ASSERT_FALSE(modality.IsDicomTlsEnabled()); |
4463
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1329 ASSERT_FALSE(modality.HasLocalAet()); |
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1330 ASSERT_THROW(modality.GetLocalAet(), OrthancException); |
4518
cb8fcecf1b02
new option "Timeout" in "DicomModalities" to set DICOM SCU timeout on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4463
diff
changeset
|
1331 ASSERT_FALSE(modality.HasTimeout()); |
cb8fcecf1b02
new option "Timeout" in "DicomModalities" to set DICOM SCU timeout on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4463
diff
changeset
|
1332 ASSERT_EQ(0u, modality.GetTimeout()); |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1333 } |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1334 |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1335 s = Json::nullValue; |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1336 |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1337 { |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1338 RemoteModalityParameters modality; |
2872
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1339 ASSERT_THROW(modality.SetPortNumber(0), OrthancException); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1340 ASSERT_THROW(modality.SetPortNumber(65535), OrthancException); |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1341 modality.SetApplicationEntityTitle("HELLO"); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1342 modality.SetHost("world"); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1343 modality.SetPortNumber(45); |
3561
bdafff1ce443
C-Find SCU at Instance level now sets the 0008,0052 tag to IMAGE per default (was INSTANCE). Source: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/orthanc-users/FYxHXzlaQ0M/rn6d0SowAAAJ
Alain Mazy <alain@mazy.be>
parents:
3240
diff
changeset
|
1344 modality.SetManufacturer(ModalityManufacturer_GenericNoWildcardInDates); |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1345 ASSERT_FALSE(modality.IsAdvancedFormatNeeded()); |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1346 modality.Serialize(s, true); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1347 ASSERT_EQ(Json::objectValue, s.type()); |
4463
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1348 ASSERT_FALSE(modality.HasLocalAet()); |
4518
cb8fcecf1b02
new option "Timeout" in "DicomModalities" to set DICOM SCU timeout on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4463
diff
changeset
|
1349 ASSERT_FALSE(modality.HasTimeout()); |
cb8fcecf1b02
new option "Timeout" in "DicomModalities" to set DICOM SCU timeout on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4463
diff
changeset
|
1350 ASSERT_EQ(0u, modality.GetTimeout()); |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1351 } |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1352 |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1353 { |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1354 RemoteModalityParameters modality(s); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1355 ASSERT_EQ("HELLO", modality.GetApplicationEntityTitle()); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1356 ASSERT_EQ("world", modality.GetHost()); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1357 ASSERT_EQ(45u, modality.GetPortNumber()); |
3561
bdafff1ce443
C-Find SCU at Instance level now sets the 0008,0052 tag to IMAGE per default (was INSTANCE). Source: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/orthanc-users/FYxHXzlaQ0M/rn6d0SowAAAJ
Alain Mazy <alain@mazy.be>
parents:
3240
diff
changeset
|
1358 ASSERT_EQ(ModalityManufacturer_GenericNoWildcardInDates, modality.GetManufacturer()); |
2872
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1359 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Echo)); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1360 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Find)); |
4888
8523078f3f4b
added new configuration to authorize C-Find for worklist independently from other C-Find
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
1361 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_FindWorklist)); |
2872
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1362 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Get)); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1363 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Store)); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1364 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Move)); |
3602
085283445db0
AllowNAction in remote modality parameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3561
diff
changeset
|
1365 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_NAction)); |
3613
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1366 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_NEventReport)); |
3894
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3878
diff
changeset
|
1367 ASSERT_TRUE(modality.IsTranscodingAllowed()); |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1368 ASSERT_FALSE(modality.IsDicomTlsEnabled()); |
4463
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1369 ASSERT_FALSE(modality.HasLocalAet()); |
4518
cb8fcecf1b02
new option "Timeout" in "DicomModalities" to set DICOM SCU timeout on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4463
diff
changeset
|
1370 ASSERT_FALSE(modality.HasTimeout()); |
cb8fcecf1b02
new option "Timeout" in "DicomModalities" to set DICOM SCU timeout on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4463
diff
changeset
|
1371 ASSERT_EQ(0u, modality.GetTimeout()); |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1372 } |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1373 |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1374 s["Port"] = "46"; |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1375 |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1376 { |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1377 RemoteModalityParameters modality(s); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1378 ASSERT_EQ(46u, modality.GetPortNumber()); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1379 } |
2872
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1380 |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1381 s["Port"] = -1; ASSERT_THROW(RemoteModalityParameters m(s), OrthancException); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1382 s["Port"] = 65535; ASSERT_THROW(RemoteModalityParameters m(s), OrthancException); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1383 s["Port"] = "nope"; ASSERT_THROW(RemoteModalityParameters m(s), OrthancException); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1384 |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1385 std::set<DicomRequestType> operations; |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1386 operations.insert(DicomRequestType_Echo); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1387 operations.insert(DicomRequestType_Find); |
4888
8523078f3f4b
added new configuration to authorize C-Find for worklist independently from other C-Find
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
1388 operations.insert(DicomRequestType_FindWorklist); |
2872
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1389 operations.insert(DicomRequestType_Get); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1390 operations.insert(DicomRequestType_Move); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1391 operations.insert(DicomRequestType_Store); |
3602
085283445db0
AllowNAction in remote modality parameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3561
diff
changeset
|
1392 operations.insert(DicomRequestType_NAction); |
3613
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1393 operations.insert(DicomRequestType_NEventReport); |
2872
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1394 |
4890 | 1395 ASSERT_EQ(8u, operations.size()); |
2872
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1396 |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1397 for (std::set<DicomRequestType>::const_iterator |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1398 it = operations.begin(); it != operations.end(); ++it) |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1399 { |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1400 { |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1401 RemoteModalityParameters modality; |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1402 modality.SetRequestAllowed(*it, false); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1403 ASSERT_TRUE(modality.IsAdvancedFormatNeeded()); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1404 |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1405 modality.Serialize(s, false); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1406 ASSERT_EQ(Json::objectValue, s.type()); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1407 } |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1408 |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1409 { |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1410 RemoteModalityParameters modality(s); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1411 |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1412 ASSERT_FALSE(modality.IsRequestAllowed(*it)); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1413 |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1414 for (std::set<DicomRequestType>::const_iterator |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1415 it2 = operations.begin(); it2 != operations.end(); ++it2) |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1416 { |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1417 if (*it2 != *it) |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1418 { |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1419 ASSERT_TRUE(modality.IsRequestAllowed(*it2)); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1420 } |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1421 } |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1422 } |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1423 } |
3613
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1424 |
4463
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1425 s = Json::nullValue; |
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1426 |
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1427 { |
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1428 RemoteModalityParameters modality; |
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1429 modality.SetLocalAet("hello"); |
4518
cb8fcecf1b02
new option "Timeout" in "DicomModalities" to set DICOM SCU timeout on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4463
diff
changeset
|
1430 modality.SetTimeout(42); |
4463
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1431 ASSERT_TRUE(modality.IsAdvancedFormatNeeded()); |
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1432 modality.Serialize(s, true); |
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1433 ASSERT_EQ(Json::objectValue, s.type()); |
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1434 ASSERT_TRUE(modality.HasLocalAet()); |
4518
cb8fcecf1b02
new option "Timeout" in "DicomModalities" to set DICOM SCU timeout on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4463
diff
changeset
|
1435 ASSERT_TRUE(modality.HasTimeout()); |
cb8fcecf1b02
new option "Timeout" in "DicomModalities" to set DICOM SCU timeout on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4463
diff
changeset
|
1436 ASSERT_EQ(42u, modality.GetTimeout()); |
4463
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1437 } |
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1438 |
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1439 { |
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1440 RemoteModalityParameters modality(s); |
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1441 ASSERT_TRUE(modality.HasLocalAet()); |
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1442 ASSERT_EQ("hello", modality.GetLocalAet()); |
4518
cb8fcecf1b02
new option "Timeout" in "DicomModalities" to set DICOM SCU timeout on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4463
diff
changeset
|
1443 ASSERT_TRUE(modality.HasTimeout()); |
cb8fcecf1b02
new option "Timeout" in "DicomModalities" to set DICOM SCU timeout on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4463
diff
changeset
|
1444 ASSERT_EQ(42u, modality.GetTimeout()); |
4463
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1445 } |
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1446 |
3613
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1447 { |
4204 | 1448 Json::Value t; |
1449 t["AllowStorageCommitment"] = false; | |
1450 t["AET"] = "AET"; | |
1451 t["Host"] = "host"; | |
1452 t["Port"] = "104"; | |
3613
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1453 |
4204 | 1454 RemoteModalityParameters modality(t); |
3613
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1455 ASSERT_TRUE(modality.IsAdvancedFormatNeeded()); |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1456 ASSERT_EQ("AET", modality.GetApplicationEntityTitle()); |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1457 ASSERT_EQ("host", modality.GetHost()); |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1458 ASSERT_EQ(104u, modality.GetPortNumber()); |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1459 ASSERT_FALSE(modality.IsRequestAllowed(DicomRequestType_NAction)); |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1460 ASSERT_FALSE(modality.IsRequestAllowed(DicomRequestType_NEventReport)); |
3894
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3878
diff
changeset
|
1461 ASSERT_TRUE(modality.IsTranscodingAllowed()); |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1462 ASSERT_FALSE(modality.IsDicomTlsEnabled()); |
4463
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1463 ASSERT_FALSE(modality.HasLocalAet()); |
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1464 ASSERT_THROW(modality.GetLocalAet(), OrthancException); |
4518
cb8fcecf1b02
new option "Timeout" in "DicomModalities" to set DICOM SCU timeout on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4463
diff
changeset
|
1465 ASSERT_FALSE(modality.HasTimeout()); |
cb8fcecf1b02
new option "Timeout" in "DicomModalities" to set DICOM SCU timeout on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4463
diff
changeset
|
1466 ASSERT_EQ(0u, modality.GetTimeout()); |
3613
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1467 } |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1468 |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1469 { |
4204 | 1470 Json::Value t; |
1471 t["AllowNAction"] = false; | |
1472 t["AllowNEventReport"] = true; | |
1473 t["AET"] = "AET"; | |
1474 t["Host"] = "host"; | |
1475 t["Port"] = "104"; | |
1476 t["AllowTranscoding"] = false; | |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1477 t["UseDicomTls"] = true; |
4463
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1478 t["LocalAet"] = "world"; |
4518
cb8fcecf1b02
new option "Timeout" in "DicomModalities" to set DICOM SCU timeout on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4463
diff
changeset
|
1479 t["Timeout"] = 20; |
3613
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1480 |
4204 | 1481 RemoteModalityParameters modality(t); |
3613
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1482 ASSERT_TRUE(modality.IsAdvancedFormatNeeded()); |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1483 ASSERT_EQ("AET", modality.GetApplicationEntityTitle()); |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1484 ASSERT_EQ("host", modality.GetHost()); |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1485 ASSERT_EQ(104u, modality.GetPortNumber()); |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1486 ASSERT_FALSE(modality.IsRequestAllowed(DicomRequestType_NAction)); |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1487 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_NEventReport)); |
3894
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3878
diff
changeset
|
1488 ASSERT_FALSE(modality.IsTranscodingAllowed()); |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1489 ASSERT_TRUE(modality.IsDicomTlsEnabled()); |
4463
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1490 ASSERT_TRUE(modality.HasLocalAet()); |
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1491 ASSERT_EQ("world", modality.GetLocalAet()); |
4518
cb8fcecf1b02
new option "Timeout" in "DicomModalities" to set DICOM SCU timeout on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4463
diff
changeset
|
1492 ASSERT_TRUE(modality.HasTimeout()); |
cb8fcecf1b02
new option "Timeout" in "DicomModalities" to set DICOM SCU timeout on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4463
diff
changeset
|
1493 ASSERT_EQ(20u, modality.GetTimeout()); |
3613
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1494 } |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1495 |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1496 { |
4204 | 1497 Json::Value t; |
1498 t["AllowNAction"] = true; | |
1499 t["AllowNEventReport"] = true; | |
1500 t["AET"] = "AET"; | |
1501 t["Host"] = "host"; | |
1502 t["Port"] = "104"; | |
3613
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1503 |
4204 | 1504 RemoteModalityParameters modality(t); |
3613
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1505 ASSERT_FALSE(modality.IsAdvancedFormatNeeded()); |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1506 ASSERT_EQ("AET", modality.GetApplicationEntityTitle()); |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1507 ASSERT_EQ("host", modality.GetHost()); |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1508 ASSERT_EQ(104u, modality.GetPortNumber()); |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1509 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_NAction)); |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1510 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_NEventReport)); |
3894
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3878
diff
changeset
|
1511 ASSERT_TRUE(modality.IsTranscodingAllowed()); |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1512 ASSERT_FALSE(modality.IsDicomTlsEnabled()); |
4463
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1513 ASSERT_FALSE(modality.HasLocalAet()); |
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1514 ASSERT_THROW(modality.GetLocalAet(), OrthancException); |
3613
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1515 } |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1516 } |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1517 |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1518 |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1519 |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1520 TEST(JobsSerialization, DicomAssociationParameters) |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1521 { |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1522 { |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1523 DicomAssociationParameters a; |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1524 |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1525 Json::Value v = Json::objectValue; |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1526 a.SerializeJob(v); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1527 ASSERT_EQ(Json::objectValue, v.type()); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1528 ASSERT_EQ("ORTHANC", v["LocalAet"].asString()); |
4457
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4451
diff
changeset
|
1529 ASSERT_EQ(DicomAssociationParameters::GetDefaultTimeout(), v["Timeout"].asUInt()); |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1530 ASSERT_TRUE(v.isMember("Remote")); |
4451
f4dbdb2dcba6
new configuration option "MaximumPduLength" to tune the maximum PDU length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4438
diff
changeset
|
1531 ASSERT_TRUE(v.isMember("MaximumPduLength")); |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1532 |
4656
82a314325351
New configuration option: "DicomTlsRemoteCertificateRequired"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4518
diff
changeset
|
1533 ASSERT_EQ(5u, v.getMemberNames().size()); |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1534 |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1535 DicomAssociationParameters b; |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1536 b.UnserializeJob(v); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1537 ASSERT_EQ("ANY-SCP", b.GetRemoteModality().GetApplicationEntityTitle()); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1538 ASSERT_EQ("127.0.0.1", b.GetRemoteModality().GetHost()); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1539 ASSERT_EQ(104u, b.GetRemoteModality().GetPortNumber()); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1540 ASSERT_EQ("ORTHANC", b.GetLocalApplicationEntityTitle()); |
4451
f4dbdb2dcba6
new configuration option "MaximumPduLength" to tune the maximum PDU length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4438
diff
changeset
|
1541 ASSERT_EQ(DicomAssociationParameters::GetDefaultMaximumPduLength(), b.GetMaximumPduLength()); |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1542 ASSERT_FALSE(b.GetRemoteModality().IsDicomTlsEnabled()); |
4463
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1543 ASSERT_FALSE(b.GetRemoteModality().HasLocalAet()); |
522e13a60cfc
"LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
1544 ASSERT_THROW(b.GetRemoteModality().GetLocalAet(), OrthancException); |
4518
cb8fcecf1b02
new option "Timeout" in "DicomModalities" to set DICOM SCU timeout on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4463
diff
changeset
|
1545 ASSERT_FALSE(b.GetRemoteModality().HasTimeout()); |
cb8fcecf1b02
new option "Timeout" in "DicomModalities" to set DICOM SCU timeout on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4463
diff
changeset
|
1546 ASSERT_EQ(0u, b.GetRemoteModality().GetTimeout()); |
4656
82a314325351
New configuration option: "DicomTlsRemoteCertificateRequired"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4518
diff
changeset
|
1547 ASSERT_TRUE(b.IsRemoteCertificateRequired()); |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1548 } |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1549 |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1550 { |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1551 RemoteModalityParameters p; |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1552 p.SetApplicationEntityTitle("WORLD"); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1553 p.SetPortNumber(4242); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1554 p.SetHost("hello.world.com"); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1555 p.SetDicomTlsEnabled(true); |
4518
cb8fcecf1b02
new option "Timeout" in "DicomModalities" to set DICOM SCU timeout on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4463
diff
changeset
|
1556 p.SetTimeout(42); |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1557 |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1558 DicomAssociationParameters a("HELLO", p); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1559 a.SetOwnCertificatePath("key", "crt"); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1560 a.SetTrustedCertificatesPath("trusted"); |
4656
82a314325351
New configuration option: "DicomTlsRemoteCertificateRequired"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4518
diff
changeset
|
1561 a.SetRemoteCertificateRequired(false); |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1562 |
4451
f4dbdb2dcba6
new configuration option "MaximumPduLength" to tune the maximum PDU length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4438
diff
changeset
|
1563 ASSERT_THROW(a.SetMaximumPduLength(4095), OrthancException); |
f4dbdb2dcba6
new configuration option "MaximumPduLength" to tune the maximum PDU length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4438
diff
changeset
|
1564 ASSERT_THROW(a.SetMaximumPduLength(131073), OrthancException); |
f4dbdb2dcba6
new configuration option "MaximumPduLength" to tune the maximum PDU length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4438
diff
changeset
|
1565 a.SetMaximumPduLength(4096); |
f4dbdb2dcba6
new configuration option "MaximumPduLength" to tune the maximum PDU length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4438
diff
changeset
|
1566 a.SetMaximumPduLength(131072); |
f4dbdb2dcba6
new configuration option "MaximumPduLength" to tune the maximum PDU length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4438
diff
changeset
|
1567 |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1568 Json::Value v = Json::objectValue; |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1569 a.SerializeJob(v); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1570 |
4656
82a314325351
New configuration option: "DicomTlsRemoteCertificateRequired"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4518
diff
changeset
|
1571 ASSERT_EQ(8u, v.getMemberNames().size()); |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1572 |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1573 DicomAssociationParameters b = DicomAssociationParameters::UnserializeJob(v); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1574 |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1575 ASSERT_EQ("WORLD", b.GetRemoteModality().GetApplicationEntityTitle()); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1576 ASSERT_EQ("hello.world.com", b.GetRemoteModality().GetHost()); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1577 ASSERT_EQ(4242u, b.GetRemoteModality().GetPortNumber()); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1578 ASSERT_EQ("HELLO", b.GetLocalApplicationEntityTitle()); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1579 ASSERT_TRUE(b.GetRemoteModality().IsDicomTlsEnabled()); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1580 ASSERT_EQ("key", b.GetOwnPrivateKeyPath()); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1581 ASSERT_EQ("crt", b.GetOwnCertificatePath()); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1582 ASSERT_EQ("trusted", b.GetTrustedCertificatesPath()); |
4457
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4451
diff
changeset
|
1583 ASSERT_EQ(131072u, b.GetMaximumPduLength()); |
4518
cb8fcecf1b02
new option "Timeout" in "DicomModalities" to set DICOM SCU timeout on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4463
diff
changeset
|
1584 ASSERT_TRUE(b.GetRemoteModality().HasTimeout()); |
cb8fcecf1b02
new option "Timeout" in "DicomModalities" to set DICOM SCU timeout on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4463
diff
changeset
|
1585 ASSERT_EQ(42u, b.GetRemoteModality().GetTimeout()); |
4656
82a314325351
New configuration option: "DicomTlsRemoteCertificateRequired"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4518
diff
changeset
|
1586 ASSERT_FALSE(b.IsRemoteCertificateRequired()); |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1587 } |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1588 } |
4775
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1589 |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1590 |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1591 TEST(SerializationToolbox, Numbers) |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1592 { |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1593 { |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1594 int32_t i; |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1595 ASSERT_FALSE(SerializationToolbox::ParseInteger32(i, "")); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1596 ASSERT_FALSE(SerializationToolbox::ParseInteger32(i, "ee")); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1597 ASSERT_TRUE(SerializationToolbox::ParseInteger32(i, "42")); ASSERT_EQ(42, i); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1598 ASSERT_TRUE(SerializationToolbox::ParseInteger32(i, "-42")); ASSERT_EQ(-42, i); |
4779 | 1599 ASSERT_TRUE(SerializationToolbox::ParseInteger32(i, "-2147483648")); ASSERT_EQ(-2147483648l, i); |
1600 ASSERT_TRUE(SerializationToolbox::ParseInteger32(i, "2147483647")); ASSERT_EQ(2147483647l, i); | |
4775
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1601 ASSERT_FALSE(SerializationToolbox::ParseInteger32(i, "-2147483649")); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1602 ASSERT_FALSE(SerializationToolbox::ParseInteger32(i, "2147483648")); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1603 ASSERT_FALSE(SerializationToolbox::ParseInteger32(i, "-2\\-3\\-4")); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1604 ASSERT_TRUE(SerializationToolbox::ParseFirstInteger32(i, "-2\\-3\\-4")); ASSERT_EQ(-2, i); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1605 } |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1606 |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1607 { |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1608 uint32_t i; |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1609 ASSERT_FALSE(SerializationToolbox::ParseUnsignedInteger32(i, "")); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1610 ASSERT_FALSE(SerializationToolbox::ParseUnsignedInteger32(i, "ee")); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1611 ASSERT_TRUE(SerializationToolbox::ParseUnsignedInteger32(i, "42")); ASSERT_EQ(42u, i); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1612 ASSERT_FALSE(SerializationToolbox::ParseUnsignedInteger32(i, "-42")); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1613 ASSERT_TRUE(SerializationToolbox::ParseUnsignedInteger32(i, "4294967295")); ASSERT_EQ(4294967295u, i); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1614 ASSERT_FALSE(SerializationToolbox::ParseUnsignedInteger32(i, "4294967296")); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1615 ASSERT_FALSE(SerializationToolbox::ParseUnsignedInteger32(i, "2\\3\\4")); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1616 ASSERT_TRUE(SerializationToolbox::ParseFirstUnsignedInteger32(i, "2\\3\\4")); ASSERT_EQ(2u, i); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1617 } |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1618 |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1619 { |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1620 int64_t i; |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1621 ASSERT_FALSE(SerializationToolbox::ParseInteger64(i, "")); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1622 ASSERT_FALSE(SerializationToolbox::ParseInteger64(i, "ee")); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1623 ASSERT_TRUE(SerializationToolbox::ParseInteger64(i, "42")); ASSERT_EQ(42, i); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1624 ASSERT_TRUE(SerializationToolbox::ParseInteger64(i, "-42")); ASSERT_EQ(-42, i); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1625 ASSERT_TRUE(SerializationToolbox::ParseInteger64(i, "-2147483649")); ASSERT_EQ(-2147483649ll, i); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1626 ASSERT_TRUE(SerializationToolbox::ParseInteger64(i, "2147483648")); ASSERT_EQ(2147483648ll, i); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1627 ASSERT_FALSE(SerializationToolbox::ParseInteger64(i, "-2\\-3\\-4")); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1628 ASSERT_TRUE(SerializationToolbox::ParseFirstInteger64(i, "-2\\-3\\-4")); ASSERT_EQ(-2, i); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1629 } |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1630 |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1631 { |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1632 uint64_t i; |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1633 ASSERT_FALSE(SerializationToolbox::ParseUnsignedInteger64(i, "")); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1634 ASSERT_FALSE(SerializationToolbox::ParseUnsignedInteger64(i, "ee")); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1635 ASSERT_TRUE(SerializationToolbox::ParseUnsignedInteger64(i, "42")); ASSERT_EQ(42u, i); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1636 ASSERT_FALSE(SerializationToolbox::ParseUnsignedInteger64(i, "-42")); |
4779 | 1637 ASSERT_TRUE(SerializationToolbox::ParseUnsignedInteger64(i, "4294967296")); ASSERT_EQ(4294967296lu, i); |
4775
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1638 ASSERT_FALSE(SerializationToolbox::ParseUnsignedInteger64(i, "2\\3\\4")); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1639 ASSERT_TRUE(SerializationToolbox::ParseFirstUnsignedInteger64(i, "2\\3\\4")); ASSERT_EQ(2u, i); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1640 } |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1641 |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1642 { |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1643 float i; |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1644 ASSERT_FALSE(SerializationToolbox::ParseFloat(i, "")); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1645 ASSERT_FALSE(SerializationToolbox::ParseFloat(i, "ee")); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1646 ASSERT_TRUE(SerializationToolbox::ParseFloat(i, "42")); ASSERT_FLOAT_EQ(42.0f, i); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1647 ASSERT_TRUE(SerializationToolbox::ParseFloat(i, "-42")); ASSERT_FLOAT_EQ(-42.0f, i); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1648 ASSERT_FALSE(SerializationToolbox::ParseFloat(i, "2\\3\\4")); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1649 ASSERT_TRUE(SerializationToolbox::ParseFirstFloat(i, "1.367\\2.367\\3.367")); ASSERT_FLOAT_EQ(1.367f, i); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1650 |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1651 ASSERT_TRUE(SerializationToolbox::ParseFloat(i, "1.2")); ASSERT_FLOAT_EQ(1.2f, i); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1652 ASSERT_TRUE(SerializationToolbox::ParseFloat(i, "-1.2e+2")); ASSERT_FLOAT_EQ(-120.0f, i); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1653 ASSERT_TRUE(SerializationToolbox::ParseFloat(i, "-1e-2")); ASSERT_FLOAT_EQ(-0.01f, i); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1654 ASSERT_TRUE(SerializationToolbox::ParseFloat(i, "1.3671875")); ASSERT_FLOAT_EQ(1.3671875f, i); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1655 } |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1656 |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1657 { |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1658 double i; |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1659 ASSERT_FALSE(SerializationToolbox::ParseDouble(i, "")); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1660 ASSERT_FALSE(SerializationToolbox::ParseDouble(i, "ee")); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1661 ASSERT_TRUE(SerializationToolbox::ParseDouble(i, "42")); ASSERT_DOUBLE_EQ(42.0, i); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1662 ASSERT_TRUE(SerializationToolbox::ParseDouble(i, "-42")); ASSERT_DOUBLE_EQ(-42.0, i); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1663 ASSERT_FALSE(SerializationToolbox::ParseDouble(i, "2\\3\\4")); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1664 ASSERT_TRUE(SerializationToolbox::ParseFirstDouble(i, "1.367\\2.367\\3.367")); ASSERT_DOUBLE_EQ(1.367, i); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1665 |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1666 ASSERT_TRUE(SerializationToolbox::ParseDouble(i, "1.2")); ASSERT_DOUBLE_EQ(1.2, i); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1667 ASSERT_TRUE(SerializationToolbox::ParseDouble(i, "-1.2e+2")); ASSERT_DOUBLE_EQ(-120.0, i); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1668 ASSERT_TRUE(SerializationToolbox::ParseDouble(i, "-1e-2")); ASSERT_DOUBLE_EQ(-0.01, i); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1669 ASSERT_TRUE(SerializationToolbox::ParseDouble(i, "1.3671875")); ASSERT_DOUBLE_EQ(1.3671875, i); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1670 } |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1671 } |