2 * Copyright 2001-2006 Internet2
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include <saml/saml2/core/Assertions.h>
19 #include <saml/util/SAMLConstants.h>
21 using namespace opensaml::saml2;
23 class ProxyRestriction20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {
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();
36 SAMLObjectBaseTestCase::tearDown();
39 void testSingleElementUnmarshall() {
40 auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));
41 ProxyRestriction* pr = dynamic_cast<ProxyRestriction*>(xo.get());
44 TSM_ASSERT_EQUALS("Count attribute presence", false, pr->getCount().first);
45 TSM_ASSERT_EQUALS("# of Audience child elements", 0, pr->getAudiences().size());
48 void testSingleElementOptionalAttributesUnmarshall() {
49 auto_ptr<XMLObject> xo(unmarshallElement(singleElementOptionalAttributesFile));
50 ProxyRestriction* pr = dynamic_cast<ProxyRestriction*>(xo.get());
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());
58 void testChildElementsUnmarshall() {
59 auto_ptr<XMLObject> xo(unmarshallElement(childElementsFile));
60 ProxyRestriction* pr= dynamic_cast<ProxyRestriction*>(xo.get());
63 TSM_ASSERT_EQUALS("Count attribute presence", false, pr->getCount().first);
64 TSM_ASSERT_EQUALS("# of Audience child elements", 2, pr->getAudiences().size());
67 void testSingleElementMarshall() {
68 ProxyRestriction* pr=ProxyRestrictionBuilder::buildProxyRestriction();
69 assertEquals(expectedDOM, pr);
72 void testSingleElementOptionalAttributesMarshall() {
73 ProxyRestriction* pr=ProxyRestrictionBuilder::buildProxyRestriction();
74 pr->setCount(expectedCount);
75 assertEquals(expectedOptionalAttributesDOM, pr);
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);