/** * In this method we just test a sender and receiver with acknowledgements 1. Create consumer * client with duplicate acknowledge mode 2. Publisher sends {@link #SEND_COUNT} messages. 3. * Consumer will receive {@link #EXPECTED_COUNT} or more messages. * * @throws AndesClientConfigurationException * @throws JMSException * @throws NamingException * @throws IOException * @throws AndesClientException */ @Test( groups = {"wso2.mb", "queue"}, description = "Single queue send-receive test case with dup messages") public void duplicatesOkAcknowledgementsTest() throws AndesClientConfigurationException, JMSException, NamingException, IOException, AndesClientException, XPathExpressionException { // Creating a initial JMS consumer client configuration AndesJMSConsumerClientConfiguration consumerConfig = new AndesJMSConsumerClientConfiguration( getAMQPPort(), ExchangeType.QUEUE, "dupOkAckTestQueue"); consumerConfig.setMaximumMessagesToReceived(EXPECTED_COUNT); consumerConfig.setAcknowledgeMode(JMSAcknowledgeMode.DUPS_OK_ACKNOWLEDGE); consumerConfig.setPrintsPerMessageCount(EXPECTED_COUNT / 10L); consumerConfig.setAsync(false); AndesJMSPublisherClientConfiguration publisherConfig = new AndesJMSPublisherClientConfiguration( getAMQPPort(), ExchangeType.QUEUE, "dupOkAckTestQueue"); publisherConfig.setNumberOfMessagesToSend(SEND_COUNT); publisherConfig.setPrintsPerMessageCount(EXPECTED_COUNT / 10L); // Creating clients AndesClient consumerClient = new AndesClient(consumerConfig, true); consumerClient.startClient(); AndesClient publisherClient = new AndesClient(publisherConfig, true); publisherClient.startClient(); AndesClientUtils.sleepForInterval(5000); AndesClientUtils.waitForMessagesAndShutdown( consumerClient, AndesClientConstants.DEFAULT_RUN_TIME); // Evaluating Assert.assertEquals(publisherClient.getSentMessageCount(), SEND_COUNT, "Message send failed"); Assert.assertTrue( consumerClient.getReceivedMessageCount() >= EXPECTED_COUNT, "The number of received messages should be equal or more than the amount sent"); }
/** * Create with sub id= x topic=y to node 'mb002'. Publish from 'mb003'. * * @throws JMSException * @throws NamingException * @throws AndesClientConfigurationException * @throws IOException * @throws AndesClientException */ @Test( groups = "wso2.mb", description = "Reconnect to topic with same sub ID after " + "disconnecting", enabled = true) @Parameters({"messageCount"}) public void subscribeDisconnectAndSubscribeAgainTest(long messageCount) throws JMSException, NamingException, AndesClientConfigurationException, IOException, AndesClientException { long sendCount = messageCount; long expectedCount = messageCount; // Creating configurations AndesJMSConsumerClientConfiguration consumerConfig = new AndesJMSConsumerClientConfiguration( hostNode1, portInNode1, ExchangeType.TOPIC, "durableTopicPublishing1"); consumerConfig.setDurable(true, "durableTopicPublisherID1"); AndesJMSPublisherClientConfiguration publisherConfig = new AndesJMSPublisherClientConfiguration( hostNode2, portInNode2, ExchangeType.TOPIC, "durableTopicPublishing1"); publisherConfig.setNumberOfMessagesToSend(sendCount); publisherConfig.setPrintsPerMessageCount(sendCount / 10L); // Creating clients AndesClient consumerClient = new AndesClient(consumerConfig, true); consumerClient.startClient(); AndesClient publisherClient = new AndesClient(publisherConfig, true); publisherClient.startClient(); AndesClientUtils.waitForMessagesAndShutdown( consumerClient, AndesClientConstants.DEFAULT_RUN_TIME); // Evaluating Assert.assertEquals( publisherClient.getSentMessageCount(), sendCount, "Message sending failed."); Assert.assertEquals( consumerClient.getReceivedMessageCount(), expectedCount, "Message receiving failed."); }
/** * Prepare environment for tests * * @throws XPathExpressionException */ @BeforeClass public void prepare() throws XPathExpressionException { super.init(TestUserMode.SUPER_TENANT_USER); AndesClientUtils.sleepForInterval(1000); }