Commit 7d1f6277 authored by legoc's avatar legoc

Added test for requester/responder memory

parent 45d1f30d
......@@ -224,6 +224,14 @@
<application name="startrepcpp" starting_time="0" retries="0" stopping_time="1" stream="yes" multiple="no" restart="no">
<start executable="build/bin/testrequesterandresponder" args="repcpp"/>
</application>
<application name="responder-server" starting_time="0" retries="0" stopping_time="1" stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="build/bin/testresponderserver"/>
</application>
<application name="requester-client" starting_time="0" retries="0" stopping_time="1" stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="build/bin/testrequesterclient"/>
</application>
</applications>
......
......@@ -245,7 +245,14 @@
<application name="startstream" starting_time="0" retries="0" stopping_time="1" stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="build/bin/teststream"/>
</application>
<application name="responder-server" starting_time="0" retries="0" stopping_time="1" stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="build/bin/testresponderserver"/>
</application>
<application name="requester-client" starting_time="0" retries="0" stopping_time="1" stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="build/bin/testrequesterclient"/>
</application>
</applications>
......
......@@ -182,6 +182,14 @@
<start executable="msvc/x64/Release/reqrepcpp" args="repcpp"/>
</application>
<application name="responder-server" starting_time="0" retries="0" stopping_time="1" stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="msvc/x64/Release/testresponderserver"/>
</application>
<application name="requester-client" starting_time="0" retries="0" stopping_time="1" stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="msvc/x64/Release/testrequesterclient"/>
</application>
</applications>
</config>
......@@ -29,8 +29,10 @@ bin_PROGRAMS = \
responderserver \
testrespondertimeout \
testrequesterandrespondertimeout \
teststream
teststream \
testresponderserver \
testrequesterclient
testcameo_SOURCES = \
Test.cpp
......@@ -261,3 +263,17 @@ teststream_CPPFLAGS = $(CT_CXXFLAGS)
teststream_LDFLAGS = $(CT_LDFLAGS)
teststream_LDADD = $(CT_LIBS)
testresponderserver_SOURCES = \
TestResponderServer.cpp
testresponderserver_CPPFLAGS = $(CT_CXXFLAGS)
testresponderserver_LDFLAGS = $(CT_LDFLAGS)
testresponderserver_LDADD = $(CT_LIBS)
testrequesterclient_SOURCES = \
TestRequesterClient.cpp
testrequesterclient_CPPFLAGS = $(CT_CXXFLAGS)
testrequesterclient_LDFLAGS = $(CT_LDFLAGS)
testrequesterclient_LDADD = $(CT_LIBS)
/*
* Copyright 2015 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include <cameo/cameo.h>
#include <iostream>
#include <sstream>
using namespace std;
using namespace cameo;
int main(int argc, char *argv[]) {
application::This::init(argc, argv);
// New block to ensure cameo objects are terminated before the application.
{
// The request message is the second argument.
string requestMessage;
if (argc > 1) {
requestMessage = argv[1];
}
string serverEndpoint;
if (argc > 2) {
serverEndpoint = argv[2];
}
unique_ptr<Server> server;
if (serverEndpoint == "") {
server.reset(new Server(application::This::getServer().getEndpoint()));
} else {
server.reset(new Server(serverEndpoint));
}
if (application::This::isAvailable() && server->isAvailable()) {
cout << "Connected server " << *server << endl;
}
// Connect to the server.
unique_ptr<application::Instance> responderServer = server->connect("responder-server");
cout << "Application " << *responderServer << " has state " << application::toString(responderServer->now()) << endl;
// Create a requester.
unique_ptr<application::Requester> requester = application::Requester::create(*responderServer, "responder");
cout << "Created requester " << *requester << endl;
if (requester.get() == 0) {
cout << "requester error" << endl;
return -1;
}
for (int i = 0; ; ++i) {
// Send a simple message as string.
ostringstream os;
os << requestMessage << "-" << i;
requester->send(os.str());
string response;
requester->receive(response);
cout << "Response is " << response << endl;
}
cout << "Finished the application" << endl;
}
return 0;
}
/*
* Copyright 2015 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <cameo/cameo.h>
using namespace std;
using namespace cameo;
int main(int argc, char *argv[]) {
application::This::init(argc, argv);
// New block to ensure cameo objects are terminated before the application.
{
if (application::This::isAvailable()) {
cout << "connected" << endl;
}
unique_ptr<application::Responder> responder;
try {
cout << "creating responder" << endl;
responder = application::Responder::create("responder");
} catch (const ResponderCreationException& e) {
cout << "responder error" << endl;
return -1;
}
application::This::setRunning();
while (true) {
unique_ptr<application::Request> request = responder->receive();
cout << "received request " << *request << endl;
request->reply("done");
this_thread::sleep_for(chrono::milliseconds(10));
}
cout << "finished the application" << endl;
}
return 0;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment