/**************************************************************************** ** ** 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 "wsdl_kdtest.h" #include "httpserver_p.h" #include #include #include #include #include #include #include using namespace KDSoapUnitTestHelpers; // Server side to perform job operation request class GuestServerObject : public GuestServerBase /* generated from wsdl */ { Q_OBJECT public: virtual TNS__AddPersonResponse addPerson(const TNS__AddPersonRequest ¶meters) override { Q_UNUSED(parameters); return TNS__AddPersonResponse(); } virtual TNS__AuthenticateResponse authenticate(const TNS__AuthenticateRequest ¶meters) override { if (parameters.serijskiBrojSertifikata() == "cert") { TNS__AuthenticateResponse response; response.setResult("result"); TNS__User user; user.setFullName("userFullName"); response.setUser(user); return response; } return TNS__AuthenticateResponse(); } virtual TNS__SearchPersonResponse searchPerson(const TNS__SearchPersonRequest ¶meters) override { Q_UNUSED(parameters); return TNS__SearchPersonResponse(); } virtual TNS__EditPersonResponse editPerson(const TNS__EditPersonRequest ¶meters) override { Q_UNUSED(parameters); return TNS__EditPersonResponse(); } virtual TNS__CityListResponse cityList(const TNS__CityListRequest ¶meters) override { Q_UNUSED(parameters); return TNS__CityListResponse(); } virtual TNS__PlaceListResponse placeList(const TNS__PlaceListRequest ¶meters) override { Q_UNUSED(parameters); return TNS__PlaceListResponse(); } virtual TNS__DocumentListResponse documentList(const TNS__DocumentListRequest ¶meters) override { Q_UNUSED(parameters); return TNS__DocumentListResponse(); } virtual TNS__GuestTypeListResponse guestTypeList(const TNS__GuestTypeListRequest ¶meters) override { Q_UNUSED(parameters); return TNS__GuestTypeListResponse(); } virtual TNS__CountrytListResponse countrytList(const TNS__CountrytListRequest ¶meters) override { Q_UNUSED(parameters); return TNS__CountrytListResponse(); } virtual TNS__BuildingListResponse buildingList(const TNS__BuildingListRequest ¶meters) override { Q_UNUSED(parameters); return TNS__BuildingListResponse(); } virtual TNS__EntranceListResponse entranceList(const TNS__EntranceListRequest ¶meters) override { Q_UNUSED(parameters); return TNS__EntranceListResponse(); } virtual TNS__ServiceResponse service(const TNS__ServiceRequest ¶meters) override { Q_UNUSED(parameters); return TNS__ServiceResponse(); } }; class GuestServer : public KDSoapServer { Q_OBJECT public: GuestServer() : KDSoapServer() , m_lastServerObject(0) { setPath(QLatin1String("/xml")); } virtual QObject *createServerObject() override { m_lastServerObject = new GuestServerObject; return m_lastServerObject; } GuestServerObject *lastServerObject() { return m_lastServerObject; } private: GuestServerObject *m_lastServerObject; // only for unittest purposes }; class PrefixTest : public QObject { Q_OBJECT private slots: void testTransformJob() { TestServerThread serverThread; GuestServer *server = serverThread.startThread(); Guest service; service.setEndPoint(server->endPoint()); AuthenticateJob *job = new AuthenticateJob(&service, this); TNS__AuthenticateRequest req; req.setSerijskiBrojSertifikata("cert"); job->setParameters(req); connect(job, &AuthenticateJob::finished, this, &PrefixTest::slotAuthenticateJobFinished); job->start(); m_eventLoop.exec(); TNS__AuthenticateResponse response = job->resultParameters(); QCOMPARE(response.user().fullName(), QString("userFullName")); QCOMPARE(response.result(), QString("result")); } protected slots: // the really private ones void slotAuthenticateJobFinished(KDSoapJob *) { m_eventLoop.quit(); } private: QEventLoop m_eventLoop; }; QTEST_MAIN(PrefixTest) #include "test_prefix.moc"