Package com.taobao.metamorphosis.consumer

Examples of com.taobao.metamorphosis.consumer.MessageIterator


    }


    @Test
    public void testHasNext_End() {
        this.it = new MessageIterator("test", new byte[16]);
        this.it.setOffset(16);
        assertFalse(this.it.hasNext());
    }
View Full Code Here


    }


    @Test
    public void testHasNext_Over() {
        this.it = new MessageIterator("test", new byte[16]);
        this.it.setOffset(17);
        assertFalse(this.it.hasNext());
    }
View Full Code Here

    }


    @Test
    public void testIteratorAsKey() {
        this.it = new MessageIterator("test", new byte[16]);
        final Map<MessageIterator, Integer> map = new HashMap<MessageIterator, Integer>();
        assertNull(map.get(this.it));
        map.put(this.it, 100);
        assertEquals((Integer) 100, map.get(this.it));
    }
View Full Code Here

    }


    @Test(expected = UnsupportedOperationException.class)
    public void tsetRemove() {
        this.it = new MessageIterator("test", new byte[16]);
        this.it.remove();
    }
View Full Code Here

    }


    @Test
    public void testHasNext_HeaderNotComplete() {
        this.it = new MessageIterator("test", new byte[16]);
        assertFalse(this.it.hasNext());
    }
View Full Code Here

    @Test
    public void testHasNext_NotEnoughPayload() {
        final ByteBuffer buf = ByteBuffer.allocate(MessageUtils.HEADER_LEN);
        buf.putInt(20);// msg length

        this.it = new MessageIterator("test", buf.array());
        assertFalse(this.it.hasNext());
    }
View Full Code Here

    public void testHasNext_true() {
        final ByteBuffer buf = ByteBuffer.allocate(MessageUtils.HEADER_LEN + 4);
        buf.putInt(4);// msg length
        buf.position(20);
        buf.putInt(99); // payload
        this.it = new MessageIterator("test", buf.array());
        assertTrue(this.it.hasNext());
    }
View Full Code Here

        buf.putInt(5);// msg length
        buf.putInt(CheckSum.crc32("hello".getBytes())); // checksum

        buf.position(MessageUtils.HEADER_LEN);
        buf.put("world".getBytes());
        this.it = new MessageIterator("test", buf.array());
        assertTrue(this.it.hasNext());
        this.it.next();

    }
View Full Code Here

        buf.putLong(9999); // id
        buf.putInt(0); // flag

        buf.position(MessageUtils.HEADER_LEN);
        buf.put("hello".getBytes());
        this.it = new MessageIterator("test", buf.array());
        assertTrue(this.it.hasNext());
        final Message msg = this.it.next();
        assertNotNull(msg);
        assertEquals(9999L, msg.getId());
        assertEquals("test", msg.getTopic());
View Full Code Here

        buf.putLong(9999); // id
        buf.putInt(1); // flag
        buf.position(MessageUtils.HEADER_LEN);
        buf.put(dataBuf);

        this.it = new MessageIterator("test", buf.array());
        assertTrue(this.it.hasNext());
        final Message msg = this.it.next();
        assertNotNull(msg);
        assertEquals(9999L, msg.getId());
        assertEquals("test", msg.getTopic());
View Full Code Here

TOP

Related Classes of com.taobao.metamorphosis.consumer.MessageIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.