aboutsummaryrefslogtreecommitdiff
path: root/tests/Unitaire.java
blob: 894bb8870144ed61a47d7d10a3b43a3f5c869ef7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
 * Ivy java library API tester.
 *
 * @author  Yannick Jestin <mailto:yannick.jestin@enac.fr>
 *
 * (c) ENAC
 *
 * usage: java Unitaire
 *
 */
import fr.dgac.ivy.*;

public class Unitaire  {

  public static void main(final String[] args) {
    Ivy bus = new Ivy("Test Unitaire" , "TU ready" , null);
    final int PORT_TEST = 5000;
    try {
      bus.start(Ivy.getDomainArgs("IvyTest" , args));
      System.out.println("waiting 5 seconds for a coucou");
      System.out.println(((bus.waitForMsg("^coucou" , PORT_TEST)) != null) ? "coucou received" : "coucou not received");
      System.out.println("waiting 5 seconds for IvyProbe");
      System.out.println(((bus.waitForClient("IVYPROBE" , PORT_TEST)) != null) ? "Ivyprobe joined the bus" : "nobody came");
      System.out.println("random values: " + bus.getWBUId() + ", " + bus.getWBUId() + ", " + bus.getWBUId());
      bus.stop();
    } catch (IvyException ie) {
      System.out.println("Ivy main test error");
      ie.printStackTrace();
    }
  }

}