2 * Copyright 2001-2010 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/saml1/core/Assertions.h>
20 using namespace opensaml::saml1;
22 class AssertionIDReferenceTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {
23 XMLCh* expectedNCName;
27 singleElementFile = data_path + "saml1/core/impl/singleAssertionIDReference.xml";
28 singleElementOptionalAttributesFile = data_path + "saml1/core/impl/singleAssertionIDReferenceContents.xml";
29 expectedNCName = XMLString::transcode("NibbleAHappyWarthog");
30 SAMLObjectBaseTestCase::setUp();
34 XMLString::release(&expectedNCName);
35 SAMLObjectBaseTestCase::tearDown();
38 void testSingleElementUnmarshall() {
39 auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));
40 AssertionIDReference* assertionIDReference = dynamic_cast<AssertionIDReference*>(xo.get());
41 TS_ASSERT(assertionIDReference!=nullptr);
42 TSM_ASSERT("NCName present", assertionIDReference->getAssertionID()==nullptr);
45 void testSingleElementOptionalAttributesUnmarshall() {
46 auto_ptr<XMLObject> xo(unmarshallElement(singleElementOptionalAttributesFile));
47 AssertionIDReference* assertionIDReference = dynamic_cast<AssertionIDReference*>(xo.get());
48 assertEquals("NCName ", expectedNCName, assertionIDReference->getAssertionID());
51 void testSingleElementMarshall() {
52 assertEquals(expectedDOM, AssertionIDReferenceBuilder::buildAssertionIDReference());
55 void testSingleElementOptionalAttributesMarshall() {
56 AssertionIDReference* assertionIDReference=AssertionIDReferenceBuilder::buildAssertionIDReference();
57 assertionIDReference->setAssertionID(expectedNCName);
58 assertEquals(expectedOptionalAttributesDOM, assertionIDReference);