Multi-line svn commit, see body.
[shibboleth/cpp-opensaml.git] / samltest / saml2 / core / impl / IDPEntry20Test.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 IDPEntry20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {\r
25     XMLCh* expectedProviderID; \r
26     XMLCh* expectedName; \r
27     XMLCh* expectedLoc;\r
28 \r
29 public:\r
30     void setUp() {\r
31         expectedProviderID = XMLString::transcode("urn:string:providerid");; \r
32         expectedName = XMLString::transcode("Example IdP"); \r
33         expectedLoc = XMLString::transcode("http://idp.example.org/endpoint"); \r
34 \r
35         singleElementFile = data_path + "saml2/core/impl/IDPEntry.xml";\r
36         singleElementOptionalAttributesFile = data_path + "saml2/core/impl/IDPEntryOptionalAttributes.xml";\r
37         SAMLObjectBaseTestCase::setUp();\r
38     }\r
39     \r
40     void tearDown() {\r
41         XMLString::release(&expectedProviderID);\r
42         XMLString::release(&expectedName);\r
43         XMLString::release(&expectedLoc);\r
44         SAMLObjectBaseTestCase::tearDown();\r
45     }\r
46 \r
47     void testSingleElementUnmarshall() {\r
48         auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));\r
49         IDPEntry* entry = dynamic_cast<IDPEntry*>(xo.get());\r
50         TS_ASSERT(entry!=NULL);\r
51         assertEquals("ProviderID attribute", expectedProviderID, entry->getProviderID());\r
52     }\r
53 \r
54     void testSingleElementOptionalAttributesUnmarshall() {\r
55         auto_ptr<XMLObject> xo(unmarshallElement(singleElementOptionalAttributesFile));\r
56         IDPEntry* entry = dynamic_cast<IDPEntry*>(xo.get());\r
57         TS_ASSERT(entry!=NULL);\r
58         assertEquals("ProviderID attribute", expectedProviderID, entry->getProviderID());\r
59         assertEquals("Name attribute", expectedName, entry->getName());\r
60         assertEquals("Loc attribute", expectedLoc, entry->getLoc());\r
61     }\r
62 \r
63     void testSingleElementMarshall() {\r
64         IDPEntry* entry=IDPEntryBuilder::buildIDPEntry();\r
65         entry->setProviderID(expectedProviderID);\r
66         assertEquals(expectedDOM, entry);\r
67     }\r
68 \r
69     void testSingleElementOptionalAttributesMarshall() {\r
70         IDPEntry* entry=IDPEntryBuilder::buildIDPEntry();\r
71         entry->setProviderID(expectedProviderID);\r
72         entry->setName(expectedName);\r
73         entry->setLoc(expectedLoc);\r
74         assertEquals(expectedOptionalAttributesDOM, entry);\r
75     }\r
76 \r
77 };\r