--- /dev/null
+/*\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 "XMLObjectBaseTestCase.h"\r
+\r
+#include <xmltooling/exceptions.h>\r
+\r
+\r
+class ExceptionTest : public CxxTest::TestSuite {\r
+public:\r
+\r
+ void testException(void) {\r
+ TS_TRACE("testException");\r
+\r
+#define TEST(n,b,a) XMLToolingException e##n(b); \\r
+ TS_ASSERT(!strcmp(a,e##n.what()))\r
+\r
+#define TESTP(n,b,a,p) MarshallingException e##n(b,p); \\r
+ TS_ASSERT(!strcmp(a,e##n.what()))\r
+\r
+\r
+ TESTP(1,"This is a test.", "This is a test.", params(2,"Foo","bar"));\r
+ TESTP(2,"This is a test.$", "This is a test.", params(2,"Foo","bar"));\r
+ TESTP(3,"This is a $ test.", "This is a test.", params(2,"Foo","bar"));\r
+ TESTP(4,"$$This is a test.$", "$This is a test.", params(2,"Foo","bar"));\r
+ TESTP(5,"$This is a $test.", "This is a test.", params(2,"Foo","bar"));\r
+ TESTP(6,"$1 is a $2", "Foo is a bar", params(2,"Foo","bar"));\r
+ TESTP(7,"$This is a $test.", "Foo is a bar.", namedparams(2,"This","Foo","test","bar"));\r
+ TESTP(8,"Unable to generate random data: $1",\r
+ "Unable to generate random data: OpenSSLCryptoProvider::getRandom - OpenSSL random not properly initialised",\r
+ params(1,"OpenSSLCryptoProvider::getRandom - OpenSSL random not properly initialised"));\r
+\r
+ string buf=e7.toString();\r
+ TS_TRACE(buf.c_str());\r
+ auto_ptr<XMLToolingException> ptr(XMLToolingException::fromString(buf.c_str()));\r
+ TS_ASSERT(typeid(*ptr)==typeid(MarshallingException));\r
+ TS_ASSERT(!strcmp(ptr->what(),"Foo is a bar."));\r
+ }\r
+};\r