Author: fjuma
Date: 2009-05-28 15:38:38 -0400 (Thu, 28 May 2009)
New Revision: 483
Added:
trunk/jsfunit/testdata/destinations/ListAllMessagesMultipleMessagesExistingQueue-service.xml
trunk/jsfunit/testdata/destinations/ListDurableMessagesMultipleMessagesExistingQueue-service.xml
trunk/jsfunit/testdata/destinations/ListDurableMessagesMultipleMessagesExistingTopic-service.xml
trunk/jsfunit/testdata/destinations/ListNonDurableMessagesMultipleMessagesExistingQueue-service.xml
trunk/jsfunit/testdata/destinations/ListNonDurableMessagesMultipleMessagesExistingTopic-service.xml
Modified:
trunk/jsfunit/pom.xml
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ResourceTestBase.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jmsDestinations/JMSMetricsTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jmsDestinations/JMSOperationsTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jmsDestinations/JMSTest.java
Log:
Adding tests for the "List All Messages", "List Durable Messages", and
"List Non Durable Messages" operations for Topics and Queues.
Modified: trunk/jsfunit/pom.xml
===================================================================
--- trunk/jsfunit/pom.xml 2009-05-26 22:56:25 UTC (rev 482)
+++ trunk/jsfunit/pom.xml 2009-05-28 19:38:38 UTC (rev 483)
@@ -128,6 +128,12 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>jboss.messaging</groupId>
+ <artifactId>jboss-messaging</artifactId>
+ <version>1.4.3.GA</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.jboss.javaee</groupId>
<artifactId>jboss-javaee</artifactId>
<version>5.0.1.GA</version>
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ResourceTestBase.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ResourceTestBase.java 2009-05-26
22:56:25 UTC (rev 482)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ResourceTestBase.java 2009-05-28
19:38:38 UTC (rev 483)
@@ -94,9 +94,9 @@
public static final String NO_PARAMETERS = "noParameters";
public static final String NO_RESULTS = "noResults";
public static final String OPERATION_RESULTS = "operationResults";
- public static final String REFRESH_OPERATIONS_TABLE = "refreshLink";
public static final String RESOURCE_SUMMARY_FORM = "resourceSummaryForm";
public static final String EDIT_RESOURCE_CONFIGURATION_FORM =
"editResourceConfigurationForm";
+ public static final String PARAMETERS_FORM = "parametersForm";
public static final String ERROR_MESSAGE = "errorMessage";
// Pagination constants
@@ -109,6 +109,9 @@
public static final String LIST_FORMATTED_SUB_POOL_STATISTICS = "List Formatted
Sub Pool Statistics";
public static final String LIST_STATISTICS = "List Statistics";
+ // Argument boxes on the operations parameters page
+ public static final String ARG_0 = "arg#0";
+
// Datasource and ConnectionFactory metrics
public static final String AVAILABLE_CONNECTION_COUNT = "Available Connection
Count";
public static final String CONNECTION_COUNT = "Connection Count";
@@ -291,7 +294,7 @@
String resourceSubCategory,
String resourceName,
String tabName) throws Exception {
- //refreshTreeNode(resourceCategory);
+ //refreshTreeNode(resourceCategory);
NavTreeNode resourceSubCategoryNode =
ejtt.getNavTree().getNodeByLabel(resourceSubCategory);
if(!resourceSubCategoryNode.isExpanded()) {
expandNavTreeArrow(resourceSubCategory);
@@ -333,6 +336,48 @@
waitForResourceOperationToFinish();
+ checkOperationStatus();
+ }
+
+ /**
+ * Perform the given operation on the given resource using the given
+ * parameters.
+ *
+ * performResourceOperation() assumes that the resource tree
+ * node (eg. "JMS Destinations", "Datasources", etc.) is already
+ * expanded when this method is called.
+ *
+ * @param parametersMap maps parameter names to parameter values
+ */
+ protected void performResourceOperationWithParameters(String resourceCategory,
+ String resourceSubCategory,
+ String resourceName,
+ String operationName,
+ Map<String, String>
parametersMap) throws Exception{
+
+ navigateToPage(resourceCategory, resourceSubCategory,
+ resourceName, CONTROL_TAB);
+
+ HtmlForm form = (HtmlForm)client.getElement(OPERATIONS_FORM);
+ String xpath = ".//input[@value=\"" + operationName +
"\"]";
+
+ HtmlButtonInput operationButton = (HtmlButtonInput)form.getFirstByXPath(xpath);
+ operationButton.click();
+
+ fillOutForm(parametersMap, PARAMETERS_FORM);
+ client.click(PARAMETERS_FORM_OK_BUTTON);
+
+ waitForResourceOperationToFinish();
+
+ checkOperationStatus();
+ }
+
+ /**
+ * Check the status of the latest operation. If the operation was not
+ * successful, output the error message.
+ */
+ private void checkOperationStatus() throws HtmlElementNotFoundException {
+
// Make sure the operation completed successfully
String status = getLatestOperationStatus();
@@ -354,13 +399,12 @@
*/
protected void waitForResourceOperationToFinish() throws
HtmlElementNotFoundException, IOException, InterruptedException {
- for(int i = 0; i < 10; i++) {
+ for(int i = 0; i < 20; i++) {
String status = getLatestOperationStatus();
if(status.contains(INPROGRESS)) {
Thread.sleep(100);
- client.click(REFRESH_OPERATIONS_TABLE);
} else {
// The operation has completed
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jmsDestinations/JMSMetricsTest.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jmsDestinations/JMSMetricsTest.java 2009-05-26
22:56:25 UTC (rev 482)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jmsDestinations/JMSMetricsTest.java 2009-05-28
19:38:38 UTC (rev 483)
@@ -35,6 +35,8 @@
import javax.jms.Queue;
import javax.jms.QueueSession;
import javax.jms.QueueReceiver;
+import javax.naming.InitialContext;
+import javax.jms.TopicConnectionFactory;
/**
* This class contains metrics tests for JMS topics and queues.
@@ -293,7 +295,15 @@
*/
private void checkTopicMetricsAfterMultipleMessages(String jndiName) throws Exception
{
- TopicSession session = createTopicSession();
+ InitialContext context = new InitialContext();
+ Object tmp = context.lookup(TOPIC_FACTORY);
+
+ TopicConnectionFactory tcf = (TopicConnectionFactory)tmp;
+ topicConnection = tcf.createTopicConnection();
+ topicConnection.setClientID(CLIENT_ID);
+
+ TopicSession session = topicConnection.createTopicSession(Boolean.FALSE,
+
TopicSession.AUTO_ACKNOWLEDGE);
Topic topic = getTopic(jndiName);
// Create 1 durable subscriber, 1 non-durable subscriber
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jmsDestinations/JMSOperationsTest.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jmsDestinations/JMSOperationsTest.java 2009-05-26
22:56:25 UTC (rev 482)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jmsDestinations/JMSOperationsTest.java 2009-05-28
19:38:38 UTC (rev 483)
@@ -30,16 +30,24 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Set;
+import java.util.List;
+import java.io.IOException;
import org.jboss.jopr.jsfunit.*;
import org.jboss.jopr.jsfunit.exceptions.EmbJoprTestException;
+import javax.management.MalformedObjectNameException;
+import javax.management.JMException;
import javax.jms.Topic;
import javax.jms.TopicSession;
import javax.jms.Queue;
+import javax.jms.QueueSession;
+import javax.jms.DeliveryMode;
+import org.jboss.jms.server.messagecounter.MessageCounter;
import org.jboss.jms.destination.JBossDestination;
import javax.management.ObjectName;
import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.ContentTableRow;
import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit;
+
/**
* This class contains operations tests for JMS topics and queues.
* This class should be run against JBAS 5.x.
@@ -1007,6 +1015,8 @@
}
/* OPERATION #12 - CREATE - APPLIES TO TOPICS AND QUEUES */
+ // These tests are now disabled since the "Create" operation has been
+ // removed.
/**
* Test Name: testTopicCreateOperation
@@ -1123,6 +1133,8 @@
}
/* OPERATION #14 - DESTROY - APPLIES TO TOPICS AND QUEUES */
+ // These tests are now disabled since the "Destroy" operation has been
+ // removed.
/**
* Test Name: testTopicDestroyOperation
@@ -1241,8 +1253,552 @@
STOP, Boolean.FALSE);
}
+
+ /* OPERATION #16 - LIST ALL MESSAGES - APPLIES TO TOPICS AND QUEUES */
+
+ /**
+ * Test Name: testListAllMessagesAfterTopicCreation
+ * Assertion: Make sure that the "List All Messages" operation for topics
+ * returns the correct results after creating a new topic.
+ */
+ public void testListAllMessagesAfterTopicCreation() throws Exception {
+ String jndiName = "ListAllMessagesAfterTopicCreation";
+
+ // Create the topic first
+ createTopic(jndiName);
+
+ // Some message counts to check before performing the operation
+ Map<String, String> expectedMetrics = new LinkedHashMap<String,
String>();
+ expectedMetrics.put(ALL_MSG_COUNT, "0");
+ expectedMetrics.put(DURABLE_MSG_COUNT, "0");
+ expectedMetrics.put(NON_DURABLE_MSG_COUNT, "0");
+ expectedMetrics.put(ALL_SUB_COUNT, "0");
+
+ performListMessages(jndiName, DestinationType.TOPIC, LIST_ALL_MSGS,
+ 0, Boolean.FALSE, null, expectedMetrics);
+ }
+
+ /**
+ * Test Name: testTopicListAllMessagesAfterMultipleMessages
+ * Assertion: Make sure that the "List All Messages" operation for topics
+ * returns the correct results when the topic has multiple messages.
+ */
+ public void testTopicListAllMessagesAfterMultipleMessages() throws Exception {
+ String jndiName = "TopicListAllMessagesAfterMultipleMessages";
+
+ // Create the topic first
+ createTopic(jndiName);
+ performTopicListAllMessagesAfterMultipleMessages(jndiName);
+ }
+
+ /**
+ * Test Name: testTopicListAllMessagesAfterMultipleMessagesUsingExistingServiceFile
+ * Assertion: Make sure that the "List All Messages" operation for topics
+ * returns the correct results when the topic has multiple messages.
+ * Use a topic that already exists.
+ */
+ public void testTopicListAllMessagesAfterMultipleMessagesUsingExistingServiceFile()
throws Exception {
+ String jndiName = "ListAllMessagesMultipleMessagesExistingTopic";
+
+ expandNavTreeArrow(JMS_NAV_LABEL);
+ performTopicListAllMessagesAfterMultipleMessages(jndiName);
+ }
+
+ /**
+ * Common code for the testTopicListAllMessagesAfterMultipleMessages*
+ * tests.
+ */
+ private void performTopicListAllMessagesAfterMultipleMessages(String jndiName) throws
Exception {
+
+ TopicSession session = createTopicSession();
+ Topic topic = getTopic(jndiName);
+
+ // Send some messages to the topic
+ createDurableTopicSubscriber(session, topic, jndiName);
+ publishMessages(session, topic, 3);
+
+ // The operation parameters
+ Map<String, String> parametersMap = new HashMap<String, String>();
+ parametersMap.put(ARG_0, CLIENT_ID + "." + jndiName);
+
+ // Message counts to check before performing the operation
+ Map<String, String> expectedMetrics = new LinkedHashMap<String,
String>();
+ expectedMetrics.put(ALL_MSG_COUNT, "3");
+ expectedMetrics.put(DURABLE_MSG_COUNT, "3");
+ expectedMetrics.put(NON_DURABLE_MSG_COUNT, "0");
+ expectedMetrics.put(ALL_SUB_COUNT, "1");
+
+ performListMessages(jndiName, DestinationType.TOPIC, LIST_ALL_MSGS,
+ 3, Boolean.TRUE, parametersMap, expectedMetrics);
+ }
+
+ /**
+ * Test Name: testListAllMessagesAfterQueueCreation
+ * Assertion: Make sure that the "List All Messages" operation for queues
+ * returns the correct results after creating a new queue.
+ */
+ public void testListAllMessagesAfterQueueCreation() throws Exception {
+ String jndiName = "ListAllMessagesAfterQueueCreation";
+
+ // Create the queue first
+ createQueue(jndiName);
+
+ // Some message counts to check before performing the operation
+ Map<String, String> expectedMetrics = new LinkedHashMap<String,
String>();
+ expectedMetrics.put(CONSUMER_COUNT, "0");
+ expectedMetrics.put(MSG_COUNT, "0");
+
+ performListMessages(jndiName, DestinationType.QUEUE, LIST_ALL_MSGS,
+ 0, Boolean.FALSE, null, expectedMetrics);
+ }
+
+ /**
+ * Test Name: testQueueListAllMessagesAfterMultipleMessages
+ * Assertion: Make sure that the "List All Messages" operation for queues
+ * returns the correct results when the queue has multiple messages.
+ */
+ public void testQueueListAllMessagesAfterMultipleMessages() throws Exception {
+ String jndiName = "QueueListAllMessagesAfterMultipleMessages";
+
+ // Create the queue first
+ createQueue(jndiName);
+ performQueueListAllMessagesAfterMultipleMessages(jndiName);
+ }
+
+ /**
+ * Test Name: testQueueListAllMessagesAfterMultipleMessagesUsingExistingServiceFile
+ * Assertion: Make sure that the "List All Messages" operation for queues
+ * returns the correct results when the queue has multiple messages.
+ * Use a queue that already exists.
+ */
+ public void testQueueListAllMessagesAfterMultipleMessagesUsingExistingServiceFile()
throws Exception {
+ String jndiName = "ListAllMessagesMultipleMessagesExistingQueue";
+
+ expandNavTreeArrow(JMS_NAV_LABEL);
+ performQueueListAllMessagesAfterMultipleMessages(jndiName);
+ }
+
+ /**
+ * Common code for the testQueueListAllMessagesAfterMultipleMessages*
+ * tests.
+ */
+ private void performQueueListAllMessagesAfterMultipleMessages(String jndiName) throws
Exception {
+ QueueSession session = createQueueSession();
+ Queue queue = getQueue(jndiName);
+
+ // Send 1 durable message and 1 non-durable message
+ sendMessagesAndSpecifyDeliveryMode(session, queue, 1, DeliveryMode.PERSISTENT);
+ sendMessagesAndSpecifyDeliveryMode(session, queue, 1,
DeliveryMode.NON_PERSISTENT);
+
+ // The operation parameters
+ Map<String, String> parametersMap = new HashMap<String, String>();
+ parametersMap.put(ARG_0, EMBJOPR_TEST_SELECTOR);
+
+ // Some message counts to check before performing the operation
+ Map<String, String> expectedMetrics = new LinkedHashMap<String,
String>();
+ expectedMetrics.put(CONSUMER_COUNT, "0");
+ expectedMetrics.put(MSG_COUNT, "2");
+
+ performListMessages(jndiName, DestinationType.QUEUE, LIST_ALL_MSGS,
+ 2, Boolean.TRUE, parametersMap, expectedMetrics);
+ }
+
+ /* OPERATION #17 - LIST DURABLE MESSAGES - APPLIES TO TOPICS AND QUEUES */
+
+ /**
+ * Test Name: testListDurableMessagesAfterTopicCreation
+ * Assertion: Make sure that the "List Durable Messages" operation for
topics
+ * returns the correct results after creating a new topic.
+ */
+ public void testListDurableMessagesAfterTopicCreation() throws Exception {
+ String jndiName = "ListDurableMessagesAfterTopicCreation";
+
+ // Create the topic first
+ createTopic(jndiName);
+
+ // Message counts to check before performing the operation
+ Map<String, String> expectedMetrics = new LinkedHashMap<String,
String>();
+ expectedMetrics.put(ALL_MSG_COUNT, "0");
+ expectedMetrics.put(DURABLE_MSG_COUNT, "0");
+ expectedMetrics.put(NON_DURABLE_MSG_COUNT, "0");
+ expectedMetrics.put(ALL_SUB_COUNT, "0");
+
+ performListMessages(jndiName, DestinationType.TOPIC, LIST_DURABLE_MSGS,
+ 0, Boolean.FALSE, null, expectedMetrics);
+ }
+
+ /**
+ * Test Name: testTopicListDurableMessagesAfterMultipleMessages
+ * Assertion: Make sure that the "List Durable Messages" operation for
topics
+ * returns the correct results when the topic has multiple messages.
+ */
+ public void testTopicListDurableMessagesAfterMultipleMessages() throws Exception {
+ String jndiName = "TopicListDurableMessagesAfterMultipleMessages";
+
+ // Create the topic first
+ createTopic(jndiName);
+ performTopicListDurableMessagesAfterMultipleMessages(jndiName);
+ }
+
+ /**
+ * Test Name:
testTopicListDurableMessagesAfterMultipleMessagesUsingExistingServiceFile
+ * Assertion: Make sure that the "List Durable Messages" operation for
topics
+ * returns the correct results when the topic has multiple messages.
+ * Use a topic that already exists.
+ */
+ public void
testTopicListDurableMessagesAfterMultipleMessagesUsingExistingServiceFile() throws
Exception {
+ String jndiName = "ListDurableMessagesMultipleMessagesExistingTopic";
+
+ expandNavTreeArrow(JMS_NAV_LABEL);
+ performTopicListDurableMessagesAfterMultipleMessages(jndiName);
+ }
+
+ /**
+ * Common code for the testTopicListDurableMessagesAfterMultipleMessages* tests.
+ */
+ private void performTopicListDurableMessagesAfterMultipleMessages(String jndiName)
throws Exception {
+ TopicSession session = createTopicSession();
+ Topic topic = getTopic(jndiName);
+
+ // Create a durable subscriber and send some messages to the topic
+ createDurableTopicSubscriber(session, topic, jndiName);
+ publishMessages(session, topic, 2);
+
+ // The operation parameters
+ Map<String, String> parametersMap = new HashMap<String, String>();
+ parametersMap.put(ARG_0, CLIENT_ID + "." + jndiName);
+
+ // Message counts to check before performing the operation
+ Map<String, String> expectedMetrics = new LinkedHashMap<String,
String>();
+ expectedMetrics.put(ALL_MSG_COUNT, "2");
+ expectedMetrics.put(DURABLE_MSG_COUNT, "2");
+ expectedMetrics.put(NON_DURABLE_MSG_COUNT, "0");
+ expectedMetrics.put(ALL_SUB_COUNT, "1");
+
+ performListMessages(jndiName, DestinationType.TOPIC, LIST_DURABLE_MSGS,
+ 2, Boolean.TRUE, parametersMap, expectedMetrics);
+ }
+
+ /**
+ * Test Name: testListDurableMessagesAfterQueueCreation
+ * Assertion: Make sure that the "List Durable Messages" operation for
+ * queues returns the correct results after creating a new queue.
+ */
+ public void testListDurableMessagesAfterQueueCreation() throws Exception {
+ String jndiName = "ListDurableMessagesAfterQueueCreation";
+
+ // Create the queue first
+ createQueue(jndiName);
+
+ // Some message counts to check before performing the operation
+ Map<String, String> expectedMetrics = new LinkedHashMap<String,
String>();
+ expectedMetrics.put(CONSUMER_COUNT, "0");
+ expectedMetrics.put(MSG_COUNT, "0");
+
+ performListMessages(jndiName, DestinationType.QUEUE, LIST_DURABLE_MSGS,
+ 0, Boolean.FALSE, null, expectedMetrics);
+ }
+
+ /**
+ * Test Name: testQueueListDurableMessagesAfterMultipleMessages
+ * Assertion: Make sure that the "List Durable Messages" operation for
queues
+ * returns the correct results when the queue has multiple messages.
+ */
+ public void testQueueListDurableMessagesAfterMultipleMessages() throws Exception {
+ String jndiName = "QueueListDurableMessagesAfterMultipleMessages";
+
+ // Create the queue first
+ createQueue(jndiName);
+ performQueueListDurableMessagesAfterMultipleMessages(jndiName);
+ }
+
+ /**
+ * Test Name:
testQueueListDurableMessagesAfterMultipleMessagesUsingExistingServiceFile
+ * Assertion: Make sure that the "List Durable Messages" operation for
queues
+ * returns the correct results when the queue has multiple messages. Use a queue
+ * that already exists.
+ */
+ public void
testQueueListDurableMessagesAfterMultipleMessagesUsingExistingServiceFile() throws
Exception {
+ String jndiName = "ListDurableMessagesMultipleMessagesExistingQueue";
+
+ expandNavTreeArrow(JMS_NAV_LABEL);
+ performQueueListDurableMessagesAfterMultipleMessages(jndiName);
+ }
+
+ /**
+ * Common code for the testQueueListDurableMessagesAfterMultipleMessages* tests.
+ */
+ private void performQueueListDurableMessagesAfterMultipleMessages(String jndiName)
throws Exception {
+
+ // Send some durable messages to the queue
+ createQueueSessionAndSendMessages(2, jndiName);
+
+ // The operation parameters
+ Map<String, String> parametersMap = new HashMap<String, String>();
+ parametersMap.put(ARG_0, EMBJOPR_TEST_SELECTOR);
+
+ // Some message counts to check before performing the operation
+ Map<String, String> expectedMetrics = new LinkedHashMap<String,
String>();
+ expectedMetrics.put(CONSUMER_COUNT, "0");
+ expectedMetrics.put(MSG_COUNT, "2");
+
+ performListMessages(jndiName, DestinationType.QUEUE, LIST_DURABLE_MSGS,
+ 2, Boolean.TRUE, parametersMap, expectedMetrics);
+ }
+
+ /* OPERATION #18 - LIST NON DURABLE MESSAGES - APPLIES TO TOPICS AND QUEUES */
+
+ /**
+ * Test Name: testListNonDurableMessagesAfterTopicCreation
+ * Assertion: Make sure that the "List Non Durable Messages" operation for
+ * topics returns the correct results after creating a new topic.
+ */
+ public void testListNonDurableMessagesAfterTopicCreation() throws Exception {
+ String jndiName = "ListNonDurableMessagesAfterTopicCreation";
+
+ // Create the topic first
+ createTopic(jndiName);
+ Map<String, String> expectedMetrics = new LinkedHashMap<String,
String>();
+ expectedMetrics.put(ALL_MSG_COUNT, "0");
+ expectedMetrics.put(DURABLE_MSG_COUNT, "0");
+ expectedMetrics.put(NON_DURABLE_MSG_COUNT, "0");
+ expectedMetrics.put(ALL_SUB_COUNT, "0");
+
+ performListMessages(jndiName, DestinationType.TOPIC, LIST_NON_DURABLE_MSGS,
+ 0, Boolean.FALSE, null, expectedMetrics);
+ }
+
/**
+ * Test Name: testTopicListNonDurableMessagesAfterMultipleMessages
+ * Assertion: Make sure that the "List Non Durable Messages" operation for
+ * topics returns the correct results when the topic has multiple messages.
+ */
+ public void testTopicListNonDurableMessagesAfterMultipleMessages() throws Exception
{
+ String jndiName = "TopicListNonDurableMessagesAfterMultipleMessages";
+
+ // Create the topic first
+ createTopic(jndiName);
+ performTopicListNonDurableMessagesAfterMultipleMessages(jndiName);
+ }
+
+ /**
+ * Test Name:
testTopicListNonDurableMessagesAfterMultipleMessagesUsingExistingServiceFile
+ * Assertion: Make sure that the "List Non Durable Messages" operation for
+ * topics returns the correct results when the topic has multiple messages.
+ * Use a topic that already exists.
+ */
+ public void
testTopicListNonDurableMessagesAfterMultipleMessagesUsingExistingServiceFile() throws
Exception {
+ String jndiName =
"ListNonDurableMessagesMultipleMessagesExistingTopic";
+
+ expandNavTreeArrow(JMS_NAV_LABEL);
+ performTopicListNonDurableMessagesAfterMultipleMessages(jndiName);
+ }
+
+ /**
+ * Common code for the testTopicListNonDurableMessagesAfterMultipleMessages* tests.
+ */
+ private void performTopicListNonDurableMessagesAfterMultipleMessages(String jndiName)
throws Exception {
+ createTopicSessionAndSendNonDurableMessages(2, jndiName);
+
+ // Get the subscription ID to pass as a parameter to "List Non Durable
Messages"
+ String subID = getSubID(jndiName);
+
+ Map<String, String> parametersMap = new HashMap<String, String>();
+ parametersMap.put(ARG_0, subID);
+
+ // Message counts to check before performing the operation
+ Map<String, String> expectedMetrics = new LinkedHashMap<String,
String>();
+ expectedMetrics.put(ALL_MSG_COUNT, "2");
+ expectedMetrics.put(DURABLE_MSG_COUNT, "0");
+ expectedMetrics.put(NON_DURABLE_MSG_COUNT, "2");
+ expectedMetrics.put(ALL_SUB_COUNT, "1");
+
+ performListMessages(jndiName, DestinationType.TOPIC, LIST_NON_DURABLE_MSGS,
+ 2, Boolean.TRUE, parametersMap, expectedMetrics);
+ }
+
+ /**
+ * Get the subscription id of a topic subscriber.
+ */
+ private String getSubID(String jndiName) throws MalformedObjectNameException,
JMException, IOException {
+
+ JMXUtils jmxUtils = JMXUtils.getInstanceForLocalJBoss();
+ ObjectName deploymentMBean = new
ObjectName("jboss.messaging.destination:name="
+ + jndiName + ",service="
+ + DestinationType.TOPIC.getName());
+
+ Object messageCounters = jmxUtils.getMBeanAttribute(deploymentMBean,
"MessageCounters");
+
+ assertTrue(((List<MessageCounter>)messageCounters).size() == 1);
+
+ // Get the subscription ID
+ String subID = "";
+ MessageCounter mc = ((List<MessageCounter>)messageCounters).get(0);
+ String mcString = mc.getCounterAsString();
+ String temp = mcString.substring(mcString.indexOf(".") + 1);
+ subID = temp.substring(0, temp.indexOf(","));
+
+ return subID;
+ }
+
+ /**
+ * Test Name: testListNonDurableMessagesAfterQueueCreation
+ * Assertion: Make sure that the "List Non Durable Messages" operation for
+ * queues returns the correct results after creating a new queue.
+ */
+ public void testListNonDurableMessagesAfterQueueCreation() throws Exception {
+ String jndiName = "ListNonDurableMessagesAfterQueueCreation";
+
+ // Create the queue first
+ createQueue(jndiName);
+
+ // Some message counts to check before performing the operation
+ Map<String, String> expectedMetrics = new LinkedHashMap<String,
String>();
+ expectedMetrics.put(CONSUMER_COUNT, "0");
+ expectedMetrics.put(MSG_COUNT, "0");
+
+ performListMessages(jndiName, DestinationType.QUEUE, LIST_NON_DURABLE_MSGS,
+ 0, Boolean.FALSE, null, expectedMetrics);
+ }
+
+ /**
+ * Test Name: testQueueListNonDurableMessagesAfterMultipleMessages
+ * Assertion: Make sure that the "List Non Durable Messages" operation for
+ * queues returns the correct results when the queue has multiple messages.
+ */
+ public void testQueueListNonDurableMessagesAfterMultipleMessages() throws Exception
{
+ String jndiName = "QueueListNonDurableMessagesAfterMultipleMessages";
+
+ // Create the queue first
+ createQueue(jndiName);
+ performQueueListNonDurableMessagesAfterMultipleMessages(jndiName);
+ }
+
+ /**
+ * Test Name:
testQueueListNonDurableMessagesAfterMultipleMessagesUsingExistingServiceFile
+ * Assertion: Make sure that the "List Non Durable Messages" operation for
+ * queues returns the correct results when the queue has multiple messages.
+ * Use a queue that already exists.
+ */
+ public void
testQueueListNonDurableMessagesAfterMultipleMessagesUsingExistingServiceFile() throws
Exception {
+ String jndiName =
"ListNonDurableMessagesMultipleMessagesExistingQueue";
+
+ expandNavTreeArrow(JMS_NAV_LABEL);
+ performQueueListNonDurableMessagesAfterMultipleMessages(jndiName);
+ }
+
+ /**
+ * Common code for the testQueueListNonDurableMessagesAfterMultipleMessages* tests.
+ */
+ private void performQueueListNonDurableMessagesAfterMultipleMessages(String jndiName)
throws Exception {
+ QueueSession session = createQueueSession();
+ Queue queue = getQueue(jndiName);
+
+ // Send some non-durable messages to the queue
+ sendMessagesAndSpecifyDeliveryMode(session, queue, 2,
DeliveryMode.NON_PERSISTENT);
+
+ Map<String, String> parametersMap = new HashMap<String, String>();
+ parametersMap.put(ARG_0, EMBJOPR_TEST_SELECTOR);
+
+ // Some message counts to check before performing the operation
+ Map<String, String> expectedMetrics = new LinkedHashMap<String,
String>();
+ expectedMetrics.put(CONSUMER_COUNT, "0");
+ expectedMetrics.put(MSG_COUNT, "2");
+
+ performListMessages(jndiName, DestinationType.QUEUE, LIST_NON_DURABLE_MSGS,
+ 2, Boolean.TRUE, parametersMap, expectedMetrics);
+ }
+
+ /**
+ * Common code for the List*Messages tests.
+ */
+ private void performListMessages(String jndiName,
+ DestinationType destinationType,
+ String operationName,
+ int expectedNumMessages,
+ boolean useParameters,
+ Map<String, String> parametersMap,
+ Map<String, String> expectedMetrics) throws
Exception {
+
+ // Check some message metrics before performing the operation
+ ArrayList<String> summaryMetrics = new ArrayList<String>();
+
+ if(destinationType == DestinationType.TOPIC) {
+ summaryMetrics = getTopicSummaryMetrics();
+ } else {
+ summaryMetrics = getQueueSummaryMetrics();
+ }
+
+ checkResourceMetrics(JMS_NAV_LABEL, destinationType.getNavLabel(),
+ jndiName, expectedMetrics, summaryMetrics);
+
+ // Invoke the operation and check the results
+ if(useParameters) {
+ performResourceOperationWithParameters(JMS_NAV_LABEL,
destinationType.getNavLabel(),
+ jndiName, operationName,
parametersMap);
+ } else {
+ performResourceOperation(JMS_NAV_LABEL, destinationType.getNavLabel(),
+ jndiName, operationName, Boolean.TRUE);
+ }
+
+ checkListMessagesTable(expectedNumMessages);
+
+ // Clean up
+ disconnect();
+ deleteDestination(destinationType, jndiName);
+ }
+
+ /**
+ * Make sure the correct number of messages gets displayed in the
+ * output of the "List * Messages" operations.
+ */
+ private void checkListMessagesTable(int expectedNumMessages) {
+
+ // Get the result of the operation
+ HtmlDivision historyPanel =
(HtmlDivision)client.getElement(OPERATION_HISTORY_FORM);
+ HtmlTable resultsTable =
(HtmlTable)historyPanel.getFirstByXPath(".//table[@class='property-map-summary-table']");
+ assertNotNull("Could not get the result of the operation",
resultsTable);
+
+ List<HtmlTableRow> rows = resultsTable.getRows();
+
+ // Don't include the header row
+ int numMessages = rows.size() - 1;
+
+ String emptyTableMessage = "";
+ if((numMessages == 0) && (expectedNumMessages > 0)) {
+ emptyTableMessage = "An empty table was displayed - ";
+ }
+
+ assertEquals(emptyTableMessage + "Incorrect number of messages displayed in
the results table: ",
+ expectedNumMessages, numMessages);
+
+ Iterator i = rows.iterator();
+
+ int rowNum = 0;
+
+ // The table should contain these columns: "JMS Correlation ID",
"JMS Message ID",
+ // and "JMS Timestamp"
+ while(i.hasNext()) {
+ HtmlTableRow row = (HtmlTableRow)i.next();
+ String jmsCorrelationID =
((HtmlTableCell)row.getCell(JMS_CORRELATION_ID)).asText();
+
+ String jmsMessageID = ((HtmlTableCell)row.getCell(JMS_MESSAGE_ID)).asText();
+ assertNotNull("The JMS Message ID was null", jmsMessageID);
+
+ String jmsTimestamp = ((HtmlTableCell)row.getCell(JMS_TIMESTAMP)).asText();
+ assertNotNull("The JMS Timestamp was null", jmsTimestamp);
+
+ log.info("Row " + rowNum + ": ");
+ log.info("JMS Correlation ID: " + jmsCorrelationID);
+ log.info("JMS Message ID: " + jmsMessageID);
+ log.info("JMS Timestamp: " + jmsTimestamp);
+
+ rowNum = rowNum + 1;
+ }
+ }
+
+ /**
* Common code for the Create/Start/Stop/Destroy operations.
*/
private void performServletLifecycleOperation(String jndiName,
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jmsDestinations/JMSTest.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jmsDestinations/JMSTest.java 2009-05-26
22:56:25 UTC (rev 482)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jmsDestinations/JMSTest.java 2009-05-28
19:38:38 UTC (rev 483)
@@ -52,6 +52,7 @@
import javax.jms.ConnectionFactory;
import javax.jms.TextMessage;
import javax.jms.JMSException;
+import javax.jms.DeliveryMode;
import javax.naming.NamingException;
import org.jboss.metatype.api.values.CompositeValue;
import org.jboss.metatype.api.values.CompositeValueSupport;
@@ -133,6 +134,11 @@
public static final String RESET_MSG_COUNTER = "Reset Message Counter";
public static final String RESET_MSG_COUNTER_HISTORY = "Reset Message Counter
History";
+ // Column numbers for the headers in the "List * Messages" results table
+ public static final int JMS_CORRELATION_ID = 0;
+ public static final int JMS_MESSAGE_ID = 1;
+ public static final int JMS_TIMESTAMP = 2;
+
public enum DestinationType {
QUEUE(QUEUES_NAV_LABEL, "Queue"),
TOPIC(TOPICS_NAV_LABEL, "Topic");
@@ -158,6 +164,8 @@
public static final String SERVICE_FILE_ROOT_ELEMENT = "server";
public static final String SERVICE_FILE_CHILD_ELEMENT = "mbean";
public static final String CLIENT_ID = "EmbjoprTest";
+ public static final String EMBJOPR_TEST_PROPERTY = "EmbjoprTestProperty";
+ public static final String EMBJOPR_TEST_SELECTOR = EMBJOPR_TEST_PROPERTY +
"=0";
public static final long SCHEDULED_TIME = 3600000;
public static final String DLQ =
"jboss.messaging.destination:name=DLQ,service=Queue";
public static final String EXPIRY_QUEUE =
"jboss.messaging.destination:name=ExpiryQueue,service=Queue";
@@ -465,10 +473,27 @@
Queue queue,
int numMessages) throws JMSException {
+ // Send durable messages
+ sendMessagesAndSpecifyDeliveryMode(session, queue,
+ numMessages, DeliveryMode.PERSISTENT);
+ }
+
+ /**
+ * Create a QueueSender for the given queue and send the given
+ * number of messages.
+ *
+ * @param deliveryMode is the delivery mode for the QueueSender
+ */
+ protected void sendMessagesAndSpecifyDeliveryMode(QueueSession session,
+ Queue queue,
+ int numMessages,
+ int deliveryMode) throws
JMSException {
QueueSender sender = session.createSender(queue);
+ sender.setDeliveryMode(deliveryMode);
for(int i = 0; i < numMessages; i++) {
TextMessage message = session.createTextMessage("Message " + i);
+ message.setIntProperty(EMBJOPR_TEST_PROPERTY, 0);
sender.send(message);
}
@@ -651,6 +676,28 @@
return topicSession;
}
+
+ /**
+ * Create a topic session and a non-durable subscriber. Then, send the
+ * specified number of messages to the given topic.
+ */
+ protected void createTopicSessionAndSendNonDurableMessages(int numMessages,
+ String jndiName) throws
Exception {
+ InitialContext context = new InitialContext();
+ Object tmp = context.lookup(TOPIC_FACTORY);
+
+ TopicConnectionFactory tcf = (TopicConnectionFactory)tmp;
+ topicConnection = tcf.createTopicConnection();
+ topicConnection.setClientID(CLIENT_ID);
+
+ TopicSession session = topicConnection.createTopicSession(Boolean.FALSE,
+
TopicSession.AUTO_ACKNOWLEDGE);
+ Topic topic = getTopic(jndiName);
+
+ createNonDurableTopicSubscriber(session, topic);
+
+ publishMessages(session, topic, numMessages);
+ }
/**
* Create a queue session and specify the given username and password
Added:
trunk/jsfunit/testdata/destinations/ListAllMessagesMultipleMessagesExistingQueue-service.xml
===================================================================
---
trunk/jsfunit/testdata/destinations/ListAllMessagesMultipleMessagesExistingQueue-service.xml
(rev 0)
+++
trunk/jsfunit/testdata/destinations/ListAllMessagesMultipleMessagesExistingQueue-service.xml 2009-05-28
19:38:38 UTC (rev 483)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
+<server>
+ <mbean xmbean-dd="xmdesc/Queue-xmbean.xml"
name="jboss.messaging.destination:service=Queue,name=ListAllMessagesMultipleMessagesExistingQueue"
code="org.jboss.jms.server.destination.QueueService">
+
<annotation>(a)org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.QueueServiceMO)</annotation>
+ <attribute
name="JNDIName">ListAllMessagesMultipleMessagesExistingQueue</attribute>
+ <depends
optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+</server>
Added:
trunk/jsfunit/testdata/destinations/ListDurableMessagesMultipleMessagesExistingQueue-service.xml
===================================================================
---
trunk/jsfunit/testdata/destinations/ListDurableMessagesMultipleMessagesExistingQueue-service.xml
(rev 0)
+++
trunk/jsfunit/testdata/destinations/ListDurableMessagesMultipleMessagesExistingQueue-service.xml 2009-05-28
19:38:38 UTC (rev 483)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
+<server>
+ <mbean xmbean-dd="xmdesc/Queue-xmbean.xml"
name="jboss.messaging.destination:service=Queue,name=ListDurableMessagesMultipleMessagesExistingQueue"
code="org.jboss.jms.server.destination.QueueService">
+
<annotation>(a)org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.QueueServiceMO)</annotation>
+ <attribute
name="JNDIName">ListDurableMessagesMultipleMessagesExistingQueue</attribute>
+ <depends
optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+</server>
Added:
trunk/jsfunit/testdata/destinations/ListDurableMessagesMultipleMessagesExistingTopic-service.xml
===================================================================
---
trunk/jsfunit/testdata/destinations/ListDurableMessagesMultipleMessagesExistingTopic-service.xml
(rev 0)
+++
trunk/jsfunit/testdata/destinations/ListDurableMessagesMultipleMessagesExistingTopic-service.xml 2009-05-28
19:38:38 UTC (rev 483)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
+<server>
+ <mbean xmbean-dd="xmdesc/Topic-xmbean.xml"
name="jboss.messaging.destination:service=Topic,name=ListDurableMessagesMultipleMessagesExistingTopic"
code="org.jboss.jms.server.destination.TopicService">
+
<annotation>(a)org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.TopicServiceMO)</annotation>
+ <attribute
name="JNDIName">ListDurableMessagesMultipleMessagesExistingTopic</attribute>
+ <depends
optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+</server>
Added:
trunk/jsfunit/testdata/destinations/ListNonDurableMessagesMultipleMessagesExistingQueue-service.xml
===================================================================
---
trunk/jsfunit/testdata/destinations/ListNonDurableMessagesMultipleMessagesExistingQueue-service.xml
(rev 0)
+++
trunk/jsfunit/testdata/destinations/ListNonDurableMessagesMultipleMessagesExistingQueue-service.xml 2009-05-28
19:38:38 UTC (rev 483)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
+<server>
+ <mbean xmbean-dd="xmdesc/Queue-xmbean.xml"
name="jboss.messaging.destination:service=Queue,name=ListNonDurableMessagesMultipleMessagesExistingQueue"
code="org.jboss.jms.server.destination.QueueService">
+
<annotation>(a)org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.QueueServiceMO)</annotation>
+ <attribute
name="JNDIName">ListNonDurableMessagesMultipleMessagesExistingQueue</attribute>
+ <depends
optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+</server>
Added:
trunk/jsfunit/testdata/destinations/ListNonDurableMessagesMultipleMessagesExistingTopic-service.xml
===================================================================
---
trunk/jsfunit/testdata/destinations/ListNonDurableMessagesMultipleMessagesExistingTopic-service.xml
(rev 0)
+++
trunk/jsfunit/testdata/destinations/ListNonDurableMessagesMultipleMessagesExistingTopic-service.xml 2009-05-28
19:38:38 UTC (rev 483)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
+<server>
+ <mbean xmbean-dd="xmdesc/Topic-xmbean.xml"
name="jboss.messaging.destination:service=Topic,name=ListNonDurableMessagesMultipleMessagesExistingTopic"
code="org.jboss.jms.server.destination.TopicService">
+
<annotation>(a)org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.TopicServiceMO)</annotation>
+ <attribute
name="JNDIName">ListNonDurableMessagesMultipleMessagesExistingTopic</attribute>
+ <depends
optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+</server>