Author: ozizka(a)redhat.com
Date: 2009-07-30 17:19:20 -0400 (Thu, 30 Jul 2009)
New Revision: 639
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jmsDestinations/JMSOperationsTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/exceptions/ActionNotAvailableException.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/exceptions/HtmlElementNotFoundException.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java
Log:
* JMSOperationsTest updated.
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-07-30
19:29:15 UTC (rev 638)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/jmsDestinations/JMSOperationsTest.java 2009-07-30
21:19:20 UTC (rev 639)
@@ -44,6 +44,7 @@
import org.jboss.jms.server.messagecounter.MessageCounter;
import org.jboss.jms.destination.JBossDestination;
import javax.management.ObjectName;
+import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.ContentTable;
import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.ContentTableRow;
import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit;
@@ -1866,7 +1867,7 @@
/**
* Common code for the list subscriptions tests.
*
- * @param isEmptyList - whether or not the list of subscriptions that
+ * @param shouldBeEmpty - whether or not the list of subscriptions that
* gets displayed should be empty
*
* FAILS: This got implemented as structured result; before, it was only a string.
@@ -1876,20 +1877,20 @@
*/
private void performListSubscriptionsAndCheckResults(String jndiName,
String operationName,
- Boolean isEmptyList) throws
Exception {
- performResourceOperation(JMS_NAV_LABEL, DestinationType.TOPIC.getNavLabel(),
- jndiName, operationName, Boolean.FALSE);
+ Boolean shouldBeEmpty) throws
Exception {
+ performResourceOperation(JMS_NAV_LABEL, DestinationType.TOPIC.getNavLabel(),
+ jndiName, operationName, Boolean.FALSE);
- String actualOperationResults =
((HtmlDivision)client.getElement(OPERATION_RESULTS)).getTextContent();
- fail("Operation result used to be toString(), now it's a table. Need to fix
the test method.");
+ //fail("Operation result used to be toString(), now it's a table. Need to
fix the test method.");
/*
+ String actualOperationResults =
((HtmlDivision)client.getElement(OPERATION_RESULTS)).getTextContent();
String shortenedResult =
actualOperationResults.substring(actualOperationResults.indexOf("Viewing"),
actualOperationResults.indexOf("]") + 1);
log.info("Operation result was: " + shortenedResult);
-
- if(!isEmptyList) {
+
+ if(!shouldBeEmpty) {
assertFalse("Expected non-empty list but was: '" +
shortenedResult + "'",
actualOperationResults.contains(EMPTY_LIST));
} else {
@@ -1897,12 +1898,49 @@
actualOperationResults.contains(EMPTY_LIST));
}
/**/
+
+
+ // Find the result values table.
+ HtmlDivision opResDiv = (HtmlDivision)
client.getElement("operationResults");
+ final String xPath = ".//table[ contains( @class, 'properties-table' )
]//table[ contains( @class, 'property-map-summary-table' ) ]";
+ ContentTable opResultTable = ejtt.getTable((HtmlTable)
opResDiv.getFirstByXPath(xPath) );
+ if( null == opResultTable )
+ throw new
org.jboss.jopr.jsfunit.exceptions.HtmlElementNotFoundException("Can't find
operation result table: "+xPath, this);
+
+ // Get the rows and list them.
+ List<ContentTableRow> rows = opResultTable.getRows();
+ int rowsCount = rows.size();
+ log.info("List contains "+rowsCount+" subscriptions.");
+ for( ContentTableRow row : rows ) {
+ // Id Durable Message Count Actions
+ String rowInfo = String.format(" Id: '%s' Durable: '%s' Message
Count: '%s' Actions: '%s'",
+ row.getCellTextByColumnName("Id"),
+ row.getCellTextByColumnName("Durable"),
+ row.getCellTextByColumnName("Message Count"),
+ row.getCellTextByColumnName("Actions"));
+ log.info(" * "+ rowInfo );
+ }
+
+ // Check whether the list is empty / non-empty as expected.
+ if(shouldBeEmpty) {
+ if( rowsCount != 0 ){
+ throw new EmbJoprTestException("Expected empty list but found
"+rowsCount+" subscriptions. See the log for more info. Page dumped.",
this);
+ }
+ } else {
+ {
+ throw new EmbJoprTestException("Expected non-empty list. See the log for
more info. Page dumped.", this);
+ }
+ }
+
// Clean up
disconnect();
deleteDestination(DestinationType.TOPIC, jndiName);
}
-
+
+
+
+
/**
* Common code for the operations tests.
*/
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/exceptions/ActionNotAvailableException.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/exceptions/ActionNotAvailableException.java 2009-07-30
19:29:15 UTC (rev 638)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/exceptions/ActionNotAvailableException.java 2009-07-30
21:19:20 UTC (rev 639)
@@ -1,5 +1,7 @@
package org.jboss.jopr.jsfunit.exceptions;
+import org.jboss.jopr.jsfunit.EmbjoprTestCase;
+
/**
* Signalizes that there was an action performed
* that was out of context - e.g. clicking on a button
@@ -17,6 +19,10 @@
super(message);
}
+ public ActionNotAvailableException(String message, EmbjoprTestCase test) {
+ super(message, test);
+ }
+
public ActionNotAvailableException(String message, Throwable cause) {
super(message, cause);
}
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/exceptions/HtmlElementNotFoundException.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/exceptions/HtmlElementNotFoundException.java 2009-07-30
19:29:15 UTC (rev 638)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/exceptions/HtmlElementNotFoundException.java 2009-07-30
21:19:20 UTC (rev 639)
@@ -1,6 +1,5 @@
package org.jboss.jopr.jsfunit.exceptions;
-import org.jboss.jopr.jsfunit.DebugUtils;
import org.jboss.jopr.jsfunit.EmbjoprTestCase;
/**
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java 2009-07-30
19:29:15 UTC (rev 638)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java 2009-07-30
21:19:20 UTC (rev 639)
@@ -1662,24 +1662,30 @@
/** Returns the HTML Select element of page size selection. */
public HtmlSelect getPageSizeSelect() throws HtmlElementNotFoundException {
- //return (HtmlSelect) client.getElement(ID_PAGE_SIZE_SELECT);
String xPath = ".//select[contains(@id,
'SummaryForm:currentPageSize')]";
- HtmlSelect select = (HtmlSelect) getTabMenu().getTabContentBox().getElement()
- .getFirstByXPath(xPath);
+ HtmlSelect select = (HtmlSelect)
getTabMenu().getTabContentBox().getElement().getFirstByXPath(xPath);
if( null == select )
throw new HtmlElementNotFoundException("Can't find page size <select>
using: "+xPath, currentTest);
return select;
}
/** Returns total items count, taken from the "Total: N" element. */
- public int getTotalItemsCount() throws ActionNotAvailableException
+ public int getTotalItemsCount() throws ActionNotAvailableException,
HtmlElementNotFoundException
{
Element e = client.getElement(ID_PAGINATION_TOTAL_ITEMS);
- String textContent = e.getTextContent();
- log.debug("Element #"+ID_PAGINATION_TOTAL_ITEMS+" content:
"+textContent);
+ String textContent_ = e.getTextContent();
+ log.debug("Element #"+ID_PAGINATION_TOTAL_ITEMS+" content:
"+textContent_);
+
+ String xPath = ".//select[contains(@id,
'SummaryForm:paginationTotalItems')]";
+ HtmlDivision totalDiv = (HtmlDivision)
getTabMenu().getTabContentBox().getElement().getFirstByXPath(xPath);
+ if( null == totalDiv )
+ throw new HtmlElementNotFoundException("Can't find items count div (Total:
...) using: "+xPath, currentTest);
+ String textContent = totalDiv.getTextContent();
+ log.debug("Element #...SummaryForm:paginationTotalItems content:
"+textContent);
+
String[] parts = textContent.split(":");
if( parts.length < 2 )
- throw new ActionNotAvailableException("Total pagination items count expected
after 'Total:' or similar.");
+ throw new ActionNotAvailableException("Total pagination items count expected
after 'Total:' or similar.", currentTest);
String countStr = parts[1].trim();
try{