Completed SAML 1 assertion schema, started test cases.
[shibboleth/cpp-opensaml.git] / samltest / saml1 / core / impl / ActionTest.h
1 /*\r
2  *  Copyright 2001-2006 Internet2\r
3  * \r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  *     http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  */\r
16 \r
17 #include "internal.h"\r
18 #include <saml/saml1/core/Assertions.h>\r
19 \r
20 using namespace opensaml::saml1;\r
21 \r
22 class ActionTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {\r
23     XMLCh* expectedContents;\r
24     XMLCh* expectedNamespace;\r
25     QName* qname;\r
26 \r
27 public:\r
28     void setUp() {\r
29         singleElementFile = data_path + "saml1/core/impl/singleAction.xml";\r
30         singleElementOptionalAttributesFile  = data_path + "saml1/core/impl/singleActionAttributes.xml";    \r
31         expectedContents = XMLString::transcode("Action Contents");\r
32         expectedNamespace = XMLString::transcode("namespace");\r
33         qname = new QName(SAMLConstants::SAML1_NS, Action::LOCAL_NAME, SAMLConstants::SAML1_PREFIX);\r
34         SAMLObjectBaseTestCase::setUp();\r
35     }\r
36     \r
37     void tearDown() {\r
38         delete qname;\r
39         XMLString::release(&expectedContents);\r
40         XMLString::release(&expectedNamespace);\r
41         SAMLObjectBaseTestCase::tearDown();\r
42     }\r
43 \r
44     void testSingleElementUnmarshall() {\r
45         auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));\r
46         Action* action = dynamic_cast<Action*>(xo.get());\r
47         TS_ASSERT(action!=NULL);\r
48         TSM_ASSERT("namespace attribute present", action->getNamespace()==NULL);\r
49         TSM_ASSERT("Contents present", action->getValue()==NULL);\r
50     }\r
51 \r
52     void testSingleElementOptionalAttributesUnmarshall() {\r
53         auto_ptr<XMLObject> xo(unmarshallElement(singleElementOptionalAttributesFile));\r
54         Action* action = dynamic_cast<Action*>(xo.get());\r
55         TSM_ASSERT_SAME_DATA("namespace attribute ", expectedNamespace, action->getNamespace(), XMLString::stringLen(expectedNamespace));\r
56         TSM_ASSERT_SAME_DATA("Contents ", expectedContents, action->getValue(), XMLString::stringLen(expectedContents));\r
57     }\r
58 \r
59     void testSingleElementMarshall() {\r
60         auto_ptr<Action> action(ActionBuilder::buildAction());\r
61         assertEquals(expectedDOM, action.get());\r
62     }\r
63 \r
64     void testSingleElementOptionalAttributesMarshall() {\r
65         auto_ptr<Action> action(ActionBuilder::buildAction());\r
66         action->setNamespace(expectedNamespace);\r
67         action->setValue(expectedContents);\r
68         assertEquals(expectedOptionalAttributesDOM, action.get());\r
69     }\r
70 \r
71 };\r