Package com.taobao.metamorphosis

Examples of com.taobao.metamorphosis.Message


    @Test
    public void testEncodeData_HasAttribute() throws Exception {
        final String topic = "topic1";
        final byte[] data = "hello".getBytes();
        final String attribute = "attribute";
        final Message message = new Message(topic, data, attribute);
        final byte[] encoded = MessageUtils.encodePayload(message);
        assertEquals(4 + attribute.length() + data.length, encoded.length);
        assertEquals(attribute.length(), MessageUtils.getInt(0, encoded));
        assertEquals(attribute, new String(encoded, 4, attribute.length()));
        assertEquals("hello", new String(encoded, 4 + attribute.length(), data.length));
View Full Code Here


    @Test
    public void testEncodeData_EmptyAttribute() throws Exception {
        final String topic = "topic1";
        final byte[] data = "hello".getBytes();
        final String attribute = "";
        final Message message = new Message(topic, data, attribute);
        final byte[] encoded = MessageUtils.encodePayload(message);
        assertEquals(4 + attribute.length() + data.length, encoded.length);
        assertEquals(attribute.length(), MessageUtils.getInt(0, encoded));
        assertEquals(attribute, new String(encoded, 4, attribute.length()));
        assertEquals("hello", new String(encoded, 4 + attribute.length(), data.length));
View Full Code Here

            public Executor getExecutor() {
                return null;
            }
        }, null);
        for (int i = 0; i < 100; i++) {
            final Message msg2 = new Message("test", ("hello" + i).getBytes());
            MessageAccessor.setId(msg2, i);
            this.recoverStorageManager.append(group, msg2);
        }
        this.recoverStorageManager.shutdown();
View Full Code Here

            public Executor getExecutor() {
                return null;
            }
        }, null);
        for (int i = 0; i < 100; i++) {
            final Message msg2 = new Message("test", ("hello" + i).getBytes());
            MessageAccessor.setId(msg2, i);
            this.recoverStorageManager.append(group, msg2);
        }

        while (queue.size() < 100) {
View Full Code Here

    }


    @Test
    public void testAppendDupKey2() throws Exception {
        final Message msg1 = new Message("test", "hello".getBytes());
        MessageAccessor.setId(msg1, 1);
        this.recoverStorageManager.append("group", msg1);
        this.recoverStorageManager.append("group", msg1);
        this.recoverStorageManager.append("group", msg1);
        this.recoverStorageManager.append("group", msg1);
View Full Code Here

    private Message msg = null;


    @Before
    public void setUp() {
        this.msg = new Message("CodecUnitTest", "hello world".getBytes());
        this.msg.setAttribute("test attribute");
    }
View Full Code Here

    @Test
    public void testJavaDecoder() throws Exception {
        final Serializer encoder = CodecBuilder.buildSerializer(Codec_Type.JAVA);
        final Deserializer decoder = CodecBuilder.buildDeserializer(Codec_Type.JAVA);
        final byte buf[] = encoder.encodeObject(this.msg);
        final Message entity1 = (Message) decoder.decodeObject(buf);

        Assert.assertEquals(this.msg, entity1);
    }
View Full Code Here

    public void testHessianDecoder() throws Exception {
        final Deserializer decoder = CodecBuilder.buildDeserializer(Codec_Type.HESSIAN1);
        final Serializer encoder = CodecBuilder.buildSerializer(Codec_Type.HESSIAN1);

        final byte buf[] = encoder.encodeObject(this.msg);
        final Message entity1 = (Message) decoder.decodeObject(buf);

        Assert.assertEquals(this.msg, entity1);
    }
View Full Code Here


public class MessageFlagUtilsUnitTest {
    @Test
    public void testFlagWithoutAttribute() {
        final Message message = new Message("test", "hello".getBytes());
        final int flag = MessageFlagUtils.getFlag(message);

        assertFalse(MessageFlagUtils.hasAttribute(flag));

    }
View Full Code Here

    }


    @Test
    public void testFlagWithAttribute() {
        final Message message = new Message("test", "hello".getBytes(), "");
        final int flag = MessageFlagUtils.getFlag(message);

        assertTrue(MessageFlagUtils.hasAttribute(flag));

    }
View Full Code Here

TOP

Related Classes of com.taobao.metamorphosis.Message

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.