org.apache.rocketmq.test.util.RandomUtils Java Examples

The following examples show how to use org.apache.rocketmq.test.util.RandomUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TagMessageWithSameGroupConsumerIT.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
@Test
public void testConsumerStartWithInterval() {
    int msgSize = 100;
    String originMsgDCName = RandomUtils.getStringByUUID();
    String msgBodyDCName = RandomUtils.getStringByUUID();

    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, tag,
        new RMQNormalListener(originMsgDCName, msgBodyDCName));
    producer.send(tag, msgSize, 100);
    TestUtils.waitForMoment(5);
    getConsumer(nsAddr, consumer1.getConsumerGroup(), tag,
        new RMQNormalListener(originMsgDCName, msgBodyDCName));
    TestUtils.waitForMoment(5);

    consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #2
Source File: TagMessageWithSameGroupConsumerIT.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
@Test
public void testConsumerStartTwoAndCrashOneAfterWhile() {
    int msgSize = 100;
    String originMsgDCName = RandomUtils.getStringByUUID();
    String msgBodyDCName = RandomUtils.getStringByUUID();

    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, tag,
        new RMQNormalListener(originMsgDCName, msgBodyDCName));
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), tag,
        new RMQNormalListener(originMsgDCName, msgBodyDCName));

    producer.send(tag, msgSize, 100);
    TestUtils.waitForMoment(5);
    consumer2.shutdown();
    mqClients.remove(1);
    TestUtils.waitForMoment(5);

    consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #3
Source File: TagMessageWithSameGroupConsumerIT.java    From rocketmq_trans_message with Apache License 2.0 6 votes vote down vote up
@Test
public void testConsumerStartTwoAndCrashOnsAfterWhile() {
    String tag = "jueyin";
    int msgSize = 100;
    String originMsgDCName = RandomUtils.getStringByUUID();
    String msgBodyDCName = RandomUtils.getStringByUUID();

    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, tag,
        new RMQNormalListner(originMsgDCName, msgBodyDCName));
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), tag,
        new RMQNormalListner(originMsgDCName, msgBodyDCName));

    producer.send(tag, msgSize, 100);
    TestUtils.waitForMonment(5);
    consumer2.shutdown();
    mqClients.remove(1);
    TestUtils.waitForMonment(5);

    consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #4
Source File: TagMessageWithSameGroupConsumerIT.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
@Test
public void testConsumerStartTwoAndCrashOneAfterWhile() {
    int msgSize = 100;
    String originMsgDCName = RandomUtils.getStringByUUID();
    String msgBodyDCName = RandomUtils.getStringByUUID();

    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, tag,
        new RMQNormalListner(originMsgDCName, msgBodyDCName));
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), tag,
        new RMQNormalListner(originMsgDCName, msgBodyDCName));

    producer.send(tag, msgSize, 100);
    TestUtils.waitForMoment(5);
    consumer2.shutdown();
    mqClients.remove(1);
    TestUtils.waitForMoment(5);

    consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #5
Source File: BatchSendIT.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Test
public void testBatchSend_ViewMessage() throws Exception {
    List<Message> messageList = new ArrayList<>();
    int batchNum = 100;
    for (int i = 0; i < batchNum; i++) {
        messageList.add(new Message(topic, RandomUtils.getStringByUUID().getBytes()));
    }

    DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr);
    SendResult sendResult = producer.send(messageList);
    Assert.assertEquals(SendStatus.SEND_OK, sendResult.getSendStatus());

    String[] offsetIds = sendResult.getOffsetMsgId().split(",");
    String[] msgIds = sendResult.getMsgId().split(",");
    Assert.assertEquals(messageList.size(), offsetIds.length);
    Assert.assertEquals(messageList.size(), msgIds.length);

    Thread.sleep(2000);

    for (int i = 0; i < 3; i++) {
        producer.viewMessage(offsetIds[random.nextInt(batchNum)]);
    }
    for (int i = 0; i < 3; i++) {
        producer.viewMessage(topic, msgIds[random.nextInt(batchNum)]);
    }
}
 
Example #6
Source File: TagMessageWithSameGroupConsumerIT.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Test
public void testConsumerStartTwoAndCrashOneAfterWhile() {
    int msgSize = 100;
    String originMsgDCName = RandomUtils.getStringByUUID();
    String msgBodyDCName = RandomUtils.getStringByUUID();

    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, tag,
        new RMQNormalListener(originMsgDCName, msgBodyDCName));
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), tag,
        new RMQNormalListener(originMsgDCName, msgBodyDCName));

    producer.send(tag, msgSize, 100);
    TestUtils.waitForMoment(5);
    consumer2.shutdown();
    mqClients.remove(1);
    TestUtils.waitForMoment(5);

    consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #7
Source File: TagMessageWithSameGroupConsumerIT.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
@Test
public void testConsumerStartWithInterval() {
    int msgSize = 100;
    String originMsgDCName = RandomUtils.getStringByUUID();
    String msgBodyDCName = RandomUtils.getStringByUUID();

    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, tag,
        new RMQNormalListener(originMsgDCName, msgBodyDCName));
    producer.send(tag, msgSize, 100);
    TestUtils.waitForMoment(5);
    getConsumer(nsAddr, consumer1.getConsumerGroup(), tag,
        new RMQNormalListener(originMsgDCName, msgBodyDCName));
    TestUtils.waitForMoment(5);

    consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #8
Source File: TagMessageWithSameGroupConsumerIT.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
@Test
public void testTwoConsumerWithSameGroup() {
    int msgSize = 20;
    String originMsgDCName = RandomUtils.getStringByUUID();
    String msgBodyDCName = RandomUtils.getStringByUUID();
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, tag,
        new RMQNormalListener(originMsgDCName, msgBodyDCName));
    getConsumer(nsAddr, consumer1.getConsumerGroup(), tag,
        new RMQNormalListener(originMsgDCName, msgBodyDCName));
    producer.send(tag, msgSize);
    Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size());
    consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #9
Source File: TagMessageWithSameGroupConsumerIT.java    From rocketmq_trans_message with Apache License 2.0 6 votes vote down vote up
@Test
public void testConsumerStartWithInterval() {
    String tag = "jueyin";
    int msgSize = 100;
    String originMsgDCName = RandomUtils.getStringByUUID();
    String msgBodyDCName = RandomUtils.getStringByUUID();

    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, tag,
        new RMQNormalListner(originMsgDCName, msgBodyDCName));
    producer.send(tag, msgSize, 100);
    TestUtils.waitForMonment(5);
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), tag,
        new RMQNormalListner(originMsgDCName, msgBodyDCName));
    TestUtils.waitForMonment(5);

    consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #10
Source File: TagMessageWithSameGroupConsumerIT.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Test
public void testTwoConsumerWithSameGroup() {
    int msgSize = 20;
    String originMsgDCName = RandomUtils.getStringByUUID();
    String msgBodyDCName = RandomUtils.getStringByUUID();
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, tag,
        new RMQNormalListener(originMsgDCName, msgBodyDCName));
    getConsumer(nsAddr, consumer1.getConsumerGroup(), tag,
        new RMQNormalListener(originMsgDCName, msgBodyDCName));
    producer.send(tag, msgSize);
    Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size());
    consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #11
Source File: TagMessageWithSameGroupConsumerIT.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Test
public void testTwoConsumerWithSameGroup() {
    int msgSize = 20;
    String originMsgDCName = RandomUtils.getStringByUUID();
    String msgBodyDCName = RandomUtils.getStringByUUID();
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, tag,
        new RMQNormalListener(originMsgDCName, msgBodyDCName));
    getConsumer(nsAddr, consumer1.getConsumerGroup(), tag,
        new RMQNormalListener(originMsgDCName, msgBodyDCName));
    producer.send(tag, msgSize);
    Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size());
    consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #12
Source File: BatchSendIT.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
@Test
public void testBatchSend_ViewMessage() throws Exception {
    List<Message> messageList = new ArrayList<>();
    int batchNum = 100;
    for (int i = 0; i < batchNum; i++) {
        messageList.add(new Message(topic, RandomUtils.getStringByUUID().getBytes()));
    }

    DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr);
    SendResult sendResult = producer.send(messageList);
    Assert.assertEquals(SendStatus.SEND_OK, sendResult.getSendStatus());

    String[] offsetIds = sendResult.getOffsetMsgId().split(",");
    String[] msgIds = sendResult.getMsgId().split(",");
    Assert.assertEquals(messageList.size(), offsetIds.length);
    Assert.assertEquals(messageList.size(), msgIds.length);

    Thread.sleep(2000);

    for (int i = 0; i < 3; i++) {
        producer.viewMessage(offsetIds[random.nextInt(batchNum)]);
    }
    for (int i = 0; i < 3; i++) {
        producer.viewMessage(topic, msgIds[random.nextInt(batchNum)]);
    }
}
 
Example #13
Source File: TagMessageWithSameGroupConsumerIT.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Test
public void testConsumerStartWithInterval() {
    int msgSize = 100;
    String originMsgDCName = RandomUtils.getStringByUUID();
    String msgBodyDCName = RandomUtils.getStringByUUID();

    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, tag,
        new RMQNormalListener(originMsgDCName, msgBodyDCName));
    producer.send(tag, msgSize, 100);
    TestUtils.waitForMoment(5);
    getConsumer(nsAddr, consumer1.getConsumerGroup(), tag,
        new RMQNormalListener(originMsgDCName, msgBodyDCName));
    TestUtils.waitForMoment(5);

    consumer1.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #14
Source File: TagMessageWithSameGroupConsumerIT.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testConsumerStartWithInterval() {
    String tag = "jueyin";
    int msgSize = 100;
    String originMsgDCName = RandomUtils.getStringByUUID();
    String msgBodyDCName = RandomUtils.getStringByUUID();

    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, tag,
        new RMQNormalListner(originMsgDCName, msgBodyDCName));
    producer.send(tag, msgSize, 100);
    TestUtils.waitForMonment(5);
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), tag,
        new RMQNormalListner(originMsgDCName, msgBodyDCName));
    TestUtils.waitForMonment(5);

    consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #15
Source File: TagMessageWithSameGroupConsumerIT.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testTwoConsumerWithSameGroup() {
    String tag = "jueyin";
    int msgSize = 20;
    String originMsgDCName = RandomUtils.getStringByUUID();
    String msgBodyDCName = RandomUtils.getStringByUUID();
    RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, tag,
        new RMQNormalListner(originMsgDCName, msgBodyDCName));
    RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), tag,
        new RMQNormalListner(originMsgDCName, msgBodyDCName));
    producer.send(tag, msgSize);
    Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size());
    consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumer1.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(producer.getAllMsgBody());
}
 
Example #16
Source File: AsyncSendExceptionIT.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
@Test
public void testSendCallBackNull() throws Exception {
    Message msg = new Message(topic, RandomUtils.getStringByUUID().getBytes());
    DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr);
    SendCallback sendCallback = null;
    producer.send(msg, sendCallback);
}
 
Example #17
Source File: OneWaySendExceptionIT.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
@Test(expected = java.lang.NullPointerException.class)
public void testSendMQNull() throws Exception {
    Message msg = new Message(topic, RandomUtils.getStringByUUID().getBytes());
    DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr);
    MessageQueue messageQueue = null;
    producer.sendOneway(msg, messageQueue);
}
 
Example #18
Source File: AsyncSendExceptionIT.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
@Test
public void testQueueIdBigThanQueueNum() throws Exception {
    int queueId = 100;
    sendFail = false;
    MessageQueue mq = new MessageQueue(topic, broker1Name, queueId);
    Message msg = new Message(topic, RandomUtils.getStringByUUID().getBytes());
    DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr);

    producer.send(msg, mq, new SendCallback() {
        @Override
        public void onSuccess(SendResult sendResult) {
        }

        @Override
        public void onException(Throwable throwable) {
            sendFail = true;
        }
    });

    int checkNum = 50;
    while (!sendFail && checkNum > 0) {
        checkNum--;
        TestUtils.waitForMoment(100);
    }
    producer.shutdown();
    assertThat(sendFail).isEqualTo(true);
}
 
Example #19
Source File: OneWaySendExceptionIT.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
@Test(expected = org.apache.rocketmq.client.exception.MQClientException.class)
public void testSelectorThrowsException() throws Exception {
    Message msg = new Message(topic, RandomUtils.getStringByUUID().getBytes());
    DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr);
    producer.sendOneway(msg, new MessageQueueSelector() {
        @Override
        public MessageQueue select(List<MessageQueue> list, Message message, Object o) {
            String str = null;
            return list.get(str.length());
        }
    }, null);
}
 
Example #20
Source File: ProducerGroupAndInstanceNameValidityIT.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
/**
 * @since version3.4.6
 */
@Test
public void testTwoProducerSameGroup() {
    RMQNormalProducer producer1 = getProducer(nsAddr, topic);
    assertThat(producer1.isStartSuccess()).isEqualTo(true);
    RMQNormalProducer producer2 = getProducer(nsAddr, topic,
        producer1.getProducerGroupName(), RandomUtils.getStringByUUID());
    assertThat(producer2.isStartSuccess()).isEqualTo(true);
}
 
Example #21
Source File: AsyncSendExceptionIT.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
@Test
public void testSendCallBackNull() throws Exception {
    Message msg = new Message(topic, RandomUtils.getStringByUUID().getBytes());
    DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr);
    SendCallback sendCallback = null;
    producer.send(msg, sendCallback);
}
 
Example #22
Source File: AsyncSendExceptionIT.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
@Test
public void testQueueIdSmallZero() throws Exception {
    int queueId = -100;
    sendFail = true;
    MessageQueue mq = new MessageQueue(topic, broker1Name, queueId);
    Message msg = new Message(topic, RandomUtils.getStringByUUID().getBytes());
    DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr);

    producer.send(msg, mq, new SendCallback() {
        @Override
        public void onSuccess(SendResult sendResult) {
            sendFail = false;
        }

        @Override
        public void onException(Throwable throwable) {
            sendFail = true;
        }
    });

    int checkNum = 50;
    while (sendFail && checkNum > 0) {
        checkNum--;
        TestUtils.waitForMoment(100);
    }
    producer.shutdown();
    assertThat(sendFail).isEqualTo(false);
}
 
Example #23
Source File: OneWaySendExceptionIT.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
@Test(expected = org.apache.rocketmq.client.exception.MQClientException.class)
public void testSendSelectorNull() throws Exception {
    Message msg = new Message(topic, RandomUtils.getStringByUUID().getBytes());
    DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr);
    MessageQueueSelector selector = null;
    producer.sendOneway(msg, selector, 100);
}
 
Example #24
Source File: AsyncSendExceptionIT.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
@Test
public void testSendSelectorNull() throws Exception {
    Message msg = new Message(topic, RandomUtils.getStringByUUID().getBytes());
    DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr);
    MessageQueueSelector selector = null;
    producer.send(msg, selector, 100, SendCallBackFactory.getSendCallBack());
}
 
Example #25
Source File: MessageExceptionIT.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Test
public void testSendMsgWithUserProperty() {
    Message msg = MessageFactory.getRandomMessage(topic);
    msg.putUserProperty("key", RandomUtils.getCheseWord(10 * 1024));
    SendResult sendResult = null;
    try {
        sendResult = producer.send(msg);
    } catch (Exception e) {
    }
    assertThat(sendResult.getSendStatus()).isEqualTo(SendStatus.SEND_OK);
}
 
Example #26
Source File: AsyncSendExceptionIT.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
@Test
public void testSendCallBackNull() throws Exception {
    Message msg = new Message(topic, RandomUtils.getStringByUUID().getBytes());
    DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr);
    SendCallback sendCallback = null;
    producer.send(msg, sendCallback);
}
 
Example #27
Source File: AsyncSendExceptionIT.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Test(expected = java.lang.NullPointerException.class)
public void testSendMQNull() throws Exception {
    Message msg = new Message(topic, RandomUtils.getStringByUUID().getBytes());
    DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr);
    MessageQueue messageQueue = null;
    producer.send(msg, messageQueue, SendCallBackFactory.getSendCallBack());
}
 
Example #28
Source File: OneWaySendExceptionIT.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
@Test(expected = java.lang.NullPointerException.class)
public void testSendMQNull() throws Exception {
    Message msg = new Message(topic, RandomUtils.getStringByUUID().getBytes());
    DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr);
    MessageQueue messageQueue = null;
    producer.sendOneway(msg, messageQueue);
}
 
Example #29
Source File: AsyncSendExceptionIT.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
@Test(expected = java.lang.NullPointerException.class)
public void testSendMQNull() throws Exception {
    Message msg = new Message(topic, RandomUtils.getStringByUUID().getBytes());
    DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr);
    MessageQueue messageQueue = null;
    producer.send(msg, messageQueue, SendCallBackFactory.getSendCallBack());
}
 
Example #30
Source File: MessageExceptionIT.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
@Test
public void testSendMsgWithUserProperty() {
    Message msg = MessageFactory.getRandomMessage(topic);
    msg.putUserProperty("key", RandomUtils.getCheseWord(10 * 1024));
    SendResult sendResult = null;
    try {
        sendResult = producer.send(msg);
    } catch (Exception e) {
    }
    assertThat(sendResult.getSendStatus()).isEqualTo(SendStatus.SEND_OK);
}