Commit a05aec51 authored by legoc's avatar legoc

Added tests for requester/responder

parent 7ed1f8a9
......@@ -11,7 +11,7 @@
<dependency>
<groupId>fr.ill.ics</groupId>
<artifactId>cameo-server</artifactId>
<version>0.1.5</version>
<version>0.1.6</version>
</dependency>
<dependency>
<groupId>fr.ill.ics</groupId>
......
......@@ -11,7 +11,7 @@
<dependency>
<groupId>fr.ill.ics</groupId>
<artifactId>cameo-server-jzmq</artifactId>
<version>0.1.5</version>
<version>0.1.6</version>
</dependency>
<dependency>
<groupId>fr.ill.ics</groupId>
......
......@@ -108,6 +108,10 @@
<start executable="java" args="-classpath cameo-tests-jeromq/target/cameo-tests-jeromq-0.0.1-full.jar fr.ill.ics.cameo.test.TestRequesterAndResponderApplication"/>
</application>
<application name="reqjava" starting_time="inf" retries="0" stopping_time="1" stream="yes" log_directory="logs" multiple="yes" restart="no">
<start executable="java" args="-classpath cameo-tests-jeromq/target/cameo-tests-jeromq-0.0.1-full.jar fr.ill.ics.cameo.test.TestRequesterApplication"/>
</application>
<application name="timeoutjava" starting_time="0" retries="0" stopping_time="1000" stream="yes" multiple="no" restart="no">
<start executable="java" args="-classpath cameo-tests-jeromq/target/cameo-tests-jeromq-0.0.1-full.jar fr.ill.ics.cameo.test.TestTimeoutApplication"/>
</application>
......@@ -127,6 +131,14 @@
<application name="startrepjava" starting_time="inf" retries="0" stopping_time="1" stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="java" args="-classpath cameo-tests-jeromq/target/cameo-tests-jeromq-0.0.1-full.jar fr.ill.ics.cameo.test.TestRequesterAndResponderApplication repjava"/>
</application>
<application name="startreqjava" starting_time="inf" retries="0" stopping_time="1" stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="java" args="-classpath cameo-tests-jeromq/target/cameo-tests-jeromq-0.0.1-full.jar fr.ill.ics.cameo.test.TestResponderAndRequesterApplication reqjava"/>
</application>
<application name="startareqjava" starting_time="inf" retries="0" stopping_time="1" stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="java" args="-classpath cameo-tests-jeromq/target/cameo-tests-jeromq-0.0.1-full.jar fr.ill.ics.cameo.test.TestAsyncResponderAndRequesterApplication reqjava"/>
</application>
<!-- Managed cpp apps -->
<application name="simplecpp" starting_time="0" retries="0" stopping_time="1" stream="yes" log_directory="logs" multiple="no" restart="no">
......
......@@ -108,6 +108,10 @@
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-0.0.1-full.jar fr.ill.ics.cameo.test.TestRequesterAndResponderApplication"/>
</application>
<application name="reqjava" starting_time="inf" retries="0" stopping_time="1" stream="yes" log_directory="logs" multiple="yes" restart="no">
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-0.0.1-full.jar fr.ill.ics.cameo.test.TestRequesterApplication"/>
</application>
<application name="timeoutjava" starting_time="0" retries="0" stopping_time="1000" stream="yes" multiple="no" restart="no">
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-0.0.1-full.jar fr.ill.ics.cameo.test.TestTimeoutApplication"/>
</application>
......@@ -135,6 +139,14 @@
<application name="startlistjava" starting_time="inf" retries="0" stopping_time="1" stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-0.0.1-full.jar fr.ill.ics.cameo.test.TestList"/>
</application>
<application name="startreqjava" starting_time="inf" retries="0" stopping_time="1" stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-0.0.1-full.jar fr.ill.ics.cameo.test.TestResponderAndRequesterApplication reqjava"/>
</application>
<application name="startareqjava" starting_time="inf" retries="0" stopping_time="1" stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-0.0.1-full.jar fr.ill.ics.cameo.test.TestAsyncResponderAndRequesterApplication reqjava"/>
</application>
<!-- Managed cpp apps -->
<application name="simplecpp" starting_time="0" retries="0" stopping_time="1" stream="yes" log_directory="logs" multiple="no" restart="no">
......
......@@ -124,6 +124,7 @@ public class TestSelector {
apps.add("startpubjava");
apps.add("startnpubjava");
apps.add("startrepjava");
apps.add("startreqjava");
apps.add("canceljava");
apps.add("startsimplecpp");
......
/*
* 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.
*/
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 TestAsyncResponderAndRequesterApplication {
public static void main(String[] args) {
Application.This.init(args);
String applicationName = null;
int numberOfTimes = 1;
if (args.length > 1) {
applicationName = args[0];
System.out.println("requester application is " + applicationName);
if (args.length > 2) {
numberOfTimes = Integer.parseInt(args[1]);
}
} else {
System.err.println("arguments: [application name]");
System.exit(-1);
}
// get the client services
Server server = Application.This.getServer();
if (Application.This.isAvailable() && server.isAvailable()) {
System.out.println("connected application");
System.out.println("connected server " + server);
} else {
System.exit(-1);
}
try {
// Create the responder.
Application.Responder responder = Application.Responder.create("responder");
// Set the state.
Application.This.setRunning();
int N = 5;
// loop the number of times.
for (int i = 0; i < numberOfTimes; ++i) {
Application.Instance[] requesterApps = new Application.Instance[N];
// Start the requester applications.
for (int j = 0; j < N; ++j) {
// Start the application.
requesterApps[j] = server.start(applicationName);
System.out.println("started application " + requesterApps[j]);
}
Thread[] threads = new Thread[N];
// Process the requests.
for (int j = 0; j < N; ++j) {
// Receive the simple request.
Application.Request request = responder.receive();
threads[j] = new Thread(new Runnable() {
@Override
public void run() {
// Reply.
request.reply("done");
// Terminate the request.
request.terminate();
}
});
threads[j].start();
}
// Wait for the requester applications.
for (int j = 0; j < N; ++j) {
requesterApps[j].waitFor();
System.out.println("finished application " + requesterApps[j]);
try {
threads[j].join();
} catch (InterruptedException e) {
}
}
}
} catch (RemoteException e) {
System.out.println("requester error:" + e);
} finally {
// Do not forget to terminate This.
Application.This.terminate();
}
System.out.println("finished the application");
}
}
\ No newline at end of file
/*
* 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.
*/
package fr.ill.ics.cameo.test;
import fr.ill.ics.cameo.Application;
import fr.ill.ics.cameo.Application.This;
import fr.ill.ics.cameo.RemoteException;
import fr.ill.ics.cameo.impl.Buffer;
public class TestRequesterApplication {
public static void main(String[] args) {
Application.This.init(args);
if (Application.This.isAvailable()) {
System.out.println("connected");
}
try {
System.out.println("creating requester");
// Get the starter app.
Application.Instance starter = This.connectToStarter();
// Create the requester.
Application.Requester requester = Application.Requester.create(starter, "responder");
// Set the state.
Application.This.setRunning();
// Send and wait for the result.
requester.send(Buffer.serialize("test"));
String result = requester.receiveString();
System.out.println("received " + result);
// Terminate the requester.
requester.terminate();
} catch (RemoteException e) {
System.out.println("responder error");
} finally {
// Do not forget to terminate This.
Application.This.terminate();
}
System.out.println("finished the application");
}
}
\ No newline at end of file
/*
* 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.
*/
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 TestResponderAndRequesterApplication {
public static void main(String[] args) {
Application.This.init(args);
String applicationName = null;
int numberOfTimes = 1;
if (args.length > 1) {
applicationName = args[0];
System.out.println("requester application is " + applicationName);
if (args.length > 2) {
numberOfTimes = Integer.parseInt(args[1]);
}
} else {
System.err.println("arguments: [application name]");
System.exit(-1);
}
// get the client services
Server server = Application.This.getServer();
if (Application.This.isAvailable() && server.isAvailable()) {
System.out.println("connected application");
System.out.println("connected server " + server);
} else {
System.exit(-1);
}
try {
// Create the responder.
Application.Responder responder = Application.Responder.create("responder");
// Set the state.
Application.This.setRunning();
int N = 5;
// loop the number of times.
for (int i = 0; i < numberOfTimes; ++i) {
Application.Instance[] requesterApps = new Application.Instance[N];
// Start the requester applications.
for (int j = 0; j < N; ++j) {
// Start the application.
requesterApps[j] = server.start(applicationName);
System.out.println("started application " + requesterApps[j]);
}
// Process the requests.
for (int j = 0; j < N; ++j) {
// Receive the simple request.
Application.Request request = responder.receive();
request.reply("done");
// Terminate the request.
request.terminate();
}
// Wait for the requester applications.
for (int j = 0; j < N; ++j) {
requesterApps[j].waitFor();
System.out.println("finished application " + requesterApps[j]);
}
}
} catch (RemoteException e) {
System.out.println("requester error:" + e);
} finally {
// Do not forget to terminate This.
Application.This.terminate();
}
System.out.println("finished the application");
}
}
\ No newline at end of file
......@@ -34,7 +34,7 @@ public class TestResponderApplication {
try {
System.out.println("creating responder");
// create the publisher
// Create the responder.
Application.Responder responder = Application.Responder.create("responder");
// Set the state.
......
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