Removed ValidatingXMLObject interface and implementations, first draft of metadata...
[shibboleth/cpp-opensaml.git] / samltest / saml2 / metadata / FilesystemMetadataProviderTest.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/metadata/MetadataProvider.h>\r
19 \r
20 using namespace opensaml::saml2md;\r
21 \r
22 class FilesystemMetadataProviderTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {\r
23     XMLCh* entityID;\r
24     XMLCh* supportedProtocol;\r
25     MetadataProvider* metadataProvider;\r
26 \r
27 public:\r
28     void setUp() {\r
29         entityID=XMLString::transcode("urn:mace:incommon:washington.edu");\r
30         supportedProtocol=XMLString::transcode("urn:oasis:names:tc:SAML:1.1:protocol");\r
31         \r
32         auto_ptr_XMLCh MP("MetadataProvider");\r
33         auto_ptr_XMLCh path("path");\r
34         auto_ptr_XMLCh validate("validate");\r
35         string s=data_path + "saml2/metadata/InCommon-metadata.xml";\r
36         auto_ptr_XMLCh file(s.c_str());\r
37         DOMDocument* doc=XMLToolingConfig::getConfig().getParser().newDocument();\r
38         XercesJanitor<DOMDocument> janitor(doc);\r
39         DOMElement* root=doc->createElementNS(NULL,MP.get());\r
40         root->setAttributeNS(NULL,path.get(),file.get());\r
41         root->setAttributeNS(NULL,validate.get(),XMLConstants::XML_ZERO);\r
42         metadataProvider = NULL;\r
43         metadataProvider = SAMLConfig::getConfig().MetadataProviderManager.newPlugin(FILESYSTEM_METADATA_PROVIDER,root);\r
44         metadataProvider->init();\r
45         \r
46         SAMLObjectBaseTestCase::setUp();\r
47     }\r
48     \r
49     void tearDown() {\r
50         XMLString::release(&entityID);\r
51         XMLString::release(&supportedProtocol);\r
52         delete metadataProvider;\r
53         SAMLObjectBaseTestCase::tearDown();\r
54     }\r
55 \r
56     void testGetEntityDescriptor() {\r
57         Locker locker(metadataProvider);\r
58         const EntityDescriptor* descriptor = metadataProvider->lookup(entityID);\r
59         TSM_ASSERT("Retrieved entity descriptor was null", descriptor!=NULL);\r
60         assertEquals("Entity's ID does not match requested ID", entityID, descriptor->getEntityID());\r
61     }\r
62 \r
63 };\r