annotate UnitTestsSources/UnitTestsMain.cpp @ 82:cee8f308a4bc wasm

Getting rid of Orthanc*WebService
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 24 May 2017 23:05:10 +0200
parents f40a78cc7070
children 4a541cd4fa83
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
40
7207a407bcd8 shared copyright with osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
5 * Copyright (C) 2017 Osimis, Belgium
20
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
47
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
10 * the License, or (at your option) any later version.
20
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
47
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
15 * Affero General Public License for more details.
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
16 *
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
20
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "gtest/gtest.h"
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
80
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
24 #include "../Platforms/Generic/OracleWebService.h"
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 72
diff changeset
25 #include "../Framework/Toolbox/OrthancSlicesLoader.h"
80
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
26 #include "../Resources/Orthanc/Core/HttpClient.h"
20
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include "../Resources/Orthanc/Core/Logging.h"
80
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
28 #include "../Resources/Orthanc/Core/MultiThreading/SharedMessageQueue.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
29 #include "../Resources/Orthanc/Core/OrthancException.h"
67
acb60cbb8301 refactoring SeriesLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 66
diff changeset
30
68
1526d38ef6da SliceSorter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 67
diff changeset
31 #include <boost/lexical_cast.hpp>
70
f73aed014bde OrthancAsynchronousWebService
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 69
diff changeset
32 #include <boost/date_time/posix_time/posix_time.hpp>
f73aed014bde OrthancAsynchronousWebService
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 69
diff changeset
33 #include <boost/thread/thread.hpp>
68
1526d38ef6da SliceSorter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 67
diff changeset
34
65
885932a893de OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 47
diff changeset
35 namespace OrthancStone
885932a893de OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 47
diff changeset
36 {
72
c1cc3bdba18c cleaning up OrthancSlicesLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 71
diff changeset
37 class Tata : public OrthancSlicesLoader::ICallback
67
acb60cbb8301 refactoring SeriesLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 66
diff changeset
38 {
acb60cbb8301 refactoring SeriesLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 66
diff changeset
39 public:
72
c1cc3bdba18c cleaning up OrthancSlicesLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 71
diff changeset
40 virtual void NotifyGeometryReady(const OrthancSlicesLoader& loader)
67
acb60cbb8301 refactoring SeriesLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 66
diff changeset
41 {
80
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
42 printf(">> %d\n", (int) loader.GetSliceCount());
70
f73aed014bde OrthancAsynchronousWebService
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 69
diff changeset
43
f73aed014bde OrthancAsynchronousWebService
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 69
diff changeset
44 for (size_t i = 0; i < loader.GetSliceCount(); i++)
f73aed014bde OrthancAsynchronousWebService
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 69
diff changeset
45 {
72
c1cc3bdba18c cleaning up OrthancSlicesLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 71
diff changeset
46 const_cast<OrthancSlicesLoader&>(loader).ScheduleLoadSliceImage(i);
70
f73aed014bde OrthancAsynchronousWebService
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 69
diff changeset
47 }
68
1526d38ef6da SliceSorter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 67
diff changeset
48 }
1526d38ef6da SliceSorter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 67
diff changeset
49
72
c1cc3bdba18c cleaning up OrthancSlicesLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 71
diff changeset
50 virtual void NotifyGeometryError(const OrthancSlicesLoader& loader)
68
1526d38ef6da SliceSorter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 67
diff changeset
51 {
1526d38ef6da SliceSorter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 67
diff changeset
52 printf("Error\n");
67
acb60cbb8301 refactoring SeriesLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 66
diff changeset
53 }
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 65
diff changeset
54
72
c1cc3bdba18c cleaning up OrthancSlicesLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 71
diff changeset
55 virtual void NotifySliceImageReady(const OrthancSlicesLoader& loader,
68
1526d38ef6da SliceSorter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 67
diff changeset
56 unsigned int sliceIndex,
1526d38ef6da SliceSorter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 67
diff changeset
57 const Slice& slice,
1526d38ef6da SliceSorter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 67
diff changeset
58 Orthanc::ImageAccessor* image)
67
acb60cbb8301 refactoring SeriesLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 66
diff changeset
59 {
68
1526d38ef6da SliceSorter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 67
diff changeset
60 std::auto_ptr<Orthanc::ImageAccessor> tmp(image);
70
f73aed014bde OrthancAsynchronousWebService
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 69
diff changeset
61 printf("Slice OK %dx%d\n", tmp->GetWidth(), tmp->GetHeight());
68
1526d38ef6da SliceSorter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 67
diff changeset
62 }
1526d38ef6da SliceSorter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 67
diff changeset
63
72
c1cc3bdba18c cleaning up OrthancSlicesLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 71
diff changeset
64 virtual void NotifySliceImageError(const OrthancSlicesLoader& loader,
68
1526d38ef6da SliceSorter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 67
diff changeset
65 unsigned int sliceIndex,
1526d38ef6da SliceSorter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 67
diff changeset
66 const Slice& slice)
1526d38ef6da SliceSorter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 67
diff changeset
67 {
1526d38ef6da SliceSorter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 67
diff changeset
68 printf("ERROR 2\n");
67
acb60cbb8301 refactoring SeriesLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 66
diff changeset
69 }
acb60cbb8301 refactoring SeriesLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 66
diff changeset
70 };
65
885932a893de OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 47
diff changeset
71 }
885932a893de OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 47
diff changeset
72
885932a893de OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 47
diff changeset
73
885932a893de OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 47
diff changeset
74 TEST(Toto, Tutu)
885932a893de OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 47
diff changeset
75 {
80
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
76 OrthancStone::Oracle oracle(4);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
77 oracle.Start();
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
78
65
885932a893de OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 47
diff changeset
79 Orthanc::WebServiceParameters web;
80
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
80 //OrthancStone::OrthancAsynchronousWebService orthanc(web, 4);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
81 OrthancStone::OracleWebService orthanc(oracle, web);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
82 //orthanc.Start();
65
885932a893de OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 47
diff changeset
83
885932a893de OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 47
diff changeset
84 OrthancStone::Tata tata;
72
c1cc3bdba18c cleaning up OrthancSlicesLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 71
diff changeset
85 OrthancStone::OrthancSlicesLoader loader(tata, orthanc);
80
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
86 loader.ScheduleLoadSeries("c1c4cb95-05e3bd11-8da9f5bb-87278f71-0b2b43f5");
77
f5f54ed8d307 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
87 //loader.ScheduleLoadSeries("67f1b334-02c16752-45026e40-a5b60b6b-030ecab5");
71
30c768873d47 OrthancSliceLoader::ScheduleLoadInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 70
diff changeset
88
80
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
89 //loader.ScheduleLoadInstance("19816330-cb02e1cf-df3a8fe8-bf510623-ccefe9f5", 0);
68
1526d38ef6da SliceSorter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 67
diff changeset
90
70
f73aed014bde OrthancAsynchronousWebService
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 69
diff changeset
91 /*printf(">> %d\n", loader.GetSliceCount());
f73aed014bde OrthancAsynchronousWebService
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 69
diff changeset
92 loader.ScheduleLoadSliceImage(31);*/
f73aed014bde OrthancAsynchronousWebService
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 69
diff changeset
93
f73aed014bde OrthancAsynchronousWebService
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 69
diff changeset
94 boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
f73aed014bde OrthancAsynchronousWebService
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 69
diff changeset
95
80
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
96 //orthanc.Stop();
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
97 oracle.Stop();
65
885932a893de OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 47
diff changeset
98 }
885932a893de OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 47
diff changeset
99
885932a893de OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 47
diff changeset
100
20
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 int main(int argc, char **argv)
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 {
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 Orthanc::Logging::Initialize();
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 Orthanc::Logging::EnableInfoLevel(true);
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 ::testing::InitGoogleTest(&argc, argv);
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 int result = RUN_ALL_TESTS();
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 Orthanc::Logging::Finalize();
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 return result;
946377d1c992 skeleton for unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 }