diff options
author | jestin | 2004-07-27 16:23:00 +0000 |
---|---|---|
committer | jestin | 2004-07-27 16:23:00 +0000 |
commit | d5d548edaf6cf1ffb2d214b2bf0329ec341c42a1 (patch) | |
tree | 7bea89fe499bf27ecc37c1c5b0d58e4639c26421 /tests/TestNet.java | |
parent | fd9c3e8ea4c7093bff92ec2162ca0be338024fa2 (diff) | |
download | ivy-java-d5d548edaf6cf1ffb2d214b2bf0329ec341c42a1.zip ivy-java-d5d548edaf6cf1ffb2d214b2bf0329ec341c42a1.tar.gz ivy-java-d5d548edaf6cf1ffb2d214b2bf0329ec341c42a1.tar.bz2 ivy-java-d5d548edaf6cf1ffb2d214b2bf0329ec341c42a1.tar.xz |
major test rewrite to abide to the latest API. Updated tests for async msg
handling and protect newline
Diffstat (limited to 'tests/TestNet.java')
-rw-r--r-- | tests/TestNet.java | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/tests/TestNet.java b/tests/TestNet.java index e65684a..d1ff968 100644 --- a/tests/TestNet.java +++ b/tests/TestNet.java @@ -1,12 +1,25 @@ +/** + * Ivy software bus tester + * + * @author Yannick Jestin <jestin@cena.fr> + * + * (c) CENA 1998-2004 + * + * CHANGELOG + * + * 1.2.6 + * goes jakarta regexp + */ + import java.lang.Thread; import java.net.*; import java.io.*; import java.util.StringTokenizer; -import gnu.regexp.*; +import org.apache.regexp.*; import gnu.getopt.*; class TestNet implements Runnable { - private String domain; + private String mydomain; private boolean watcherrunning = false; private boolean isMulticastAddress = false; private Thread broadcastListener ; @@ -17,7 +30,7 @@ class TestNet implements Runnable { byte buf[] = new byte[256]; DatagramPacket packet=new DatagramPacket(buf, 256); int port; - String s = "Server waiting for Broadcast on "+domain; + String s = "Server waiting for Broadcast on "+mydomain; s+=(isMulticastAddress)?" (TCP multicast)":" (UDP broadcast)"; System.out.println(s); while( watcherrunning ) try { @@ -45,15 +58,9 @@ class TestNet implements Runnable { private static String getDomain(String net) { int sep_index = net.lastIndexOf( ":" ); if ( sep_index != -1 ) { net = net.substring(0,sep_index); } - try { - net += ".255.255.255"; - RE exp = new RE( "^(\\d+\\.\\d+\\.\\d+\\.\\d+).*"); - net = exp.substitute( net , "$1" ); - } catch ( REException e ){ - System.out.println("Bad broascat addr " + net); - return null; - } - //System.out.println("net: "+net); + net += ".255.255.255"; + RE exp = new RE( "^(\\d+\\.\\d+\\.\\d+\\.\\d+).*"); + net = exp.subst( net , "$1" ); return net; } @@ -94,7 +101,7 @@ class TestNet implements Runnable { void start(String domain) { String domainaddr=getDomain(domain); int port=getPort(domain); - this.domain=domainaddr+":"+port; + mydomain=domainaddr+":"+port; try { InetAddress group = InetAddress.getByName(domainaddr); if (group.isMulticastAddress()) { |