Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkDICOMReaderConfiguratorTest.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
19 
20 #include "mitkTestingMacros.h"
21 
25 int mitkDICOMReaderConfiguratorTest(int /*argc*/, char* /*argv*/[])
26 {
27  MITK_TEST_BEGIN("mitkDICOMReaderConfiguratorTest");
28 
30  readerSource->LoadBuiltIn3DConfigs();
31  readerSource->LoadBuiltIn3DnTConfigs();
32 
33  mitk::DICOMFileReaderSelector::ReaderList allReaders = readerSource->GetAllConfiguredReaders(); // this already parses XML config for this reader
34  for (auto rIter = allReaders.begin();
35  rIter != allReaders.end();
36  ++rIter)
37  {
38  mitk::DICOMFileReader::Pointer originalReader = *rIter;
39 
40  MITK_TEST_OUTPUT(<< "********************************************************************************");
41  MITK_TEST_OUTPUT(<< "Testing reader '" << originalReader->GetConfigurationLabel() << "'" );
42  MITK_TEST_OUTPUT(<< "********************************************************************************");
43  // ask for an XML serialization of this reader, then compare the XML files.
45  std::string xmlSerialization = serializer->CreateConfigStringFromReader( originalReader.GetPointer() );
46  MITK_TEST_CONDITION( !xmlSerialization.empty(), "DICOMReaderConfigurator is able to serialize reader");
47  MITK_INFO << "Got serialization:";
48  std::cout << xmlSerialization << std::endl;
49 
51  try
52  {
53  mitk::DICOMFileReader::Pointer reconstructedReader = creator->CreateFromUTF8ConfigString(xmlSerialization);
54  MITK_TEST_CONDITION( reconstructedReader.IsNotNull(), "DICOMReaderConfigurator is able to create reader from XML");
55 
56  MITK_TEST_CONDITION( *reconstructedReader == *originalReader, "Readers are equal before and after serialization" )
57  }
58  catch(std::exception& e)
59  {
60  MITK_TEST_CONDITION_REQUIRED(false, "Exception from DICOMReaderConfigurator: " << e.what());
61  }
62  }
63 
64  MITK_TEST_END();
65 }
66 
itk::SmartPointer< Self > Pointer
#define MITK_INFO
Definition: mitkLogMacros.h:22
#define MITK_TEST_CONDITION_REQUIRED(COND, MSG)
std::list< DICOMFileReader::Pointer > ReaderList
section GeneralTestsDeprecatedOldTestingStyle Deprecated macros All tests with MITK_TEST_BEGIN()
int mitkDICOMReaderConfiguratorTest(int, char *[])
Verify serialization ability of DICOMReaderConfigurator.
#define MITK_TEST_OUTPUT(x)
Output some text.
#define MITK_TEST_CONDITION(COND, MSG)
and MITK_TEST_END()
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.