@Test public void testSubTwoTabAndMatchTwo() { String tags[] = {"jueyin1", "jueyin2"}; String subExpress = String.format("%s||%s", tags[0], tags[1]); int msgSize = 10; TagMessage tagMessage = new TagMessage(tags, topic, msgSize); RMQNormalConsumer consumer = getConsumer(nsAddr, topic, subExpress, new RMQNormalListener()); producer.send(tagMessage.getMixedTagMessages()); Assert.assertEquals("Not all sent succeeded", msgSize * tags.length, producer.getAllUndupMsgBody().size()); consumer.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody())) .containsExactlyElementsIn(tagMessage.getAllTagMessageBody()); }
@Test public void testTwoConsumerOneMatchOneOtherMatchAll() { String tags[] = {"jueyin1", "jueyin2"}; String sub1 = String.format("%s||%s", tags[0], tags[1]); String sub2 = String.format("%s|| noExist", tags[0]); int msgSize = 10; TagMessage tagMessage = new TagMessage(tags, topic, msgSize); RMQNormalConsumer consumerTag1 = getConsumer(nsAddr, topic, sub1, new RMQNormalListener()); RMQNormalConsumer consumerTag2 = getConsumer(nsAddr, topic, sub2, new RMQNormalListener()); List<Object> tagMsgs = tagMessage.getMixedTagMessages(); producer.send(tagMsgs); Assert.assertEquals("Not all are sent", msgSize * tags.length, producer.getAllUndupMsgBody().size()); consumerTag1.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags), consumeTime); consumerTag2.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumerTag1.getListener().getAllMsgBody())) .containsExactlyElementsIn(tagMessage.getAllTagMessageBody()); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumerTag2.getListener().getAllMsgBody())) .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0])); }
consumeTime); consumerSubAll.getListener().waitForMessageConsume( MQMessageFactory.getMessage(msgsWithNoTag, tagMessage.getAllTagMessageBody()), consumeTime); .containsExactlyElementsIn(tagMessage.getAllTagMessageBody()); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumerSubTwoMachieOne.getListener().getAllMsgBody())) consumerSubAll.getListener().getAllMsgBody())) .containsExactlyElementsIn(MQMessageFactory.getMessage(msgsWithNoTag, tagMessage.getAllTagMessageBody()));
@Test public void testSubTwoTabAndMatchTwo() { String tags[] = {"jueyin1", "jueyin2"}; String subExpress = String.format("%s||%s", tags[0], tags[1]); int msgSize = 10; TagMessage tagMessage = new TagMessage(tags, topic, msgSize); RMQNormalConsumer consumer = getConsumer(nsAddr, topic, subExpress, new RMQNormalListener()); producer.send(tagMessage.getMixedTagMessages()); Assert.assertEquals("Not all sent succeeded", msgSize * tags.length, producer.getAllUndupMsgBody().size()); consumer.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody())) .containsExactlyElementsIn(tagMessage.getAllTagMessageBody()); }
@Test public void testTwoConsumerOneMatchOneOtherMatchAll() { String tags[] = {"jueyin1", "jueyin2"}; String sub1 = String.format("%s||%s", tags[0], tags[1]); String sub2 = String.format("%s|| noExist", tags[0]); int msgSize = 10; TagMessage tagMessage = new TagMessage(tags, topic, msgSize); RMQNormalConsumer consumerTag1 = getConsumer(nsAddr, topic, sub1, new RMQNormalListener()); RMQNormalConsumer consumerTag2 = getConsumer(nsAddr, topic, sub2, new RMQNormalListener()); List<Object> tagMsgs = tagMessage.getMixedTagMessages(); producer.send(tagMsgs); Assert.assertEquals("Not all are sent", msgSize * tags.length, producer.getAllUndupMsgBody().size()); consumerTag1.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags), consumeTime); consumerTag2.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumerTag1.getListener().getAllMsgBody())) .containsExactlyElementsIn(tagMessage.getAllTagMessageBody()); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumerTag2.getListener().getAllMsgBody())) .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0])); }
consumeTime); consumerSubAll.getListener().waitForMessageConsume( MQMessageFactory.getMessage(msgsWithNoTag, tagMessage.getAllTagMessageBody()), consumeTime); .containsExactlyElementsIn(tagMessage.getAllTagMessageBody()); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumerSubTwoMachieOne.getListener().getAllMsgBody())) consumerSubAll.getListener().getAllMsgBody())) .containsExactlyElementsIn(MQMessageFactory.getMessage(msgsWithNoTag, tagMessage.getAllTagMessageBody()));