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 ActionTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {
23 XMLCh* expectedContents;
24 XMLCh* expectedNamespace;
28 singleElementFile = data_path + "saml1/core/impl/singleAction.xml";
29 singleElementOptionalAttributesFile = data_path + "saml1/core/impl/singleActionAttributes.xml";
30 expectedContents = XMLString::transcode("Action Contents");
31 expectedNamespace = XMLString::transcode("namespace");
32 SAMLObjectBaseTestCase::setUp();
36 XMLString::release(&expectedContents);
37 XMLString::release(&expectedNamespace);
38 SAMLObjectBaseTestCase::tearDown();
41 void testSingleElementUnmarshall() {
42 auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));
43 Action* action = dynamic_cast<Action*>(xo.get());
44 TS_ASSERT(action!=NULL);
45 TSM_ASSERT("namespace attribute present", action->getNamespace()==NULL);
46 TSM_ASSERT("Contents present", action->getAction()==NULL);
49 void testSingleElementOptionalAttributesUnmarshall() {
50 auto_ptr<XMLObject> xo(unmarshallElement(singleElementOptionalAttributesFile));
51 Action* action = dynamic_cast<Action*>(xo.get());
52 assertEquals("namespace attribute ", expectedNamespace, action->getNamespace());
53 assertEquals("Contents ", expectedContents, action->getAction());
56 void testSingleElementMarshall() {
57 assertEquals(expectedDOM, ActionBuilder::buildAction());
60 void testSingleElementOptionalAttributesMarshall() {
61 Action* action=ActionBuilder::buildAction();
62 action->setNamespace(expectedNamespace);
63 action->setAction(expectedContents);
64 assertEquals(expectedOptionalAttributesDOM, action);