Search in sources :

Example 1 with Fortune

use of org.zeromq.ZStar.Fortune in project jeromq by zeromq.

the class TestZStar method testNoStar.

@Test
public void testNoStar() {
    System.out.print("No star: ");
    ZStar.Fortune fortune = new BlackHole();
    ZStar.Entourage entourage = new ZStar.Entourage() {

        @Override
        public void breakaleg(ZContext ctx, Fortune fortune, Socket phone, Object[] bags) {
        // Crepi il lupo!
        }

        @Override
        public void party(ZContext ctx) {
            // right now there are some random closing issues
            ZStar.party(30, TimeUnit.MILLISECONDS);
        // waited a bit here seems to arrange that.
        // no user penalty cost, the show is over.
        }
    };
    ZStar star = new ZStar(fortune, "motdelafin", Arrays.asList("TEST", entourage).toArray());
    ZMsg msg = star.recv();
    Assert.assertNull("Able to receive a message from a black hole", msg);
    boolean rc = star.sign();
    Assert.assertFalse("Able to detect the presence of a black hole", rc);
    rc = star.send("whatever");
    Assert.assertFalse("Able to send a command to a black hole", rc);
    // don't try it
    // rc = star.pipe().send("boom ?!");
    //        star.retire();
    System.out.println(".");
}
Also used : Fortune(org.zeromq.ZStar.Fortune) Fortune(org.zeromq.ZStar.Fortune) Socket(org.zeromq.ZMQ.Socket) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Socket (org.zeromq.ZMQ.Socket)1 Fortune (org.zeromq.ZStar.Fortune)1