diff options
author | jestin | 2012-05-13 08:54:38 +0000 |
---|---|---|
committer | jestin | 2012-05-13 08:54:38 +0000 |
commit | e854a58a81ec90e419a4b3effa5a83caac05df90 (patch) | |
tree | 16eb84a66b62ff38e744c8cd474df81561436b9f /tests/Filter.java | |
parent | 4ffe8b84071babe544086f94c66431380d301d59 (diff) | |
download | ivy-java-e854a58a81ec90e419a4b3effa5a83caac05df90.zip ivy-java-e854a58a81ec90e419a4b3effa5a83caac05df90.tar.gz ivy-java-e854a58a81ec90e419a4b3effa5a83caac05df90.tar.bz2 ivy-java-e854a58a81ec90e419a4b3effa5a83caac05df90.tar.xz |
Modified the tests to remove bus.getDomain(null)
make Waiter and WaiterClient sons of WaitFor
Added a few tests into svn
Diffstat (limited to 'tests/Filter.java')
-rw-r--r-- | tests/Filter.java | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/Filter.java b/tests/Filter.java new file mode 100644 index 0000000..92ef190 --- /dev/null +++ b/tests/Filter.java @@ -0,0 +1,73 @@ +/** + * Another Ivy java library API tester: filters + * + * @author Yannick Jestin <mailto:jestin@cena.fr> + * + * (c) CENA + * + * usage: java Request + * + * Changelog + * 1.2.16 : first release + * + * rationale: + * Filter limits the bounded sends to toto and blah + * Remote subscribes to (.*), unbounded, and truc, bounded + * Filter sends truc ble bli (should have one hit only ) + * Filter sends TOTO rules, one hit + * total should be 3 (ready message) + * + */ +import fr.dgac.ivy.*; + +class Filter { + + public static void main(String[] args) throws IvyException { + String domain=Ivy.getDomainArgs("FilterTest",args); + new Filter(domain); + } + + int nb=0; + private Ivy bus; + private String[] filterStrings = { "toto", "blah" }; + + public Filter(String domain) throws IvyException { + bus = new Ivy("FilterTest","FilterTest ready", null); + bus.setFilter(filterStrings); + bus.start(domain); + new Remote(domain); + IvyClient remote = bus.waitForClient("Remote", 0); + bus.sendMsg("truc ble bli"); + bus.sendMsg("TOTO rules"); + remote.sendDie("goodbye"); + bus.stop(); + if (nb != 3) { + System.out.println("n = "+nb+" should be 3"); + System.exit(-1); + } + System.out.println("Filter test successful"); + } + + private class Remote implements IvyMessageListener { + Ivy bus; + String name; + public Remote(String domain) throws IvyException { + bus = new Ivy("Remote","Remote ready",null); + bus.bindMsg("^truc (.*)",this); + bus.bindMsg("(.*)", new IvyMessageListener() { + public void receive(IvyClient ic,String[] args) { + System.out.println("something received: "+args[0]); + nb++; + } + }); + bus.start(domain); + } + + public void receive(IvyClient ic,String[] args) { + System.out.println("truc received"+args[0]); + nb++; + } + + } + +} |