diff options
-rw-r--r-- | Changelog | 56 | ||||
-rw-r--r-- | build.xml | 162 | ||||
-rw-r--r-- | examples/Makefile | 4 | ||||
-rw-r--r-- | tests/AsyncAPI.java | 83 | ||||
-rw-r--r-- | tests/BenchLocal.java | 58 | ||||
-rw-r--r-- | tests/BugTok.java | 8 | ||||
-rw-r--r-- | tests/Makefile | 136 | ||||
-rw-r--r-- | tests/NewLine.java | 6 | ||||
-rw-r--r-- | tests/TESTBENCH | 21 | ||||
-rw-r--r-- | tests/TestApi.java | 4 | ||||
-rw-r--r-- | tests/TestNet.java | 7 | ||||
-rw-r--r-- | tests/TestNetSwing.java | 15 |
12 files changed, 469 insertions, 91 deletions
@@ -1,4 +1,60 @@ -------------------------------------------------------------------- +1.2.14 + + New API: + - added sypport to the Swing Dispatch Thread in the bindAsyncMsg api. + this breaks the former API. Use BindType.SWING as the latter argument. + - severe problems throws RuntimeException instead of System.exit(), + allows code reuse. + - many methods now are protected, with accessors + - removed unread fields (Ivy.domainaddr, e.g.) + - ready message is set to appName + " READY" if null has been + provided, like in the C# api + - lowercase CheckRegexp to checkRegexp (bad practice, thanks to + FindBugs). + Doc: + - javadoc updated (a bit) + - removed protected methods from javadoc + switch to apache fop + docbook for documentation translation + Internals: + + - added a lock mechanism to be sure that once a connexion + has been initiated, the ready message will be sent before + stopping the bus now: Ivy b = new Ivy(...); b.sendMsg("coucou"); + b.stop(); should send messages (at least the ready message) + if there is a connexion attempt made before b.stop() is + effective. To be sure, there is a 200ms delay before b.stop() + can be effective (the Threads stopped, the sockets closed) + - IMPORTANT ! switch from gnu regexp (deprecated) to the + built in java + regexp. + - IMPORTANT ! Reintroduced a mechanism to allow the drop of a double + connexion attempt. + - use new synchronization scheme with locks (app socket, structures) + - add generic types to declarations, the code now won't ompile on java + prior to the 1.5 platform + - fixed a potential null pointer dereference on quit (thanks to + findBugs) + - remove the Thread.start() from the constructor, to avoid mulithread + issues. see + http://findbugs.sourceforge.net/bugDescriptions.html#SC_START_IN_CTOR. + now ,we have to call IvyClient.start() after it has been created + - IvyWatcher tries to fix a lock on accept() by becoming a Thread + instead of runnalbe (see tests/test2). + Internal performance issus + - use of stringbuffers to concatenate strings, instead of using +, + which could lead to a quadractic cost in the number of iteraction (the + growing string was recopied in each iteration). + - when possible, move the regexp Pattern.compile in static areas, to + avoid multiple calls. + - recopy the filter String[] in setfilter, to avoid exposing internal + representation (unsafe operation). + - in many areas, e.g. Hashtable keys, use autoboxing for the creation + of Integer (instead of new Integer(int). This alows caching, avoids + object allocation, and the * code will be faster. + + +-------------------------------------------------------------------- 1.2.13 mise en place de TCP_NO_DELAY, pour desactiver l'algorithme de Naggle diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..f1bc6a6 --- /dev/null +++ b/build.xml @@ -0,0 +1,162 @@ +<project name="ivy-java" basedir="." default="main"> + + <property name="version" value="1.2.14"/> + <property name="defaultbus" value="-DIVYBUS=224.5.6.7:8910" /> + + <property name="src.dir" value="src"/> + <property name="build.dir" value="build"/> + <property name="classes.dir" value="${build.dir}/classes"/> + <property name="jar.dir" value="${build.dir}/jar"/> + <property name="main-class" value="fr.dgac.ivy.tools.Probe"/> + <property name="lib.dir" value="lib"/> + <property name="target.dir" value="jestin@ssh.lii-enac.fr:public_html/ivy-java/unstable"/> + <property name="tgz.dir" value="${build.dir}/${ant.project.name}-${version}" /> + + <!-- + LOCAL SETTINGS + should be overriden to reflect your installation. This is a MacOSX / + Macports setup + --> + <property name="docbook-xsl" value="/opt/local/share/xsl/docbook-xsl" /> + <property name="jars.home" value="/opt/local/share/java/"/> + <property name="fop.home" value="${jars.home}/fop/1.0/"/> + <property name="xslt.jar" value="${jars.home}/xalan.jar"/> + <property name="jsch.jar" value="${jars.home}/jsch.jar"/> + <property name="servlet.jar" value="servlet25-api.jar "/> + + <path id="classpath"> + <fileset dir="${lib.dir}" includes="**/*.jar"/> + <fileset dir="${jars.home}" includes="**/${servlet.jar}"/> + </path> + + <target name="init"> + <mkdir dir="${build.dir}"/> + <mkdir dir="${classes.dir}"/> + <mkdir dir="${jar.dir}"/> + <mkdir dir="${build.dir}/doc/api"/> + </target> + + <target name="clean"> + <delete dir="${build.dir}"/> + </target> + + <target name="compile" depends="init"> + <javac includeantruntime="true" srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/> + </target> + + + <target name="jar" depends="compile"> + <jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}"> + <manifest> + <attribute name="Main-Class" value="${main-class}"/> + </manifest> + <archives> + <zips><fileset dir="lib" includes="**/java-getopt-1.0.13.jar"/></zips> + </archives> + <fileset dir="." includes="README,COPYING.LIB,BUGS,Changelog"/> + </jar> + </target> + + <target name="dist" depends="compile,doc" > + <jar destfile="${jar.dir}/${ant.project.name}-${version}.jar" basedir="${classes.dir}"> + <manifest> + <attribute name="Main-Class" value="${main-class}"/> + </manifest> + <archives> + <zips><fileset dir="lib" includes="**/java-getopt-1.0.13.jar"/></zips> + </archives> + <fileset dir="." includes="build.xml,Makefile,java.mk,manifest,README,COPYING.LIB,Changelog,BUGS" /> + <fileset dir="src" includes="${src.dir}/*.java" /> + <fileset dir="tests" includes="tests/*.java" /> + <fileset dir="examples" includes="tests/*.java, tests/*.xml, tests/*.txt" /> + <fileset dir="doc" includes="doc/html/api/*" /> + </jar> + </target> + + <target name="doc" depends="init"> + <!-- JAVADOC --> + <javadoc packagenames="fr.dgac.ivy.*" sourcepath="${src.dir}" + destdir="${build.dir}/doc/api/" defaultexcludes="yes" classpathref="classpath" + public="true" use="true" windowtitle="Ivy Java API"> + <fileset dir="src" includes="**/*.java" /> + </javadoc> + + <!-- library guide HTML ONE BIG CHUNK --> + <xslt basedir="doc" destdir="${build.dir}/doc/html" extension=".html" + in="doc/ivy-java.sgml" + out="${build.dir}/doc/html/ivy-java.html" + style="${docbook-xsl}/xhtml/chunk.xsl"> + <classpath location="${xslt.jar}" /> + </xslt> + + <!-- library guide HTML MULTIPLE FILES --> + <xslt basedir="doc" destdir="${build.dir}/doc/html" extension=".html" + in="doc/ivy-java.sgml" + out="${build.dir}/doc/html/" + style="${docbook-xsl}/xhtml/docbook.xsl"> + <classpath location="${xslt.jar}" /> + </xslt> + + <!-- library guide PDF --> + <xslt basedir="doc" destdir="${build.dir}/doc/" extension=".fo" classpathref="classpath" + includes="ivy-java.sgml" + style="${docbook-xsl}/fo/docbook.xsl"> + <classpath location="${xslt.jar}" /> + </xslt> + <fop format="application/pdf" fofile="${build.dir}/doc/ivy-java.fo" outfile="${build.dir}/doc/ivy-java.pdf" /> + </target> + + <taskdef name="fop" classname="org.apache.fop.tools.anttasks.Fop"> + <classpath> + <fileset dir="${fop.home}/lib"><include name="*.jar"/></fileset> + <fileset dir="${fop.home}/build"><include name="fop.jar"/> + <include name="fop-hyph.jar" /></fileset> + </classpath> + </taskdef> + + <target name="tar"> + <delete file="${tgz.dir}.tar.gz" /> + <tar destfile="${tgz.dir}.tar.gz" compression="gzip"> + <tarfileset dir="." includes="${src.dir}/*.java" /> + <tarfileset dir="." includes="${testsrc.dir}/*.java" /> + <tarfileset dir="." includes="${testsrc.dir}/Makefile" /> + <tarfileset dir="." includes="examples/*.java" /> + <tarfileset dir="." includes="examples/*.xml" /> + <tarfileset dir="." includes="examples/*.txt" /> + <tarfileset dir="." includes="examples/*.java" /> + <tarfileset dir="." includes="doc/*.dgml" /> + <tarfileset dir="." includes="doc/*.1" /> + <tarfileset dir="." includes="doc/Makefile" /> + <fileset dir="." includes="build.xml,Makefile,java.mk,manifest,README,COPYING.LIB,Changelog,BUGS" /> + </tar> + </target> + + <target name="run" depends="jar"> + <java fork="true" classname="${main-class}"> + <jvmarg value="${defaultbus}"/> + <arg value="(.*)"/> + <classpath> + <path refid="classpath"/> + <path location="${jar.dir}/${ant.project.name}.jar"/> + </classpath> + </java> + </target> + + <target name="release" depends="clean,compile,jar,dist,doc,tar"> + <scp todir="${target.dir}"> + <classpath> + <path refid="classpath"/> + <path location="${jsch.jar}"/> + </classpath> + <fileset dir="build"> + <include name="**/*.tar.gz"/> + <include name="**/jar/*.jar"/> + <include name="**/doc/*"/> + </fileset> + </scp> + </target> + + <target name="clean-build" depends="clean,jar"/> + <target name="main" depends="clean,run"/> + +</project> diff --git a/examples/Makefile b/examples/Makefile index 923b69e..ed34497 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -4,10 +4,10 @@ include ../java.mk SRCS = TestIvy.java TestIvySwing.java Counter.java ivyTranslater.java Translate.java TranslateXML.java EndApp.java OBJS = $(SRCS:.java=.class) -BUILDPATH=../ivy-1.2.12.jar +BUILDPATH=../ivy-java.jar .java.class: - $(JAVAC) $(JAVACOPTS) -classpath $(BUILDPATH):$(GNUPATH) $< + $(JAVAC) $(JAVACOPTS) -classpath $(BUILDPATH) $< all: $(OBJS) 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); } |