0a064f1899165afba2b73a9c7786971be5abd311
[shibboleth/cpp-xmltooling.git] / xmltoolingtest / SOAPTest.h
1 /*
2  *  Licensed to Internet2 under one or more contributor license agreements.
3  *  See the NOTICE file distributed with this work for additional information
4  *  regarding copyright ownership. Internet2 licenses this file to you under
5  *  the Apache License, Version 2.0 (the "License"); you may not use this
6  *  file except in compliance with the License.  You may obtain a copy of the
7  *  License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13  *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
14  *  License for the specific language governing permissions and limitations
15  *  under the License.
16  */
17
18 #include "XMLObjectBaseTestCase.h"
19
20 #include <fstream>
21 #include <xmltooling/soap/SOAP.h>
22 #include <xmltooling/validation/ValidatorSuite.h>
23
24 using namespace soap11;
25
26 class SOAPTest : public CxxTest::TestSuite {
27 public:
28     SOAPTest() {}
29
30     void testSOAPFault() {
31         string path=data_path + "SOAPFault.xml";
32         ifstream fs(path.c_str());
33         DOMDocument* doc=XMLToolingConfig::getConfig().getValidatingParser().parse(fs);
34         TS_ASSERT(doc!=nullptr);
35
36         const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement());
37         TS_ASSERT(b!=nullptr);
38
39         auto_ptr<Envelope> envObject(dynamic_cast<Envelope*>(b->buildFromDocument(doc)));
40         TS_ASSERT(envObject.get()!=nullptr);
41         TSM_ASSERT("SOAP Envelope missing Body", envObject->getBody() != nullptr);
42         TSM_ASSERT_EQUALS("SOAP Body missing Fault", 1, envObject->getBody()->getOrderedChildren().size());
43
44         SchemaValidators.validate(envObject.get());
45     }
46 };