c996bdec7b32484c76b1dddd29284673a4d495b2
[shibboleth/cpp-opensaml.git] / samltest / samltest.h
1 /*
2  *  Copyright 2001-2007 Internet2
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "internal.h"
18 #include <fstream>
19 #include <cxxtest/GlobalFixture.h>
20 #include <saml/SAMLConfig.h>
21 #include <saml/binding/ArtifactMap.h>
22 #include <xmltooling/util/ReplayCache.h>
23 #include <xmltooling/util/TemplateEngine.h>
24
25 using namespace opensaml;
26
27 //#define SAML_LEAKCHECK
28
29 std::string data_path = "../samltest/data/";
30
31 class SAMLFixture : public CxxTest::GlobalFixture
32 {
33 public:
34     bool setUpWorld() {
35         XMLToolingConfig::getConfig().log_config();
36         if (!SAMLConfig::getConfig().init())
37             return false;
38         if (!SAMLConfig::getConfig().init())    // should be a no-op
39             return false;
40         XMLToolingConfig::getConfig().setReplayCache(new ReplayCache());
41         XMLToolingConfig::getConfig().setTemplateEngine(new TemplateEngine());
42         SAMLConfig::getConfig().setArtifactMap(new ArtifactMap());
43
44         if (getenv("SAMLTEST_DATA"))
45             data_path=std::string(getenv("SAMLTEST_DATA")) + "/";
46         //std::string catpath=data_path + "catalog.xml";
47         //auto_ptr_XMLCh temp(catpath.c_str());
48         //return XMLToolingConfig::getConfig().getValidatingParser().loadCatalog(temp.get());
49         return true;
50     }
51     bool tearDownWorld() {
52         SAMLConfig::getConfig().term();     // should be a no-op
53         SAMLConfig::getConfig().term();
54         SAMLConfig::getConfig().term();     // shouldn't cause a crash
55 #if defined(_MSC_VER ) && defined(SAML_LEAKCHECK)
56        _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE );
57        _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT );
58        _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE );
59        _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT );
60        _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
61        _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDOUT );
62        _CrtDumpMemoryLeaks();
63 #endif
64         return true;
65     }
66     //bool setUp() { printf( "</test>" ); return true; }
67     //bool tearDown() { printf( "</test>" ); return true; }
68 };
69
70 static SAMLFixture globalFixture;
71
72 class GlobalTest : public CxxTest::TestSuite
73 {
74 public:
75     void testGlobal() {
76     }
77 };