From e854a58a81ec90e419a4b3effa5a83caac05df90 Mon Sep 17 00:00:00 2001 From: jestin Date: Sun, 13 May 2012 08:54:38 +0000 Subject: Modified the tests to remove bus.getDomain(null) make Waiter and WaiterClient sons of WaitFor Added a few tests into svn --- tests/SendNowSelf.java | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tests/SendNowSelf.java (limited to 'tests/SendNowSelf.java') diff --git a/tests/SendNowSelf.java b/tests/SendNowSelf.java new file mode 100644 index 0000000..ef3df0c --- /dev/null +++ b/tests/SendNowSelf.java @@ -0,0 +1,46 @@ +/** + * Ivy java library API tester. + * TODO does not work if there is anotehr agent on the bus ...? FIXME + * + * @author Yannick Jestin + * + * (c) ENAC + * + * usage: java Unitaire + * + */ +import fr.dgac.ivy.*; + +public class SendNowSelf { + + Ivy bus; + + public SendNowSelf(String domain) { + bus = new Ivy("SendNowSelf" , null, null); + try { + System.out.println("starting sender"); + bus.sendToSelf(true); + bus.bindMsg("^hop hop", new IvyMessageListener() { + public void receive(IvyClient ic, String args[]){ + System.out.println("stopping"); + bus.stop(); + System.out.println("end stopping"); + } + }); + bus.start(domain); + System.out.println("sending"); + if ( bus.sendMsg("hop hop") != 1) { + System.out.println("error, lock, hop hop not received"); + System.exit(-1); + } + } catch (IvyException ie) { + System.out.println("Ivy main test error"); + ie.printStackTrace(); + } + } + + public static void main(final String[] args) throws IvyException,InterruptedException { + new SendNowSelf(Ivy.getDomainArgs("SendNowSelf" , args)); + } + +} -- cgit v1.1