/**************************************************************************** ** ** This file is part of the KD Soap project. ** ** SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company ** ** SPDX-License-Identifier: MIT ** ****************************************************************************/ #include "KDDateTime.h" #include "KDSoapClientInterface.h" #include "KDSoapMessage.h" #include "KDSoapValue.h" #include "httpserver_p.h" #include "wsdl_DWService.h" #include #include using namespace KDSoapUnitTestHelpers; class DWServiceTest : public QObject { Q_OBJECT private Q_SLOTS: void testLogin() { HttpServerThread server(loginResponse(), HttpServerThread::Public); KDAB::DWService service; service.setEndPoint(server.endPoint()); KDAB::TNS__Login loginParams; loginParams.setUserName(QString::fromLatin1("Foo")); loginParams.setOrganization(QString::fromLatin1("KDAB")); const KDAB::TNS__LoginResponse resp = service.login(loginParams); // Check what we sent QByteArray expectedRequestXml = QByteArray(xmlEnvBegin11()) + ">" "" "Foo" // minoccurs=0, so we don't need this: "" "KDAB" "" "" + xmlEnvEnd() + '\n'; // added by QXmlStreamWriter::writeEndDocument QVERIFY(xmlBufferCompare(server.receivedData(), expectedRequestXml)); const KDAB::Q1__ClientServiceSession session = resp.loginResult(); const KDAB::SER__Guid sessionId = session.sessionID(); QCOMPARE(sessionId.value(), QString::fromLatin1("65a65c1f-2613-47d0-89ec-1c7b1fe34777")); } void testLogoff() { HttpServerThread server(loginResponse(), HttpServerThread::Public); KDAB::DWService service; service.setEndPoint(server.endPoint()); KDAB::Q1__ClientServiceSession session; session.setSessionID(KDAB::SER__Guid(QString::fromLatin1("65a65c1f-2613-47d0-89ec-1c7b1fe34777"))); KDAB::TNS__Logoff logoffParams; logoffParams.setClientSession(session); service.logoff(logoffParams); // Check what we sent QByteArray expectedRequestXml = QByteArray(xmlEnvBegin11()) + ">" "" "65a65c1f-2613-47d0-89ec-1c7b1fe34777" "" "" + xmlEnvEnd() + '\n'; // added by QXmlStreamWriter::writeEndDocument QVERIFY(xmlBufferCompare(server.receivedData(), expectedRequestXml)); } private: static QByteArray loginResponse() { return QByteArray(xmlEnvBegin11()) + " xmlns:dw=\"http://schemas.novell.com/2005/01/GroupWise/groupwise.wsdl\">" "" "65a65c1f-2613-47d0-89ec-1c7b1fe34777" "" "" + xmlEnvEnd(); } }; QTEST_MAIN(DWServiceTest) #include "test_dwservice_wsdl.moc"