#define BOOST_TEST_MODULE Recording #include #include #include #include #include #include #include #include #include "mockDevices.h" #include "mockScheduler.h" #include #include #include #include #include "mockDefs.h" #include "sqlSelectDeserializer.h" #include "commonHelpers.h" #include "serviceStreamer.h" #include "temporaryIceAdapterObject.h" #include class Core : public CommonObjects { public: Core() { int paramCount = 0; ic = Ice::initialize(paramCount, NULL); adapter = ic->createObjectAdapterWithEndpoints("Adp", "tcp -p 12005"); TestOptionsSource::LoadTestOptions({ { "common.datasourceRoot", (RootDir / "datasources").string() }, }); adapter->add(new MockDevices(), ic->stringToIdentity("GlobalDevices")); adapter->add(new MockScheduler(), ic->stringToIdentity("Schedules")); adapter->add(new SI(), ic->stringToIdentity("SI")); adapter->add(new Recordings(), ic->stringToIdentity("Recordings")); adapter->add(new Maintenance(adapter, NULL), ic->stringToIdentity("Maintenance")); adapter->activate(); r = P2PVR::RecordingsPrx::checkedCast(ic->stringToProxy("Recordings")); BOOST_REQUIRE(r); r->ice_ping(); s = P2PVR::SIPrx::checkedCast(ic->stringToProxy("SI")); BOOST_REQUIRE(s); s->ice_ping(); m = P2PVR::MaintenancePrx::checkedCast(ic->stringToProxy("Maintenance")); BOOST_REQUIRE(m); m->ice_ping(); } ~Core() { ic->destroy(); } P2PVR::MaintenancePrx m; P2PVR::RecordingsPrx r; P2PVR::SIPrx s; protected: Ice::CommunicatorPtr ic; Ice::ObjectAdapterPtr adapter; }; class MockTarget : public P2PVR::RawDataClient { public: MockTarget() : bytesReceived(0) { } bool NewData(const P2PVR::Data & data, const Ice::Current &) override { bytesReceived += data.size(); return false; } unsigned int bytesReceived; }; BOOST_GLOBAL_FIXTURE( StandardMockDatabase ); BOOST_FIXTURE_TEST_SUITE( RecordingCore, Core ); BOOST_AUTO_TEST_CASE( streamServiceToTarget ) { BOOST_CHECKPOINT("Create mock target"); IceUtil::Handle target = new MockTarget(); TemporaryIceAdapterObject targetPrx(adapter, target); BOOST_CHECKPOINT("Create service streamer"); auto ss = ServiceStreamerPtr(new ServiceStreamer(4170, targetPrx, ic, adapter)); BOOST_CHECKPOINT("Start"); ss->Start(); sleep(2); BOOST_CHECKPOINT("Stop"); ss->Stop(); BOOST_MESSAGE("Received bytes: " << target->bytesReceived); BOOST_REQUIRE(target->bytesReceived > 150000); } BOOST_AUTO_TEST_SUITE_END();