Convert from NULL macro to nullptr, remove unused zlib code.
[shibboleth/cpp-opensaml.git] / samltest / saml2 / core / impl / IDPEntry20Test.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/Protocols.h>
19 #include <saml/util/SAMLConstants.h>
20
21 using namespace opensaml::saml2p;
22 using namespace opensaml::saml2;
23
24 class IDPEntry20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {
25     XMLCh* expectedProviderID; 
26     XMLCh* expectedName; 
27     XMLCh* expectedLoc;
28
29 public:
30     void setUp() {
31         expectedProviderID = XMLString::transcode("urn:string:providerid");; 
32         expectedName = XMLString::transcode("Example IdP"); 
33         expectedLoc = XMLString::transcode("http://idp.example.org/endpoint"); 
34
35         singleElementFile = data_path + "saml2/core/impl/IDPEntry.xml";
36         singleElementOptionalAttributesFile = data_path + "saml2/core/impl/IDPEntryOptionalAttributes.xml";
37         SAMLObjectBaseTestCase::setUp();
38     }
39     
40     void tearDown() {
41         XMLString::release(&expectedProviderID);
42         XMLString::release(&expectedName);
43         XMLString::release(&expectedLoc);
44         SAMLObjectBaseTestCase::tearDown();
45     }
46
47     void testSingleElementUnmarshall() {
48         auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));
49         IDPEntry* entry = dynamic_cast<IDPEntry*>(xo.get());
50         TS_ASSERT(entry!=nullptr);
51         assertEquals("ProviderID attribute", expectedProviderID, entry->getProviderID());
52     }
53
54     void testSingleElementOptionalAttributesUnmarshall() {
55         auto_ptr<XMLObject> xo(unmarshallElement(singleElementOptionalAttributesFile));
56         IDPEntry* entry = dynamic_cast<IDPEntry*>(xo.get());
57         TS_ASSERT(entry!=nullptr);
58         assertEquals("ProviderID attribute", expectedProviderID, entry->getProviderID());
59         assertEquals("Name attribute", expectedName, entry->getName());
60         assertEquals("Loc attribute", expectedLoc, entry->getLoc());
61     }
62
63     void testSingleElementMarshall() {
64         IDPEntry* entry=IDPEntryBuilder::buildIDPEntry();
65         entry->setProviderID(expectedProviderID);
66         assertEquals(expectedDOM, entry);
67     }
68
69     void testSingleElementOptionalAttributesMarshall() {
70         IDPEntry* entry=IDPEntryBuilder::buildIDPEntry();
71         entry->setProviderID(expectedProviderID);
72         entry->setName(expectedName);
73         entry->setLoc(expectedLoc);
74         assertEquals(expectedOptionalAttributesDOM, entry);
75     }
76
77 };