2 * Copyright 2001-2007 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 SubjectConfirmation20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {
24 XMLCh* expectedMethod;
28 expectedMethod = XMLString::transcode("urn:string:cm");
30 singleElementFile = data_path + "saml2/core/impl/SubjectConfirmation.xml";
31 childElementsFile = data_path + "saml2/core/impl/SubjectConfirmationChildElements.xml";
32 SAMLObjectBaseTestCase::setUp();
36 XMLString::release(&expectedMethod);
37 SAMLObjectBaseTestCase::tearDown();
40 void testSingleElementUnmarshall() {
41 auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));
42 SubjectConfirmation* sc = dynamic_cast<SubjectConfirmation*>(xo.get());
45 assertEquals("Method attribute", expectedMethod, sc->getMethod());
47 TS_ASSERT(sc->getBaseID()==NULL);
48 TS_ASSERT(sc->getNameID()==NULL);
49 TS_ASSERT(sc->getEncryptedID()==NULL);
50 TS_ASSERT(sc->getSubjectConfirmationData()==NULL);
53 void testChildElementsUnmarshall() {
54 auto_ptr<XMLObject> xo(unmarshallElement(childElementsFile));
55 SubjectConfirmation* sc= dynamic_cast<SubjectConfirmation*>(xo.get());
58 TS_ASSERT(sc->getBaseID()==NULL);
59 TS_ASSERT(sc->getNameID()!=NULL);
60 TS_ASSERT(sc->getEncryptedID()==NULL);
61 TS_ASSERT(sc->getSubjectConfirmationData()!=NULL);
64 void testSingleElementMarshall() {
65 SubjectConfirmation* sc=SubjectConfirmationBuilder::buildSubjectConfirmation();
66 sc->setMethod(expectedMethod);
67 assertEquals(expectedDOM, sc);
70 void testChildElementsMarshall() {
71 SubjectConfirmation* sc=SubjectConfirmationBuilder::buildSubjectConfirmation();
72 sc->setNameID(NameIDBuilder::buildNameID());
73 sc->setSubjectConfirmationData(SubjectConfirmationDataBuilder::buildSubjectConfirmationData());
74 assertEquals(expectedChildElementsDOM, sc);