2 * Copyright 2001-2009 Internet2
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "XMLObjectBaseTestCase.h"
21 #include <xmltooling/util/TemplateEngine.h>
23 class TemplateEngineTest : public CxxTest::TestSuite {
31 void testTemplateEngine() {
32 auto_ptr<TemplateEngine> engine(new TemplateEngine());
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"));
42 string path = data_path + "template.in";
43 ifstream in(path.c_str());
46 engine->run(in,out,p);
49 path = data_path + "template.out";
50 ifstream compfile(path.c_str());
51 while (getline(compfile,path))
52 compstr += path + '\n';
54 TSM_ASSERT_EQUALS("Template output did not match.", out.str(), compstr);