[jboss-cvs] JBossAS SVN: r59925 - projects/admin-console/trunk/src/webtest/org/jboss/admin/console/webtest.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jan 22 15:26:46 EST 2007
Author: chilin
Date: 2007-01-22 15:26:46 -0500 (Mon, 22 Jan 2007)
New Revision: 59925
Added:
projects/admin-console/trunk/src/webtest/org/jboss/admin/console/webtest/JBossmqQueueTest.java
Removed:
projects/admin-console/trunk/src/webtest/org/jboss/admin/console/webtest/DestinationQueueTest.java
Log:
c:/temp/message.txt
Deleted: projects/admin-console/trunk/src/webtest/org/jboss/admin/console/webtest/DestinationQueueTest.java
===================================================================
--- projects/admin-console/trunk/src/webtest/org/jboss/admin/console/webtest/DestinationQueueTest.java 2007-01-22 20:24:44 UTC (rev 59924)
+++ projects/admin-console/trunk/src/webtest/org/jboss/admin/console/webtest/DestinationQueueTest.java 2007-01-22 20:26:46 UTC (rev 59925)
@@ -1,750 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.admin.console.webtest;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.jms.BytesMessage;
-import javax.jms.JMSException;
-import javax.jms.MapMessage;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.Queue;
-import javax.jms.QueueConnection;
-import javax.jms.QueueConnectionFactory;
-import javax.jms.QueueReceiver;
-import javax.jms.QueueSender;
-import javax.jms.QueueSession;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import junit.framework.TestCase;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput;
-import com.gargoylesoftware.htmlunit.html.HtmlForm;
-import com.gargoylesoftware.htmlunit.html.HtmlPage;
-import com.gargoylesoftware.htmlunit.html.HtmlTable;
-import com.gargoylesoftware.htmlunit.html.HtmlTableRow;
-import com.gargoylesoftware.htmlunit.html.HtmlTextArea;
-import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
-
-/**
- * Integration tests of the jboss admin console's Queue handling capabilities.
- *
- * @author <a href="chi.lin at unisys.com">Chi Lin </a>
- * @version $Revision$
- */
-public class DestinationQueueTest extends DestinationTestCase {
-
- private static Log log = LogFactory.getLog(DestinationQueueTest.class);
-
- private final static String DESTINATION_QUEUE = "queue";
-
- private final static String TEST_QUEUE = "testQueue1";
-
- private final static String TEST_QUEUE_JNDI_NAME = "queue/" + TEST_QUEUE;
-
- public DestinationQueueTest(String arg0) throws Exception {
- super(arg0);
-
- /*
- * Remove the test queue if it already exists:
- */
- removeDestination(DESTINATION_QUEUE, TEST_QUEUE, true);
- }
-
- /**
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- /**
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- /**
- * Listens for a TextMessage from the test queue Asynchronously.
- */
- class ReceiveMessageFromQueueAsync {
- InitialContext ctx;
-
- QueueConnectionFactory cf;
-
- QueueConnection connection;
-
- QueueSession session;
-
- Queue destination;
-
- QueueReceiver receiver;
-
- public void run() throws NamingException, JMSException {
- ctx = getInitialContext();
- cf = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
- destination = (Queue) ctx.lookup(TEST_QUEUE_JNDI_NAME);
-
- connection = cf.createQueueConnection();
- session = connection.createQueueSession(false,
- Session.AUTO_ACKNOWLEDGE);
- receiver = session.createReceiver(destination);
- receiver.setMessageListener(new MyMessageListener());
-
- // Waiting for a message:
- connection.start();
- }
-
- class MyMessageListener implements MessageListener {
-
- public void onMessage(Message msg) {
- try {
- TextMessage message = (TextMessage) msg;
- // Message received, we're done.
- connection.close();
- } catch (JMSException e) {
- e.printStackTrace();
- }
- }
- }
- }
-
- /**
- * Sends a TextMessage, a MapMessage, and a ByteMessage to the test queue.
- *
- * @throws NamingException
- * @throws JMSException
- */
- private void sendMessagesToQueue() throws NamingException, JMSException {
- InitialContext ctx;
- QueueConnectionFactory cf;
- QueueConnection connection;
- QueueSession session;
- Queue destination;
- QueueSender sender;
-
- ctx = getInitialContext();
- cf = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
- destination = (Queue) ctx.lookup(TEST_QUEUE_JNDI_NAME);
-
- connection = cf.createQueueConnection();
- session = connection
- .createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
- sender = session.createSender(destination);
-
- // send a TextMessage:
- TextMessage message = session.createTextMessage();
- message.setText("Hello World!");
- sender.send(message);
-
- // send a MapMessage:
- MapMessage mMsg = session.createMapMessage();
- mMsg.setBoolean("myBoolean", true);
- mMsg.setInt("myInt", 11);
- sender.send(mMsg);
-
- // send a ByteMessage:
- BytesMessage bMsg = session.createBytesMessage();
- bMsg.writeBoolean(true);
- bMsg.writeChar('a');
- bMsg.writeInt(88);
- sender.send(bMsg);
-
- connection.close();
- }
-
- /**
- * Verify the provided page contains the expected input fields of the "More"
- * page of a queue. The value of the input fields are not checked.
- *
- * @param page
- * The page to be verified
- * @throws Exception
- */
- private void verifyMorePage(HtmlPage page) throws Exception {
- /*
- * Get the destTable and verify it is not empty:
- */
- final HtmlTable table = (HtmlTable) page
- .getHtmlElementById("destTable");
- final List rows = table.getRows();
- assertFalse(TABLE_EMPTY, rows.isEmpty());
-
- /*
- * Verify correct labels exist in the table:
- */
- assertEquals(TABLE_CELL_MISMATCH, msgProps
- .getProperty("destination.view.queueDepth"), table.getCellAt(0,
- 0).asText());
- assertEquals(TABLE_CELL_MISMATCH, msgProps
- .getProperty("destination.view.scheduledMsgCount"), table
- .getCellAt(1, 0).asText());
- assertEquals(TABLE_CELL_MISMATCH, msgProps
- .getProperty("destination.view.receiversCount"), table
- .getCellAt(2, 0).asText());
-
- /*
- * Verify the data column of each row is not null:
- */
- HtmlTableRow row = null;
- for (int i = 0; i < rows.size(); i++) {
- row = (HtmlTableRow) rows.get(i);
- assertNotNull("Null data in table, row = " + i, row.getCell(1));
- }
- }
-
- /**
- * Test creating a destination queue with a bad name.
- *
- * @throws Exception
- */
- private void createQueueWithBadName() throws Exception {
- /*
- * Build an attributes map with a bad name attribute:
- */
- Map attMap = new HashMap();
- attMap.put("name", "bad!Queue");
-
- /*
- * Create the queue and verify the returned error message:
- */
- HtmlPage listPage = createDestination(DESTINATION_QUEUE, attMap);
- String expectedMsg = msgProps.getProperty("destination.create.failure");
- assertTrue(EXP_MSG_NOT_FOUND, findMessage(listPage, expectedMsg));
- }
-
- /**
- * Test creating a destination queue without providing the required
- * information (the name).
- *
- * @throws Exception
- */
- private void createQueueWithMissingRequiredData() throws Exception {
- /*
- * Create a queue with an empty attribute map and verify the returned
- * error message:
- */
- HtmlPage listPage = createDestination(DESTINATION_QUEUE, new HashMap());
- String expectedMsg = msgProps.getProperty("destination.view.name")
- + " is required";
- assertTrue(EXP_MSG_NOT_FOUND, findMessage(listPage, expectedMsg));
- }
-
- /**
- * Test creating a destination queue providing the minimum required data.
- * The queue created by this test will be used by other test cases in this
- * suite.
- *
- * @throws Exception
- */
- private void createQueue() throws Exception {
- /*
- * Find out the number of existing queues:
- */
- int prevQueueNo = getNumberOfDestinations(DESTINATION_QUEUE);
- log.debug("prevQueueNo = " + prevQueueNo);
-
- /*
- * Build a map containing minimum attributes needed to create the queue:
- */
- Map attMap = new HashMap();
- attMap.put("name", TEST_QUEUE);
-
- /*
- * Create the queue and verify the success message:
- */
- HtmlPage listPage = createDestination(DESTINATION_QUEUE, attMap);
- String expectedMsg = msgProps.getProperty("destination.create.success");
- assertTrue(EXP_MSG_NOT_FOUND, findMessage(listPage, expectedMsg));
-
- /*
- * Wait for a few seconds then refresh the list (for a maximum of 3
- * times) and verify the number of queues is incremented by 1:
- */
- boolean queueCreated = false;
- for (int i = 0; i < 3; i++) {
- Thread.sleep(hotDeployWaitTime);
- listPage = refreshPage(listPage);
- int queueNo = getNumberOfDestinations(listPage);
- log.debug("queueNo = " + queueNo);
- if (queueNo == prevQueueNo + 1) {
- queueCreated = true;
- break;
- }
- }
- assertTrue("Queue not created", queueCreated);
-
- /*
- * Make sure we can get the newly created queue:
- */
- HtmlForm form = getDestinationEntryFromList(listPage, TEST_QUEUE);
- assertNotNull("Can't find the newly created queue", form);
- }
-
- /**
- * Test creating a queue using a name that already exists.
- *
- * @throws Exception
- */
- private void createQueueWithDuplicateName() throws Exception {
- /*
- * Build an attributes map containing duplicate queue name:
- */
- Map attMap = new HashMap();
- attMap.put("name", TEST_QUEUE);
-
- /*
- * Create the queue and verify the returned error message:
- */
- HtmlPage listPage = createDestination(DESTINATION_QUEUE, attMap);
- String expectedMsg = msgProps.getProperty("destination.create.failure");
- assertTrue(EXP_MSG_NOT_FOUND, findMessage(listPage, expectedMsg));
- }
-
- /**
- * Test the action to view a queue.
- *
- * @throws Exception
- */
- private void viewQueue() throws Exception {
- /*
- * Click the "View" button of the test queue and verify the correct page
- * was obtained:
- */
- HtmlPage destPage = getDestinationDetailPage(DESTINATION_QUEUE,
- TEST_QUEUE);
- verifySettingsPage(destPage);
-
- /*
- * Click the "More" tab and verify the page:
- */
- HtmlPage morePage = clickLink(destPage, HREF_MORE_PAGE);
- verifyMorePage(morePage);
- }
-
- /**
- * Test various actions related to managing the messages in the destination
- * queue.
- *
- * @throws Exception
- */
- private void viewDataActions() throws Exception {
- /*
- * Send 3 messages to the test queue:
- */
- sendMessagesToQueue();
-
- /*
- * Get the "View Data" page of the test queue and verify there's one
- * message statistics entry and the message count is 3:
- */
- HtmlPage dataPage = getViewDataPage(DESTINATION_QUEUE, TEST_QUEUE);
- verifyMessageStatisticsPage(dataPage, DESTINATION_QUEUE, TEST_QUEUE, 1,
- 1, 3);
-
- /*
- * Click the "Reset Message Counter" button and verify the message count
- * becomes 0:
- */
- HtmlForm form = dataPage.getFormByName("destinationIdentifier");
- dataPage = clickButton(form, RESET_MSG_COUNTER_BUTTON);
- verifyMessageStatisticsPage(dataPage, DESTINATION_QUEUE, TEST_QUEUE, 1,
- 1, 0);
-
- /*
- * Switch to the "Messages" tab and verify the page heading:
- */
- dataPage = clickLink(dataPage, HREF_MESSAGES_PAGE);
- String expectedMsg = "Destination Messages: " + DESTINATION_QUEUE + "/"
- + TEST_QUEUE;
- assertTrue(EXP_MSG_NOT_FOUND, findMessage(dataPage, expectedMsg));
-
- /*
- * Verify the three types of messages we just sent were reported
- * correctly:
- */
- expectedMsg = "javax.jms.TextMessage";
- assertTrue(EXP_MSG_NOT_FOUND, findMessage(dataPage, expectedMsg));
- expectedMsg = "javax.jms.MapMessage";
- assertTrue(EXP_MSG_NOT_FOUND, findMessage(dataPage, expectedMsg));
- expectedMsg = "javax.jms.BytesMessage";
- assertTrue(EXP_MSG_NOT_FOUND, findMessage(dataPage, expectedMsg));
-
- /*
- * Click the "Remove All Messages" button and verify the result:
- */
- form = dataPage.getFormByName("destinationIdentifier");
- dataPage = clickButton(form, REMOVE_ALL_MESSAGES_BUTTON);
- expectedMsg = msgProps
- .getProperty("destination.msg.view.queueMessages.empty");
- assertTrue(EXP_MSG_NOT_FOUND, findMessage(dataPage, expectedMsg));
-
- /*
- * Start a receiver, then switch to the "Receivers" tab and verify the
- * page heading:
- */
- ReceiveMessageFromQueueAsync receiver = new ReceiveMessageFromQueueAsync();
- receiver.run();
- dataPage = clickLink(dataPage, HREF_RECEIVERS_PAGE);
- expectedMsg = "Receivers: " + DESTINATION_QUEUE + "/" + TEST_QUEUE;
- assertTrue(EXP_MSG_NOT_FOUND, findMessage(dataPage, expectedMsg));
-
- /*
- * Verify the "Receivers" page reports one receiver:
- */
- HtmlTable table = (HtmlTable) dataPage
- .getHtmlElementById("receiversTable");
- assertEquals(1, table.getBodies().size());
-
- /*
- * Switch to the "Message Counter History" tab and verify the page
- * heading. Note that since the message counter history report comes
- * directly from the MBean method, no further validation is performed
- * here until the message counter history implementation is changed:
- */
- dataPage = clickLink(dataPage, HREF_MSG_COUNTER_HISTORY_PAGE);
- expectedMsg = "Message Counter History: " + DESTINATION_QUEUE + "/"
- + TEST_QUEUE;
- assertTrue(EXP_MSG_NOT_FOUND, findMessage(dataPage, expectedMsg));
-
- /*
- * Click the "Reset Message Counter History" button and verify it
- * returns to the same page:
- */
- form = dataPage.getFormByName("destinationIdentifier");
- dataPage = clickButton(form, RESET_MSG_COUNTER_HISTORY_BUTTON);
- expectedMsg = "Message Counter History: " + DESTINATION_QUEUE + "/"
- + TEST_QUEUE;
- assertTrue(EXP_MSG_NOT_FOUND, findMessage(dataPage, expectedMsg));
- }
-
- /**
- * Test the action to change some queue attributes and cancel the request.
- *
- * @throws Exception
- */
- private void cancelQueueAttributeChanges() throws Exception {
- /*
- * Get the "View" page of the test queue:
- */
- HtmlPage page = getDestinationDetailPage(DESTINATION_QUEUE, TEST_QUEUE);
-
- /*
- * Save old value and assign new one to some selected attributes:
- */
- HtmlForm form = page.getFormByName("destination");
- HtmlTextInput reDeliveryLimit = (HtmlTextInput) form
- .getInputByName("reDeliveryLimit");
- String savedReDeliveryLimit = reDeliveryLimit.asText();
- reDeliveryLimit.setValueAttribute("8");
-
- HtmlTextInput maxDepth = (HtmlTextInput) form
- .getInputByName("maxDepth");
- String savedMaxDepth = maxDepth.asText();
- maxDepth.setValueAttribute("10");
-
- HtmlTextInput msgCounterHistoryDayLimit = (HtmlTextInput) form
- .getInputByName("msgCounterHistoryDayLimit");
- String savedMsgCounterHistoryDayLimit = msgCounterHistoryDayLimit
- .asText();
- msgCounterHistoryDayLimit.setValueAttribute("5");
-
- /*
- * Click the "Cancel" button and verify the list page is displayed:
- */
- HtmlPage newPage = clickButton(form, CANCEL_BUTTON);
- String expectedMsg = msgProps
- .getProperty("destination.list.destinations.page.header");
- assertTrue(EXP_MSG_NOT_FOUND, findMessage(newPage, expectedMsg));
-
- /*
- * Wait for a couple of seconds then view the queue to verify the
- * previous settings were retained:
- */
- Thread.sleep(hotDeployWaitTime);
- page = getDestinationDetailPage(DESTINATION_QUEUE, TEST_QUEUE);
- form = page.getFormByName("destination");
-
- reDeliveryLimit = (HtmlTextInput) form
- .getInputByName("reDeliveryLimit");
- assertEquals(savedReDeliveryLimit, reDeliveryLimit.asText());
-
- maxDepth = (HtmlTextInput) form.getInputByName("maxDepth");
- assertEquals(savedMaxDepth, maxDepth.asText());
-
- msgCounterHistoryDayLimit = (HtmlTextInput) form
- .getInputByName("msgCounterHistoryDayLimit");
- assertEquals(savedMsgCounterHistoryDayLimit, msgCounterHistoryDayLimit
- .asText());
- }
-
- /**
- * Test updating a destination queue with wrong type of data.
- *
- * @throws Exception
- */
- private void updateQueueWithInvalidData() throws Exception {
- /*
- * Get the "View" page of the test queue:
- */
- HtmlPage destPage = getDestinationDetailPage(DESTINATION_QUEUE,
- TEST_QUEUE);
- HtmlForm destForm = destPage.getFormByName("destination");
-
- /*
- * Enter invalid data (e.g. put text into integer fields):
- */
- String badInt = "badInt";
- HtmlTextInput reDeliveryDelay = (HtmlTextInput) destForm
- .getInputByName("reDeliveryDelay");
- reDeliveryDelay.setValueAttribute(badInt);
-
- HtmlTextInput reDeliveryLimit = (HtmlTextInput) destForm
- .getInputByName("reDeliveryLimit");
- reDeliveryLimit.setValueAttribute(badInt);
-
- HtmlTextInput maxDepth = (HtmlTextInput) destForm
- .getInputByName("maxDepth");
- maxDepth.setValueAttribute(badInt);
-
- HtmlTextInput msgCounterHistoryDayLimit = (HtmlTextInput) destForm
- .getInputByName("msgCounterHistoryDayLimit");
- msgCounterHistoryDayLimit.setValueAttribute(badInt);
-
- HtmlTextInput receiversImplName = (HtmlTextInput) destForm
- .getInputByName("receiversImplName");
- receiversImplName.setValueAttribute("no.such.class");
-
- /*
- * Switching tab will trigger data validation too. So instead of saving
- * the changes, we'll simply click the "More" tab and verify the
- * returned error message:
- */
- destPage = clickLink(destPage, HREF_MORE_PAGE);
- String pageText = destPage.asText();
-
- // Because the special characters must be escaped, the following
- // message is hard-coded.
- String expectedMsg = "Redelivery delay \\(milliseconds\\): must be a long";
- assertTrue(EXP_MSG_NOT_FOUND, findMessage(pageText, expectedMsg));
-
- expectedMsg = msgProps.getProperty("destination.view.reDeliveryLimit")
- + " must be an integer";
- assertTrue(EXP_MSG_NOT_FOUND, findMessage(pageText, expectedMsg));
-
- expectedMsg = msgProps.getProperty("destination.view.maxDepth")
- + " must be an integer";
- assertTrue(EXP_MSG_NOT_FOUND, findMessage(pageText, expectedMsg));
-
- expectedMsg = msgProps
- .getProperty("destination.view.msgCounterHistoryDayLimit")
- + " must be an integer";
- assertTrue(EXP_MSG_NOT_FOUND, findMessage(pageText, expectedMsg));
-
- expectedMsg = msgProps.getProperty("destination.view.receiversImpl")
- + " must be a valid class name";
- assertTrue(EXP_MSG_NOT_FOUND, findMessage(pageText, expectedMsg));
-
- /*
- * Fix the data then click the "More" tab again. It should work this
- * time:
- */
- destForm = destPage.getFormByName("destination");
-
- reDeliveryDelay = (HtmlTextInput) destForm
- .getInputByName("reDeliveryDelay");
- reDeliveryDelay.setValueAttribute("5000");
-
- reDeliveryLimit = (HtmlTextInput) destForm
- .getInputByName("reDeliveryLimit");
- reDeliveryLimit.setValueAttribute("8");
-
- maxDepth = (HtmlTextInput) destForm.getInputByName("maxDepth");
- maxDepth.setValueAttribute("10");
-
- msgCounterHistoryDayLimit = (HtmlTextInput) destForm
- .getInputByName("msgCounterHistoryDayLimit");
- msgCounterHistoryDayLimit.setValueAttribute("5");
-
- receiversImplName = (HtmlTextInput) destForm
- .getInputByName("receiversImplName");
- receiversImplName.setValueAttribute("");
-
- HtmlPage morePage = clickLink(destPage, HREF_MORE_PAGE);
- verifyMorePage(morePage);
- }
-
- /**
- * Test the action to update the attributes of a queue.
- *
- * @throws Exception
- */
- private void updateQueueAttributes() throws Exception {
- /*
- * Get the "View" page of the test queue:
- */
- HtmlPage page = getDestinationDetailPage(DESTINATION_QUEUE, TEST_QUEUE);
-
- /*
- * Assign new values to the attributes:
- */
- HtmlForm form = page.getFormByName("destination");
-
- HtmlTextInput jndiName = (HtmlTextInput) form
- .getInputByName("jndiName");
- jndiName.setValueAttribute("newJndiName");
-
- HtmlCheckBoxInput inMemory = (HtmlCheckBoxInput) form
- .getInputByName("inMemory");
- inMemory.setChecked(true);
-
- HtmlTextInput reDeliveryDelay = (HtmlTextInput) form
- .getInputByName("reDeliveryDelay");
- reDeliveryDelay.setValueAttribute("3000");
-
- HtmlTextInput reDeliveryLimit = (HtmlTextInput) form
- .getInputByName("reDeliveryLimit");
- reDeliveryLimit.setValueAttribute("5");
-
- HtmlTextInput maxDepth = (HtmlTextInput) form
- .getInputByName("maxDepth");
- maxDepth.setValueAttribute("10");
-
- HtmlTextInput msgCounterHistoryDayLimit = (HtmlTextInput) form
- .getInputByName("msgCounterHistoryDayLimit");
- msgCounterHistoryDayLimit.setValueAttribute("8");
-
- List textAreas = form.getTextAreasByName("securityRoles");
- HtmlTextArea securityRoles = (HtmlTextArea) textAreas.get(0);
- String prop1 = "admin:read:write:create";
- String prop2 = "guest:read:write";
- securityRoles.setText(prop1 + NL + prop2);
-
- /*
- * Click the "Save" button and verify an update successful message was
- * returned:
- */
- page = clickButton(form, SAVE_BUTTON);
- String expectedMsg = msgProps.getProperty("destination.update.success");
- assertTrue(EXP_MSG_NOT_FOUND, findMessage(page, expectedMsg));
-
- /*
- * Wait for a couple of seconds then get the test queue and verify the
- * changes:
- */
- Thread.sleep(hotDeployWaitTime * 2);
- page = getDestinationDetailPage(DESTINATION_QUEUE, TEST_QUEUE);
- form = page.getFormByName("destination");
-
- jndiName = (HtmlTextInput) form.getInputByName("jndiName");
- assertEquals("newJndiName", jndiName.asText());
-
- inMemory = (HtmlCheckBoxInput) form.getInputByName("inMemory");
- assertTrue(ITEM_NOT_CHECKED, inMemory.isChecked());
-
- reDeliveryDelay = (HtmlTextInput) form
- .getInputByName("reDeliveryDelay");
- assertEquals("3000", reDeliveryDelay.asText());
-
- reDeliveryLimit = (HtmlTextInput) form
- .getInputByName("reDeliveryLimit");
- assertEquals("5", reDeliveryLimit.asText());
-
- maxDepth = (HtmlTextInput) form.getInputByName("maxDepth");
- assertEquals("10", maxDepth.asText());
-
- msgCounterHistoryDayLimit = (HtmlTextInput) form
- .getInputByName("msgCounterHistoryDayLimit");
- assertEquals("8", msgCounterHistoryDayLimit.asText());
-
- textAreas = form.getTextAreasByName("securityRoles");
- securityRoles = (HtmlTextArea) textAreas.get(0);
- assertEquals(prop1 + " " + prop2, securityRoles.asText());
- }
-
- /**
- * Test actions to remove a destination queue.
- *
- * @throws Exception
- */
- private void removeQueue() throws Exception {
- /*
- * Remember the number of existing queues:
- */
- int prevQueueNo = getNumberOfDestinations(DESTINATION_QUEUE);
- log.debug("prevQueueNo = " + prevQueueNo);
-
- /*
- * Remove the test queue but cancel the request. Make sure the number of
- * queues doesn't change:
- */
- removeDestination(DESTINATION_QUEUE, TEST_QUEUE, false);
- int queueNo = getNumberOfDestinations(DESTINATION_QUEUE);
- assertEquals("Number of queues should be the same", prevQueueNo,
- queueNo);
-
- /*
- * Remove the test queue again and ok the request. The number of queues
- * should be decremented by 1:
- */
- removeDestination(DESTINATION_QUEUE, TEST_QUEUE, true);
- queueNo = getNumberOfDestinations(DESTINATION_QUEUE);
- assertEquals("Number of queues should be decremented by 1",
- prevQueueNo - 1, queueNo);
-
- /*
- * Make sure the test queue is no longer available:
- */
- HtmlPage listPage = getDestinationListPage(DESTINATION_QUEUE);
- HtmlForm form = getDestinationEntryFromList(listPage, TEST_QUEUE);
- assertNull("Test queue should not be avaialable", form);
- }
-
- /**
- * Perform a list of tests in sequence.
- *
- * @throws Exception
- */
- public void testQueueOperations() throws Exception {
- createQueueWithBadName();
- createQueueWithMissingRequiredData();
- createQueue();
- createQueueWithDuplicateName();
- viewQueue();
- viewDataActions();
- cancelQueueAttributeChanges();
- updateQueueWithInvalidData();
- updateQueueAttributes();
- removeQueue();
- }
-}
\ No newline at end of file
Copied: projects/admin-console/trunk/src/webtest/org/jboss/admin/console/webtest/JBossmqQueueTest.java (from rev 59924, projects/admin-console/trunk/src/webtest/org/jboss/admin/console/webtest/DestinationQueueTest.java)
===================================================================
--- projects/admin-console/trunk/src/webtest/org/jboss/admin/console/webtest/JBossmqQueueTest.java (rev 0)
+++ projects/admin-console/trunk/src/webtest/org/jboss/admin/console/webtest/JBossmqQueueTest.java 2007-01-22 20:26:46 UTC (rev 59925)
@@ -0,0 +1,750 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.admin.console.webtest;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.jms.BytesMessage;
+import javax.jms.JMSException;
+import javax.jms.MapMessage;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueReceiver;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput;
+import com.gargoylesoftware.htmlunit.html.HtmlForm;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlTable;
+import com.gargoylesoftware.htmlunit.html.HtmlTableRow;
+import com.gargoylesoftware.htmlunit.html.HtmlTextArea;
+import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
+
+/**
+ * Integration tests of the jboss admin console's Queue handling capabilities.
+ *
+ * @author <a href="chi.lin at unisys.com">Chi Lin </a>
+ * @version $Revision$
+ */
+public class DestinationQueueTest extends DestinationTestCase {
+
+ private static Log log = LogFactory.getLog(DestinationQueueTest.class);
+
+ private final static String DESTINATION_QUEUE = "queue";
+
+ private final static String TEST_QUEUE = "testQueue1";
+
+ private final static String TEST_QUEUE_JNDI_NAME = "queue/" + TEST_QUEUE;
+
+ public DestinationQueueTest(String arg0) throws Exception {
+ super(arg0);
+
+ /*
+ * Remove the test queue if it already exists:
+ */
+ removeDestination(DESTINATION_QUEUE, TEST_QUEUE, true);
+ }
+
+ /**
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /**
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * Listens for a TextMessage from the test queue Asynchronously.
+ */
+ class ReceiveMessageFromQueueAsync {
+ InitialContext ctx;
+
+ QueueConnectionFactory cf;
+
+ QueueConnection connection;
+
+ QueueSession session;
+
+ Queue destination;
+
+ QueueReceiver receiver;
+
+ public void run() throws NamingException, JMSException {
+ ctx = getInitialContext();
+ cf = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
+ destination = (Queue) ctx.lookup(TEST_QUEUE_JNDI_NAME);
+
+ connection = cf.createQueueConnection();
+ session = connection.createQueueSession(false,
+ Session.AUTO_ACKNOWLEDGE);
+ receiver = session.createReceiver(destination);
+ receiver.setMessageListener(new MyMessageListener());
+
+ // Waiting for a message:
+ connection.start();
+ }
+
+ class MyMessageListener implements MessageListener {
+
+ public void onMessage(Message msg) {
+ try {
+ TextMessage message = (TextMessage) msg;
+ // Message received, we're done.
+ connection.close();
+ } catch (JMSException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ /**
+ * Sends a TextMessage, a MapMessage, and a ByteMessage to the test queue.
+ *
+ * @throws NamingException
+ * @throws JMSException
+ */
+ private void sendMessagesToQueue() throws NamingException, JMSException {
+ InitialContext ctx;
+ QueueConnectionFactory cf;
+ QueueConnection connection;
+ QueueSession session;
+ Queue destination;
+ QueueSender sender;
+
+ ctx = getInitialContext();
+ cf = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
+ destination = (Queue) ctx.lookup(TEST_QUEUE_JNDI_NAME);
+
+ connection = cf.createQueueConnection();
+ session = connection
+ .createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
+ sender = session.createSender(destination);
+
+ // send a TextMessage:
+ TextMessage message = session.createTextMessage();
+ message.setText("Hello World!");
+ sender.send(message);
+
+ // send a MapMessage:
+ MapMessage mMsg = session.createMapMessage();
+ mMsg.setBoolean("myBoolean", true);
+ mMsg.setInt("myInt", 11);
+ sender.send(mMsg);
+
+ // send a ByteMessage:
+ BytesMessage bMsg = session.createBytesMessage();
+ bMsg.writeBoolean(true);
+ bMsg.writeChar('a');
+ bMsg.writeInt(88);
+ sender.send(bMsg);
+
+ connection.close();
+ }
+
+ /**
+ * Verify the provided page contains the expected input fields of the "More"
+ * page of a queue. The value of the input fields are not checked.
+ *
+ * @param page
+ * The page to be verified
+ * @throws Exception
+ */
+ private void verifyMorePage(HtmlPage page) throws Exception {
+ /*
+ * Get the destTable and verify it is not empty:
+ */
+ final HtmlTable table = (HtmlTable) page
+ .getHtmlElementById("destTable");
+ final List rows = table.getRows();
+ assertFalse(TABLE_EMPTY, rows.isEmpty());
+
+ /*
+ * Verify correct labels exist in the table:
+ */
+ assertEquals(TABLE_CELL_MISMATCH, msgProps
+ .getProperty("destination.view.queueDepth"), table.getCellAt(0,
+ 0).asText());
+ assertEquals(TABLE_CELL_MISMATCH, msgProps
+ .getProperty("destination.view.scheduledMsgCount"), table
+ .getCellAt(1, 0).asText());
+ assertEquals(TABLE_CELL_MISMATCH, msgProps
+ .getProperty("destination.view.receiversCount"), table
+ .getCellAt(2, 0).asText());
+
+ /*
+ * Verify the data column of each row is not null:
+ */
+ HtmlTableRow row = null;
+ for (int i = 0; i < rows.size(); i++) {
+ row = (HtmlTableRow) rows.get(i);
+ assertNotNull("Null data in table, row = " + i, row.getCell(1));
+ }
+ }
+
+ /**
+ * Test creating a destination queue with a bad name.
+ *
+ * @throws Exception
+ */
+ private void createQueueWithBadName() throws Exception {
+ /*
+ * Build an attributes map with a bad name attribute:
+ */
+ Map attMap = new HashMap();
+ attMap.put("name", "bad!Queue");
+
+ /*
+ * Create the queue and verify the returned error message:
+ */
+ HtmlPage listPage = createDestination(DESTINATION_QUEUE, attMap);
+ String expectedMsg = msgProps.getProperty("destination.create.failure");
+ assertTrue(EXP_MSG_NOT_FOUND, findMessage(listPage, expectedMsg));
+ }
+
+ /**
+ * Test creating a destination queue without providing the required
+ * information (the name).
+ *
+ * @throws Exception
+ */
+ private void createQueueWithMissingRequiredData() throws Exception {
+ /*
+ * Create a queue with an empty attribute map and verify the returned
+ * error message:
+ */
+ HtmlPage listPage = createDestination(DESTINATION_QUEUE, new HashMap());
+ String expectedMsg = msgProps.getProperty("destination.view.name")
+ + " is required";
+ assertTrue(EXP_MSG_NOT_FOUND, findMessage(listPage, expectedMsg));
+ }
+
+ /**
+ * Test creating a destination queue providing the minimum required data.
+ * The queue created by this test will be used by other test cases in this
+ * suite.
+ *
+ * @throws Exception
+ */
+ private void createQueue() throws Exception {
+ /*
+ * Find out the number of existing queues:
+ */
+ int prevQueueNo = getNumberOfDestinations(DESTINATION_QUEUE);
+ log.debug("prevQueueNo = " + prevQueueNo);
+
+ /*
+ * Build a map containing minimum attributes needed to create the queue:
+ */
+ Map attMap = new HashMap();
+ attMap.put("name", TEST_QUEUE);
+
+ /*
+ * Create the queue and verify the success message:
+ */
+ HtmlPage listPage = createDestination(DESTINATION_QUEUE, attMap);
+ String expectedMsg = msgProps.getProperty("destination.create.success");
+ assertTrue(EXP_MSG_NOT_FOUND, findMessage(listPage, expectedMsg));
+
+ /*
+ * Wait for a few seconds then refresh the list (for a maximum of 3
+ * times) and verify the number of queues is incremented by 1:
+ */
+ boolean queueCreated = false;
+ for (int i = 0; i < 3; i++) {
+ Thread.sleep(hotDeployWaitTime);
+ listPage = refreshPage(listPage);
+ int queueNo = getNumberOfDestinations(listPage);
+ log.debug("queueNo = " + queueNo);
+ if (queueNo == prevQueueNo + 1) {
+ queueCreated = true;
+ break;
+ }
+ }
+ assertTrue("Queue not created", queueCreated);
+
+ /*
+ * Make sure we can get the newly created queue:
+ */
+ HtmlForm form = getDestinationEntryFromList(listPage, TEST_QUEUE);
+ assertNotNull("Can't find the newly created queue", form);
+ }
+
+ /**
+ * Test creating a queue using a name that already exists.
+ *
+ * @throws Exception
+ */
+ private void createQueueWithDuplicateName() throws Exception {
+ /*
+ * Build an attributes map containing duplicate queue name:
+ */
+ Map attMap = new HashMap();
+ attMap.put("name", TEST_QUEUE);
+
+ /*
+ * Create the queue and verify the returned error message:
+ */
+ HtmlPage listPage = createDestination(DESTINATION_QUEUE, attMap);
+ String expectedMsg = msgProps.getProperty("destination.create.failure");
+ assertTrue(EXP_MSG_NOT_FOUND, findMessage(listPage, expectedMsg));
+ }
+
+ /**
+ * Test the action to view a queue.
+ *
+ * @throws Exception
+ */
+ private void viewQueue() throws Exception {
+ /*
+ * Click the "View" button of the test queue and verify the correct page
+ * was obtained:
+ */
+ HtmlPage destPage = getDestinationDetailPage(DESTINATION_QUEUE,
+ TEST_QUEUE);
+ verifySettingsPage(destPage);
+
+ /*
+ * Click the "More" tab and verify the page:
+ */
+ HtmlPage morePage = clickLink(destPage, HREF_MORE_PAGE);
+ verifyMorePage(morePage);
+ }
+
+ /**
+ * Test various actions related to managing the messages in the destination
+ * queue.
+ *
+ * @throws Exception
+ */
+ private void viewDataActions() throws Exception {
+ /*
+ * Send 3 messages to the test queue:
+ */
+ sendMessagesToQueue();
+
+ /*
+ * Get the "View Data" page of the test queue and verify there's one
+ * message statistics entry and the message count is 3:
+ */
+ HtmlPage dataPage = getViewDataPage(DESTINATION_QUEUE, TEST_QUEUE);
+ verifyMessageStatisticsPage(dataPage, DESTINATION_QUEUE, TEST_QUEUE, 1,
+ 1, 3);
+
+ /*
+ * Click the "Reset Message Counter" button and verify the message count
+ * becomes 0:
+ */
+ HtmlForm form = dataPage.getFormByName("destinationIdentifier");
+ dataPage = clickButton(form, RESET_MSG_COUNTER_BUTTON);
+ verifyMessageStatisticsPage(dataPage, DESTINATION_QUEUE, TEST_QUEUE, 1,
+ 1, 0);
+
+ /*
+ * Switch to the "Messages" tab and verify the page heading:
+ */
+ dataPage = clickLink(dataPage, HREF_MESSAGES_PAGE);
+ String expectedMsg = "Destination Messages: " + DESTINATION_QUEUE + "/"
+ + TEST_QUEUE;
+ assertTrue(EXP_MSG_NOT_FOUND, findMessage(dataPage, expectedMsg));
+
+ /*
+ * Verify the three types of messages we just sent were reported
+ * correctly:
+ */
+ expectedMsg = "javax.jms.TextMessage";
+ assertTrue(EXP_MSG_NOT_FOUND, findMessage(dataPage, expectedMsg));
+ expectedMsg = "javax.jms.MapMessage";
+ assertTrue(EXP_MSG_NOT_FOUND, findMessage(dataPage, expectedMsg));
+ expectedMsg = "javax.jms.BytesMessage";
+ assertTrue(EXP_MSG_NOT_FOUND, findMessage(dataPage, expectedMsg));
+
+ /*
+ * Click the "Remove All Messages" button and verify the result:
+ */
+ form = dataPage.getFormByName("destinationIdentifier");
+ dataPage = clickButton(form, REMOVE_ALL_MESSAGES_BUTTON);
+ expectedMsg = msgProps
+ .getProperty("destination.msg.view.queueMessages.empty");
+ assertTrue(EXP_MSG_NOT_FOUND, findMessage(dataPage, expectedMsg));
+
+ /*
+ * Start a receiver, then switch to the "Receivers" tab and verify the
+ * page heading:
+ */
+ ReceiveMessageFromQueueAsync receiver = new ReceiveMessageFromQueueAsync();
+ receiver.run();
+ dataPage = clickLink(dataPage, HREF_RECEIVERS_PAGE);
+ expectedMsg = "Receivers: " + DESTINATION_QUEUE + "/" + TEST_QUEUE;
+ assertTrue(EXP_MSG_NOT_FOUND, findMessage(dataPage, expectedMsg));
+
+ /*
+ * Verify the "Receivers" page reports one receiver:
+ */
+ HtmlTable table = (HtmlTable) dataPage
+ .getHtmlElementById("receiversTable");
+ assertEquals(1, table.getBodies().size());
+
+ /*
+ * Switch to the "Message Counter History" tab and verify the page
+ * heading. Note that since the message counter history report comes
+ * directly from the MBean method, no further validation is performed
+ * here until the message counter history implementation is changed:
+ */
+ dataPage = clickLink(dataPage, HREF_MSG_COUNTER_HISTORY_PAGE);
+ expectedMsg = "Message Counter History: " + DESTINATION_QUEUE + "/"
+ + TEST_QUEUE;
+ assertTrue(EXP_MSG_NOT_FOUND, findMessage(dataPage, expectedMsg));
+
+ /*
+ * Click the "Reset Message Counter History" button and verify it
+ * returns to the same page:
+ */
+ form = dataPage.getFormByName("destinationIdentifier");
+ dataPage = clickButton(form, RESET_MSG_COUNTER_HISTORY_BUTTON);
+ expectedMsg = "Message Counter History: " + DESTINATION_QUEUE + "/"
+ + TEST_QUEUE;
+ assertTrue(EXP_MSG_NOT_FOUND, findMessage(dataPage, expectedMsg));
+ }
+
+ /**
+ * Test the action to change some queue attributes and cancel the request.
+ *
+ * @throws Exception
+ */
+ private void cancelQueueAttributeChanges() throws Exception {
+ /*
+ * Get the "View" page of the test queue:
+ */
+ HtmlPage page = getDestinationDetailPage(DESTINATION_QUEUE, TEST_QUEUE);
+
+ /*
+ * Save old value and assign new one to some selected attributes:
+ */
+ HtmlForm form = page.getFormByName("destination");
+ HtmlTextInput reDeliveryLimit = (HtmlTextInput) form
+ .getInputByName("reDeliveryLimit");
+ String savedReDeliveryLimit = reDeliveryLimit.asText();
+ reDeliveryLimit.setValueAttribute("8");
+
+ HtmlTextInput maxDepth = (HtmlTextInput) form
+ .getInputByName("maxDepth");
+ String savedMaxDepth = maxDepth.asText();
+ maxDepth.setValueAttribute("10");
+
+ HtmlTextInput msgCounterHistoryDayLimit = (HtmlTextInput) form
+ .getInputByName("msgCounterHistoryDayLimit");
+ String savedMsgCounterHistoryDayLimit = msgCounterHistoryDayLimit
+ .asText();
+ msgCounterHistoryDayLimit.setValueAttribute("5");
+
+ /*
+ * Click the "Cancel" button and verify the list page is displayed:
+ */
+ HtmlPage newPage = clickButton(form, CANCEL_BUTTON);
+ String expectedMsg = msgProps
+ .getProperty("destination.list.destinations.page.header");
+ assertTrue(EXP_MSG_NOT_FOUND, findMessage(newPage, expectedMsg));
+
+ /*
+ * Wait for a couple of seconds then view the queue to verify the
+ * previous settings were retained:
+ */
+ Thread.sleep(hotDeployWaitTime);
+ page = getDestinationDetailPage(DESTINATION_QUEUE, TEST_QUEUE);
+ form = page.getFormByName("destination");
+
+ reDeliveryLimit = (HtmlTextInput) form
+ .getInputByName("reDeliveryLimit");
+ assertEquals(savedReDeliveryLimit, reDeliveryLimit.asText());
+
+ maxDepth = (HtmlTextInput) form.getInputByName("maxDepth");
+ assertEquals(savedMaxDepth, maxDepth.asText());
+
+ msgCounterHistoryDayLimit = (HtmlTextInput) form
+ .getInputByName("msgCounterHistoryDayLimit");
+ assertEquals(savedMsgCounterHistoryDayLimit, msgCounterHistoryDayLimit
+ .asText());
+ }
+
+ /**
+ * Test updating a destination queue with wrong type of data.
+ *
+ * @throws Exception
+ */
+ private void updateQueueWithInvalidData() throws Exception {
+ /*
+ * Get the "View" page of the test queue:
+ */
+ HtmlPage destPage = getDestinationDetailPage(DESTINATION_QUEUE,
+ TEST_QUEUE);
+ HtmlForm destForm = destPage.getFormByName("destination");
+
+ /*
+ * Enter invalid data (e.g. put text into integer fields):
+ */
+ String badInt = "badInt";
+ HtmlTextInput reDeliveryDelay = (HtmlTextInput) destForm
+ .getInputByName("reDeliveryDelay");
+ reDeliveryDelay.setValueAttribute(badInt);
+
+ HtmlTextInput reDeliveryLimit = (HtmlTextInput) destForm
+ .getInputByName("reDeliveryLimit");
+ reDeliveryLimit.setValueAttribute(badInt);
+
+ HtmlTextInput maxDepth = (HtmlTextInput) destForm
+ .getInputByName("maxDepth");
+ maxDepth.setValueAttribute(badInt);
+
+ HtmlTextInput msgCounterHistoryDayLimit = (HtmlTextInput) destForm
+ .getInputByName("msgCounterHistoryDayLimit");
+ msgCounterHistoryDayLimit.setValueAttribute(badInt);
+
+ HtmlTextInput receiversImplName = (HtmlTextInput) destForm
+ .getInputByName("receiversImplName");
+ receiversImplName.setValueAttribute("no.such.class");
+
+ /*
+ * Switching tab will trigger data validation too. So instead of saving
+ * the changes, we'll simply click the "More" tab and verify the
+ * returned error message:
+ */
+ destPage = clickLink(destPage, HREF_MORE_PAGE);
+ String pageText = destPage.asText();
+
+ // Because the special characters must be escaped, the following
+ // message is hard-coded.
+ String expectedMsg = "Redelivery delay \\(milliseconds\\): must be a long";
+ assertTrue(EXP_MSG_NOT_FOUND, findMessage(pageText, expectedMsg));
+
+ expectedMsg = msgProps.getProperty("destination.view.reDeliveryLimit")
+ + " must be an integer";
+ assertTrue(EXP_MSG_NOT_FOUND, findMessage(pageText, expectedMsg));
+
+ expectedMsg = msgProps.getProperty("destination.view.maxDepth")
+ + " must be an integer";
+ assertTrue(EXP_MSG_NOT_FOUND, findMessage(pageText, expectedMsg));
+
+ expectedMsg = msgProps
+ .getProperty("destination.view.msgCounterHistoryDayLimit")
+ + " must be an integer";
+ assertTrue(EXP_MSG_NOT_FOUND, findMessage(pageText, expectedMsg));
+
+ expectedMsg = msgProps.getProperty("destination.view.receiversImpl")
+ + " must be a valid class name";
+ assertTrue(EXP_MSG_NOT_FOUND, findMessage(pageText, expectedMsg));
+
+ /*
+ * Fix the data then click the "More" tab again. It should work this
+ * time:
+ */
+ destForm = destPage.getFormByName("destination");
+
+ reDeliveryDelay = (HtmlTextInput) destForm
+ .getInputByName("reDeliveryDelay");
+ reDeliveryDelay.setValueAttribute("5000");
+
+ reDeliveryLimit = (HtmlTextInput) destForm
+ .getInputByName("reDeliveryLimit");
+ reDeliveryLimit.setValueAttribute("8");
+
+ maxDepth = (HtmlTextInput) destForm.getInputByName("maxDepth");
+ maxDepth.setValueAttribute("10");
+
+ msgCounterHistoryDayLimit = (HtmlTextInput) destForm
+ .getInputByName("msgCounterHistoryDayLimit");
+ msgCounterHistoryDayLimit.setValueAttribute("5");
+
+ receiversImplName = (HtmlTextInput) destForm
+ .getInputByName("receiversImplName");
+ receiversImplName.setValueAttribute("");
+
+ HtmlPage morePage = clickLink(destPage, HREF_MORE_PAGE);
+ verifyMorePage(morePage);
+ }
+
+ /**
+ * Test the action to update the attributes of a queue.
+ *
+ * @throws Exception
+ */
+ private void updateQueueAttributes() throws Exception {
+ /*
+ * Get the "View" page of the test queue:
+ */
+ HtmlPage page = getDestinationDetailPage(DESTINATION_QUEUE, TEST_QUEUE);
+
+ /*
+ * Assign new values to the attributes:
+ */
+ HtmlForm form = page.getFormByName("destination");
+
+ HtmlTextInput jndiName = (HtmlTextInput) form
+ .getInputByName("jndiName");
+ jndiName.setValueAttribute("newJndiName");
+
+ HtmlCheckBoxInput inMemory = (HtmlCheckBoxInput) form
+ .getInputByName("inMemory");
+ inMemory.setChecked(true);
+
+ HtmlTextInput reDeliveryDelay = (HtmlTextInput) form
+ .getInputByName("reDeliveryDelay");
+ reDeliveryDelay.setValueAttribute("3000");
+
+ HtmlTextInput reDeliveryLimit = (HtmlTextInput) form
+ .getInputByName("reDeliveryLimit");
+ reDeliveryLimit.setValueAttribute("5");
+
+ HtmlTextInput maxDepth = (HtmlTextInput) form
+ .getInputByName("maxDepth");
+ maxDepth.setValueAttribute("10");
+
+ HtmlTextInput msgCounterHistoryDayLimit = (HtmlTextInput) form
+ .getInputByName("msgCounterHistoryDayLimit");
+ msgCounterHistoryDayLimit.setValueAttribute("8");
+
+ List textAreas = form.getTextAreasByName("securityRoles");
+ HtmlTextArea securityRoles = (HtmlTextArea) textAreas.get(0);
+ String prop1 = "admin:read:write:create";
+ String prop2 = "guest:read:write";
+ securityRoles.setText(prop1 + NL + prop2);
+
+ /*
+ * Click the "Save" button and verify an update successful message was
+ * returned:
+ */
+ page = clickButton(form, SAVE_BUTTON);
+ String expectedMsg = msgProps.getProperty("destination.update.success");
+ assertTrue(EXP_MSG_NOT_FOUND, findMessage(page, expectedMsg));
+
+ /*
+ * Wait for a couple of seconds then get the test queue and verify the
+ * changes:
+ */
+ Thread.sleep(hotDeployWaitTime * 2);
+ page = getDestinationDetailPage(DESTINATION_QUEUE, TEST_QUEUE);
+ form = page.getFormByName("destination");
+
+ jndiName = (HtmlTextInput) form.getInputByName("jndiName");
+ assertEquals("newJndiName", jndiName.asText());
+
+ inMemory = (HtmlCheckBoxInput) form.getInputByName("inMemory");
+ assertTrue(ITEM_NOT_CHECKED, inMemory.isChecked());
+
+ reDeliveryDelay = (HtmlTextInput) form
+ .getInputByName("reDeliveryDelay");
+ assertEquals("3000", reDeliveryDelay.asText());
+
+ reDeliveryLimit = (HtmlTextInput) form
+ .getInputByName("reDeliveryLimit");
+ assertEquals("5", reDeliveryLimit.asText());
+
+ maxDepth = (HtmlTextInput) form.getInputByName("maxDepth");
+ assertEquals("10", maxDepth.asText());
+
+ msgCounterHistoryDayLimit = (HtmlTextInput) form
+ .getInputByName("msgCounterHistoryDayLimit");
+ assertEquals("8", msgCounterHistoryDayLimit.asText());
+
+ textAreas = form.getTextAreasByName("securityRoles");
+ securityRoles = (HtmlTextArea) textAreas.get(0);
+ assertEquals(prop1 + " " + prop2, securityRoles.asText());
+ }
+
+ /**
+ * Test actions to remove a destination queue.
+ *
+ * @throws Exception
+ */
+ private void removeQueue() throws Exception {
+ /*
+ * Remember the number of existing queues:
+ */
+ int prevQueueNo = getNumberOfDestinations(DESTINATION_QUEUE);
+ log.debug("prevQueueNo = " + prevQueueNo);
+
+ /*
+ * Remove the test queue but cancel the request. Make sure the number of
+ * queues doesn't change:
+ */
+ removeDestination(DESTINATION_QUEUE, TEST_QUEUE, false);
+ int queueNo = getNumberOfDestinations(DESTINATION_QUEUE);
+ assertEquals("Number of queues should be the same", prevQueueNo,
+ queueNo);
+
+ /*
+ * Remove the test queue again and ok the request. The number of queues
+ * should be decremented by 1:
+ */
+ removeDestination(DESTINATION_QUEUE, TEST_QUEUE, true);
+ queueNo = getNumberOfDestinations(DESTINATION_QUEUE);
+ assertEquals("Number of queues should be decremented by 1",
+ prevQueueNo - 1, queueNo);
+
+ /*
+ * Make sure the test queue is no longer available:
+ */
+ HtmlPage listPage = getDestinationListPage(DESTINATION_QUEUE);
+ HtmlForm form = getDestinationEntryFromList(listPage, TEST_QUEUE);
+ assertNull("Test queue should not be avaialable", form);
+ }
+
+ /**
+ * Perform a list of tests in sequence.
+ *
+ * @throws Exception
+ */
+ public void testQueueOperations() throws Exception {
+ createQueueWithBadName();
+ createQueueWithMissingRequiredData();
+ createQueue();
+ createQueueWithDuplicateName();
+ viewQueue();
+ viewDataActions();
+ cancelQueueAttributeChanges();
+ updateQueueWithInvalidData();
+ updateQueueAttributes();
+ removeQueue();
+ }
+}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list