Multi-line svn commit, see body.
[shibboleth/cpp-opensaml.git] / samltest / saml2 / core / impl / Scoping20Test.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/saml2/core/Protocols.h>\r
19 #include <saml/util/SAMLConstants.h>\r
20 \r
21 using namespace opensaml::saml2p;\r
22 using namespace opensaml::saml2;\r
23 \r
24 class Scoping20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {\r
25     int expectedProxycount;\r
26 \r
27 public:\r
28     void setUp() {\r
29         expectedProxycount = 5;\r
30         singleElementFile = data_path + "saml2/core/impl/Scoping.xml";\r
31         singleElementOptionalAttributesFile = data_path + "saml2/core/impl/ScopingOptionalAttributes.xml";\r
32         childElementsFile  = data_path + "saml2/core/impl/ScopingChildElements.xml";    \r
33         SAMLObjectBaseTestCase::setUp();\r
34     }\r
35     \r
36     void tearDown() {\r
37         SAMLObjectBaseTestCase::tearDown();\r
38     }\r
39 \r
40     void testSingleElementUnmarshall() {\r
41         auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));\r
42         Scoping* scoping = dynamic_cast<Scoping*>(xo.get());\r
43         TS_ASSERT(scoping!=NULL);\r
44 \r
45         TSM_ASSERT_EQUALS("ProxyCount attribute presence", false, scoping->getProxyCount().first);\r
46         TS_ASSERT(scoping->getIDPList()==NULL);\r
47         TSM_ASSERT_EQUALS("# of RequesterID child elements", 0, scoping->getRequesterIDs().size());\r
48     }\r
49 \r
50     void testSingleElementOptionalAttributesUnmarshall() {\r
51         auto_ptr<XMLObject> xo(unmarshallElement(singleElementOptionalAttributesFile));\r
52         Scoping* scoping = dynamic_cast<Scoping*>(xo.get());\r
53         TS_ASSERT(scoping!=NULL);\r
54 \r
55         TSM_ASSERT_EQUALS("ProxyCount attribute presence", true, scoping->getProxyCount().first);\r
56         TSM_ASSERT_EQUALS("ProxyCount attribute value", expectedProxycount, scoping->getProxyCount().second);\r
57         TS_ASSERT(scoping->getIDPList()==NULL);\r
58         TSM_ASSERT_EQUALS("# of RequesterID child elements", 0, scoping->getRequesterIDs().size());\r
59     }\r
60 \r
61     void testChildElementsUnmarshall() {\r
62         auto_ptr<XMLObject> xo(unmarshallElement(childElementsFile));\r
63         Scoping* scoping= dynamic_cast<Scoping*>(xo.get());\r
64         TS_ASSERT(scoping!=NULL);\r
65 \r
66         TSM_ASSERT_EQUALS("ProxyCount attribute presence", false, scoping->getProxyCount().first);\r
67         TS_ASSERT(scoping->getIDPList()!=NULL);\r
68         TSM_ASSERT_EQUALS("# of RequesterID child elements", 3, scoping->getRequesterIDs().size());\r
69     }\r
70 \r
71     void testSingleElementMarshall() {\r
72         Scoping* scoping=ScopingBuilder::buildScoping();\r
73         assertEquals(expectedDOM, scoping);\r
74     }\r
75 \r
76     void testSingleElementOptionalAttributesMarshall() {\r
77         Scoping* scoping=ScopingBuilder::buildScoping();\r
78         scoping->setProxyCount(expectedProxycount);\r
79         assertEquals(expectedOptionalAttributesDOM, scoping);\r
80     }\r
81 \r
82     void testChildElementsMarshall() {\r
83         Scoping* scoping=ScopingBuilder::buildScoping();\r
84         scoping->setIDPList(IDPListBuilder::buildIDPList());\r
85         scoping->getRequesterIDs().push_back(RequesterIDBuilder::buildRequesterID());\r
86         scoping->getRequesterIDs().push_back(RequesterIDBuilder::buildRequesterID());\r
87         scoping->getRequesterIDs().push_back(RequesterIDBuilder::buildRequesterID());\r
88         assertEquals(expectedChildElementsDOM, scoping);\r
89     }\r
90 \r
91 };\r