123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- /*=============================================================================
- Library: CTK
- Copyright (c) German Cancer Research Center,
- Division of Medical and Biological Informatics
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- =============================================================================*/
- #ifndef CTKEASCENARIO3TESTSUITE_P_H
- #define CTKEASCENARIO3TESTSUITE_P_H
- #include <QObject>
- #include <QThread>
- #include <QMutex>
- #include <service/event/ctkEventHandler.h>
- #include <ctkTestSuiteInterface.h>
- #include <ctkServiceRegistration.h>
- #include <ctkException.h>
- struct ctkEventAdmin;
- class ctkEAScenario3EventConsumer : public QObject, public ctkEventHandler
- {
- Q_OBJECT
- Q_INTERFACES(ctkEventHandler)
- private:
- ctkPluginContext* context;
- /** class variable for service registration */
- ctkServiceRegistration serviceRegistration;
- /** class variable indicating the topics correct version */
- QStringList topicsToConsume;
- /** class variable keeping number of asynchronous message */
- int asynchMessages;
- /** class variable keeping number of synchronous message */
- int synchMessages;
- /**
- * class variable indication the number of synchronous messages to be
- * received
- */
- int numSyncMessages;
- /**
- * class variable indication the number of asynchronous messages to be
- * received
- */
- int numAsyncMessages;
- bool error;
- ctkRuntimeException exc;
- QMutex mutex;
- public:
- /**
- * Constructor creates a consumer service
- *
- * @param bundleContext
- * @param topics
- * @param numSyncMsg
- * number of synchronous messages to be received
- * @param numAsyncMsg
- * number of asynchronous messages to be received
- * @param name
- * name of the Consumer
- * @param id
- */
- ctkEAScenario3EventConsumer(ctkPluginContext* pluginContext, const QStringList topics,
- int numSyncMsg, int numAsyncMsg);
- void runTest();
- void cleanup();
- /**
- * This method takes events from the event admin service.
- */
- void handleEvent(const ctkEvent& event);
- };
- class ctkEAScenario3EventPublisher : public QObject
- {
- Q_OBJECT
- private:
- /** A reference to a service */
- ctkServiceReference serviceReference;
- /** The admin which delivers the events */
- ctkEventAdmin* eventAdmin;
- /** class variable holding plugin context */
- ctkPluginContext* context;
- /** variable holding messages to send */
- int messageTosend;
- /** variable holding the topic to use */
- QString topicToSend;
- QThread thread;
- protected Q_SLOTS:
- void sendEvents();
- void postEvents();
- public:
- ctkEAScenario3EventPublisher(ctkPluginContext* context, const QString& name,
- int id, int numOfMessage, const QString& topic);
- void runTest();
- };
- /**
- * Test suite for testing the requirements specified in the test specification
- * for the EventAdmin service.
- *
- * Several minor test of the Topics, this is done both synchronously and
- * asynchronously.
- */
- class ctkEAScenario3TestSuite : public QObject, public ctkTestSuiteInterface
- {
- Q_OBJECT
- Q_INTERFACES(ctkTestSuiteInterface)
- private:
- /** plugin context variable */
- ctkPluginContext* pluginContext;
- long eventPluginId;
- QList<ctkEAScenario3EventConsumer*> eventConsumers;
- QList<ctkEAScenario3EventPublisher*> eventPublishers;
- public:
- /**
- * Constructor for the TestSuite class.
- *
- * @param context
- * the handle to the frame work
- */
- ctkEAScenario3TestSuite(ctkPluginContext* context, long eventPluginId);
- private Q_SLOTS:
- void initTestCase();
- void cleanupTestCase();
- void testRegisterConsumer();
- void testPublishEvents();
- };
- #endif // CTKEASCENARIO3TESTSUITE_P_H
|