Convert from NULL macro to nullptr, remove unused zlib code.
[shibboleth/cpp-opensaml.git] / samltest / saml1 / core / impl / ActionTest.h
1 /*
2  *  Copyright 2001-2010 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 ActionTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {
23     XMLCh* expectedContents;
24     XMLCh* expectedNamespace;
25
26 public:
27     void setUp() {
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();
33     }
34     
35     void tearDown() {
36         XMLString::release(&expectedContents);
37         XMLString::release(&expectedNamespace);
38         SAMLObjectBaseTestCase::tearDown();
39     }
40
41     void testSingleElementUnmarshall() {
42         auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));
43         Action* action = dynamic_cast<Action*>(xo.get());
44         TS_ASSERT(action!=nullptr);
45         TSM_ASSERT("namespace attribute present", action->getNamespace()==nullptr);
46         TSM_ASSERT("Contents present", action->getAction()==nullptr);
47     }
48
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());
54     }
55
56     void testSingleElementMarshall() {
57         assertEquals(expectedDOM, ActionBuilder::buildAction());
58     }
59
60     void testSingleElementOptionalAttributesMarshall() {
61         Action* action=ActionBuilder::buildAction();
62         action->setNamespace(expectedNamespace);
63         action->setAction(expectedContents);
64         assertEquals(expectedOptionalAttributesDOM, action);
65     }
66
67 };