Commit 63ae586f authored by legoc's avatar legoc

Renamed test publisher

parent faba683f
......@@ -65,7 +65,11 @@ target_link_libraries(waitstorage PUBLIC cameo zmq)
add_executable(testwaitstorage src/tests/TestWaitStorage.cpp)
target_link_libraries(testwaitstorage PUBLIC cameo zmq)
add_executable(publisher src/tests/Publisher.cpp)
target_link_libraries(publisher PUBLIC cameo zmq)
add_executable(testpublisher src/tests/TestPublisher.cpp)
target_link_libraries(testpublisher PUBLIC cameo zmq)
......@@ -86,8 +90,6 @@ target_link_libraries(testbadendpoint PUBLIC cameo zmq)
add_executable(teststate src/tests/TestStateApplication.cpp)
target_link_libraries(teststate PUBLIC cameo zmq)
add_executable(testpublisher src/tests/TestPublisherApplication.cpp)
target_link_libraries(testpublisher PUBLIC cameo zmq)
add_executable(testpublishertwo src/tests/TestPublisherTwoApplication.cpp)
target_link_libraries(testpublishertwo PUBLIC cameo zmq)
......@@ -95,8 +97,6 @@ target_link_libraries(testpublishertwo PUBLIC cameo zmq)
add_executable(testsubscriber src/tests/TestSubscriberApplication.cpp)
target_link_libraries(testsubscriber PUBLIC cameo zmq)
add_executable(testsubscriberandpublisher src/tests/TestSubscriberAndPublisherApplication.cpp)
target_link_libraries(testsubscriberandpublisher PUBLIC cameo zmq)
add_executable(testsubscriberandpublishertwo src/tests/TestSubscriberAndPublisherTwoApplication.cpp)
target_link_libraries(testsubscriberandpublishertwo PUBLIC cameo zmq)
......
......@@ -139,8 +139,8 @@ public class TestSelector {
apps.add("testerrorjava");
apps.add("teststoragejava");
apps.add("testwaitstoragejava");
apps.add("testpublisherjava");
apps.add("startpubjava");
apps.add("startnpubjava");
apps.add("startrepjava");
apps.add("startreqjava");
......@@ -154,8 +154,8 @@ public class TestSelector {
apps.add("testerrorcpp");
apps.add("teststoragecpp");
apps.add("testwaitstoragecpp");
apps.add("testpublishercpp");
apps.add("startpubcpp");
apps.add("startnpubcpp");
apps.add("startrepcpp");
apps.add("cancelcpp");
......@@ -166,6 +166,7 @@ public class TestSelector {
apps.add("teststoppy");
apps.add("testresultpy");
apps.add("testerrorpy");
apps.add("testpublisherpy");
}
else if (appName.equals("java")) {
apps.add("testsimplejava");
......@@ -175,8 +176,8 @@ public class TestSelector {
apps.add("testerrorjava");
apps.add("teststoragejava");
apps.add("testwaitstoragejava");
apps.add("testpublisherjava");
apps.add("startpubjava");
apps.add("startnpubjava");
apps.add("startrepjava");
apps.add("startreqjava");
......@@ -190,8 +191,8 @@ public class TestSelector {
apps.add("testerrorcpp");
apps.add("teststoragecpp");
apps.add("testwaitstoragecpp");
apps.add("testpublishercpp");
apps.add("startpubcpp");
apps.add("startnpubcpp");
apps.add("startrepcpp");
apps.add("cancelcpp");
......@@ -202,6 +203,7 @@ public class TestSelector {
apps.add("teststoppy");
apps.add("testresultpy");
apps.add("testerrorpy");
apps.add("testpublisherpy");
}
else {
apps.add(appName);
......
......@@ -20,7 +20,7 @@ import fr.ill.ics.cameo.Application;
import fr.ill.ics.cameo.RemoteException;
public class TestPublisherApplication {
public class Publisher {
public static void main(String[] args) {
......@@ -31,26 +31,22 @@ public class TestPublisherApplication {
numberOfSubscribers = Integer.parseInt(args[0]);
}
System.out.println("number of subscribers is " + numberOfSubscribers);
if (Application.This.isAvailable()) {
System.out.println("connected");
}
System.out.println("Number of subscribers is " + numberOfSubscribers);
try {
System.out.println("creating publisher and waiting for " + numberOfSubscribers + " subscriber(s)...");
System.out.println("Creating publisher and waiting for " + numberOfSubscribers + " subscriber(s)...");
// create the publisher
// Create the publisher.
Application.Publisher publisher = Application.Publisher.create("publisher", numberOfSubscribers);
// synchronize with subscribers
// Synchronize with subscribers.
publisher.waitForSubscribers();
System.out.println("synchronized with the subscriber(s)");
System.out.println("Synchronized with the subscriber(s)");
Application.This.setRunning();
// sending data
// Sending data.
for (int i = 0; i < 100; ++i) {
publisher.send("message " + i);
}
......@@ -58,14 +54,13 @@ public class TestPublisherApplication {
publisher.terminate();
} catch (RemoteException e) {
System.out.println("publisher error");
System.out.println("Publisher error");
} finally {
// Do not forget to terminate This.
Application.This.terminate();
}
System.out.println("finished the application");
System.out.println("Finished the application");
}
}
\ No newline at end of file
......@@ -16,14 +16,11 @@
package fr.ill.ics.cameo.test;
import java.util.Date;
import fr.ill.ics.cameo.Application;
import fr.ill.ics.cameo.ConnectionTimeout;
import fr.ill.ics.cameo.Server;
public class TestSubscriberAndPublisherApplication {
public class TestPublisher {
public static void main(String[] args) {
......@@ -34,69 +31,55 @@ public class TestSubscriberAndPublisherApplication {
if (args.length > 1) {
applicationName = args[0];
System.out.println("publisher application is " + applicationName);
System.out.println("Publisher application is " + applicationName);
if (args.length > 2) {
numberOfTimes = Integer.parseInt(args[1]);
}
} else {
System.err.println("arguments: [application name]");
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);
}
Date d = new Date();
try {
// loop the number of times.
// Loop the number of times.
for (int i = 0; i < numberOfTimes; ++i) {
// start the application.
// Start the application.
Application.Instance publisherApplication = server.start(applicationName);
System.out.println("started application " + publisherApplication);
System.out.println("Started application " + publisherApplication);
Application.Subscriber subscriber = Application.Subscriber.create(publisherApplication, "publisher");
System.out.println("created subscriber " + subscriber);
System.out.println("Created subscriber " + subscriber);
// receiving data
// Receiving data.
while (true) {
String data = subscriber.receiveString();
if (data != null) {
System.out.println("received " + data);
System.out.println("Received " + data);
} else {
break;
}
}
System.out.println("finished stream, stream ? " + !subscriber.isEnded());
System.out.println("Finished stream");
// wait for the application.
// Wait for the application.
int state = publisherApplication.waitFor();
System.out.println("publisher application terminated with state " + Application.State.toString(state));
System.out.println("Publisher application terminated with state " + Application.State.toString(state));
// terminate the subscriber.
// Terminate the subscriber.
subscriber.terminate();
}
} catch (ConnectionTimeout e) {
System.out.println("connection timeout");
} finally {
// Do not forget to terminate This.
Application.This.terminate();
}
System.out.println("finished the application after " + ((new Date()).getTime() - d.getTime()) + "ms");
System.out.println("Finished the application");
}
}
\ No newline at end of file
......@@ -85,7 +85,15 @@
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-full.jar fr.ill.ics.cameo.test.TestWaitStorage"/>
</application>
<application name="publisherjava" starting_time="inf" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-full.jar fr.ill.ics.cameo.test.Publisher"/>
</application>
<application name="testpublisherjava" starting_time="0" stopping_time="1" output_stream="yes" multiple="no" restart="no">
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-full.jar fr.ill.ics.cameo.test.TestPublisher publisherjava"/>
</application>
......@@ -98,9 +106,6 @@
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-full.jar fr.ill.ics.cameo.test.TestStateApplication"/>
</application>
<application name="pubjava" starting_time="inf" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-full.jar fr.ill.ics.cameo.test.TestPublisherApplication"/>
</application>
<application name="publoopjava" starting_time="inf" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-full.jar fr.ill.ics.cameo.test.TestPublisherLoopApplication"/>
......@@ -153,10 +158,6 @@
<application name="connectioncheckerjava" starting_time="0" stopping_time="1000" output_stream="yes" multiple="no" restart="no">
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-full.jar fr.ill.ics.cameo.test.TestConnectionCheckerApplication"/>
</application>
<application name="startpubjava" starting_time="0" stopping_time="1" output_stream="yes" multiple="no" restart="no">
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-full.jar fr.ill.ics.cameo.test.TestSubscriberAndPublisherApplication pubjava"/>
</application>
<application name="startnpubjava" starting_time="0" stopping_time="1" output_stream="yes" multiple="no" restart="no">
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-full.jar fr.ill.ics.cameo.test.TestNonSyncSubscribersAndPublisherApplication nsubjava"/>
......@@ -244,6 +245,13 @@
<start executable="testwaitstorage"/>
</application>
<application name="publishercpp" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="publisher"/>
</application>
<application name="testpublishercpp" starting_time="0" stopping_time="1" output_stream="yes" multiple="no" restart="no">
<start executable="testpublisher" args="publishercpp"/>
</application>
......@@ -252,9 +260,7 @@
<start executable="teststate"/>
</application>
<application name="pubcpp" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="testpublisher"/>
</application>
<application name="publoopcpp" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="testpublisherloop"/>
......@@ -311,11 +317,7 @@
<application name="stoptimeoutcpp" starting_time="0" stopping_time="1" output_stream="yes" multiple="no" restart="no">
<start executable="teststoptimeout"/>
</application>
<application name="startpubcpp" starting_time="0" stopping_time="1" output_stream="yes" multiple="no" restart="no">
<start executable="testsubscriberandpublisher" args="pubcpp"/>
</application>
<application name="startnpubcpp" starting_time="0" stopping_time="1" output_stream="yes" multiple="no" restart="no">
<start executable="testnonsyncsubscribersandpublisher" args="nsubcpp 10"/>
</application>
......@@ -391,6 +393,15 @@
<start executable="testerror.py"/>
</application>
<application name="publisherpy" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="publisher.py"/>
</application>
<application name="testpublisherpy" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="testpublisher.py" args="publisherpy"/>
</application>
<!-- Test apps -->
......
#!/usr/bin/python3 -u
import sys
import cameopy
this = cameopy.This
this.init(sys.argv)
numberOfSubscribers = 1 if len(sys.argv) < 3 else int(sys.argv[1])
print("Number of subscribers:", numberOfSubscribers)
print("Creating publisher and waiting for ", numberOfSubscribers, "subscriber(s)...")
publisher = cameopy.Publisher.create("publisher", numberOfSubscribers)
publisher.waitForSubscribers()
this.setRunning()
print("Synchronized with ", numberOfSubscribers, "subscriber(s)")
for i in range(100):
message = "message " + str(i)
publisher.send(message)
publisher.sendEnd()
print("Finished the application")
#!/usr/bin/python3 -u
import sys
import cameopy
applicationName = ""
numberOfTimes = 1
if len(sys.argv) >= 3:
applicationName = sys.argv[1]
if len(sys.argv) >= 4:
numberOfTimes = int(sys.argv[2])
print("Publisher application is", applicationName)
this = cameopy.This
this.init(sys.argv)
server = this.getServer()
for i in range(numberOfTimes):
app = server.start(applicationName, 0)
print("Started application", applicationName)
subscriber = cameopy.Subscriber.create(app, "publisher")
while True:
data = subscriber.receive()
if data:
print("Received", data)
else:
break
print("Finished stream")
state = app.waitFor()
print("Publisher application terminated")
\ No newline at end of file
......@@ -14,11 +14,10 @@
* limitations under the Licence.
*/
#include <cameo/cameo.h>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <cameo/cameo.h>
using namespace std;
using namespace cameo;
......@@ -36,37 +35,33 @@ int main(int argc, char *argv[]) {
is >> numberOfSubscribers;
}
cout << "number of subscribers is " << numberOfSubscribers << endl;
if (application::This::isAvailable()) {
cout << "connected" << endl;
}
cout << "Number of subscribers is " << numberOfSubscribers << endl;
unique_ptr<application::Publisher> publisher;
try {
cout << "creating publisher and waiting for " << numberOfSubscribers << " subscriber(s)..." << endl;
cout << "Creating publisher and waiting for " << numberOfSubscribers << " subscriber(s)..." << endl;
publisher = application::Publisher::create("publisher", numberOfSubscribers);
publisher->waitForSubscribers();
} catch (const PublisherCreationException& e) {
cout << "publisher error" << endl;
cout << "Publisher error" << endl;
return -1;
}
application::This::setRunning();
cout << "synchronized with " << numberOfSubscribers << " subscriber(s)" << endl;
cout << "Synchronized with " << numberOfSubscribers << " subscriber(s)" << endl;
// sending data
publisher->send("hello");
publisher->send("world");
publisher->send("!");
// Sending data.
for (int i = 0; i < 100; ++i) {
publisher->send("message " + to_string(i));
}
publisher->sendEnd();
cout << "finished the application" << endl;
cout << "Finished the application" << endl;
}
return 0;
......
......@@ -14,11 +14,9 @@
* limitations under the Licence.
*/
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <cameo/cameo.h>
#include <iostream>
using namespace std;
using namespace cameo;
......@@ -35,57 +33,53 @@ int main(int argc, char *argv[]) {
if (argc > 2) {
applicationName = argv[1];
cout << "publisher application is " + applicationName << endl;
cout << "Publisher application is " + applicationName << endl;
if (argc > 3) {
numberOfTimes = stoi(argv[2]);
}
} else {
cerr << "arguments: [application name]" << endl;
cerr << "Arguments: [application name]" << endl;
return -1;
}
// get the client services
Server& server = application::This::getServer();
if (application::This::isAvailable() && server.isAvailable()) {
cout << "connected server " << server << endl;
}
// loop the number of times.
// Loop the number of times.
for (int i = 0; i < numberOfTimes; ++i) {
// start the application.
// Start the application.
unique_ptr<application::Instance> publisherApplication = server.start(applicationName);
cout << "started application " << *publisherApplication << endl;
cout << "Started application " << *publisherApplication << endl;
// create a subscriber to the application applicationName
// Create a subscriber to the application
unique_ptr<application::Subscriber> subscriber = application::Subscriber::create(*publisherApplication, "publisher");
cout << "created subscriber " << *subscriber << endl;
cout << "Created subscriber " << *subscriber << endl;
if (subscriber.get() == 0) {
cout << "subscriber error" << endl;
cout << "Subscriber error" << endl;
return -1;
}
application::This::setRunning();
// receiving data
// Receiving data.
while (true) {
optional<string> data = subscriber->receive();
if (!data.has_value()) {
break;
}
cout << "received " << data.value() << endl;
cout << "Received " << data.value() << endl;
}
cout << "finished stream" << endl;
cout << "Finished stream" << endl;
application::State state = publisherApplication->waitFor();
cout << "publisher application terminated with state " << application::toString(state) << endl;
cout << "Publisher application terminated with state " << application::toString(state) << endl;
}
}
......
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