Commit bfaa2c3e authored by legoc's avatar legoc

Added more tests to responder/requester.

parent 1b991538
......@@ -74,12 +74,25 @@ int main(int argc, char *argv[]) {
return -1;
}
// send a simple message.
requester->send("request");
string response;
requester->receive(response);
cout << "response is " << response << endl;
// send a two-parts message.
string buffer1, buffer2;
serialize("first", buffer1);
serialize("second", buffer2);
requester->sendTwoBinaryParts(buffer1, buffer2);
requester->receive(response);
cout << "response is " << response << endl;
application::State state = responderApplication->waitFor();
cout << "responder application terminated with state " << application::toString(state) << endl;
......
......@@ -48,11 +48,24 @@ int main(int argc, char *argv[]) {
application::This::setRunning();
auto_ptr<application::Request> request = responder->receive();
cout << "received request " << *request << endl;
request->reply("done");
request = responder->receive();
string data1, data2;
parse(request->getBinary(), data1);
parse(request->getSecondBinaryPart(), data2);
cout << "received request " << data1 << " " << data2 << endl;
request->reply("done");
auto_ptr<application::Instance> requester = request->connectToRequester();
cout << "requester " << *requester << endl;
cout << "finished the application" << endl;
}
......
......@@ -200,6 +200,8 @@ public class TestCancelApplication {
cancel.join();
System.out.println("responder request " + request);
request.terminate();
}
} catch (RemoteException e) {
......
......@@ -19,6 +19,7 @@ package fr.ill.ics.cameo.test;
import fr.ill.ics.cameo.Application;
import fr.ill.ics.cameo.RemoteException;
import fr.ill.ics.cameo.Server;
import fr.ill.ics.cameo.impl.Buffer;
public class TestRequesterAndResponderApplication {
......@@ -65,9 +66,14 @@ public class TestRequesterAndResponderApplication {
Application.Requester requester = Application.Requester.create(responderApplication, "responder");
System.out.println("created requester " + requester);
// Send a simple message.
requester.send("request");
System.out.println("response is " + requester.receiveString());
// Send a two-parts message.
requester.sendTwoParts(Buffer.serialize("first"), Buffer.serialize("second"));
System.out.println("response is " + requester.receiveString());
int state = responderApplication.waitFor();
System.out.println("responder application terminated with state " + Application.State.toString(state));
......
......@@ -18,6 +18,7 @@ package fr.ill.ics.cameo.test;
import fr.ill.ics.cameo.Application;
import fr.ill.ics.cameo.RemoteException;
import fr.ill.ics.cameo.impl.Buffer;
public class TestResponderApplication {
......@@ -36,14 +37,33 @@ public class TestResponderApplication {
// create the publisher
Application.Responder responder = Application.Responder.create("responder");
// Set the state.
Application.This.setRunning();
// Receive the simple request.
Application.Request request = responder.receive();
System.out.println("received request " + request.get());
// Reply.
request.reply("done");
request.terminate();
System.out.println("received request " + request);
// Receive the two-parts request.
request = responder.receive();
byte[][] data = request.getTwoBinaryParts();
System.out.println("received request " + Buffer.parseString(data[0]) + " " + Buffer.parseString(data[1]));
// Reply.
request.reply("done");
// Test connection.
Application.Instance requester = request.connectToRequester();
System.out.println("requester is " + requester);
request.terminate();
} catch (RemoteException e) {
System.out.println("responder error");
......
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