aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/AsyncAPI.java83
-rw-r--r--tests/BenchLocal.java58
-rw-r--r--tests/BugTok.java8
-rw-r--r--tests/Makefile136
-rw-r--r--tests/NewLine.java6
-rw-r--r--tests/TESTBENCH21
-rw-r--r--tests/TestApi.java4
-rw-r--r--tests/TestNet.java7
-rw-r--r--tests/TestNetSwing.java15
9 files changed, 249 insertions, 89 deletions
diff --git a/tests/AsyncAPI.java b/tests/AsyncAPI.java
index eca9ddc..2b85745 100644
--- a/tests/AsyncAPI.java
+++ b/tests/AsyncAPI.java
@@ -27,7 +27,7 @@ class AsyncAPI {
public static final int NBITER = 100;
public static final int DELAYMS = 1000;
public static final String HEADER = "ASYNCPACKET";
- public static final String TOSUBSCRIBE = "^"+HEADER+"([0-9]*) (.*)";
+ public static final String TOSUBSCRIBE = "^"+HEADER+"([0-9]+) (.*)";
public static final String RECEIVENAME = "MSreceive";
public static final String SENDNAME = "MSsend";
private static long epoch = System.currentTimeMillis();
@@ -38,19 +38,17 @@ class AsyncAPI {
private String name;
boolean verbose;
private int nbpacket;
- private int count=0,total=0;
- protected Integer truc = new Integer(0);
+ private int wait=0;
public AsyncAPI(int nb,String domain,int d, boolean v,boolean async) throws IvyException {
verbose=v;
nbpacket=nb;
name = "MSreceive";
- bus = new Ivy(name,name+" Ready", null);
- delay=new DelayAnswer(d);
- if (async)
- re = bus.bindAsyncMsg(TOSUBSCRIBE,delay);
- else
- re = bus.bindMsg(TOSUBSCRIBE,delay);
+ bus = new Ivy(name,null, null);
+ wait = d;
+ delay=new DelayAnswer();
+ if (async) re = bus.bindAsyncMsg(TOSUBSCRIBE,delay,BindType.ASYNC);
+ else re = bus.bindMsg(TOSUBSCRIBE,delay);
bus.start(domain);
}
@@ -59,29 +57,46 @@ class AsyncAPI {
return "["+df.format(new java.util.Date())+"] ";
}
- class DelayAnswer implements IvyMessageListener {
- int delay;
- public DelayAnswer(int delay) {
- this.delay=delay;
+
+ static Object truc = new Object();
+ int count=0,total=0;
+ int status = 0;
+
+ synchronized void huh(IvyClient ic, String[] args) {
+ count++;
+ if (verbose) {
+ System.out.println(date()+"RECEIVE "+ count+"/"+nbpacket+" packets received arg:("+args[0]+")");
+ int nb = Integer.parseInt(args[0]);
+ total+=nb;
+ if (nb!=count) {
+ System.out.println("RECEIVE *** ERROR *** "+count+"!="+nb+ " - probable double connexion");
+ for (IvyClient i : bus.getIvyClients() ) System.out.println("client: "+i);
+ ic.sendDie("nok, bye");
+ bus.stop();
+ System.exit(-1);
+ }
}
+ if (count<nbpacket) return;
+ if (total==(((nbpacket+1)*nbpacket)/2)) {
+ System.out.println("RECEIVE receiver quitting the bus normally");
+ ic.sendDie("ok, bye");
+ bus.stop();
+ } else {
+ System.out.println("RECEIVE wrong count and total, hit ^C to exit");
+ //System.exit(-1);
+ }
+ }
+
+ class DelayAnswer implements IvyMessageListener {
public void receive(IvyClient ic, String[] args) {
- synchronized(truc) {
- count++;
- if (verbose) {
- System.out.println(date()+count+"/"+nbpacket+" packets received ("+args[0]+")");
- total+=Integer.parseInt(args[0]);
- }
- if (count<nbpacket) return;
- if (total==(((nbpacket+1)*nbpacket)/2)) {
- System.out.println("receiver quitting the bus normally");
- ic.sendDie("ok, bye");
- bus.stop();
- } else {
- System.out.println("wrong count and total, hit ^C to exit");
- //System.exit(-1);
- }
+ huh(ic,args);
+ try {
+ System.out.println("RECEIVE Sleeping "+wait+"ms");
+ Thread.sleep(wait);
+ System.out.println("RECEIVE Finished Sleeping");
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
}
- try { Thread.sleep(delay); } catch (InterruptedException ie) { }
}
}
@@ -127,21 +142,21 @@ class AsyncAPI {
doasyncBind+" asyncSend:"+doasyncSend+" msgsize:"+size);
AsyncAPI receiver = new AsyncAPI(nb,domain,delay,verbose,doasyncBind);
- Ivy mainbus = new Ivy(SENDNAME,SENDNAME+" Ready", null);
+ Ivy mainbus = new Ivy(SENDNAME,null, null);
mainbus.start(domain);
if ((mainbus.waitForClient(RECEIVENAME,5000))==null) {
System.out.println(RECEIVENAME+" did not join the bus. Quitting");
- System.exit(0);
+ System.exit(-1);
}
System.out.println(RECEIVENAME+" is here, sending packets");
StringBuffer tosend = new StringBuffer(size);
for (int i=0;i<size;i++) tosend.append("a");
for (int i=1;i<=nb;i++) {
- if (verbose) System.out.println(date()+"sending packet "+i);
+ if (verbose) System.out.println(date()+"SENDER sending packet "+i);
mainbus.sendMsg(HEADER+i+" "+tosend.toString());
- // mainbus.sendMsg(HEADER+i+" "+tosend.toString(),doasyncSend);
+ // TODO mainbus.sendMsg(HEADER+i+" "+tosend.toString(),doasyncSend);
}
- System.out.println(date()+"sender has sent all its packets, waiting for a die message");
+ System.out.println(date()+"SENDER sender has sent all its packets, waiting for a die message");
// i won't stop the sender's bus here, otherwise the all the packet
// can still be unprocessed
// TODO regession test for Ivy.stop()
diff --git a/tests/BenchLocal.java b/tests/BenchLocal.java
index 6c11360..ef0e4c7 100644
--- a/tests/BenchLocal.java
+++ b/tests/BenchLocal.java
@@ -1,9 +1,10 @@
/**
* Ivy software bus bench tester
*
- * @author Yannick Jestin <jestin@cena.fr>
+ * @author Yannick Jestin <yannick.jestin@enac.fr>
*
* (c) CENA 1998-2004
+ * (c) ENAC 2005-2011
*
* a program with 2 busses testing
* - the rendez vous
@@ -49,10 +50,15 @@ class BenchLocal {
}
public BenchLocal(int testtoperform,String domain,int delay) throws IvyException {
+ System.out.println("test to perform: "+testtoperform);
switch (testtoperform) {
- case 2: testRegex(domain,delay); break;
+ case 2:
+ testRegex(domain,delay);
+ break;
case 1:
- default: test2bus(domain,delay); break;
+ default:
+ test2bus(domain,delay);
+ break;
}
}
@@ -67,11 +73,11 @@ class BenchLocal {
IAL ial=new IAL();
bus1=new Ivy("BUS1","Bus1 ready",ial);
bus2=new Ivy("BUS2","Bus2 ready",ial);
- bus1.bindMsg("^Bus2 ready",new RML(bus1,delay));
SuccessStory success=new SuccessStory(bus1,bus2);
+ bus1.bindMsg("^Bus2 ready",new RML(bus1,delay));
bus2.bindMsg("^([^ ]*) ([^ ]*) ([^ ]*)$",new RMLAnswer1(success));
- bus2.bindMsg("(.*)",new RMLAnswer2(success));
- bus2.bindMsg("y=([^ ]*)",new RMLAnswer3(success));
+ bus2.bindMsg("blah(.*)",new RMLAnswer2(success));
+ bus2.bindMsg(".*y=([^ ]+).*",new RMLAnswer3(success));
bus1.start(domain);
bus2.start(domain);
}
@@ -84,25 +90,32 @@ class BenchLocal {
try {
b.sendMsg("a b c");
sleep(delay);
- b.sendMsg("");
+ b.sendMsg("blah");
sleep(delay);
b.sendMsg("x=1 y=2 z=3");
} catch (IvyException ie) {
+ ie.printStackTrace();
}
b.stop();
}
}
private class SuccessStory {
- int i=0;
+ Object lock = new Object();
+ private int i=0;
Ivy b1,b2;
public SuccessStory(Ivy b1,Ivy b2){this.b1=b1;this.b2=b2;}
public void incr(){
- i++;
- log("regex "+i+" successful");
- if (i==3) {
- log("quitting the bus");
- b1.stop();b2.stop();
+ synchronized (lock) {
+ i++;
+ log("regex "+i+" successful");
+ if (i>=3) {
+ log("quitting the bus");
+ b1.stop();
+ b2.stop();
+ } else {
+ log("pas encore, j'ai reçu "+i+" <3");
+ }
}
}
}
@@ -114,16 +127,21 @@ class BenchLocal {
if ( (args.length==3)
&& (args[0].compareTo("a")==0)
&& (args[1].compareTo("b")==0)
- && (args[2].compareTo("c")==0)
- ) ss.incr();
- }
+ && (args[2].compareTo("c")==0)) {
+ ss.incr();
+ System.out.println("answer 1 ok");
+ }
+ }
}
private class RMLAnswer2 implements IvyMessageListener {
SuccessStory ss;
public RMLAnswer2(SuccessStory ss) {this.ss=ss;}
public void receive(IvyClient c,String[] args) {
- if ( (args.length==1) && (args[0].compareTo("")==0) ) ss.incr();
+ if ( (args.length==1) && (args[0].compareTo("")==0) ) {
+ ss.incr();
+ System.out.println("answer 2 ok");
+ }
}
}
@@ -132,7 +150,10 @@ class BenchLocal {
public RMLAnswer3(SuccessStory ss) {this.ss=ss;}
public void receive(IvyClient c,String[] args) {
if ( (args.length==1) && (args[0].compareTo("2")==0)
- ) ss.incr();
+ ) {
+ ss.incr();
+ System.out.println("answer 3 ok");
+ }
}
}
@@ -159,6 +180,7 @@ class BenchLocal {
try {
b.sendMsg("out");
} catch (IvyException ie) {
+ ie.printStackTrace();
}
b.stop();
}
diff --git a/tests/BugTok.java b/tests/BugTok.java
index 004ac8b..0bfca0d 100644
--- a/tests/BugTok.java
+++ b/tests/BugTok.java
@@ -14,7 +14,7 @@ class BugTok {
public static String[] decoupe(String s,String sep) {
int index=0, last=0, length=s.length();
- Vector v = new Vector();
+ Vector<String> v = new Vector<String>();
if (length!=0) while (true) {
index=s.indexOf(sep,last);
if (index==-1) {
@@ -41,9 +41,9 @@ class BugTok {
}
public static void main(String[] arg) {
- doprint(decoupe("ils ont changé ma chanson"," ")) ;
- doprint(decoupe(" ils ont changé ma chanson"," ")) ;
- doprint(decoupe("\u0003ils\u0003ont\u0003\u0003changé ma chanson","\u0003")) ;
+ doprint(decoupe("ils ont change ma chanson"," ")) ;
+ doprint(decoupe(" ils ont change ma chanson"," ")) ;
+ doprint(decoupe("\u0003ils\u0003ont\u0003\u0003change ma chanson","\u0003")) ;
doprint(decoupe(""," ")) ;
}
}
diff --git a/tests/Makefile b/tests/Makefile
index 9801c09..d8a6e8e 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -3,7 +3,7 @@
# you'll have to play with the network settings to make it run
include ../java.mk # in this file you can change your java compiler and VM
-IVYPATH=../ivy-1.2.12.jar
+IVYPATH=../build/jar/ivy-java.jar
CLASSPATH=-classpath classes:$(IVYPATH):$(GNUPATH)
SRC = *.java
@@ -14,46 +14,146 @@ SRC = *.java
#LOCALNET=10.0.0.255:3456
#LOCALNET=192.168.19:3456
LOCALNET=
-MULTICAST=228.1.2.3:4567
-DOMAIN=
-#DOMAIN=-b $(MULTICAST)
-
+MULTICAST=224.5.6.7:8910
+#DOMAIN=
+DOMAIN=-b $(MULTICAST)
+DEBUG=
+#DEBUG= -DIVY_DEBUG
all:
+ /bin/rm -fR -- classes
+ mkdir classes
$(JAVAC) -d classes $(JAVACOPTS) $(CLASSPATH) $(SRC)
@echo "all modules built. run make run"
-run: nl api unitaires test1 test2 probe async stop request
+run: sendnow sendnowself nl api unitaires probe stop request test1 async test2
request:
- $(JAVA) $(JAVAOPTS) $(CLASSPATH) Request $(DOMAIN)
+ @echo "*****************************"
+ @echo "TEST REQUEST"
+ @echo "*****************************"
+ $(JAVA) $(DEBUG) $(DEBUG) $(JAVAOPTS) $(CLASSPATH) Request $(DOMAIN)
+ @echo "*****************************"
+ @echo "TEST REQUEST successful"
+ @echo "*****************************"
+ @echo "\n\n\n"
+
+sendnowself:
+ @echo "*****************************"
+ @echo "TEST SENDNOW SELF"
+ @echo "*****************************"
+ $(JAVA) $(DEBUG) $(DEBUG) $(JAVAOPTS) $(CLASSPATH) SendNowSelf $(DOMAIN)
+ @echo "*****************************"
+ @echo "TEST SENDNOW SELF successful"
+ @echo "*****************************"
+ @echo "\n\n\n"
+
+sendnow:
+ @echo "*****************************"
+ @echo "TEST SENDNOW"
+ @echo "*****************************"
+ $(JAVA) $(DEBUG) $(DEBUG) $(JAVAOPTS) $(CLASSPATH) SendNow $(DOMAIN)
+ @echo "*****************************"
+ @echo "TEST SENDNOW successful"
+ @echo "*****************************"
+ @echo "\n\n\n"
nl:
- $(JAVA) $(JAVAOPTS) $(CLASSPATH) NewLine -n 100000 $(DOMAIN)
+ @echo "*****************************"
+ @echo "TEST NEWLINE"
+ @echo "*****************************"
+ $(JAVA) $(DEBUG) $(JAVAOPTS) $(CLASSPATH) NewLine -n 100000 $(DOMAIN)
+ @echo "*****************************"
+ @echo "TEST NEWLINE successful"
+ @echo "*****************************"
+ @echo "\n\n\n"
probe:
- $(JAVA) $(JAVAOPTS) $(CLASSPATH) fr.dgac.ivy.tools.Probe $(DOMAIN) < /dev/null
+ @echo "*****************************"
+ @echo "TEST PROBE < /dev/null"
+ @echo "*****************************"
+ $(JAVA) $(DEBUG) $(JAVAOPTS) $(CLASSPATH) fr.dgac.ivy.tools.Probe $(DOMAIN) < /dev/null
+ @echo "*****************************"
+ @echo "TEST PROBE SUCCESSFUL"
+ @echo "*****************************"
+ @echo "\n\n\n"
+
api:
- $(JAVA) $(JAVAOPTS) $(CLASSPATH) TestApi $(DOMAIN)
+ @echo "*****************************"
+ @echo "TEST API"
+ @echo "*****************************"
+ $(JAVA) $(DEBUG) $(JAVAOPTS) $(CLASSPATH) TestApi $(DOMAIN)
+ @echo "*****************************"
+ @echo "TEST API SUCCESSFUL"
+ @echo "*****************************"
+ @echo "\n\n\n"
+
async:
- $(JAVA) $(JAVAOPTS) $(CLASSPATH) AsyncAPI -r -l 5 -d 1 -s 10 $(DOMAIN)
+ @echo "*****************************"
+ @echo "TEST ASYNC"
+ @echo "*****************************"
+ $(JAVA) $(DEBUG) $(JAVAOPTS) $(CLASSPATH) AsyncAPI -r -l 5 -d 1 -s 10 $(DOMAIN)
+ @echo "*****************************"
+ @echo "TEST ASYNC SUCCESSFUL"
+ @echo "*****************************"
+ @echo "\n\n\n"
stop:
- $(JAVA) $(JAVAOPTS) $(CLASSPATH) StopStart $(DOMAIN)
+ @echo "*****************************"
+ @echo "TEST STOP"
+ @echo "*****************************"
+ $(JAVA) $(DEBUG) $(JAVAOPTS) $(CLASSPATH) StopStart $(DOMAIN)
+ @echo "*****************************"
+ @echo "TEST STOP SUCCESSFUL"
+ @echo "*****************************"
+ @echo "\n\n\n"
unitaires:
- $(JAVA) $(JAVAOPTS) $(CLASSPATH) fr.dgac.ivy.Ivy $(DOMAIN)
+ @echo "*****************************"
+ @echo "TEST UNITAIRE"
+ @echo "*****************************"
+ $(JAVA) $(DEBUG) $(JAVAOPTS) $(CLASSPATH) Unitaire $(DOMAIN)
+ @echo "*****************************"
+ @echo "TEST UNITAIRE SUCCESSFUL"
+ @echo "*****************************"
+ @echo "\n\n\n"
test1: $(OBJ)
- $(JAVA) $(JAVAOPTS) $(CLASSPATH) BenchLocal $(DOMAIN)
- $(JAVA) $(JAVAOPTS) $(CLASSPATH) BenchLocal -d 100 $(DOMAIN)
- $(JAVA) $(JAVAOPTS) $(CLASSPATH) BenchLocal -d 0 $(DOMAIN)
+ @echo "*****************************"
+ @echo "TEST Bench"
+ @echo "*****************************"
+ $(JAVA) $(DEBUG) $(JAVAOPTS) $(CLASSPATH) BenchLocal $(DOMAIN)
+ $(JAVA) $(DEBUG) $(JAVAOPTS) $(CLASSPATH) BenchLocal -d 100 $(DOMAIN)
+ $(JAVA) $(DEBUG) $(JAVAOPTS) $(CLASSPATH) BenchLocal -d 0 $(DOMAIN)
+ @echo "*****************************"
+ @echo "TEST Bench SUCCESSFUL"
+ @echo "*****************************"
+ @echo "\n\n\n"
test2: $(OBJ)
- $(JAVA) $(JAVAOPTS) $(CLASSPATH) BenchLocal -t 2 -d 100 $(DOMAIN)
- $(JAVA) $(JAVAOPTS) $(CLASSPATH) BenchLocal -t 2 -d 0 $(DOMAIN)
+ @echo "*****************************"
+ @echo "TEST Bench 2"
+ @echo "*****************************"
+ $(JAVA) $(DEBUG) $(JAVAOPTS) $(CLASSPATH) BenchLocal -t 2 -d 100 $(DOMAIN)
+ $(JAVA) $(DEBUG) $(JAVAOPTS) $(CLASSPATH) BenchLocal -t 2 -d 0 $(DOMAIN)
+ @echo "*****************************"
+ @echo "TEST Bench 2 SUCCESSFUL"
+ @echo "*****************************"
+ @echo "\n\n\n"
+
+swing: $(OBJ)
+ @echo "*****************************"
+ @echo "TEST Swing "
+ @echo "WARNING, this is manual, you have to use the GUI to test ..."
+ @echo "TODO, add java.awt.Robot support"
+ @echo "*****************************"
+ $(JAVA) $(DEBUG) $(JAVAOPTS) $(CLASSPATH) SwingIvy $(DOMAIN)
+ @echo "*****************************"
+ @echo "TEST Swing Successful"
+ @echo "*****************************"
+ @echo "\n\n\n"
clean:
/bin/rm -fR $(OBJ) *.class classes
diff --git a/tests/NewLine.java b/tests/NewLine.java
index 5517a54..8381379 100644
--- a/tests/NewLine.java
+++ b/tests/NewLine.java
@@ -32,10 +32,10 @@ class NewLine {
bus = new Ivy("NewLine","NewLine ready", null);
bus.protectNewlines(true);
bus.sendToSelf(true);
- bus.bindMsg("^coucou(.)monde$",new IvyMessageListener() {
- public void receive(IvyClient ic,String[] args) {
+ bus.bindMsg("^coucou([^m])monde",new IvyMessageListener() {
+ public void receive(IvyClient ic,String[] a) {
recus++;
- if (recus==nbmsg) System.out.println("received "+nbmsg+" ["+args[0]+"]");
+ if (recus==nbmsg) System.out.println("received "+nbmsg+" ["+a[0]+"]");
}
});
bus.start(domain);
diff --git a/tests/TESTBENCH b/tests/TESTBENCH
index 7a4df94..c9b28bf 100644
--- a/tests/TESTBENCH
+++ b/tests/TESTBENCH
@@ -1,4 +1,25 @@
-------------------------------------------------------------------------------
+BUGS
+-------------------------------------------------------------------------------
+
+1.2.14-v1 Ven 24 jui 2011 09:50:42 CEST
+test async on MacOSX
+ make async sometimes fails, double connexion from MsReceive hangs the
+ process (each message callback is executed twice)
+ TODO !
+-->Ivy[0]<-- found a peer
+-->Ivy[0]<-- added IC[0,0] MSreceive:none:54063 in half: (none,)
+-->Ivy[0]<-- waiting for a peer
+-->Ivy[0]<-- added IC[3,0] MSreceive:MSsend:54063 in half: (MSsend,none,)
+-->Ivy[0]<-- removed IC[3,0] MSreceive:MSsend:54063 from half: (none,)
+-->Ivy[0]<-- added IC[3,0] MSreceive:MSsend:54063 in clients: (MSsend,)
+-->Ivy[0]<-- removed IC[0,0] MSreceive:MSsend:54063 from half: ()
+-->Ivy[0]<-- added IC[0,0] MSreceive:MSsend:54063 in clients: (MSsend,MSsend,)
+
+fixed in 1.2.14-v3, seemingly, or so I hope
+
+
+-------------------------------------------------------------------------------
TODO :
- DOC DOC DOC
- make run
diff --git a/tests/TestApi.java b/tests/TestApi.java
index 00c2f29..f6e8ecf 100644
--- a/tests/TestApi.java
+++ b/tests/TestApi.java
@@ -28,7 +28,9 @@ class TestApi implements IvyMessageListener, IvyApplicationListener {
bus.sendToSelf(true);
bus.bindMsg("^go$",new Self(domain));
System.out.println("sending go ...");
- try { bus.sendMsg("go"); } catch (IvyException ie) { }
+ try { bus.sendMsg("go"); } catch (IvyException ie) {
+ ie.printStackTrace();
+ }
System.out.println("go sent");
}
diff --git a/tests/TestNet.java b/tests/TestNet.java
index 56c0b17..75c8524 100644
--- a/tests/TestNet.java
+++ b/tests/TestNet.java
@@ -14,7 +14,7 @@
import java.lang.Thread;
import java.net.*;
import java.io.*;
-import org.apache.regexp.*;
+import java.util.regex.*;
import gnu.getopt.*;
class TestNet implements Runnable {
@@ -58,9 +58,8 @@ class TestNet implements Runnable {
int sep_index = net.lastIndexOf( ":" );
if ( sep_index != -1 ) { net = net.substring(0,sep_index); }
net += ".255.255.255";
- RE exp = new RE( "^(\\d+\\.\\d+\\.\\d+\\.\\d+).*");
- net = exp.subst( net , "$1" );
- return net;
+ Pattern exp = Pattern.compile( "^(\\d+\\.\\d+\\.\\d+\\.\\d+).*");
+ return exp.matcher(net).group(1);
}
private static int getPort(String net) {
diff --git a/tests/TestNetSwing.java b/tests/TestNetSwing.java
index f2dc0eb..7aed6e2 100644
--- a/tests/TestNetSwing.java
+++ b/tests/TestNetSwing.java
@@ -15,7 +15,7 @@ import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import fr.dgac.ivy.*;
-import org.apache.regexp.*;
+import java.util.regex.*;
import gnu.getopt.*;
class TestNetSwing implements Runnable {
@@ -183,19 +183,20 @@ class TestNetSwing implements Runnable {
int sep_index = net.lastIndexOf( ":" );
if ( sep_index != -1 ) { net = net.substring(0,sep_index); }
try {
- RE numbersPoint = new RE("([0-9]|\\.)+");
- if (!numbersPoint.match(net)) {
+ Pattern numbersPoint = Pattern.compile("([0-9]|\\.)+");
+ if (!numbersPoint.matcher(net).matches()) {
// traceDebug("should only have numbers and point ? I won't add anything... " + net);
return net;
}
net += ".255.255.255";
- RE exp = new RE( "^(\\d+\\.\\d+\\.\\d+\\.\\d+).*");
- if (!exp.match(net)) {
+ Pattern exp = Pattern.compile( "^(\\d+\\.\\d+\\.\\d+\\.\\d+).*");
+ Matcher m = exp.matcher(net);
+ if (!m.matches()) {
System.out.println("Bad broascat addr " + net);
throw new IvyException("bad broadcast addr");
}
- net=exp.getParen(1);
- } catch ( RESyntaxException e ){
+ net=m.group(1);
+ } catch ( PatternSyntaxException e ){
System.out.println(e);
System.exit(0);
}