aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/TestReady.java26
1 files changed, 21 insertions, 5 deletions
diff --git a/tests/TestReady.java b/tests/TestReady.java
index fc3bd91..49d9336 100644
--- a/tests/TestReady.java
+++ b/tests/TestReady.java
@@ -1,4 +1,6 @@
import fr.dgac.ivy.*;
+import gnu.getopt.*;
+
/**
* Ivy java ReadyMessage tester.
@@ -7,7 +9,7 @@ import fr.dgac.ivy.*;
*
* (c) CENA
*
- * usage: java TestReady & java TestReady 2
+ * usage: java TestReady & java TestReady -o
*
*/
@@ -54,7 +56,7 @@ class TestReady implements IvyApplicationListener {
}
}
- TestReady() {
+ TestReady(String domain) {
try {
bus = new Ivy(me, ready_message, this);
@@ -62,7 +64,7 @@ class TestReady implements IvyApplicationListener {
bus.bindMsg ("^are you there "+me, new Question());
bus.bindMsg ("^(yes i am "+other+")", new Reply());
- bus.start(null);
+ bus.start(domain);
} catch (IvyException ie) {
System.err.println("can't run the Ivy bus" + ie.getMessage());
}
@@ -84,14 +86,28 @@ class TestReady implements IvyApplicationListener {
}
public static void main(String args[]) {
+ Getopt opt = new Getopt("TestReady",args,"b:o");
+ String domain=Ivy.getDomain(null);
+ int c;
+ boolean swap = false;
+ while ((c = opt.getopt()) != -1) switch (c) {
+ case 'b':
+ domain=opt.getOptarg();
+ break;
+ case 'o':
+ swap=true;
+ break;
+ default:
+ System.exit(0);
+ }
- if (args.length >= 1) {
+ if (swap) {
me = "B";
other = "A";
ready_message = "B ready";
ready_bind = "^A ready";
}
System.out.println("I am "+me);
- new TestReady();
+ new TestReady(domain);
}
}