Initial unit test plus fixes
[shibboleth/cpp-xmltooling.git] / xmltoolingtest / xmltoolingtest.h
diff --git a/xmltoolingtest/xmltoolingtest.h b/xmltoolingtest/xmltoolingtest.h
new file mode 100644 (file)
index 0000000..f3fb5af
--- /dev/null
@@ -0,0 +1,67 @@
+/*\r
+ *  Copyright 2001-2005 Internet2\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include <cxxtest/TestSuite.h>\r
+#include <cxxtest/GlobalFixture.h>\r
+\r
+#include <xmltooling/XMLToolingConfig.h>\r
+#include <xmltooling/util/ParserPool.h>\r
+\r
+using namespace xmltooling;\r
+\r
+ParserPool* validatingPool=NULL;\r
+ParserPool* nonvalidatingPool=NULL;\r
+\r
+class ToolingFixture : public CxxTest::GlobalFixture\r
+{\r
+public:\r
+    bool setUpWorld() {\r
+        XMLToolingConfig::getConfig().log_config("DEBUG");\r
+        if (!XMLToolingConfig::getConfig().init())\r
+            return false;\r
+        validatingPool = new ParserPool(true,true);\r
+        nonvalidatingPool = new ParserPool();\r
+        return true;\r
+    }\r
+    bool tearDownWorld() {\r
+        delete validatingPool;\r
+        delete nonvalidatingPool;\r
+        XMLToolingConfig::getConfig().term();\r
+#if defined(_MSC_VER ) && defined(XMLTOOLINGTEST_LEAKCHECK)\r
+       _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE );\r
+       _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT );\r
+       _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE );\r
+       _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT );\r
+       _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );\r
+       _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDOUT );\r
+       _CrtDumpMemoryLeaks();\r
+#endif\r
+        return true;\r
+    }\r
+    //bool setUp() { printf( "</test>" ); return true; }\r
+    //bool tearDown() { printf( "</test>" ); return true; }\r
+};\r
+\r
+static ToolingFixture globalFixture;\r
+\r
+class CatalogTest : public CxxTest::TestSuite\r
+{\r
+public:\r
+    void testCatalog(void) {\r
+        auto_ptr_XMLCh temp("../xmltoolingtest/data/catalog.xml");\r
+        TS_ASSERT(validatingPool->loadCatalog(temp.get()));\r
+    }\r
+};\r