From e854a58a81ec90e419a4b3effa5a83caac05df90 Mon Sep 17 00:00:00 2001 From: jestin Date: Sun, 13 May 2012 08:54:38 +0000 Subject: Modified the tests to remove bus.getDomain(null) make Waiter and WaiterClient sons of WaitFor Added a few tests into svn --- src/Probe.java | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) (limited to 'src/Probe.java') diff --git a/src/Probe.java b/src/Probe.java index 6a4c75c..f362b38 100644 --- a/src/Probe.java +++ b/src/Probe.java @@ -103,7 +103,7 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin boolean timestamp=false; boolean quiet=false; boolean sendsToSelf=false; - String domain=Ivy.getDomain(null); + String domain=null; String name="JPROBE"; String[] messageClass=null; while ((c = opt.getopt()) != -1) switch (c) { @@ -113,11 +113,7 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin break; case 'b': domain=opt.getOptarg(); break; case 'c': - java.util.StringTokenizer classTok = new java.util.StringTokenizer(opt.getOptarg(),","); - messageClass=new String[classTok.countTokens()]; - System.out.println("YANNNN "+messageClass.length); - for (int i=0;classTok.hasMoreElements();) - messageClass[i++] = classTok.nextToken(); + messageClass = opt.getOptarg().split(","); break; case 'n': name=opt.getOptarg(); break; case 'q': quiet=true; break; @@ -133,7 +129,7 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin bus.sendToSelf(sendsToSelf); if (messageClass!=null) { System.out.println("using a message class filter of "+messageClass.length+" elements"); - for (String cls: messageClass) System.out.println(cls); + for (String cls: messageClass) System.out.println("\t "+cls); bus.setFilter(messageClass); } for (int i=opt.getOptind();iv=bus.getIvyClientsByName(target); + Collectionv=bus.getIvyClientsByName(target); if (v.size()==0) println("no Ivy client with the name \""+target+"\""); try { for (IvyClient ic : v) ic.sendDirectMsg(id,message); @@ -231,11 +228,10 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin println("-> not sent, the message contains incorrect characters"); } } else if (s.lastIndexOf(".dieall-yes-i-am-sure")>=0){ - Vectorv=bus.getIvyClients(); - for (IvyClient ic: v) ic.sendDie("java probe wants you to leave the bus"); + for (IvyClient ic: bus.getIvyClients()) ic.sendDie("java probe wants you to leave the bus"); } else if (s.lastIndexOf(".die ")>=0){ String target=s.substring(5); - Vectorv=bus.getIvyClientsByName(target); + Collectionv=bus.getIvyClientsByName(target); if (v.size()==0) println("no Ivy client with the name \""+target+"\""); for (IvyClient ic: v) ic.sendDie("java probe wants you to leave the bus"); } else if (s.lastIndexOf(".unbind ")>=0){ @@ -246,10 +242,9 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin println("you can't unsubscribe to " + regexp + ", your're not subscribed to it"); } } else if (s.lastIndexOf(".bound *")>=0){ - Vectorv=bus.getIvyClients(); int total=0; int boundedtotal=0; - for (IvyClient ic: v) { + for (IvyClient ic: bus.getIvyClients()) { for (String r : ic.getRegexps()) { total++; if (r.startsWith("^")) boundedtotal++; @@ -261,7 +256,7 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin int total=0; int boundedtotal=0; String target=s.substring(7); - Vectorv=bus.getIvyClientsByName(target); + Collectionv=bus.getIvyClientsByName(target); if (v.size()==0) println("no Ivy client with the name \""+target+"\""); for (IvyClient ic:v) { for (String r : ic.getRegexps()) { @@ -286,12 +281,12 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin bus.stop(); return false; } else if (s.lastIndexOf(".list")>=0) { - Vector v = bus.getIvyClients(); - println(v.size()+" clients on the bus"); - for (IvyClient ic: v) println("-> "+ic.getApplicationName()); + Collection c = bus.getIvyClients(); + println(c.size()+" clients on the bus"); + for (IvyClient ic: c) println("-> "+ic.getApplicationName()); } else if ( s.lastIndexOf(".ping ")>=0) { String target=s.substring(6); - Vectorv=bus.getIvyClientsByName(target); + Collectionv=bus.getIvyClientsByName(target); if (v.size()==0) println("no Ivy client with the name \""+target+"\""); for (IvyClient ic:v) { try { @@ -306,7 +301,7 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin } } else if ( s.lastIndexOf(".where ")>=0) { String target=s.substring(7); - Vectorv=bus.getIvyClientsByName(target); + Collectionv=bus.getIvyClientsByName(target); if (v.size()==0) println("no Ivy client with the name \""+target+"\""); for (IvyClient ic: v) println(target+" runs on "+ic.getHostName()); } else if (mtime.matches()) { -- cgit v1.1