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 Subject20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {
27 singleElementFile = data_path + "saml2/core/impl/Subject.xml";
28 childElementsFile = data_path + "saml2/core/impl/SubjectChildElements.xml";
29 SAMLObjectBaseTestCase::setUp();
33 SAMLObjectBaseTestCase::tearDown();
36 void testSingleElementUnmarshall() {
37 auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));
38 Subject* subject = dynamic_cast<Subject*>(xo.get());
39 TS_ASSERT(subject!=NULL);
41 TS_ASSERT(subject->getBaseID()==NULL);
42 TS_ASSERT(subject->getNameID()==NULL);
43 TS_ASSERT(subject->getEncryptedID()==NULL);
44 TSM_ASSERT_EQUALS("# of SubjectConfirmation child elements", 0, subject->getSubjectConfirmations().size());
47 void testChildElementsUnmarshall() {
48 auto_ptr<XMLObject> xo(unmarshallElement(childElementsFile));
49 Subject* subject= dynamic_cast<Subject*>(xo.get());
50 TS_ASSERT(subject!=NULL);
52 TS_ASSERT(subject->getBaseID()==NULL);
53 TS_ASSERT(subject->getNameID()!=NULL);
54 TS_ASSERT(subject->getEncryptedID()==NULL);
55 TSM_ASSERT_EQUALS("# of SubjectConfirmation child elements", 2, subject->getSubjectConfirmations().size());
58 void testSingleElementMarshall() {
59 Subject* subject=SubjectBuilder::buildSubject();
60 assertEquals(expectedDOM, subject);
63 void testChildElementsMarshall() {
64 Subject* subject=SubjectBuilder::buildSubject();
65 subject->setNameID(NameIDBuilder::buildNameID());
66 subject->getSubjectConfirmations().push_back(SubjectConfirmationBuilder::buildSubjectConfirmation());
67 subject->getSubjectConfirmations().push_back(SubjectConfirmationBuilder::buildSubjectConfirmation());
68 assertEquals(expectedChildElementsDOM, subject);