@Test
    public void testReceiving() {
        ZContext ctx = new ZContext();
        Socket output = ctx.createSocket(ZMQ.PAIR);
        output.bind("inproc://zframe.test");
        Socket input = ctx.createSocket(ZMQ.PAIR);
        input.connect("inproc://zframe.test");

        // Send same frame five times
        ZFrame f = new ZFrame("Hello".getBytes());
        for (int i = 0; i < 5; i++) {
            f.sendAndKeep(output, ZMQ.SNDMORE);
        }

        // Send END frame
        f = new ZFrame("NOT".getBytes());
        f.reset("END".getBytes());
        assertEquals("454E44", f.strhex());
        f.sendAndDestroy(output);

        // Read and count until we receive END
        int frame_nbr = 0;
        while (true) {
            f = ZFrame.recvFrame(input);
            frame_nbr++;
            if (f.streq("END")) {
                f.destroy();
                break;
            }
        }
        assertEquals(6, frame_nbr);
        f = ZFrame.recvFrame(input, ZMQ.DONTWAIT);
        assertTrue(!f.hasData());

        ctx.destroy();
    }