Skip to content

Commit

Permalink
Make SCP tests more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
lamyj committed Jan 3, 2016
1 parent 5220146 commit 7266aab
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
19 changes: 10 additions & 9 deletions tests/code/EchoSCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,19 @@ struct Status
void run_server(Status * status)
{
dcmtkpp::Association association;

association.receive_association(boost::asio::ip::tcp::v4(), 11113);

dcmtkpp::EchoSCP echo_scp(association,
[status](dcmtkpp::message::CEchoRequest const &)
{
status->called = true;
return dcmtkpp::message::Response::Success;
});
association.set_tcp_timeout(boost::posix_time::seconds(1));

try
{
association.receive_association(boost::asio::ip::tcp::v4(), 11113);

dcmtkpp::EchoSCP echo_scp(association,
[status](dcmtkpp::message::CEchoRequest const &)
{
status->called = true;
return dcmtkpp::message::Response::Success;
});

// Get echo message
auto const message = association.receive_message();
echo_scp(message);
Expand Down
13 changes: 7 additions & 6 deletions tests/code/FindSCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,16 @@ class Generator: public dcmtkpp::SCP::DataSetGenerator
void run_server(Status * status)
{
dcmtkpp::Association association;

association.receive_association(boost::asio::ip::tcp::v4(), 11113);

dcmtkpp::FindSCP find_scp(association);
auto const generator = std::make_shared<Generator>(status);
find_scp.set_generator(generator);
association.set_tcp_timeout(boost::posix_time::seconds(1));

try
{
association.receive_association(boost::asio::ip::tcp::v4(), 11113);

dcmtkpp::FindSCP find_scp(association);
auto const generator = std::make_shared<Generator>(status);
find_scp.set_generator(generator);

// Get echo message
auto const message = association.receive_message();
find_scp(message);
Expand Down

0 comments on commit 7266aab

Please sign in to comment.