2 * Copyright 2001-2006 Internet2
\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
8 * http://www.apache.org/licenses/LICENSE-2.0
\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
17 #include "internal.h"
\r
18 #include <saml/saml2/core/Assertions.h>
\r
19 #include <saml/util/SAMLConstants.h>
\r
21 using namespace opensaml::saml2;
\r
23 class AttributeStatement20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {
\r
27 singleElementFile = data_path + "saml2/core/impl/AttributeStatement.xml";
\r
28 childElementsFile = data_path + "saml2/core/impl/AttributeStatementChildElements.xml";
\r
29 SAMLObjectBaseTestCase::setUp();
\r
33 SAMLObjectBaseTestCase::tearDown();
\r
36 void testSingleElementUnmarshall() {
\r
37 auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));
\r
38 AttributeStatement* statement = dynamic_cast<AttributeStatement*>(xo.get());
\r
39 TS_ASSERT(statement!=NULL);
\r
41 TSM_ASSERT_EQUALS("# of Attribute child elements", 0, statement->getAttributes().size());
\r
42 TSM_ASSERT_EQUALS("# of EncryptedAttribute child elements", 0, statement->getEncryptedAttributes().size());
\r
45 void testChildElementsUnmarshall() {
\r
46 auto_ptr<XMLObject> xo(unmarshallElement(childElementsFile));
\r
47 AttributeStatement* statement= dynamic_cast<AttributeStatement*>(xo.get());
\r
48 TS_ASSERT(statement!=NULL);
\r
50 TSM_ASSERT_EQUALS("# of Attribute child elements", 3, statement->getAttributes().size());
\r
51 TSM_ASSERT_EQUALS("# of EncryptedAttribute child elements", 1, statement->getEncryptedAttributes().size());
\r
54 void testSingleElementMarshall() {
\r
55 AttributeStatement* statement=AttributeStatementBuilder::buildAttributeStatement();
\r
56 assertEquals(expectedDOM, statement);
\r
59 void testChildElementsMarshall() {
\r
60 AttributeStatement* statement=AttributeStatementBuilder::buildAttributeStatement();
\r
62 statement->getAttributes().push_back(AttributeBuilder::buildAttribute());
\r
63 statement->getAttributes().push_back(AttributeBuilder::buildAttribute());
\r
64 statement->getEncryptedAttributes().push_back(EncryptedAttributeBuilder::buildEncryptedAttribute());
\r
65 statement->getAttributes().push_back(AttributeBuilder::buildAttribute());
\r
66 assertEquals(expectedChildElementsDOM, statement);
\r