Mercurial > hg > orthanc
annotate OrthancFramework/UnitTestsSources/JobsTests.cpp @ 4567:b812a5f2cef3 db-changes
cont
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 08 Mar 2021 14:41:29 +0100 |
parents | cb8fcecf1b02 |
children | 82a314325351 |
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 |
4437
d9473bd5ed43
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4310
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
6 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
7 * 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
|
8 * 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
|
9 * 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
|
10 * 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
|
11 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
12 * 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
|
13 * 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
|
14 * 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
|
15 * Lesser General Public License for more details. |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
16 * |
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 * 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
|
18 * 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
|
19 * <http://www.gnu.org/licenses/>. |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
20 **/ |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
21 |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
22 |
4060
149172a06b4d
splitting MultiThreadingTests.cpp into JobsTests.cpp and ServerJobsTests.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
23 #if ORTHANC_UNIT_TESTS_LINK_FRAMEWORK == 1 |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
24 // 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
|
25 # include <OrthancFramework.h> |
149172a06b4d
splitting MultiThreadingTests.cpp into JobsTests.cpp and ServerJobsTests.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
26 #endif |
149172a06b4d
splitting MultiThreadingTests.cpp into JobsTests.cpp and ServerJobsTests.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
27 |
4062 | 28 #include <gtest/gtest.h> |
723 | 29 |
4045 | 30 #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
|
31 #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
|
32 #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
|
33 #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
|
34 #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
|
35 #include "../../OrthancFramework/Sources/JobsEngine/GenericJobUnserializer.h" |
4045 | 36 #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
|
37 #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
|
38 #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
|
39 #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
|
40 #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
|
41 #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
|
42 #include "../../OrthancFramework/Sources/JobsEngine/SetOfInstancesJob.h" |
4045 | 43 #include "../../OrthancFramework/Sources/Logging.h" |
44 #include "../../OrthancFramework/Sources/MultiThreading/SharedMessageQueue.h" | |
45 #include "../../OrthancFramework/Sources/OrthancException.h" | |
46 #include "../../OrthancFramework/Sources/SerializationToolbox.h" | |
2655 | 47 |
723 | 48 |
49 using namespace Orthanc; | |
50 | |
51 namespace | |
52 { | |
2652 | 53 class DummyJob : public IJob |
54 { | |
55 private: | |
56 bool fails_; | |
57 unsigned int count_; | |
58 unsigned int steps_; | |
59 | |
60 public: | |
61 DummyJob() : | |
62 fails_(false), | |
63 count_(0), | |
64 steps_(4) | |
65 { | |
66 } | |
67 | |
68 explicit DummyJob(bool fails) : | |
69 fails_(fails), | |
70 count_(0), | |
71 steps_(4) | |
72 { | |
73 } | |
74 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2872
diff
changeset
|
75 virtual void Start() ORTHANC_OVERRIDE |
2652 | 76 { |
77 } | |
78 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2872
diff
changeset
|
79 virtual void Reset() ORTHANC_OVERRIDE |
2652 | 80 { |
81 } | |
82 | |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
83 virtual JobStepResult Step(const std::string& jobId) ORTHANC_OVERRIDE |
2652 | 84 { |
85 if (fails_) | |
86 { | |
3240
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3093
diff
changeset
|
87 return JobStepResult::Failure(ErrorCode_ParameterOutOfRange, NULL); |
2652 | 88 } |
89 else if (count_ == steps_ - 1) | |
90 { | |
91 return JobStepResult::Success(); | |
92 } | |
93 else | |
94 { | |
95 count_++; | |
96 return JobStepResult::Continue(); | |
97 } | |
98 } | |
99 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2872
diff
changeset
|
100 virtual void Stop(JobStopReason reason) ORTHANC_OVERRIDE |
2652 | 101 { |
102 } | |
103 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2872
diff
changeset
|
104 virtual float GetProgress() ORTHANC_OVERRIDE |
2652 | 105 { |
106 return static_cast<float>(count_) / static_cast<float>(steps_ - 1); | |
107 } | |
108 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2872
diff
changeset
|
109 virtual void GetJobType(std::string& type) ORTHANC_OVERRIDE |
2652 | 110 { |
111 type = "DummyJob"; | |
112 } | |
113 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2872
diff
changeset
|
114 virtual bool Serialize(Json::Value& value) ORTHANC_OVERRIDE |
2652 | 115 { |
2667
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
116 value = Json::objectValue; |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
117 value["Type"] = "DummyJob"; |
2663
228e2783ce83
some jobs might not be serializable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2662
diff
changeset
|
118 return true; |
2652 | 119 } |
120 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2872
diff
changeset
|
121 virtual void GetPublicContent(Json::Value& value) ORTHANC_OVERRIDE |
2652 | 122 { |
123 value["hello"] = "world"; | |
124 } | |
2976
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2966
diff
changeset
|
125 |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2966
diff
changeset
|
126 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
|
127 MimeType& mime, |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2966
diff
changeset
|
128 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
|
129 { |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2966
diff
changeset
|
130 return false; |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2966
diff
changeset
|
131 } |
2652 | 132 }; |
133 | |
134 | |
135 class DummyInstancesJob : public SetOfInstancesJob | |
136 { | |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
137 private: |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
138 bool trailingStepDone_; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
139 |
2652 | 140 protected: |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2872
diff
changeset
|
141 virtual bool HandleInstance(const std::string& instance) ORTHANC_OVERRIDE |
2652 | 142 { |
2657
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
143 return (instance != "nope"); |
2652 | 144 } |
145 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2872
diff
changeset
|
146 virtual bool HandleTrailingStep() ORTHANC_OVERRIDE |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
147 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
148 if (HasTrailingStep()) |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
149 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
150 if (trailingStepDone_) |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
151 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
152 throw OrthancException(ErrorCode_InternalError); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
153 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
154 else |
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 trailingStepDone_ = true; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
157 return true; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
158 } |
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 else |
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 throw OrthancException(ErrorCode_InternalError); |
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 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
165 |
2652 | 166 public: |
2860 | 167 DummyInstancesJob() : |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
168 trailingStepDone_(false) |
2652 | 169 { |
170 } | |
171 | |
4204 | 172 explicit DummyInstancesJob(const Json::Value& value) : |
2652 | 173 SetOfInstancesJob(value) |
174 { | |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
175 if (HasTrailingStep()) |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
176 { |
2860 | 177 trailingStepDone_ = (GetPosition() == GetCommandsCount()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
178 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
179 else |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
180 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
181 trailingStepDone_ = false; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
182 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
183 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
184 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
185 bool IsTrailingStepDone() const |
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 return trailingStepDone_; |
2652 | 188 } |
189 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2872
diff
changeset
|
190 virtual void Stop(JobStopReason reason) ORTHANC_OVERRIDE |
2652 | 191 { |
192 } | |
193 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2872
diff
changeset
|
194 virtual void GetJobType(std::string& s) ORTHANC_OVERRIDE |
2652 | 195 { |
196 s = "DummyInstancesJob"; | |
197 } | |
198 }; | |
199 | |
200 | |
201 class DummyUnserializer : public GenericJobUnserializer | |
202 { | |
203 public: | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2872
diff
changeset
|
204 virtual IJob* UnserializeJob(const Json::Value& value) ORTHANC_OVERRIDE |
2652 | 205 { |
2656
a6d3e45eeff5
SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2655
diff
changeset
|
206 if (SerializationToolbox::ReadString(value, "Type") == "DummyInstancesJob") |
2652 | 207 { |
208 return new DummyInstancesJob(value); | |
209 } | |
2667
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
210 else if (SerializationToolbox::ReadString(value, "Type") == "DummyJob") |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
211 { |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
212 return new DummyJob; |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
213 } |
2652 | 214 else |
215 { | |
216 return GenericJobUnserializer::UnserializeJob(value); | |
217 } | |
218 } | |
219 }; | |
220 | |
221 | |
1396
ac4efabeb80c
Migration of the orthanc-client as a separate project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1304
diff
changeset
|
222 class DynamicInteger : public IDynamicObject |
723 | 223 { |
224 private: | |
225 int value_; | |
226 std::set<int>& target_; | |
227 | |
228 public: | |
229 DynamicInteger(int value, std::set<int>& target) : | |
230 value_(value), target_(target) | |
231 { | |
232 } | |
233 | |
234 int GetValue() const | |
235 { | |
236 return value_; | |
237 } | |
238 }; | |
239 } | |
240 | |
241 | |
242 TEST(MultiThreading, SharedMessageQueueBasic) | |
243 { | |
244 std::set<int> s; | |
245 | |
246 SharedMessageQueue q; | |
247 ASSERT_TRUE(q.WaitEmpty(0)); | |
248 q.Enqueue(new DynamicInteger(10, s)); | |
249 ASSERT_FALSE(q.WaitEmpty(1)); | |
250 q.Enqueue(new DynamicInteger(20, s)); | |
251 q.Enqueue(new DynamicInteger(30, s)); | |
252 q.Enqueue(new DynamicInteger(40, s)); | |
253 | |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
254 std::unique_ptr<DynamicInteger> i; |
723 | 255 i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(10, i->GetValue()); |
256 i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(20, i->GetValue()); | |
257 i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(30, i->GetValue()); | |
258 ASSERT_FALSE(q.WaitEmpty(1)); | |
259 i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(40, i->GetValue()); | |
260 ASSERT_TRUE(q.WaitEmpty(0)); | |
261 ASSERT_EQ(NULL, q.Dequeue(1)); | |
262 } | |
263 | |
264 | |
265 TEST(MultiThreading, SharedMessageQueueClean) | |
266 { | |
267 std::set<int> s; | |
268 | |
269 try | |
270 { | |
271 SharedMessageQueue q; | |
272 q.Enqueue(new DynamicInteger(10, s)); | |
273 q.Enqueue(new DynamicInteger(20, s)); | |
1583
9ea3d082b064
got rid of custom exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
274 throw OrthancException(ErrorCode_InternalError); |
723 | 275 } |
276 catch (OrthancException&) | |
277 { | |
278 } | |
279 } | |
280 | |
281 | |
769
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
282 |
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
283 |
2652 | 284 static bool CheckState(JobsRegistry& registry, |
285 const std::string& id, | |
286 JobState state) | |
2557 | 287 { |
2652 | 288 JobState s; |
2558 | 289 if (registry.GetState(s, id)) |
2557 | 290 { |
291 return state == s; | |
292 } | |
293 else | |
294 { | |
295 return false; | |
296 } | |
297 } | |
298 | |
299 | |
2652 | 300 static bool CheckErrorCode(JobsRegistry& registry, |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
301 const std::string& id, |
2652 | 302 ErrorCode code) |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
303 { |
2652 | 304 JobInfo s; |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
305 if (registry.GetJobInfo(s, id)) |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
306 { |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
307 return code == s.GetStatus().GetErrorCode(); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
308 } |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
309 else |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
310 { |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
311 return false; |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
312 } |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
313 } |
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 |
2558 | 316 TEST(JobsRegistry, Priority) |
2557 | 317 { |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
318 JobsRegistry registry(10); |
2557 | 319 |
320 std::string i1, i2, i3, i4; | |
2558 | 321 registry.Submit(i1, new DummyJob(), 10); |
322 registry.Submit(i2, new DummyJob(), 30); | |
323 registry.Submit(i3, new DummyJob(), 20); | |
324 registry.Submit(i4, new DummyJob(), 5); | |
2557 | 325 |
2558 | 326 registry.SetMaxCompletedJobs(2); |
2557 | 327 |
328 std::set<std::string> id; | |
2558 | 329 registry.ListJobs(id); |
2557 | 330 |
331 ASSERT_EQ(4u, id.size()); | |
332 ASSERT_TRUE(id.find(i1) != id.end()); | |
333 ASSERT_TRUE(id.find(i2) != id.end()); | |
334 ASSERT_TRUE(id.find(i3) != id.end()); | |
335 ASSERT_TRUE(id.find(i4) != id.end()); | |
336 | |
2652 | 337 ASSERT_TRUE(CheckState(registry, i2, JobState_Pending)); |
2557 | 338 |
339 { | |
2558 | 340 JobsRegistry::RunningJob job(registry, 0); |
2557 | 341 ASSERT_TRUE(job.IsValid()); |
342 ASSERT_EQ(30, job.GetPriority()); | |
343 ASSERT_EQ(i2, job.GetId()); | |
344 | |
2652 | 345 ASSERT_TRUE(CheckState(registry, i2, JobState_Running)); |
2557 | 346 } |
347 | |
2652 | 348 ASSERT_TRUE(CheckState(registry, i2, JobState_Failure)); |
349 ASSERT_TRUE(CheckState(registry, i3, JobState_Pending)); | |
2557 | 350 |
351 { | |
2558 | 352 JobsRegistry::RunningJob job(registry, 0); |
2557 | 353 ASSERT_TRUE(job.IsValid()); |
354 ASSERT_EQ(20, job.GetPriority()); | |
355 ASSERT_EQ(i3, job.GetId()); | |
356 | |
357 job.MarkSuccess(); | |
358 | |
2652 | 359 ASSERT_TRUE(CheckState(registry, i3, JobState_Running)); |
2557 | 360 } |
361 | |
2652 | 362 ASSERT_TRUE(CheckState(registry, i3, JobState_Success)); |
2557 | 363 |
364 { | |
2558 | 365 JobsRegistry::RunningJob job(registry, 0); |
2557 | 366 ASSERT_TRUE(job.IsValid()); |
367 ASSERT_EQ(10, job.GetPriority()); | |
368 ASSERT_EQ(i1, job.GetId()); | |
369 } | |
370 | |
371 { | |
2558 | 372 JobsRegistry::RunningJob job(registry, 0); |
2557 | 373 ASSERT_TRUE(job.IsValid()); |
374 ASSERT_EQ(5, job.GetPriority()); | |
375 ASSERT_EQ(i4, job.GetId()); | |
376 } | |
377 | |
378 { | |
2558 | 379 JobsRegistry::RunningJob job(registry, 1); |
2557 | 380 ASSERT_FALSE(job.IsValid()); |
381 } | |
382 | |
2652 | 383 JobState s; |
2558 | 384 ASSERT_TRUE(registry.GetState(s, i1)); |
385 ASSERT_FALSE(registry.GetState(s, i2)); // Removed because oldest | |
386 ASSERT_FALSE(registry.GetState(s, i3)); // Removed because second oldest | |
387 ASSERT_TRUE(registry.GetState(s, i4)); | |
2557 | 388 |
2558 | 389 registry.SetMaxCompletedJobs(1); // (*) |
390 ASSERT_FALSE(registry.GetState(s, i1)); // Just discarded by (*) | |
391 ASSERT_TRUE(registry.GetState(s, i4)); | |
2557 | 392 } |
393 | |
394 | |
2558 | 395 TEST(JobsRegistry, Simultaneous) |
2557 | 396 { |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
397 JobsRegistry registry(10); |
2558 | 398 |
399 std::string i1, i2; | |
400 registry.Submit(i1, new DummyJob(), 20); | |
401 registry.Submit(i2, new DummyJob(), 10); | |
402 | |
2652 | 403 ASSERT_TRUE(CheckState(registry, i1, JobState_Pending)); |
404 ASSERT_TRUE(CheckState(registry, i2, JobState_Pending)); | |
2558 | 405 |
406 { | |
407 JobsRegistry::RunningJob job1(registry, 0); | |
408 JobsRegistry::RunningJob job2(registry, 0); | |
409 | |
410 ASSERT_TRUE(job1.IsValid()); | |
411 ASSERT_TRUE(job2.IsValid()); | |
412 | |
413 job1.MarkFailure(); | |
414 job2.MarkSuccess(); | |
415 | |
2652 | 416 ASSERT_TRUE(CheckState(registry, i1, JobState_Running)); |
417 ASSERT_TRUE(CheckState(registry, i2, JobState_Running)); | |
2558 | 418 } |
419 | |
2652 | 420 ASSERT_TRUE(CheckState(registry, i1, JobState_Failure)); |
421 ASSERT_TRUE(CheckState(registry, i2, JobState_Success)); | |
2558 | 422 } |
423 | |
424 | |
425 TEST(JobsRegistry, Resubmit) | |
426 { | |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
427 JobsRegistry registry(10); |
2557 | 428 |
429 std::string id; | |
2558 | 430 registry.Submit(id, new DummyJob(), 10); |
2557 | 431 |
2652 | 432 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2557 | 433 |
2558 | 434 registry.Resubmit(id); |
2652 | 435 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2557 | 436 |
437 { | |
2558 | 438 JobsRegistry::RunningJob job(registry, 0); |
2557 | 439 ASSERT_TRUE(job.IsValid()); |
440 job.MarkFailure(); | |
441 | |
2652 | 442 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2557 | 443 |
2558 | 444 registry.Resubmit(id); |
2652 | 445 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2557 | 446 } |
447 | |
2652 | 448 ASSERT_TRUE(CheckState(registry, id, JobState_Failure)); |
2557 | 449 |
2558 | 450 registry.Resubmit(id); |
2652 | 451 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2557 | 452 |
453 { | |
2558 | 454 JobsRegistry::RunningJob job(registry, 0); |
2557 | 455 ASSERT_TRUE(job.IsValid()); |
456 ASSERT_EQ(id, job.GetId()); | |
457 | |
458 job.MarkSuccess(); | |
2652 | 459 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2558 | 460 } |
461 | |
2652 | 462 ASSERT_TRUE(CheckState(registry, id, JobState_Success)); |
2558 | 463 |
464 registry.Resubmit(id); | |
2652 | 465 ASSERT_TRUE(CheckState(registry, id, JobState_Success)); |
2558 | 466 } |
467 | |
468 | |
469 TEST(JobsRegistry, Retry) | |
470 { | |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
471 JobsRegistry registry(10); |
2558 | 472 |
473 std::string id; | |
474 registry.Submit(id, new DummyJob(), 10); | |
475 | |
2652 | 476 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2558 | 477 |
478 { | |
479 JobsRegistry::RunningJob job(registry, 0); | |
480 ASSERT_TRUE(job.IsValid()); | |
481 job.MarkRetry(0); | |
482 | |
2652 | 483 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2558 | 484 } |
485 | |
2652 | 486 ASSERT_TRUE(CheckState(registry, id, JobState_Retry)); |
2558 | 487 |
488 registry.Resubmit(id); | |
2652 | 489 ASSERT_TRUE(CheckState(registry, id, JobState_Retry)); |
2558 | 490 |
491 registry.ScheduleRetries(); | |
2652 | 492 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2558 | 493 |
494 { | |
495 JobsRegistry::RunningJob job(registry, 0); | |
496 ASSERT_TRUE(job.IsValid()); | |
497 job.MarkSuccess(); | |
498 | |
2652 | 499 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2557 | 500 } |
501 | |
2652 | 502 ASSERT_TRUE(CheckState(registry, id, JobState_Success)); |
2558 | 503 } |
504 | |
505 | |
506 TEST(JobsRegistry, PausePending) | |
507 { | |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
508 JobsRegistry registry(10); |
2558 | 509 |
510 std::string id; | |
511 registry.Submit(id, new DummyJob(), 10); | |
512 | |
2652 | 513 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2558 | 514 |
515 registry.Pause(id); | |
2652 | 516 ASSERT_TRUE(CheckState(registry, id, JobState_Paused)); |
2558 | 517 |
518 registry.Pause(id); | |
2652 | 519 ASSERT_TRUE(CheckState(registry, id, JobState_Paused)); |
2558 | 520 |
521 registry.Resubmit(id); | |
2652 | 522 ASSERT_TRUE(CheckState(registry, id, JobState_Paused)); |
2558 | 523 |
524 registry.Resume(id); | |
2652 | 525 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2557 | 526 } |
2558 | 527 |
528 | |
529 TEST(JobsRegistry, PauseRunning) | |
530 { | |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
531 JobsRegistry registry(10); |
2558 | 532 |
533 std::string id; | |
534 registry.Submit(id, new DummyJob(), 10); | |
535 | |
2652 | 536 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2558 | 537 |
538 { | |
539 JobsRegistry::RunningJob job(registry, 0); | |
540 ASSERT_TRUE(job.IsValid()); | |
541 | |
542 registry.Resubmit(id); | |
2562 | 543 job.MarkPause(); |
2652 | 544 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2558 | 545 } |
546 | |
2652 | 547 ASSERT_TRUE(CheckState(registry, id, JobState_Paused)); |
2558 | 548 |
549 registry.Resubmit(id); | |
2652 | 550 ASSERT_TRUE(CheckState(registry, id, JobState_Paused)); |
2558 | 551 |
552 registry.Resume(id); | |
2652 | 553 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2558 | 554 |
555 { | |
556 JobsRegistry::RunningJob job(registry, 0); | |
557 ASSERT_TRUE(job.IsValid()); | |
558 | |
559 job.MarkSuccess(); | |
2652 | 560 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2558 | 561 } |
562 | |
2652 | 563 ASSERT_TRUE(CheckState(registry, id, JobState_Success)); |
2558 | 564 } |
565 | |
566 | |
567 TEST(JobsRegistry, PauseRetry) | |
568 { | |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
569 JobsRegistry registry(10); |
2558 | 570 |
571 std::string id; | |
572 registry.Submit(id, new DummyJob(), 10); | |
573 | |
2652 | 574 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2558 | 575 |
576 { | |
577 JobsRegistry::RunningJob job(registry, 0); | |
578 ASSERT_TRUE(job.IsValid()); | |
579 | |
580 job.MarkRetry(0); | |
2652 | 581 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2558 | 582 } |
583 | |
2652 | 584 ASSERT_TRUE(CheckState(registry, id, JobState_Retry)); |
2558 | 585 |
586 registry.Pause(id); | |
2652 | 587 ASSERT_TRUE(CheckState(registry, id, JobState_Paused)); |
2558 | 588 |
589 registry.Resume(id); | |
2652 | 590 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2558 | 591 |
592 { | |
593 JobsRegistry::RunningJob job(registry, 0); | |
594 ASSERT_TRUE(job.IsValid()); | |
595 | |
596 job.MarkSuccess(); | |
2652 | 597 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2558 | 598 } |
599 | |
2652 | 600 ASSERT_TRUE(CheckState(registry, id, JobState_Success)); |
2558 | 601 } |
2565 | 602 |
603 | |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
604 TEST(JobsRegistry, Cancel) |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
605 { |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
606 JobsRegistry registry(10); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
607 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
608 std::string id; |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
609 registry.Submit(id, new DummyJob(), 10); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
610 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
611 ASSERT_FALSE(registry.Cancel("nope")); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
612 |
2652 | 613 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
614 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_Success)); |
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 ASSERT_TRUE(registry.Cancel(id)); |
2652 | 617 ASSERT_TRUE(CheckState(registry, id, JobState_Failure)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
618 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_CanceledJob)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
619 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
620 ASSERT_TRUE(registry.Cancel(id)); |
2652 | 621 ASSERT_TRUE(CheckState(registry, id, JobState_Failure)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
622 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_CanceledJob)); |
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.Resubmit(id)); |
2652 | 625 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
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 { |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
629 JobsRegistry::RunningJob job(registry, 0); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
630 ASSERT_TRUE(job.IsValid()); |
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(CheckErrorCode(registry, id, ErrorCode_Success)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
633 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
634 job.MarkSuccess(); |
2652 | 635 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2581
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 |
2652 | 638 ASSERT_TRUE(CheckState(registry, id, JobState_Success)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
639 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_Success)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
640 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
641 ASSERT_TRUE(registry.Cancel(id)); |
2652 | 642 ASSERT_TRUE(CheckState(registry, id, JobState_Success)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
643 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_Success)); |
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 registry.Submit(id, new DummyJob(), 10); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
646 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
647 { |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
648 JobsRegistry::RunningJob job(registry, 0); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
649 ASSERT_TRUE(job.IsValid()); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
650 ASSERT_EQ(id, job.GetId()); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
651 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
652 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_Success)); |
2652 | 653 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2581
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 job.MarkCanceled(); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
656 } |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
657 |
2652 | 658 ASSERT_TRUE(CheckState(registry, id, JobState_Failure)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
659 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_CanceledJob)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
660 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
661 ASSERT_TRUE(registry.Resubmit(id)); |
2652 | 662 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
663 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_CanceledJob)); |
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 ASSERT_TRUE(registry.Pause(id)); |
2652 | 666 ASSERT_TRUE(CheckState(registry, id, JobState_Paused)); |
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.Cancel(id)); |
2652 | 670 ASSERT_TRUE(CheckState(registry, id, JobState_Failure)); |
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.Resubmit(id)); |
2652 | 674 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
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 { |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
678 JobsRegistry::RunningJob job(registry, 0); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
679 ASSERT_TRUE(job.IsValid()); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
680 ASSERT_EQ(id, job.GetId()); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
681 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
682 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_Success)); |
2652 | 683 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2581
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 job.MarkRetry(500); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
686 } |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
687 |
2652 | 688 ASSERT_TRUE(CheckState(registry, id, JobState_Retry)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
689 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_Success)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
690 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
691 ASSERT_TRUE(registry.Cancel(id)); |
2652 | 692 ASSERT_TRUE(CheckState(registry, id, JobState_Failure)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
693 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_CanceledJob)); |
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 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
696 |
2570
2e879c796ec7
JobsRegistry::SubmitAndWait(), StoreScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2569
diff
changeset
|
697 |
2599 | 698 TEST(JobsEngine, SubmitAndWait) |
2565 | 699 { |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
700 JobsEngine engine(10); |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
701 engine.SetThreadSleep(10); |
2565 | 702 engine.SetWorkersCount(3); |
703 engine.Start(); | |
704 | |
2867 | 705 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
|
706 engine.GetRegistry().SubmitAndWait(content, new DummyJob(), rand() % 10); |
2867 | 707 ASSERT_EQ(Json::objectValue, content.type()); |
708 ASSERT_EQ("world", content["hello"].asString()); | |
709 | |
710 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
|
711 ASSERT_THROW(engine.GetRegistry().SubmitAndWait(content, new DummyJob(true), rand() % 10), OrthancException); |
2867 | 712 ASSERT_EQ(Json::nullValue, content.type()); |
2599 | 713 |
714 engine.Stop(); | |
715 } | |
716 | |
717 | |
2600
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
718 TEST(JobsEngine, DISABLED_SequenceOfOperationsJob) |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
719 { |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
720 JobsEngine engine(10); |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
721 engine.SetThreadSleep(10); |
2600
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
722 engine.SetWorkersCount(3); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
723 engine.Start(); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
724 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
725 std::string id; |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
726 SequenceOfOperationsJob* job = NULL; |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
727 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
728 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
729 std::unique_ptr<SequenceOfOperationsJob> a(new SequenceOfOperationsJob); |
2600
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
730 job = a.get(); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
731 engine.GetRegistry().Submit(id, a.release(), 0); |
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 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
734 boost::this_thread::sleep(boost::posix_time::milliseconds(500)); |
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 { |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
737 SequenceOfOperationsJob::Lock lock(*job); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
738 size_t i = lock.AddOperation(new LogJobOperation); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
739 size_t j = lock.AddOperation(new LogJobOperation); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
740 size_t k = lock.AddOperation(new LogJobOperation); |
2730 | 741 |
742 StringOperationValue a("Hello"); | |
743 StringOperationValue b("World"); | |
744 lock.AddInput(i, a); | |
745 lock.AddInput(i, b); | |
746 | |
2600
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
747 lock.Connect(i, j); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
748 lock.Connect(j, k); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
749 } |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
750 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
751 boost::this_thread::sleep(boost::posix_time::milliseconds(2000)); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
752 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
753 engine.Stop(); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
754 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
755 } |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
756 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
757 |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
758 static bool CheckSameJson(const Json::Value& a, |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
759 const Json::Value& b) |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
760 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
761 std::string s = a.toStyledString(); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
762 std::string t = b.toStyledString(); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
763 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
764 if (s == t) |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
765 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
766 return true; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
767 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
768 else |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
769 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
770 LOG(ERROR) << "Expected serialization: " << s; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
771 LOG(ERROR) << "Actual serialization: " << t; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
772 return false; |
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 } |
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 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
777 static bool CheckIdempotentSerialization(IJobUnserializer& unserializer, |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
778 IJob& job) |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
779 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
780 Json::Value a = 42; |
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 if (!job.Serialize(a)) |
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 return false; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
785 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
786 else |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
787 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
788 std::unique_ptr<IJob> unserialized(unserializer.UnserializeJob(a)); |
2666
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 Json::Value b = 43; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
791 if (unserialized->Serialize(b)) |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
792 { |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
793 return (CheckSameJson(a, b)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
794 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
795 else |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
796 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
797 return false; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
798 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
799 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
800 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
801 |
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 static bool CheckIdempotentSetOfInstances(IJobUnserializer& unserializer, |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
804 SetOfInstancesJob& job) |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
805 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
806 Json::Value a = 42; |
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 if (!job.Serialize(a)) |
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 return false; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
811 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
812 else |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
813 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
814 std::unique_ptr<SetOfInstancesJob> unserialized |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
815 (dynamic_cast<SetOfInstancesJob*>(unserializer.UnserializeJob(a))); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
816 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
817 Json::Value b = 43; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
818 if (unserialized->Serialize(b)) |
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 return (CheckSameJson(a, b) && |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
821 job.HasTrailingStep() == unserialized->HasTrailingStep() && |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
822 job.GetPosition() == unserialized->GetPosition() && |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
823 job.GetInstancesCount() == unserialized->GetInstancesCount() && |
2860 | 824 job.GetCommandsCount() == unserialized->GetCommandsCount()); |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
825 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
826 else |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
827 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
828 return false; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
829 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
830 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
831 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
832 |
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 static bool CheckIdempotentSerialization(IJobUnserializer& unserializer, |
4310
2ae905070221
renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
835 const IJobOperationValue& value) |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
836 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
837 Json::Value a = 42; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
838 value.Serialize(a); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
839 |
4310
2ae905070221
renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
840 std::unique_ptr<IJobOperationValue> unserialized(unserializer.UnserializeValue(a)); |
2666
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 Json::Value b = 43; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
843 unserialized->Serialize(b); |
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 return CheckSameJson(a, b); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
846 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
847 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
848 |
2655 | 849 TEST(JobsSerialization, BadFileFormat) |
850 { | |
851 GenericJobUnserializer unserializer; | |
852 | |
853 Json::Value s; | |
854 | |
855 s = Json::objectValue; | |
856 ASSERT_THROW(unserializer.UnserializeValue(s), OrthancException); | |
857 ASSERT_THROW(unserializer.UnserializeJob(s), OrthancException); | |
858 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); | |
859 | |
860 s = Json::arrayValue; | |
861 ASSERT_THROW(unserializer.UnserializeValue(s), OrthancException); | |
862 ASSERT_THROW(unserializer.UnserializeJob(s), OrthancException); | |
863 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); | |
864 | |
865 s = "hello"; | |
866 ASSERT_THROW(unserializer.UnserializeValue(s), OrthancException); | |
867 ASSERT_THROW(unserializer.UnserializeJob(s), OrthancException); | |
868 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); | |
869 | |
870 s = 42; | |
871 ASSERT_THROW(unserializer.UnserializeValue(s), OrthancException); | |
872 ASSERT_THROW(unserializer.UnserializeJob(s), OrthancException); | |
873 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); | |
874 } | |
875 | |
876 | |
2657
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
877 TEST(JobsSerialization, JobOperationValues) |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
878 { |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
879 Json::Value s; |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
880 |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
881 { |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
882 JobOperationValues values; |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
883 values.Append(new NullOperationValue); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
884 values.Append(new StringOperationValue("hello")); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
885 values.Append(new StringOperationValue("world")); |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
886 |
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
887 s = 42; |
2657
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
888 values.Serialize(s); |
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 |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
891 { |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
892 GenericJobUnserializer unserializer; |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
893 std::unique_ptr<JobOperationValues> values(JobOperationValues::Unserialize(unserializer, s)); |
2657
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
894 ASSERT_EQ(3u, values->GetSize()); |
4310
2ae905070221
renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
895 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
|
896 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
|
897 ASSERT_EQ(IJobOperationValue::Type_String, values->GetValue(2).GetType()); |
2657
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 ASSERT_EQ("hello", dynamic_cast<const StringOperationValue&>(values->GetValue(1)).GetContent()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
900 ASSERT_EQ("world", dynamic_cast<const StringOperationValue&>(values->GetValue(2)).GetContent()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
901 } |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
902 } |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
903 |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
904 |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
905 TEST(JobsSerialization, GenericValues) |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
906 { |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
907 GenericJobUnserializer unserializer; |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
908 Json::Value s; |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
909 |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
910 { |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
911 NullOperationValue null; |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
912 |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
913 ASSERT_TRUE(CheckIdempotentSerialization(unserializer, null)); |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
914 null.Serialize(s); |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
915 } |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
916 |
2652 | 917 ASSERT_THROW(unserializer.UnserializeJob(s), OrthancException); |
918 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); | |
2655 | 919 |
4310
2ae905070221
renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
920 std::unique_ptr<IJobOperationValue> value; |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
921 value.reset(unserializer.UnserializeValue(s)); |
2652 | 922 |
4310
2ae905070221
renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
923 ASSERT_EQ(IJobOperationValue::Type_Null, value->GetType()); |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
924 |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
925 { |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
926 StringOperationValue str("Hello"); |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
927 |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
928 ASSERT_TRUE(CheckIdempotentSerialization(unserializer, str)); |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
929 str.Serialize(s); |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
930 } |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
931 |
2652 | 932 ASSERT_THROW(unserializer.UnserializeJob(s), OrthancException); |
933 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); | |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
934 value.reset(unserializer.UnserializeValue(s)); |
2652 | 935 |
4310
2ae905070221
renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
936 ASSERT_EQ(IJobOperationValue::Type_String, value->GetType()); |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
937 ASSERT_EQ("Hello", dynamic_cast<StringOperationValue&>(*value).GetContent()); |
2600
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
938 } |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
939 |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
940 |
2655 | 941 TEST(JobsSerialization, GenericJobs) |
942 { | |
2652 | 943 Json::Value s; |
944 | |
2658 | 945 // This tests SetOfInstancesJob |
946 | |
2652 | 947 { |
2860 | 948 DummyInstancesJob job; |
2652 | 949 job.SetDescription("description"); |
2657
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
950 job.AddInstance("hello"); |
2652 | 951 job.AddInstance("nope"); |
2657
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
952 job.AddInstance("world"); |
2652 | 953 job.SetPermissive(true); |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
954 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
|
955 ASSERT_FALSE(job.HasTrailingStep()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
956 ASSERT_FALSE(job.IsTrailingStepDone()); |
2657
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
957 job.Start(); |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
958 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
|
959 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
|
960 |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
961 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
962 DummyUnserializer unserializer; |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
963 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
964 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
965 |
2663
228e2783ce83
some jobs might not be serializable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2662
diff
changeset
|
966 ASSERT_TRUE(job.Serialize(s)); |
2652 | 967 } |
968 | |
2655 | 969 { |
970 DummyUnserializer unserializer; | |
971 ASSERT_THROW(unserializer.UnserializeValue(s), OrthancException); | |
972 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); | |
2652 | 973 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
974 std::unique_ptr<IJob> job; |
2655 | 975 job.reset(unserializer.UnserializeJob(s)); |
2657
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
976 |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
977 const DummyInstancesJob& tmp = dynamic_cast<const DummyInstancesJob&>(*job); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
978 ASSERT_FALSE(tmp.IsStarted()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
979 ASSERT_TRUE(tmp.IsPermissive()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
980 ASSERT_EQ("description", tmp.GetDescription()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
981 ASSERT_EQ(3u, tmp.GetInstancesCount()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
982 ASSERT_EQ(2u, tmp.GetPosition()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
983 ASSERT_EQ(1u, tmp.GetFailedInstances().size()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
984 ASSERT_EQ("hello", tmp.GetInstance(0)); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
985 ASSERT_EQ("nope", tmp.GetInstance(1)); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
986 ASSERT_EQ("world", tmp.GetInstance(2)); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
987 ASSERT_TRUE(tmp.IsFailedInstance("nope")); |
2655 | 988 } |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
989 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
990 // SequenceOfOperationsJob |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
991 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
992 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
993 SequenceOfOperationsJob job; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
994 job.SetDescription("hello"); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
995 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
996 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
997 SequenceOfOperationsJob::Lock lock(job); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
998 size_t a = lock.AddOperation(new LogJobOperation); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
999 size_t b = lock.AddOperation(new LogJobOperation); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1000 lock.Connect(a, b); |
2730 | 1001 |
1002 StringOperationValue s1("hello"); | |
1003 StringOperationValue s2("world"); | |
1004 lock.AddInput(a, s1); | |
1005 lock.AddInput(a, s2); | |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1006 lock.SetTrailingOperationTimeout(300); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1007 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1008 |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
1009 ASSERT_EQ(JobStepCode_Continue, job.Step("jobId").GetCode()); |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1010 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1011 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1012 GenericJobUnserializer unserializer; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1013 ASSERT_TRUE(CheckIdempotentSerialization(unserializer, job)); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1014 } |
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 ASSERT_TRUE(job.Serialize(s)); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1017 } |
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_THROW(unserializer.UnserializeValue(s), OrthancException); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1022 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1023 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
1024 std::unique_ptr<IJob> job; |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1025 job.reset(unserializer.UnserializeJob(s)); |
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 std::string tmp; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1028 dynamic_cast<SequenceOfOperationsJob&>(*job).GetDescription(tmp); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1029 ASSERT_EQ("hello", tmp); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1030 } |
2658 | 1031 } |
1032 | |
1033 | |
4204 | 1034 static bool IsSameTagValue(const ParsedDicomFile& dicom1, |
1035 const ParsedDicomFile& dicom2, | |
2662
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1036 DicomTag tag) |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1037 { |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1038 std::string a, b; |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1039 return (dicom1.GetTagValue(a, tag) && |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1040 dicom2.GetTagValue(b, tag) && |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1041 (a == b)); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1042 } |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1043 |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1044 |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1045 |
2660 | 1046 TEST(JobsSerialization, DicomModification) |
1047 { | |
2662
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1048 Json::Value s; |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1049 |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1050 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
|
1051 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
|
1052 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
|
1053 source.Insert(DICOM_TAG_PATIENT_NAME, "Test 3", false, ""); |
2662
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1054 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
1055 std::unique_ptr<ParsedDicomFile> modified(source.Clone(true)); |
2662
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1056 |
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 DicomModification modification; |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1059 modification.SetLevel(ResourceType_Series); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1060 modification.Clear(DICOM_TAG_STUDY_DESCRIPTION); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1061 modification.Remove(DICOM_TAG_SERIES_DESCRIPTION); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1062 modification.Replace(DICOM_TAG_PATIENT_NAME, "Test 4", true); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1063 |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1064 modification.Apply(*modified); |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
1065 |
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
1066 s = 42; |
2662
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1067 modification.Serialize(s); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1068 } |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1069 |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1070 { |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1071 DicomModification modification(s); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1072 ASSERT_EQ(ResourceType_Series, modification.GetLevel()); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1073 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
1074 std::unique_ptr<ParsedDicomFile> second(source.Clone(true)); |
2662
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1075 modification.Apply(*second); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1076 |
4204 | 1077 std::string t; |
1078 ASSERT_TRUE(second->GetTagValue(t, DICOM_TAG_STUDY_DESCRIPTION)); | |
1079 ASSERT_TRUE(t.empty()); | |
1080 ASSERT_FALSE(second->GetTagValue(t, DICOM_TAG_SERIES_DESCRIPTION)); | |
1081 ASSERT_TRUE(second->GetTagValue(t, DICOM_TAG_PATIENT_NAME)); | |
1082 ASSERT_EQ("Test 4", t); | |
2662
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1083 |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1084 ASSERT_TRUE(IsSameTagValue(source, *modified, DICOM_TAG_STUDY_INSTANCE_UID)); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1085 ASSERT_TRUE(IsSameTagValue(source, *second, DICOM_TAG_STUDY_INSTANCE_UID)); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1086 |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1087 ASSERT_FALSE(IsSameTagValue(source, *second, DICOM_TAG_SERIES_INSTANCE_UID)); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1088 ASSERT_TRUE(IsSameTagValue(*modified, *second, DICOM_TAG_SERIES_INSTANCE_UID)); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1089 } |
2660 | 1090 } |
1091 | |
1092 | |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1093 TEST(JobsSerialization, Registry) |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1094 { |
2667
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1095 Json::Value s; |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1096 std::string i1, i2; |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1097 |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1098 { |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
1099 JobsRegistry registry(10); |
2667
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1100 registry.Submit(i1, new DummyJob(), 10); |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1101 registry.Submit(i2, new SequenceOfOperationsJob(), 30); |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1102 registry.Serialize(s); |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1103 } |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1104 |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1105 { |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1106 DummyUnserializer unserializer; |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
1107 JobsRegistry registry(unserializer, s, 10); |
2667
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1108 |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1109 Json::Value t; |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1110 registry.Serialize(t); |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1111 ASSERT_TRUE(CheckSameJson(s, t)); |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1112 } |
2658 | 1113 } |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1114 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1115 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1116 TEST(JobsSerialization, TrailingStep) |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1117 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1118 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1119 Json::Value s; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1120 |
2860 | 1121 DummyInstancesJob job; |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1122 ASSERT_EQ(0u, job.GetCommandsCount()); |
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1123 ASSERT_EQ(0u, job.GetInstancesCount()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1124 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1125 job.Start(); |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1126 ASSERT_EQ(0u, job.GetPosition()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1127 ASSERT_FALSE(job.HasTrailingStep()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1128 ASSERT_FALSE(job.IsTrailingStepDone()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1129 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1130 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1131 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1132 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1133 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1134 |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
1135 ASSERT_EQ(JobStepCode_Success, job.Step("jobId").GetCode()); |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1136 ASSERT_EQ(1u, job.GetPosition()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1137 ASSERT_FALSE(job.IsTrailingStepDone()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1138 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1139 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1140 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1141 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1142 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1143 |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
1144 ASSERT_THROW(job.Step("jobId"), OrthancException); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1145 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1146 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1147 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1148 Json::Value s; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1149 |
2860 | 1150 DummyInstancesJob job; |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1151 job.AddInstance("hello"); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1152 job.AddInstance("world"); |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1153 ASSERT_EQ(2u, job.GetCommandsCount()); |
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1154 ASSERT_EQ(2u, job.GetInstancesCount()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1155 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1156 job.Start(); |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1157 ASSERT_EQ(0u, job.GetPosition()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1158 ASSERT_FALSE(job.HasTrailingStep()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1159 ASSERT_FALSE(job.IsTrailingStepDone()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1160 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1161 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1162 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1163 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
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 |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
1166 ASSERT_EQ(JobStepCode_Continue, job.Step("jobId").GetCode()); |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1167 ASSERT_EQ(1u, job.GetPosition()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1168 ASSERT_FALSE(job.IsTrailingStepDone()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1169 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1170 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1171 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1172 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
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 |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
1175 ASSERT_EQ(JobStepCode_Success, job.Step("jobId").GetCode()); |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1176 ASSERT_EQ(2u, job.GetPosition()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1177 ASSERT_FALSE(job.IsTrailingStepDone()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1178 |
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 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1181 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1182 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1183 |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
1184 ASSERT_THROW(job.Step("jobId"), OrthancException); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1185 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1186 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1187 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1188 Json::Value s; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1189 |
2860 | 1190 DummyInstancesJob job; |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1191 ASSERT_EQ(0u, job.GetInstancesCount()); |
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1192 ASSERT_EQ(0u, job.GetCommandsCount()); |
2860 | 1193 job.AddTrailingStep(); |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1194 ASSERT_EQ(0u, job.GetInstancesCount()); |
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1195 ASSERT_EQ(1u, job.GetCommandsCount()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1196 |
2860 | 1197 job.Start(); // This adds the trailing step |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1198 ASSERT_EQ(0u, job.GetPosition()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1199 ASSERT_TRUE(job.HasTrailingStep()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1200 ASSERT_FALSE(job.IsTrailingStepDone()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1201 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1202 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1203 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1204 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1205 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1206 |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
1207 ASSERT_EQ(JobStepCode_Success, job.Step("jobId").GetCode()); |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1208 ASSERT_EQ(1u, job.GetPosition()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1209 ASSERT_TRUE(job.IsTrailingStepDone()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1210 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1211 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1212 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1213 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1214 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1215 |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
1216 ASSERT_THROW(job.Step("jobId"), OrthancException); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1217 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1218 |
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 Json::Value s; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1221 |
2860 | 1222 DummyInstancesJob job; |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1223 job.AddInstance("hello"); |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1224 ASSERT_EQ(1u, job.GetInstancesCount()); |
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1225 ASSERT_EQ(1u, job.GetCommandsCount()); |
2860 | 1226 job.AddTrailingStep(); |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1227 ASSERT_EQ(1u, job.GetInstancesCount()); |
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1228 ASSERT_EQ(2u, job.GetCommandsCount()); |
2860 | 1229 |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1230 job.Start(); |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1231 ASSERT_EQ(2u, job.GetCommandsCount()); |
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_Continue, 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_FALSE(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_EQ(JobStepCode_Success, job.Step("jobId").GetCode()); |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2976
diff
changeset
|
1251 ASSERT_EQ(2u, job.GetPosition()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1252 ASSERT_TRUE(job.IsTrailingStepDone()); |
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 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1255 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1256 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1257 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1258 |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
1259 ASSERT_THROW(job.Step("jobId"), OrthancException); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1260 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1261 } |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1262 |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1263 |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1264 TEST(JobsSerialization, RemoteModalityParameters) |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1265 { |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1266 Json::Value s; |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1267 |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1268 { |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1269 RemoteModalityParameters modality; |
2872
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1270 ASSERT_FALSE(modality.IsAdvancedFormatNeeded()); |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1271 modality.Serialize(s, false); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1272 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
|
1273 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
|
1274 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
|
1275 ASSERT_EQ(0u, modality.GetTimeout()); |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1276 } |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1277 |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1278 { |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1279 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
|
1280 ASSERT_FALSE(modality.IsAdvancedFormatNeeded()); |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1281 ASSERT_EQ("ORTHANC", modality.GetApplicationEntityTitle()); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1282 ASSERT_EQ("127.0.0.1", modality.GetHost()); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1283 ASSERT_EQ(104u, modality.GetPortNumber()); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1284 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
|
1285 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
|
1286 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Find)); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1287 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
|
1288 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
|
1289 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Move)); |
3602
085283445db0
AllowNAction in remote modality parameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3561
diff
changeset
|
1290 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
|
1291 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
|
1292 ASSERT_TRUE(modality.IsTranscodingAllowed()); |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1293 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
|
1294 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
|
1295 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
|
1296 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
|
1297 ASSERT_EQ(0u, modality.GetTimeout()); |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1298 } |
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 s = Json::nullValue; |
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_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
|
1305 ASSERT_THROW(modality.SetPortNumber(65535), OrthancException); |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1306 modality.SetApplicationEntityTitle("HELLO"); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1307 modality.SetHost("world"); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1308 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
|
1309 modality.SetManufacturer(ModalityManufacturer_GenericNoWildcardInDates); |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1310 ASSERT_FALSE(modality.IsAdvancedFormatNeeded()); |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1311 modality.Serialize(s, true); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1312 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
|
1313 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
|
1314 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
|
1315 ASSERT_EQ(0u, modality.GetTimeout()); |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1316 } |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1317 |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1318 { |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1319 RemoteModalityParameters modality(s); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1320 ASSERT_EQ("HELLO", modality.GetApplicationEntityTitle()); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1321 ASSERT_EQ("world", modality.GetHost()); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1322 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
|
1323 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
|
1324 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
|
1325 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Find)); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1326 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
|
1327 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
|
1328 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Move)); |
3602
085283445db0
AllowNAction in remote modality parameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3561
diff
changeset
|
1329 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
|
1330 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
|
1331 ASSERT_TRUE(modality.IsTranscodingAllowed()); |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1332 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
|
1333 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
|
1334 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
|
1335 ASSERT_EQ(0u, modality.GetTimeout()); |
2871
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 s["Port"] = "46"; |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1339 |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1340 { |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1341 RemoteModalityParameters modality(s); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1342 ASSERT_EQ(46u, modality.GetPortNumber()); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1343 } |
2872
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1344 |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1345 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
|
1346 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
|
1347 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
|
1348 |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1349 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
|
1350 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
|
1351 operations.insert(DicomRequestType_Find); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1352 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
|
1353 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
|
1354 operations.insert(DicomRequestType_Store); |
3602
085283445db0
AllowNAction in remote modality parameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3561
diff
changeset
|
1355 operations.insert(DicomRequestType_NAction); |
3613
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1356 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
|
1357 |
3613
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1358 ASSERT_EQ(7u, operations.size()); |
2872
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1359 |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1360 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
|
1361 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
|
1362 { |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1363 { |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1364 RemoteModalityParameters modality; |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1365 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
|
1366 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
|
1367 |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1368 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
|
1369 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
|
1370 } |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1371 |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1372 { |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1373 RemoteModalityParameters modality(s); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1374 |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1375 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
|
1376 |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1377 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
|
1378 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
|
1379 { |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1380 if (*it2 != *it) |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1381 { |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1382 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
|
1383 } |
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 } |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1386 } |
3613
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1387 |
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
|
1388 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
|
1389 |
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
|
1390 { |
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
|
1391 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
|
1392 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
|
1393 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
|
1394 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
|
1395 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
|
1396 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
|
1397 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
|
1398 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
|
1399 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
|
1400 } |
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
|
1401 |
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
|
1402 { |
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
|
1403 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
|
1404 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
|
1405 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
|
1406 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
|
1407 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
|
1408 } |
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
|
1409 |
3613
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1410 { |
4204 | 1411 Json::Value t; |
1412 t["AllowStorageCommitment"] = false; | |
1413 t["AET"] = "AET"; | |
1414 t["Host"] = "host"; | |
1415 t["Port"] = "104"; | |
3613
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1416 |
4204 | 1417 RemoteModalityParameters modality(t); |
3613
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1418 ASSERT_TRUE(modality.IsAdvancedFormatNeeded()); |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1419 ASSERT_EQ("AET", modality.GetApplicationEntityTitle()); |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1420 ASSERT_EQ("host", modality.GetHost()); |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1421 ASSERT_EQ(104u, modality.GetPortNumber()); |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1422 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
|
1423 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
|
1424 ASSERT_TRUE(modality.IsTranscodingAllowed()); |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1425 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
|
1426 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
|
1427 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
|
1428 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
|
1429 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
|
1430 } |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1431 |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1432 { |
4204 | 1433 Json::Value t; |
1434 t["AllowNAction"] = false; | |
1435 t["AllowNEventReport"] = true; | |
1436 t["AET"] = "AET"; | |
1437 t["Host"] = "host"; | |
1438 t["Port"] = "104"; | |
1439 t["AllowTranscoding"] = false; | |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1440 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
|
1441 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
|
1442 t["Timeout"] = 20; |
3613
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1443 |
4204 | 1444 RemoteModalityParameters modality(t); |
3613
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1445 ASSERT_TRUE(modality.IsAdvancedFormatNeeded()); |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1446 ASSERT_EQ("AET", modality.GetApplicationEntityTitle()); |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1447 ASSERT_EQ("host", modality.GetHost()); |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1448 ASSERT_EQ(104u, modality.GetPortNumber()); |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1449 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
|
1450 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
|
1451 ASSERT_FALSE(modality.IsTranscodingAllowed()); |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1452 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
|
1453 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
|
1454 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
|
1455 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
|
1456 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
|
1457 } |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1458 |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1459 { |
4204 | 1460 Json::Value t; |
1461 t["AllowNAction"] = true; | |
1462 t["AllowNEventReport"] = true; | |
1463 t["AET"] = "AET"; | |
1464 t["Host"] = "host"; | |
1465 t["Port"] = "104"; | |
3613
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1466 |
4204 | 1467 RemoteModalityParameters modality(t); |
3613
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1468 ASSERT_FALSE(modality.IsAdvancedFormatNeeded()); |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1469 ASSERT_EQ("AET", modality.GetApplicationEntityTitle()); |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1470 ASSERT_EQ("host", modality.GetHost()); |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1471 ASSERT_EQ(104u, modality.GetPortNumber()); |
c1e2b91c2ab4
all the abstractions for storage commitment are available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
1472 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
|
1473 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
|
1474 ASSERT_TRUE(modality.IsTranscodingAllowed()); |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1475 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
|
1476 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
|
1477 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
|
1478 } |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1479 } |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1480 |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1481 |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1482 |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1483 TEST(JobsSerialization, DicomAssociationParameters) |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1484 { |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1485 { |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1486 DicomAssociationParameters a; |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1487 |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1488 Json::Value v = Json::objectValue; |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1489 a.SerializeJob(v); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1490 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
|
1491 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
|
1492 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
|
1493 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
|
1494 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
|
1495 |
4451
f4dbdb2dcba6
new configuration option "MaximumPduLength" to tune the maximum PDU length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4438
diff
changeset
|
1496 ASSERT_EQ(4u, v.getMemberNames().size()); |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1497 |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1498 DicomAssociationParameters b; |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1499 b.UnserializeJob(v); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1500 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
|
1501 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
|
1502 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
|
1503 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
|
1504 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
|
1505 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
|
1506 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
|
1507 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
|
1508 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
|
1509 ASSERT_EQ(0u, b.GetRemoteModality().GetTimeout()); |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1510 } |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1511 |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1512 { |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1513 RemoteModalityParameters p; |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1514 p.SetApplicationEntityTitle("WORLD"); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1515 p.SetPortNumber(4242); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1516 p.SetHost("hello.world.com"); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1517 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
|
1518 p.SetTimeout(42); |
4438
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 DicomAssociationParameters a("HELLO", p); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1521 a.SetOwnCertificatePath("key", "crt"); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1522 a.SetTrustedCertificatesPath("trusted"); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1523 |
4451
f4dbdb2dcba6
new configuration option "MaximumPduLength" to tune the maximum PDU length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4438
diff
changeset
|
1524 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
|
1525 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
|
1526 a.SetMaximumPduLength(4096); |
f4dbdb2dcba6
new configuration option "MaximumPduLength" to tune the maximum PDU length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4438
diff
changeset
|
1527 a.SetMaximumPduLength(131072); |
f4dbdb2dcba6
new configuration option "MaximumPduLength" to tune the maximum PDU length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4438
diff
changeset
|
1528 |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1529 Json::Value v = Json::objectValue; |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1530 a.SerializeJob(v); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1531 |
4451
f4dbdb2dcba6
new configuration option "MaximumPduLength" to tune the maximum PDU length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4438
diff
changeset
|
1532 ASSERT_EQ(7u, v.getMemberNames().size()); |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1533 |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1534 DicomAssociationParameters b = DicomAssociationParameters::UnserializeJob(v); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1535 |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1536 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
|
1537 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
|
1538 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
|
1539 ASSERT_EQ("HELLO", b.GetLocalApplicationEntityTitle()); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1540 ASSERT_TRUE(b.GetRemoteModality().IsDicomTlsEnabled()); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1541 ASSERT_EQ("key", b.GetOwnPrivateKeyPath()); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1542 ASSERT_EQ("crt", b.GetOwnCertificatePath()); |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1543 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
|
1544 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
|
1545 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
|
1546 ASSERT_EQ(42u, b.GetRemoteModality().GetTimeout()); |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1547 } |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1548 } |