f0b767fc022e89381b0a54aaba2b7b363133a933
[shibboleth/cpp-opensaml.git] / samltest / saml1 / core / impl / AttributeDesignatorTest.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 AttributeDesignatorTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {
23     XMLCh* expectedAttributeName;
24     XMLCh* expectedAttributeNamespace;
25
26 public:
27     void setUp() {
28         expectedAttributeName=XMLString::transcode("AttributeName");
29         expectedAttributeNamespace=XMLString::transcode("namespace");
30         singleElementFile = data_path + "saml1/core/impl/singleAttributeDesignator.xml";
31         singleElementOptionalAttributesFile = data_path + "saml1/core/impl/singleAttributeDesignatorAttributes.xml";
32         SAMLObjectBaseTestCase::setUp();
33     }
34     
35     void tearDown() {
36         XMLString::release(&expectedAttributeName);
37         XMLString::release(&expectedAttributeNamespace);
38         SAMLObjectBaseTestCase::tearDown();
39     }
40
41     void testSingleElementUnmarshall() {
42         auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));
43         AttributeDesignator& ad = dynamic_cast<AttributeDesignator&>(*xo.get());
44         TSM_ASSERT("AttributeName", ad.getAttributeName()==NULL);
45         TSM_ASSERT("AttributeNamespace", ad.getAttributeNamespace()==NULL);
46     }
47
48     void testSingleElementOptionalAttributesUnmarshall() {
49         auto_ptr<XMLObject> xo(unmarshallElement(singleElementOptionalAttributesFile));
50         AttributeDesignator& ad = dynamic_cast<AttributeDesignator&>(*xo.get());
51         assertEquals("AttributeName", expectedAttributeName, ad.getAttributeName());
52         assertEquals("AttributeNamespace", expectedAttributeNamespace, ad.getAttributeNamespace());
53     }
54
55     void testSingleElementMarshall() {
56         assertEquals(expectedDOM, AttributeDesignatorBuilder::buildAttributeDesignator());
57     }
58
59     void testSingleElementOptionalAttributesMarshall() {
60         AttributeDesignator* ad=AttributeDesignatorBuilder::buildAttributeDesignator();
61         ad->setAttributeName(expectedAttributeName);
62         ad->setAttributeNamespace(expectedAttributeNamespace);
63         assertEquals(expectedOptionalAttributesDOM, ad);
64     }
65
66 };