// $Id$
//
-// Copyright (C) 2007
-// Fraunhofer Institute for Open Communication Systems (FOKUS)
-// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Copyright (C) 2007
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
// Stefan Bund <g0dil@berlios.de>
//
// This program is free software; you can redistribute it and/or modify
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/** \file
- \brief Route.test unit tests */
+ \brief Route unit tests */
//#include "Route.test.hh"
//#include "Route.test.ih"
// Custom includes
+#include <boost/scoped_ptr.hpp>
#include "Route.hh"
#include "DebugEvent.hh"
#include "DebugModules.hh"
#include "Module.hh"
#include "Setup.hh"
+#include "CloneSource.hh"
+#include "Joins.hh"
+#include "PassiveQueue.hh"
+#include "../Utils/membind.hh"
+#include "../Utils/senfassert.hh"
#include "../Utils/auto_unit_test.hh"
#include <boost/test/test_tools.hpp>
BOOST_CHECK( activeSink );
}
+///////////////////////////////////////////////////
+// test connection new modules on runtime
+
+namespace {
+ void timeout() {
+ senf::scheduler::terminate();
+ }
+
+ // just a helper class for the test
+ struct ModuleConnector {
+ module::PriorityJoin & join_;
+ ModuleConnector( module::PriorityJoin & join)
+ : join_( join) {};
+ void connect() {
+ queue.reset(new module::PassiveQueue);
+ ppi::connect( *queue, join_, 0);
+ }
+ boost::scoped_ptr<module::PassiveQueue> queue;
+ };
+
+ class TestSink : public module::Module
+ {
+ SENF_PPI_MODULE(TestSink);
+ public:
+ connector::PassiveInput<> input;
+ TestSink() {
+ noroute(input);
+ input.onRequest(&TestSink::request);
+ }
+ private:
+ void request() {
+ SENF_ASSERT(input());
+ }
+ };
+}
+
+BOOST_AUTO_UNIT_TEST(connect_runtime)
+{
+ TestSink sink;
+ module::ActiveFeeder feeder;
+ module::PriorityJoin join;
+ module::CloneSource source1 (senf::DataPacket::create());
+
+ ppi::connect( source1, join);
+ ppi::connect( join, feeder);
+ ppi::connect( feeder, sink);
+
+ ModuleConnector moduleConnector ( join);
+ senf::scheduler::TimerEvent timer (
+ "connect_runtime timer",
+ senf::membind(&ModuleConnector::connect, &moduleConnector),
+ senf::ClockService::now() + senf::ClockService::milliseconds(250));
+
+ senf::scheduler::TimerEvent timeoutTimer (
+ "connect_runtime test timeoutTimer", &timeout,
+ senf::ClockService::now() + senf::ClockService::milliseconds(500));
+
+ senf::ppi::run();
+}
+
///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_