diff options
-rw-r--r-- | tests/Bug.java | 36 | ||||
-rw-r--r-- | tests/BugTok.java | 38 | ||||
-rw-r--r-- | tests/Makefile | 8 |
3 files changed, 78 insertions, 4 deletions
diff --git a/tests/Bug.java b/tests/Bug.java new file mode 100644 index 0000000..706d951 --- /dev/null +++ b/tests/Bug.java @@ -0,0 +1,36 @@ +import fr.dgac.ivy.* ; + +class Bug implements IvyApplicationListener { + + private Ivy bus; + + Bug() { + bus = new Ivy("Bug","Hello le monde",this); + try { + bus.start(null); + } catch (IvyException ie) { + System.err.println("can't run the Ivy bus" + ie.getMessage()); + } + } + + public void disconnect(IvyClient client) { } + + public void directMessage(IvyClient client,int id,String msgarg) {} + + public void connect(IvyClient client) { + System.out.println("sending messages"); + bus.sendMsg("coucou"); + bus.sendMsg("titi"); + bus.sendMsg("tata"); + bus.sendMsg("toto"); + System.out.println("done"); + } + + public void die(IvyClient client,int id) { + System.out.println("argh. cya"); + } + + public static void main(String args[]) { + new Bug(); + } +} diff --git a/tests/BugTok.java b/tests/BugTok.java new file mode 100644 index 0000000..c5bc445 --- /dev/null +++ b/tests/BugTok.java @@ -0,0 +1,38 @@ +import java.util.Vector ; +class BugTok { + + public static String[] decoupe(String s,String sep) { + int index=0, last=0, length=s.length(); + Vector v = new Vector(); + if (length!=0) while (true) { + index=s.indexOf(sep,last); + if (index==-1) { + v.add(s.substring(last,length)); + break; + } else if (index<s.length()) { + v.add(s.substring(last,index)); + last=index+1; + } else { + break; + } + } + String[] tab = new String[v.size()]; + v.copyInto(tab); + return tab; + } + + public static void doprint(String[] tab) { + System.out.println("------------ "+tab.length+" elements --------------"); + for (int i=0; i<tab.length;i++) { + System.out.println("'"+tab[i]+"'"); + } + System.out.println("------------------------------------------------------"); + } + + 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(""," ")) ; + } +} diff --git a/tests/Makefile b/tests/Makefile index 9d130b8..bb72f81 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,11 +1,11 @@ -JIKESPATH=/usr/lib/j2re1.3/lib/rt.jar:/usr/share/java/repository:/usr/share/java/gnu.getopt.jar - +JIKESPATH=/usr/lib/j2re1.3/lib/rt.jar:../lib/ivy-java.jar +JAVAC= jikes -classpath $(JIKESPATH) .SUFFIXES: .java .class -SRC = TestNet.java +SRC = TestNet.java Bug.java BugTok.java OBJ = $(SRC:.java=.class) .java.class: - jikes $< + $(JAVAC) $< all: $(OBJ) |