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/saml1/core/Assertions.h>
20 using namespace opensaml::saml1;
22 class AttributeDesignatorTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {
23 XMLCh* expectedAttributeName;
24 XMLCh* expectedAttributeNamespace;
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();
36 XMLString::release(&expectedAttributeName);
37 XMLString::release(&expectedAttributeNamespace);
38 SAMLObjectBaseTestCase::tearDown();
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);
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());
55 void testSingleElementMarshall() {
56 assertEquals(expectedDOM, AttributeDesignatorBuilder::buildAttributeDesignator());
59 void testSingleElementOptionalAttributesMarshall() {
60 AttributeDesignator* ad=AttributeDesignatorBuilder::buildAttributeDesignator();
61 ad->setAttributeName(expectedAttributeName);
62 ad->setAttributeNamespace(expectedAttributeNamespace);
63 assertEquals(expectedOptionalAttributesDOM, ad);