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 AudienceTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {
27 expectedUri=XMLString::transcode("urn:oasis:names:tc:SAML:1.0:assertion");
28 singleElementFile = data_path + "saml1/core/impl/singleAudience.xml";
29 singleElementOptionalAttributesFile = data_path + "saml1/core/impl/singleAudienceAttributes.xml";
30 SAMLObjectBaseTestCase::setUp();
34 XMLString::release(&expectedUri);
35 SAMLObjectBaseTestCase::tearDown();
38 void testSingleElementUnmarshall() {
39 auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));
40 Audience& a = dynamic_cast<Audience&>(*xo.get());
41 TSM_ASSERT("Uri is non-null", a.getAudienceURI()==nullptr);
44 void testSingleElementOptionalAttributesUnmarshall() {
45 auto_ptr<XMLObject> xo(unmarshallElement(singleElementOptionalAttributesFile));
46 Audience& a = dynamic_cast<Audience&>(*xo.get());
47 assertEquals("Uri", expectedUri, a.getAudienceURI());
50 void testSingleElementMarshall() {
51 assertEquals(expectedDOM, AudienceBuilder::buildAudience());
54 void testSingleElementOptionalAttributesMarshall() {
55 Audience* a=AudienceBuilder::buildAudience();
56 a->setAudienceURI(expectedUri);
57 assertEquals(expectedOptionalAttributesDOM, a);