unittest/fixgeometries/main.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 // TerraLib
21 #include <terralib/raster_fw.h>
22 
24 #include <terralib/common/Module.h>
25 #include <terralib/core/plugin.h>
26 
27 // cppUnit
28 #include <cppunit/BriefTestProgressListener.h>
29 #include <cppunit/CompilerOutputter.h>
30 #include <cppunit/XmlOutputter.h>
31 #include <cppunit/TextOutputter.h>
32 
33 #include <cppunit/extensions/HelperMacros.h>
34 #include <cppunit/extensions/TestFactoryRegistry.h>
35 #include <cppunit/TestResult.h>
36 #include <cppunit/TestResultCollector.h>
37 #include <cppunit/TestRunner.h>
38 
39 // Unit-Test TerraLib includes by platform
40 #include "Config.h"
41 #include "LoadModules.h"
42 
43 
44 #include <cstdlib>
45 
46 #define TS_TEST_NAME "testResult_fixgeometries"
47 
48 int main(int /*argc*/, char** /*argv*/)
49 {
50  // initialize Terralib platform
52 
53  LoadModules();
54 
55  // it creates the event manager and test controller
56  CPPUNIT_NS::TestResult controller;
57 
58  // it adds a listener that collects test result
59  CPPUNIT_NS::TestResultCollector result;
60 
61  controller.addListener(&result);
62 
63  // it adds a listener that print dots as test run.
64  CPPUNIT_NS::BriefTestProgressListener progress;
65 
66  controller.addListener(&progress);
67 
68  // it adds the top suite to the test runner
69  CppUnit::Test* suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
70 
71  CPPUNIT_NS::TestRunner runner;
72 
73  runner.addTest(suite);
74 
75  runner.run(controller);
76 
77  CPPUNIT_NS::CompilerOutputter outputter( &result, CPPUNIT_NS::stdCOut() );
78  outputter.write();
79 
80 // Testing different outputs...
81 
82 // Print only fail results in a txt file (the same containt you see in DOS window)
83  std::ofstream file1(TERRALIB_REPORT_DIR "/" TS_TEST_NAME ".txt" );
84  CPPUNIT_NS::CompilerOutputter outputter1( &result, file1);
85  outputter1.write();
86  file1.close();
87 
88 // Printing testResults in XML file
89  // The testResult_*.xml files will be saved at TERRALIB_REPORT_DIR directory.
90  // The styleSheet 'report.xsl' should be at this directory (found originally at <third-party-lib>\cppunit-1.12.1\contrib\xml-xsl).
91  // The "data.zip" (downloaded) containing the data used in unit tests should be at TERRALIB_DATA_DIR
92 
93  CPPUNIT_NS::OFileStream file2(TERRALIB_REPORT_DIR "/" TS_TEST_NAME ".xml");
94  CPPUNIT_NS::XmlOutputter xml( &result, file2 );
95  xml.setStyleSheet( "report.xsl" );
96  xml.write();
97  file2.close();
98 
99 // Print formated testResult in a txt
100  CPPUNIT_NS::OFileStream file3(TERRALIB_REPORT_DIR "/" TS_TEST_NAME ".txt" );
101  CPPUNIT_NS::TextOutputter outputter3( &result, file3 );
102  outputter3.write();
103  file3.close();
104 
105  bool resultStatus = result.wasSuccessful();
106 
108 
109 
110  // finalize TerraLib Plataform
112 
113  return resultStatus ? EXIT_SUCCESS : EXIT_FAILURE;
114 }
Forward declarations for the Raster module.
An utility class to control the startup and cleanup of the TerraLib Platform and its resources...
Include files for Core Plugin Library.
#define TS_TEST_NAME
static PluginManager & instance()
Access the singleton.
int main(int, char **)
void finalize()
It finalizes the TerraLib Platform.
static TerraLib & getInstance()
It returns a reference to the singleton instance.
void initialize()
It initializes the TerraLib Platform.
This singleton defines an entry in the Platform for the TerraLib Common Runtime module.
void clear()
Stop and unload all plugins, then clear the internal list of plugins.
void LoadModules()
Load terralib modules.