fixed testServer

This commit is contained in:
Matej Sekoranja
2015-12-16 12:00:20 +01:00
parent d7eafcb9c5
commit 22d6db2818
2 changed files with 24 additions and 12 deletions

View File

@@ -68,6 +68,7 @@ int ChannelAccessIFTest::runAllTest() {
.build());
TestServer::shared_pointer tstserv(new TestServer(base_config));
tstserv->start();
testDiag("TestServer on ports TCP=%u UDP=%u\n",
tstserv->getServerPort(),
tstserv->getBroadcastPort());

View File

@@ -2750,10 +2750,20 @@ struct TestServer : public Runnable
context = ServerContextImpl::create(conf);
context->initialize(getChannelProviderRegistry());
runner.start();
startup.wait(); // wait for thread to start
}
void start(bool inSameThread = false)
{
if (inSameThread)
{
context->run(conf->getPropertyAsInteger("timeToRun", 0)); // default is no timeout
}
else
{
runner.start();
startup.wait(); // wait for thread to start
}
}
~TestServer()
{
context->shutdown();
@@ -2788,6 +2798,9 @@ struct TestServer : public Runnable
startup.signal();
context->run(conf->getPropertyAsInteger("timeToRun", 0)); // default is no timeout
}
void waitForShutdown() {
context->shutdown();
}
void shutdown() {
context->shutdown();
}
@@ -2861,15 +2874,13 @@ int main(int argc, char *argv[])
srand ( time(NULL) );
{
TestServer::shared_pointer srv(new TestServer(ConfigurationBuilder()
.push_env()
.add("timeToRun", timeToRun)
.push_map()
.build()));
TestServer::ctx = srv;
}
TestServer::ctx.reset();
TestServer::shared_pointer srv(new TestServer(ConfigurationBuilder()
.push_env()
.add("timeToRun", timeToRun)
.push_map()
.build()));
TestServer::ctx = srv;
srv->start(true);
cout << "Done" << endl;