Mercurial > hg > orthanc-stone
comparison UnitTestsSources/TestStructureSet.cpp @ 1418:4e7751a4b603 loader-injection-feature
Added a test for loader injection (basic "no regression" test). DISABLED_ because it requires a running Orthanc with a well-defined structure set instance.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 11 May 2020 17:41:50 +0200 |
parents | 7ec8fea061b9 |
children | 04d0c25819c3 |
comparison
equal
deleted
inserted
replaced
1417:afdd5be8731c | 1418:4e7751a4b603 |
---|---|
29 #endif | 29 #endif |
30 | 30 |
31 #include "Framework/Toolbox/DicomStructureSetUtils.h" | 31 #include "Framework/Toolbox/DicomStructureSetUtils.h" |
32 #include "Framework/Toolbox/DicomStructureSet2.h" | 32 #include "Framework/Toolbox/DicomStructureSet2.h" |
33 #include "Framework/Toolbox/DisjointDataSet.h" | 33 #include "Framework/Toolbox/DisjointDataSet.h" |
34 | |
35 #include "Framework/Loaders/GenericLoadersContext.h" | |
36 #include "Framework/Loaders/DicomStructureSetLoader.h" | |
37 | |
38 #include "boost/date_time/posix_time/posix_time.hpp" | |
34 | 39 |
35 #include <Core/SystemToolbox.h> | 40 #include <Core/SystemToolbox.h> |
36 | 41 |
37 #include "gtest/gtest.h" | 42 #include "gtest/gtest.h" |
38 #include <string> | 43 #include <string> |
5404 structureSet.ComputeDependentProperties(); | 5409 structureSet.ComputeDependentProperties(); |
5405 | 5410 |
5406 const std::vector<DicomStructure2>& structures = structureSet.structures_; | 5411 const std::vector<DicomStructure2>& structures = structureSet.structures_; |
5407 } | 5412 } |
5408 | 5413 |
5409 | |
5410 #endif | 5414 #endif |
5411 // BGO_ENABLE_DICOMSTRUCTURESETLOADER2 | 5415 // BGO_ENABLE_DICOMSTRUCTURESETLOADER2 |
5412 | 5416 |
5413 | 5417 namespace |
5414 | 5418 { |
5419 void Initialize(const char* orthancApiUrl, OrthancStone::ILoadersContext& loadersContext) | |
5420 { | |
5421 Orthanc::WebServiceParameters p; | |
5422 | |
5423 OrthancStone::GenericLoadersContext& typedLoadersContext = | |
5424 dynamic_cast<OrthancStone::GenericLoadersContext&>(loadersContext); | |
5425 // Default is http://localhost:8042 | |
5426 // Here's how you may change it | |
5427 p.SetUrl(orthancApiUrl); | |
5428 p.SetCredentials("orthanc", "orthanc"); | |
5429 typedLoadersContext.SetOrthancParameters(p); | |
5430 | |
5431 typedLoadersContext.StartOracle(); | |
5432 } | |
5433 | |
5434 void Exitialize(OrthancStone::ILoadersContext& loadersContext) | |
5435 { | |
5436 OrthancStone::GenericLoadersContext& typedLoadersContext = | |
5437 dynamic_cast<OrthancStone::GenericLoadersContext&>(loadersContext); | |
5438 | |
5439 typedLoadersContext.StopOracle(); | |
5440 } | |
5441 | |
5442 | |
5443 #if 0 | |
5444 class TestObserver : public ObserverBase<TestObserver> | |
5445 { | |
5446 public: | |
5447 TestObserver() {}; | |
5448 | |
5449 virtual void Handle | |
5450 | |
5451 }; | |
5452 #endif | |
5453 | |
5454 } | |
5455 | |
5456 | |
5457 TEST(StructureSet, DISABLED_StructureSetLoader_injection_feature_2020_05_10) | |
5458 { | |
5459 namespace pt = boost::posix_time; | |
5460 | |
5461 std::unique_ptr<OrthancStone::ILoadersContext> loadersContext(new OrthancStone::GenericLoadersContext(1,4,1)); | |
5462 Initialize("http://localhost:8042/", *loadersContext); | |
5463 | |
5464 boost::shared_ptr<DicomStructureSetLoader> loader = DicomStructureSetLoader::Create(*loadersContext); | |
5465 | |
5466 // replace with Orthanc ID of an uploaded RTSTRUCT instance! | |
5467 loader->LoadInstanceFullVisibility("72c773ac-5059f2c4-2e6a9120-4fd4bca1-45701661"); | |
5468 | |
5469 bool bContinue(true); | |
5470 | |
5471 pt::ptime initialTime = pt::second_clock::local_time(); | |
5472 | |
5473 while (bContinue) | |
5474 { | |
5475 bContinue = !loader->AreStructuresReady(); | |
5476 boost::this_thread::sleep_for(boost::chrono::milliseconds(1000)); | |
5477 | |
5478 { | |
5479 pt::ptime nowTime = pt::second_clock::local_time(); | |
5480 pt::time_duration diff = nowTime - initialTime; | |
5481 double seconds = static_cast<double>(diff.total_milliseconds()) * 0.001; | |
5482 std::cout << seconds << " seconds elapsed...\n"; | |
5483 if (seconds > 30) | |
5484 { | |
5485 std::cout << "More than 30 seconds elapsed... Aborting test :(\n"; | |
5486 //GTEST_FATAL_FAILURE_("More than 30 seconds elapsed... Aborting test :("); | |
5487 //bContinue = false; | |
5488 } | |
5489 } | |
5490 } | |
5491 } | |
5492 | |
5493 |