Convert from NULL macro to nullptr, remove unused zlib code.
[shibboleth/cpp-opensaml.git] / samltest / saml2 / core / impl / NameID20Test.h
1 /*
2  *  Copyright 2001-2010 Internet2
3  * 
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include "internal.h"
18 #include <saml/saml2/core/Assertions.h>
19 #include <saml/util/SAMLConstants.h>
20
21 using namespace opensaml::saml2;
22
23 class NameID20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {
24     XMLCh* expectedNameQualifier; 
25     XMLCh* expectedSPNameQualifier; 
26     XMLCh* expectedFormat; 
27     XMLCh* expectedSPProvidedID; 
28     XMLCh* expectedContent; 
29
30 public:
31     void setUp() {
32         expectedNameQualifier = XMLString::transcode("nq"); 
33         expectedSPNameQualifier = XMLString::transcode("spnq"); 
34         expectedFormat = XMLString::transcode("format"); 
35         expectedSPProvidedID = XMLString::transcode("spID"); 
36         expectedContent = XMLString::transcode("someNameID"); 
37
38         singleElementFile = data_path + "saml2/core/impl/NameID.xml";
39         singleElementOptionalAttributesFile = data_path + "saml2/core/impl/NameIDOptionalAttributes.xml";
40         SAMLObjectBaseTestCase::setUp();
41     }
42     
43     void tearDown() {
44         XMLString::release(&expectedNameQualifier);
45         XMLString::release(&expectedSPNameQualifier);
46         XMLString::release(&expectedFormat);
47         XMLString::release(&expectedSPProvidedID);
48         XMLString::release(&expectedContent);
49         SAMLObjectBaseTestCase::tearDown();
50     }
51
52     void testSingleElementUnmarshall() {
53         auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));
54         NameID* nameid = dynamic_cast<NameID*>(xo.get());
55         TS_ASSERT(nameid!=nullptr);
56
57         assertEquals("Element content", expectedContent, nameid->getName());
58     }
59
60     void testSingleElementOptionalAttributesUnmarshall() {
61         auto_ptr<XMLObject> xo(unmarshallElement(singleElementOptionalAttributesFile));
62         NameID* nameid = dynamic_cast<NameID*>(xo.get());
63         TS_ASSERT(nameid!=nullptr);
64
65         assertEquals("NameQualifier attribute", expectedNameQualifier, nameid->getNameQualifier());
66         assertEquals("SPNameQualifier attribute", expectedSPNameQualifier, nameid->getSPNameQualifier());
67         assertEquals("Format attribute", expectedFormat, nameid->getFormat());
68         assertEquals("SPProvidedID attribute", expectedSPProvidedID, nameid->getSPProvidedID());
69         assertEquals("Element content", expectedContent, nameid->getName());
70     }
71
72
73     void testSingleElementMarshall() {
74         NameID* nameid = NameIDBuilder::buildNameID();
75         TS_ASSERT(nameid!=nullptr);
76
77         nameid->setName(expectedContent);
78         assertEquals(expectedDOM, nameid);
79     }
80
81     void testSingleElementOptionalAttributesMarshall() {
82         NameID* nameid = NameIDBuilder::buildNameID();
83         TS_ASSERT(nameid!=nullptr);
84
85         nameid->setNameQualifier(expectedNameQualifier);
86         nameid->setSPNameQualifier(expectedSPNameQualifier);
87         nameid->setFormat(expectedFormat);
88         nameid->setSPProvidedID(expectedSPProvidedID);
89         nameid->setName(expectedContent);
90         assertEquals(expectedOptionalAttributesDOM, nameid);
91     }
92
93 };