Convert from NULL macro to nullptr, remove unused zlib code.
[shibboleth/cpp-opensaml.git] / samltest / saml2 / core / impl / ProxyRestriction20Test.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 ProxyRestriction20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {
24     int expectedCount;
25
26 public:
27     void setUp() {
28         expectedCount = 5;
29         singleElementFile = data_path + "saml2/core/impl/ProxyRestriction.xml";
30         singleElementOptionalAttributesFile = data_path + "saml2/core/impl/ProxyRestrictionOptionalAttributes.xml";
31         childElementsFile  = data_path + "saml2/core/impl/ProxyRestrictionChildElements.xml";    
32         SAMLObjectBaseTestCase::setUp();
33     }
34     
35     void tearDown() {
36         SAMLObjectBaseTestCase::tearDown();
37     }
38
39     void testSingleElementUnmarshall() {
40         auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));
41         ProxyRestriction* pr = dynamic_cast<ProxyRestriction*>(xo.get());
42         TS_ASSERT(pr!=nullptr);
43
44         TSM_ASSERT_EQUALS("Count attribute presence", false, pr->getCount().first);
45         TSM_ASSERT_EQUALS("# of Audience child elements", 0, pr->getAudiences().size());
46     }
47
48     void testSingleElementOptionalAttributesUnmarshall() {
49         auto_ptr<XMLObject> xo(unmarshallElement(singleElementOptionalAttributesFile));
50         ProxyRestriction* pr = dynamic_cast<ProxyRestriction*>(xo.get());
51         TS_ASSERT(pr!=nullptr);
52
53         TSM_ASSERT_EQUALS("Count attribute presence", true, pr->getCount().first);
54         TSM_ASSERT_EQUALS("Count attribute value", expectedCount, pr->getCount().second);
55         TSM_ASSERT_EQUALS("# of Audience child elements", 0, pr->getAudiences().size());
56     }
57
58     void testChildElementsUnmarshall() {
59         auto_ptr<XMLObject> xo(unmarshallElement(childElementsFile));
60         ProxyRestriction* pr= dynamic_cast<ProxyRestriction*>(xo.get());
61         TS_ASSERT(pr!=nullptr);
62
63         TSM_ASSERT_EQUALS("Count attribute presence", false, pr->getCount().first);
64         TSM_ASSERT_EQUALS("# of Audience child elements", 2, pr->getAudiences().size());
65     }
66
67     void testSingleElementMarshall() {
68         ProxyRestriction* pr=ProxyRestrictionBuilder::buildProxyRestriction();
69         assertEquals(expectedDOM, pr);
70     }
71
72     void testSingleElementOptionalAttributesMarshall() {
73         ProxyRestriction* pr=ProxyRestrictionBuilder::buildProxyRestriction();
74         pr->setCount(expectedCount);
75         assertEquals(expectedOptionalAttributesDOM, pr);
76     }
77
78     void testChildElementsMarshall() {
79         ProxyRestriction* pr=ProxyRestrictionBuilder::buildProxyRestriction();
80         pr->getAudiences().push_back(AudienceBuilder::buildAudience());
81         pr->getAudiences().push_back(AudienceBuilder::buildAudience());
82         assertEquals(expectedChildElementsDOM, pr);
83     }
84
85 };