e3f26788c1013185d3d91879663189c2a88f672a
[shibboleth/cpp-opensaml.git] / samltest / saml1 / core / impl / AssertionIDReferenceTest.h
1 /*
2  *  Copyright 2001-2007 Internet2
3  * 
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include "internal.h"
18 #include <saml/saml1/core/Assertions.h>
19
20 using namespace opensaml::saml1;
21
22 class AssertionIDReferenceTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {
23     XMLCh* expectedNCName;
24
25 public:
26     void setUp() {
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();
31     }
32     
33     void tearDown() {
34         XMLString::release(&expectedNCName);
35         SAMLObjectBaseTestCase::tearDown();
36     }
37
38     void testSingleElementUnmarshall() {
39         auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));
40         AssertionIDReference* assertionIDReference = dynamic_cast<AssertionIDReference*>(xo.get());
41         TS_ASSERT(assertionIDReference!=NULL);
42         TSM_ASSERT("NCName present", assertionIDReference->getAssertionID()==NULL);
43     }
44
45     void testSingleElementOptionalAttributesUnmarshall() {
46         auto_ptr<XMLObject> xo(unmarshallElement(singleElementOptionalAttributesFile));
47         AssertionIDReference* assertionIDReference = dynamic_cast<AssertionIDReference*>(xo.get());
48         assertEquals("NCName ", expectedNCName, assertionIDReference->getAssertionID());
49     }
50
51     void testSingleElementMarshall() {
52         assertEquals(expectedDOM, AssertionIDReferenceBuilder::buildAssertionIDReference());
53     }
54
55     void testSingleElementOptionalAttributesMarshall() {
56         AssertionIDReference* assertionIDReference=AssertionIDReferenceBuilder::buildAssertionIDReference();
57         assertionIDReference->setAssertionID(expectedNCName);
58         assertEquals(expectedOptionalAttributesDOM, assertionIDReference);
59     }
60
61 };