Adjust cxxtest path in build rules.
[shibboleth/cpp-xmltooling.git] / xmltoolingtest / TemplateEngineTest.h
1 /*
2  *  Copyright 2001-2009 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 "XMLObjectBaseTestCase.h"
18
19 #include <fstream>
20 #include <sstream>
21 #include <xmltooling/util/TemplateEngine.h>
22
23 class TemplateEngineTest : public CxxTest::TestSuite {
24 public:
25     void setUp() {
26     }
27     
28     void tearDown() {
29     }
30
31     void testTemplateEngine() {
32         auto_ptr<TemplateEngine> engine(new TemplateEngine());
33
34         TemplateEngine::TemplateParameters p;
35         p.m_map["foo1"] = "bar1";
36         p.m_map["foo3"] = "bar3";
37         p.m_map["encoded"] = "http://www.example.org/foo/bar#foobar";
38         multimap<string,string>& submap = p.m_collectionMap["sub"];
39         submap.insert(pair<const string,string>("subfoo1", "subbar1"));
40         submap.insert(pair<const string,string>("subfoo2", "subbar2"));
41         
42         string path = data_path + "template.in";
43         ifstream in(path.c_str());
44         ostringstream out;
45         
46         engine->run(in,out,p);
47         
48         string compstr;
49         path = data_path + "template.out";
50         ifstream compfile(path.c_str());
51         while (getline(compfile,path))
52             compstr += path + '\n';
53             
54         TSM_ASSERT_EQUALS("Template output did not match.", out.str(), compstr);
55     }
56 };