e7ca8c509584c60468fa75202d51bc23a15a7858
[shibboleth/cpp-opensaml.git] / samltest / saml1 / core / impl / AssertionIDReferenceTest.h
1 /*\r
2  *  Copyright 2001-2006 Internet2\r
3  * \r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  *     http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  */\r
16 \r
17 #include "internal.h"\r
18 #include <saml/saml1/core/Assertions.h>\r
19 \r
20 using namespace opensaml::saml1;\r
21 \r
22 class AssertionIDReferenceTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {\r
23     XMLCh* expectedNCName;\r
24 \r
25 public:\r
26     void setUp() {\r
27         singleElementFile = data_path + "saml1/core/impl/singleAssertionIDReference.xml";\r
28         singleElementOptionalAttributesFile  = data_path + "saml1/core/impl/singleAssertionIDReferenceContents.xml";    \r
29         expectedNCName = XMLString::transcode("NibbleAHappyWarthog");\r
30         SAMLObjectBaseTestCase::setUp();\r
31     }\r
32     \r
33     void tearDown() {\r
34         XMLString::release(&expectedNCName);\r
35         SAMLObjectBaseTestCase::tearDown();\r
36     }\r
37 \r
38     void testSingleElementUnmarshall() {\r
39         auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));\r
40         AssertionIDReference* assertionIDReference = dynamic_cast<AssertionIDReference*>(xo.get());\r
41         TS_ASSERT(assertionIDReference!=NULL);\r
42         TSM_ASSERT("NCName present", assertionIDReference->getReference()==NULL);\r
43     }\r
44 \r
45     void testSingleElementOptionalAttributesUnmarshall() {\r
46         auto_ptr<XMLObject> xo(unmarshallElement(singleElementOptionalAttributesFile));\r
47         AssertionIDReference* assertionIDReference = dynamic_cast<AssertionIDReference*>(xo.get());\r
48         TSM_ASSERT_SAME_DATA("NCName ", expectedNCName, assertionIDReference->getReference(), XMLString::stringLen(expectedNCName));\r
49     }\r
50 \r
51     void testSingleElementMarshall() {\r
52         assertEquals(expectedDOM, AssertionIDReferenceBuilder::buildAssertionIDReference());\r
53     }\r
54 \r
55     void testSingleElementOptionalAttributesMarshall() {\r
56         AssertionIDReference* assertionIDReference=AssertionIDReferenceBuilder::buildAssertionIDReference();\r
57         assertionIDReference->setReference(expectedNCName);\r
58         assertEquals(expectedOptionalAttributesDOM, assertionIDReference);\r
59     }\r
60 \r
61 };\r