aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfcolin2011-02-25 10:42:05 +0000
committerfcolin2011-02-25 10:42:05 +0000
commit90ac7a3566995cc244f9fdaff41e6c5122c7ca2e (patch)
tree839b1613b56b330c77eb74e717091cfb89911814
parent4d486c099ed1cdd05dd6990a0f407459c3f502d5 (diff)
downloadivy-java-90ac7a3566995cc244f9fdaff41e6c5122c7ca2e.zip
ivy-java-90ac7a3566995cc244f9fdaff41e6c5122c7ca2e.tar.gz
ivy-java-90ac7a3566995cc244f9fdaff41e6c5122c7ca2e.tar.bz2
ivy-java-90ac7a3566995cc244f9fdaff41e6c5122c7ca2e.tar.xz
using getopt
-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);
}
}