aboutsummaryrefslogtreecommitdiff
path: root/tests/SendNowSelf.java
diff options
context:
space:
mode:
authorjestin2012-05-13 08:54:38 +0000
committerjestin2012-05-13 08:54:38 +0000
commite854a58a81ec90e419a4b3effa5a83caac05df90 (patch)
tree16eb84a66b62ff38e744c8cd474df81561436b9f /tests/SendNowSelf.java
parent4ffe8b84071babe544086f94c66431380d301d59 (diff)
downloadivy-java-e854a58a81ec90e419a4b3effa5a83caac05df90.zip
ivy-java-e854a58a81ec90e419a4b3effa5a83caac05df90.tar.gz
ivy-java-e854a58a81ec90e419a4b3effa5a83caac05df90.tar.bz2
ivy-java-e854a58a81ec90e419a4b3effa5a83caac05df90.tar.xz
Modified the tests to remove bus.getDomain(null)
make Waiter and WaiterClient sons of WaitFor Added a few tests into svn
Diffstat (limited to 'tests/SendNowSelf.java')
-rw-r--r--tests/SendNowSelf.java46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/SendNowSelf.java b/tests/SendNowSelf.java
new file mode 100644
index 0000000..ef3df0c
--- /dev/null
+++ b/tests/SendNowSelf.java
@@ -0,0 +1,46 @@
+/**
+ * Ivy java library API tester.
+ * TODO does not work if there is anotehr agent on the bus ...? FIXME
+ *
+ * @author Yannick Jestin <mailto:yannick.jestin@enac.fr>
+ *
+ * (c) ENAC
+ *
+ * usage: java Unitaire
+ *
+ */
+import fr.dgac.ivy.*;
+
+public class SendNowSelf {
+
+ Ivy bus;
+
+ public SendNowSelf(String domain) {
+ bus = new Ivy("SendNowSelf" , null, null);
+ try {
+ System.out.println("starting sender");
+ bus.sendToSelf(true);
+ bus.bindMsg("^hop hop", new IvyMessageListener() {
+ public void receive(IvyClient ic, String args[]){
+ System.out.println("stopping");
+ bus.stop();
+ System.out.println("end stopping");
+ }
+ });
+ bus.start(domain);
+ System.out.println("sending");
+ if ( bus.sendMsg("hop hop") != 1) {
+ System.out.println("error, lock, hop hop not received");
+ System.exit(-1);
+ }
+ } catch (IvyException ie) {
+ System.out.println("Ivy main test error");
+ ie.printStackTrace();
+ }
+ }
+
+ public static void main(final String[] args) throws IvyException,InterruptedException {
+ new SendNowSelf(Ivy.getDomainArgs("SendNowSelf" , args));
+ }
+
+}