Package com.taobao.metamorphosis

Examples of com.taobao.metamorphosis.Message


    @Test
    public void testAsyncSendMessageMessage() throws MetaClientException, NotifyRemotingException {
        String topic = "test-topic";
        Partition partition = new Partition(0, 0);
        String serverUrl = "meta://127.0.0.1:8123";
        Message message = new Message(topic, "test".getBytes());
        EasyMock.resetToNice(remotingClient);
        EasyMock.expect(producerZooKeeper.selectPartition(topic, message, partitionSelector)).andReturn(partition);
        EasyMock.expect(producerZooKeeper.selectBroker(topic, partition)).andReturn(serverUrl);
        OpaqueGenerator.resetOpaque();
        mocksControl.replay();
View Full Code Here


    }


    @Test
    public void testAsyncSendMessageMessageLongTimeUnit_producerShutdown() throws MetaClientException {
        Message message = new Message("test-topic", "test".getBytes());
        messageSessionFactory.removeChild(producer);
        EasyMock.expectLastCall();
        EasyMock.replay();
        producer.shutdown();
        producer.asyncSendMessage(message, 10000, TimeUnit.MILLISECONDS);
View Full Code Here

    }


    @Test
    public void testAsyncSendMessageMessageLongTimeUnit_InvalidMessage() throws MetaClientException {
        producer.asyncSendMessage(new Message("", "test".getBytes()), 10000, TimeUnit.MILLISECONDS);
        producer.asyncSendMessage(new Message("  ", "test".getBytes()), 10000, TimeUnit.MILLISECONDS);
        producer.asyncSendMessage(new Message(null, "test".getBytes()), 10000, TimeUnit.MILLISECONDS);
    }
View Full Code Here

    @Test
    public void testAsyncSendMessageMessageLongTimeUnit_MetaClientException() throws Exception {

        String topic = "test-topic";
        Message message = new Message(topic, "test".getBytes());

        EasyMock.expect(producerZooKeeper.selectPartition(topic, message, partitionSelector)).andReturn(null);
        EasyMock.expect(processor.handle(message)).andReturn(true);
        mocksControl.replay();
        producer.asyncSendMessage(message, 10000, TimeUnit.MILLISECONDS);
View Full Code Here

    @Test
    public void testHandle() throws Exception {
        String topic = "test-topic";
        Partition partition = new Partition(0, 0);
        String serverUrl = "meta://127.0.0.1:8123";
        Message message = new Message(topic, "test".getBytes());
        EasyMock.resetToNice(remotingClient);
        EasyMock.expect(producerZooKeeper.selectPartition(topic, message, partitionSelector)).andReturn(partition);
        EasyMock.expect(producerZooKeeper.selectBroker(topic, partition)).andReturn(serverUrl);
        OpaqueGenerator.resetOpaque();
        mocksControl.replay();
View Full Code Here

                }
            }).completeSubscribe();

            this.producer.publish(this.topic);
            for (int i = 0; i < sentCount; i++) {
                if (!this.producer.sendMessage(new Message(this.topic, String.valueOf(i).getBytes())).isSuccess()) {
                    throw new RuntimeException("Send message failed");
                }
            }

            while (counter.get() < 2 * sentCount) {
View Full Code Here

    @Test
    public void testGetPartition_normal() throws MetaClientException {
        // �������

        Message message = this.createDefaultMessage();
        Partition partition =
                this.selector.getPartition(message.getTopic(),
                    Arrays.asList(new Partition("0-0"), new Partition("0-1"), new Partition("1-0")), message);
        Assert.assertEquals(new Partition("0-0"), partition);
    }
View Full Code Here

    @Test(expected = MetaClientException.class)
    public void testGetPartition_configPartitionsNull() throws MetaClientException {
        // ����������Ϊnull
        this.selector.setConfigPartitions(null);
        Message message = this.createDefaultMessage();
        this.selector.getPartition(message.getTopic(),
            Arrays.asList(new Partition("0-0"), new Partition("0-1"), new Partition("1-0")), message);
    }
View Full Code Here

    public void testGetPartition_configPartitionsEmpty() throws MetaClientException {
        // ����������Ϊ��
        Map<String, List<Partition>> map = new HashMap<String, List<Partition>>();
        map.put(testTopic, new ArrayList<Partition>());
        this.selector.setConfigPartitions(map);
        Message message = this.createDefaultMessage();
        this.selector.getPartition(message.getTopic(),
            Arrays.asList(new Partition("0-0"), new Partition("0-1"), new Partition("1-0")), message);
    }
View Full Code Here


    @Test(expected = AvailablePartitionNumException.class)
    public void testGetPartition_availablePartitionsNull() throws MetaClientException {
        // ���÷���sΪnull
        Message message = this.createDefaultMessage();
        this.selector.getPartition(message.getTopic(), null, message);
    }
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.