X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=samltest%2Finternal.h;h=05eeb7ea9fe2456cc0d69849c9308dd016f970e0;hb=afd36d75830cdcf970d3f017902eefc808f7f282;hp=a49c55fa6ce855f38e8d78432e16f9922d6d770e;hpb=0ba5816a876bed78a05d9ed77db97b809927f1c0;p=shibboleth%2Fcpp-opensaml.git diff --git a/samltest/internal.h b/samltest/internal.h index a49c55f..05eeb7e 100644 --- a/samltest/internal.h +++ b/samltest/internal.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2006 Internet2 + * Copyright 2001-2007 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,19 +14,23 @@ * limitations under the License. */ +#ifdef WIN32 +# define _CRT_SECURE_NO_DEPRECATE 1 +# define _CRT_NONSTDC_NO_DEPRECATE 1 +#endif + #include #include #include -#include #include -#include -#include #include #include +#include +#include -using namespace opensaml; using namespace xmltooling; +using namespace xercesc; using namespace std; extern string data_path; @@ -72,8 +76,16 @@ protected: } } - void assertEquals(const char* failMessage, DOMDocument* expectedDOM, XMLObject* xmlObject) { - DOMElement* generatedDOM = xmlObject->marshall(); + void assertEquals(const char* failMessage, DOMDocument* expectedDOM, XMLObject* xmlObject, bool canMarshall=true) { + DOMElement* generatedDOM = xmlObject->getDOM(); + if (!generatedDOM) { + if (!canMarshall) { + TSM_ASSERT("DOM not available", false); + } + else { + generatedDOM = xmlObject->marshall(); + } + } if (!generatedDOM->isEqualNode(expectedDOM->getDocumentElement())) { string buf; XMLHelper::serialize(generatedDOM, buf); @@ -85,8 +97,8 @@ protected: } } - void assertEquals(DOMDocument* expectedDOM, XMLObject* xmlObject) { - assertEquals("Marshalled DOM was not the same as the expected DOM", expectedDOM, xmlObject); + void assertEquals(DOMDocument* expectedDOM, XMLObject* xmlObject, bool canMarshall=true) { + assertEquals("Marshalled DOM was not the same as the expected DOM", expectedDOM, xmlObject, canMarshall); delete xmlObject; } @@ -94,10 +106,10 @@ protected: char* buf = NULL; if (!XMLString::equals(expectedString, testString)) { buf = XMLString::transcode(testString); - TS_TRACE(buf); + TS_TRACE(buf ? buf : "(NULL)"); XMLString::release(&buf); buf = XMLString::transcode(expectedString); - TS_TRACE(buf); + TS_TRACE(buf ? buf : "(NULL)"); XMLString::release(&buf); TSM_ASSERT(failMessage, false); } @@ -203,7 +215,7 @@ class SAMLObjectValidatorBaseTestCase : virtual public SAMLObjectBaseTestCase { validator->validate(validateTarget); TS_TRACE(message); TS_FAIL("Validation success, expected failure to raise ValidationException"); - } catch (ValidationException &e) { + } catch (ValidationException&) { } }