From e9c75177590d8546ebd9425f16c4269a9c92f517 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sat, 28 May 2016 00:24:53 +0200 Subject: Refactored the generic resource to use separate classes for changereplay and synchronization. This cleans up the API and avoids the excessive passing around of transactions. It also provides more flexibility in eventually using different synchronization strategies for different resources. --- tests/dummyresourcetest.cpp | 2 ++ tests/mailquerybenchmark.cpp | 5 +++-- tests/pipelinebenchmark.cpp | 6 +++--- tests/pipelinetest.cpp | 14 +++++++------- tests/querytest.cpp | 2 ++ tests/testimplementations.h | 2 +- 6 files changed, 18 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/dummyresourcetest.cpp b/tests/dummyresourcetest.cpp index 58df2da..d41f235 100644 --- a/tests/dummyresourcetest.cpp +++ b/tests/dummyresourcetest.cpp @@ -11,6 +11,7 @@ #include "modelresult.h" #include "pipeline.h" #include "log.h" +#include "test.h" using namespace Sink; @@ -28,6 +29,7 @@ class DummyResourceTest : public QObject private slots: void initTestCase() { + Sink::Test::initTest(); Sink::Log::setDebugOutputLevel(Sink::Log::Trace); auto factory = Sink::ResourceFactory::load("org.kde.dummy"); QVERIFY(factory); diff --git a/tests/mailquerybenchmark.cpp b/tests/mailquerybenchmark.cpp index 20ee63c..4e58899 100644 --- a/tests/mailquerybenchmark.cpp +++ b/tests/mailquerybenchmark.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include "hawd/dataset.h" #include "hawd/formatter.h" @@ -59,12 +60,11 @@ class MailQueryBenchmark : public QObject TestResource::removeFromDisk(resourceIdentifier); auto pipeline = QSharedPointer::create(resourceIdentifier); + pipeline->setResourceType("test"); - auto mailFactory = QSharedPointer::create(); auto indexer = QSharedPointer>::create(); pipeline->setPreprocessors("mail", QVector() << indexer.data()); - pipeline->setAdaptorFactory("mail", mailFactory); auto domainTypeAdaptorFactory = QSharedPointer::create(); @@ -149,6 +149,7 @@ private slots: void init() { resourceIdentifier = "org.kde.test.instance1"; + Sink::AdaptorFactoryRegistry::instance().registerFactory("test"); } void test50k() diff --git a/tests/pipelinebenchmark.cpp b/tests/pipelinebenchmark.cpp index 0133a6c..51481fd 100644 --- a/tests/pipelinebenchmark.cpp +++ b/tests/pipelinebenchmark.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include "hawd/dataset.h" #include "hawd/formatter.h" @@ -83,10 +84,8 @@ class PipelineBenchmark : public QObject TestResource::removeFromDisk(resourceIdentifier); auto pipeline = QSharedPointer::create(resourceIdentifier); - - auto mailFactory = QSharedPointer::create(); pipeline->setPreprocessors("mail", preprocessors); - pipeline->setAdaptorFactory("mail", mailFactory); + pipeline->setResourceType("test"); QTime time; time.start(); @@ -131,6 +130,7 @@ private slots: void init() { Sink::Log::setDebugOutputLevel(Sink::Log::Warning); + Sink::AdaptorFactoryRegistry::instance().registerFactory("test"); resourceIdentifier = "org.kde.test.instance1"; } diff --git a/tests/pipelinetest.cpp b/tests/pipelinetest.cpp index 9290050..6ea2041 100644 --- a/tests/pipelinetest.cpp +++ b/tests/pipelinetest.cpp @@ -19,6 +19,7 @@ #include "log.h" #include "domainadaptor.h" #include "definitions.h" +#include "adaptorfactoryregistry.h" static void removeFromDisk(const QString &name) { @@ -185,6 +186,7 @@ private slots: void initTestCase() { Sink::Log::setDebugOutputLevel(Sink::Log::Trace); + Sink::AdaptorFactoryRegistry::instance().registerFactory("test"); } void init() @@ -198,9 +200,7 @@ private slots: auto command = createEntityCommand(createEvent(entityFbb)); Sink::Pipeline pipeline("org.kde.pipelinetest.instance1"); - - auto adaptorFactory = QSharedPointer::create(); - pipeline.setAdaptorFactory("event", adaptorFactory); + pipeline.setResourceType("test"); pipeline.startTransaction(); pipeline.newEntity(command.constData(), command.size()); @@ -216,9 +216,9 @@ private slots: auto command = createEntityCommand(createEvent(entityFbb, "summary", "description")); Sink::Pipeline pipeline("org.kde.pipelinetest.instance1"); + pipeline.setResourceType("test"); auto adaptorFactory = QSharedPointer::create(); - pipeline.setAdaptorFactory("event", adaptorFactory); // Create the initial revision pipeline.startTransaction(); @@ -265,9 +265,9 @@ private slots: auto command = createEntityCommand(createEvent(entityFbb)); Sink::Pipeline pipeline("org.kde.pipelinetest.instance1"); + pipeline.setResourceType("test"); auto adaptorFactory = QSharedPointer::create(); - pipeline.setAdaptorFactory("event", adaptorFactory); // Create the initial revision pipeline.startTransaction(); @@ -309,7 +309,7 @@ private slots: flatbuffers::FlatBufferBuilder entityFbb; auto command = createEntityCommand(createEvent(entityFbb)); Sink::Pipeline pipeline("org.kde.pipelinetest.instance1"); - pipeline.setAdaptorFactory("event", QSharedPointer::create()); + pipeline.setResourceType("test"); // Create the initial revision pipeline.startTransaction(); @@ -346,9 +346,9 @@ private slots: TestProcessor testProcessor; Sink::Pipeline pipeline("org.kde.pipelinetest.instance1"); + pipeline.setResourceType("test"); pipeline.setPreprocessors("event", QVector() << &testProcessor); pipeline.startTransaction(); - pipeline.setAdaptorFactory("event", QSharedPointer::create()); // Actual test { diff --git a/tests/querytest.cpp b/tests/querytest.cpp index a654931..6d7746e 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp @@ -9,6 +9,7 @@ #include "resourceconfig.h" #include "log.h" #include "modelresult.h" +#include "test.h" /** * Test of the query system using the dummy resource. @@ -21,6 +22,7 @@ class QueryTest : public QObject private slots: void initTestCase() { + Sink::Test::initTest(); Sink::Log::setDebugOutputLevel(Sink::Log::Trace); auto factory = Sink::ResourceFactory::load("org.kde.dummy"); QVERIFY(factory); diff --git a/tests/testimplementations.h b/tests/testimplementations.h index 688875d..197602c 100644 --- a/tests/testimplementations.h +++ b/tests/testimplementations.h @@ -107,7 +107,7 @@ public: class TestResource : public Sink::GenericResource { public: - TestResource(const QByteArray &instanceIdentifier, QSharedPointer pipeline) : Sink::GenericResource(instanceIdentifier, pipeline) + TestResource(const QByteArray &instanceIdentifier, QSharedPointer pipeline) : Sink::GenericResource("test", instanceIdentifier, pipeline, QSharedPointer(), QSharedPointer()) { } -- cgit v1.2.3