@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])); }
public TagMessage(List<String> tags, String topic, int msgSize) { this.tags = tags; this.topic = topic; this.msgSize = msgSize; init(); }
@Test public void testSubThreeTabAndMatchTwo() { String tags[] = {"jueyin1", "jueyin2", "jueyin3"}; 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( tagMessage.getMessageBodyByTag(tags[0], tags[1]), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody())).containsExactlyElementsIn( tagMessage.getMessageBodyByTag(tags[0], tags[1])); }
@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 testNoMatch() { String tags[] = {"jueyin1", "jueyin2", "jueyin3"}; String subExpress = "no_match"; 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()); TestUtils.waitForSeconds(5); assertThat(VerifyUtils .getFilterdMessage(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody()) .size()).isEqualTo(0); } }
public List<Object> getMessageBodyByTag(String... tag) { return this.getMessageBodyByTag(Arrays.asList(tag)); }
@Test public void testSendMessagesWithTwoTag() { String tags[] = {"jueyin1", "jueyin2"}; int msgSize = 10; TagMessage tagMessage = new TagMessage(tags, topic, msgSize); RMQNormalConsumer consumerTag1 = getConsumer(nsAddr, topic, tags[0], new RMQNormalListener()); RMQNormalConsumer consumerTag2 = getConsumer(nsAddr, topic, tags[1], 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[0]), consumeTime); consumerTag2.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[1]), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumerTag1.getListener().getAllMsgBody())) .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0])); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumerTag2.getListener().getAllMsgBody())) .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[1])); }
@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 testNoMatch() { String tags[] = {"jueyin1", "jueyin2", "jueyin3"}; String subExpress = "no_match"; 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()); TestUtils.waitForSeconds(5); assertThat(VerifyUtils .getFilterdMessage(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody()) .size()).isEqualTo(0); } }
public List<Object> getMessageBodyByTag(String... tag) { return this.getMessageBodyByTag(Arrays.asList(tag)); }
Collection<Object> msgsWithNoTag = producer.getMsgBodysCopy(); TagMessage tagMessage = new TagMessage(tags, topic, msgSize); List<Object> tagMsgs = tagMessage.getMixedTagMessages(); producer.send(tagMsgs); Assert.assertEquals("Not all are sent", msgSize * 3, producer.getAllUndupMsgBody().size()); .waitForMessageConsume(tagMessage.getMessageBodyByTag(tags), consumeTime); consumerSubTwoMachieOne.getListener() .waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]), consumeTime); consumerSubTag1.getListener().waitForMessageConsume(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())) .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0])); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumerSubTag1.getListener().getAllMsgBody())) .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0])); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumerSubAll.getListener().getAllMsgBody())) .containsExactlyElementsIn(MQMessageFactory.getMessage(msgsWithNoTag, tagMessage.getAllTagMessageBody()));
@Test public void testSubThreeTabAndMatchTwo() { String tags[] = {"jueyin1", "jueyin2", "jueyin3"}; 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( tagMessage.getMessageBodyByTag(tags[0], tags[1]), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody())).containsExactlyElementsIn( tagMessage.getMessageBodyByTag(tags[0], tags[1])); }
public TagMessage(String tag, String topic, int msgSize) { String[] tags = {tag}; this.tags = Arrays.asList(tags); this.topic = topic; this.msgSize = msgSize; init(); }
@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])); }
@Test public void testSendMessagesWithTwoTag() { String tags[] = {"jueyin1", "jueyin2"}; int msgSize = 10; TagMessage tagMessage = new TagMessage(tags, topic, msgSize); RMQNormalConsumer consumerTag1 = getConsumer(nsAddr, topic, tags[0], new RMQNormalListener()); RMQNormalConsumer consumerTag2 = getConsumer(nsAddr, topic, tags[1], 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[0]), consumeTime); consumerTag2.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[1]), consumeTime); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumerTag1.getListener().getAllMsgBody())) .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0])); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumerTag2.getListener().getAllMsgBody())) .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[1])); }
public TagMessage(List<String> tags, String topic, int msgSize) { this.tags = tags; this.topic = topic; this.msgSize = msgSize; init(); }
Collection<Object> msgsWithNoTag = producer.getMsgBodysCopy(); TagMessage tagMessage = new TagMessage(tags, topic, msgSize); List<Object> tagMsgs = tagMessage.getMixedTagMessages(); producer.send(tagMsgs); Assert.assertEquals("Not all are sent", msgSize * 3, producer.getAllUndupMsgBody().size()); .waitForMessageConsume(tagMessage.getMessageBodyByTag(tags), consumeTime); consumerSubTwoMachieOne.getListener() .waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]), consumeTime); consumerSubTag1.getListener().waitForMessageConsume(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())) .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0])); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumerSubTag1.getListener().getAllMsgBody())) .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0])); assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(), consumerSubAll.getListener().getAllMsgBody())) .containsExactlyElementsIn(MQMessageFactory.getMessage(msgsWithNoTag, tagMessage.getAllTagMessageBody()));
public TagMessage(String tag, String topic, int msgSize) { String[] tags = {tag}; this.tags = Arrays.asList(tags); this.topic = topic; this.msgSize = msgSize; init(); }