[embjopr-commits] EMBJOPR SVN: r208 - in trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit: as5 and 1 other directories.
embjopr-commits at lists.jboss.org
embjopr-commits at lists.jboss.org
Tue Mar 10 22:04:08 EDT 2009
Author: ozizka at redhat.com
Date: 2009-03-10 22:04:08 -0400 (Tue, 10 Mar 2009)
New Revision: 208
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ApplicationsPageTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EarTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java
Log:
* Removed EmbJoprTestToolkit from the ApplicationTestBaseAS5
* Changed EarTest and ApplicationsPageTest to use EmbJoprTestToolkit from the new standalone class.
* Fixed few XPath expressions.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java 2009-03-11 00:46:33 UTC (rev 207)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java 2009-03-11 02:04:08 UTC (rev 208)
@@ -171,833 +171,7 @@
- /**
- * Single nav tree instance.
- *
- * Using instance instead of static methods is necessary
- * if we want to subclass this tools for AS 4 tests in the future.
- */
- protected NavTree navTree = new NavTree();
- /**
- * Inner class to encapsulate navigation tree operations.
- *
- * Note that this class does not hold any element reference,
- * because the reference becomes invalid with every navigation action.
- *
- * Instead, all these methods call client methods.
- */
- protected class NavTree {
-
- public static final String ID_NAV_TREE_FORM = "navTreeForm";
-
- private void clickRootNode() throws IOException, EmbJoprTestException {
- DomElement element = (DomElement)client.getElement(ID_NAV_TREE_FORM);
- if( null == element )
- throw new HtmlElementNotFoundException("Can't find #"+ID_NAV_TREE_FORM+".");
-
- // ID changes upon core build?
- //HtmlAnchor rootNodeLink = element.getFirstByXPath(".//a[@id='navTreeForm:navTree:2::homeLink']");
-
- // No XSLT 2.0 support :(
- // javax.xml.transform.TransformerException: Can't find function: matches
- //HtmlAnchor rootNodeLink = element.getFirstByXPath(
- // ".//a[matches(@id,'^navTreeForm:navTree:.+::homeLink$')]");
-
- String xPath = ".//a[ starts-with( @id, '"+ID_NAV_TREE_FORM+":navTree:' ) " +
- " and contains( @id, '::homeLink' ) ]"; // XPath 2.0: ends-with( @id, '::homeLink' )
- HtmlAnchor rootNodeLink = element.getFirstByXPath(xPath);
-
- if( null == rootNodeLink )
- throw new HtmlElementNotFoundException("Root node not found using XPath: "+xPath);
-
- rootNodeLink.click();
- }
-
-
- public void waitForNavTreeLoaded(){
- sleep(1500);///
- // TODO: Use ActiveConditionChecker
-
- }
-
-
- /**
- * Finds the nav tree node by it's link label.
- *
- * @param label
- * @return
- * @throws org.jboss.jopr.jsfunit.exceptions.HtmlElementNotFoundException
- * when there's no node with given label.
- */
- public NavTreeNode getNodeByLabel( String label ) throws HtmlElementNotFoundException{
-
- DomElement navTreeForm = (DomElement)client.getElement(ID_NAV_TREE_FORM);
-
- // A table which has an anchor containing given text.
- // Note: Different node types have different id endings - typeSummaryLink, categorySummaryLink, ...
- //String xPath = ".//table[.//td[contains(@id,':text')]//a[contains(@id,'SummaryLink') and normalize-space() = '"+label+"']]";
- // Node has @id = navTreeForm:navTree:136:137:138:139:143:195::instanceNodeOrLeafLink
- // Let's rely on the ":text" id part only and suppose there will be just one link in that TD.
- String xPath = ".//table[.//td[contains(@id,':text')]//a[normalize-space() = '"+label+"']]";
-
- HtmlTable nodeTable = navTreeForm.getFirstByXPath( xPath );
-
- if( null == nodeTable )
- throw new HtmlElementNotFoundException("Node '"+label+"' not found using XPath: "+xPath);
-
- return new NavTreeNode(nodeTable);
-
- }
-
-
- /**
- * Need a standard JSFUnit API to replace this code.
- * @see getNodeByLabel().getLabelLink()
- */
- public HtmlAnchor getNodeLink(String linkLabel)
- {
- return getLinkInsideForm(ID_NAV_TREE_FORM, linkLabel);
- }
-
-
- /**
- * Finds the arrow icon in the nav tree that corresponds to the resource
- * given by resourceName. This method is used to expand tree nodes
- * (eg. "Web Applications (WAR)", "Datasources", etc.) in the
- * navigation tree.
- * @see getNodeByLabel().getArrowLink()
- */
- public ClickableElement getNodeArrow(String resourceName)
- {
- HtmlAnchor link = getNodeLink(resourceName);
- String id = link.getIdAttribute();
-
- // An example id is: "navTreeForm:navTree:81:82:83:84::typeSummaryLink"
- // The icon's id would be: "81:82:83:84::typeSummary:handle:img:collapsed"
- int index = id.lastIndexOf("Link");
- id = id.substring(0, index) + ":handle";
- return (ClickableElement)client.getElement(id);
- }
-
- }// class NavTree
-
-
-
- /**
- * Represents nav tree node.
- * Contains convenience methods to work with the node.
- */
- protected class NavTreeNode {
-
- /** Keeps the table element of this node. */
- private HtmlElement elem;
- public HtmlElement getElement() { return this.elem; }
-
- private NavTreeNode( HtmlTable nodeTable ){
- this.elem = nodeTable;
- }
-
- /** Returns true if this node is expanded. */
- public boolean isExpanded() throws EmbJoprTestException
- {
- HtmlAnchor arrowLink = this.getArrowLink();
- HtmlElement img = (HtmlElement)arrowLink.getFirstByXPath("img[@style='display: none;']");
-
- if( img.getId().endsWith("expanded") )
- return false;
- else if( img.getId().endsWith("collapsed") )
- return true;
- else
- throw new EmbJoprTestException("Can't determine whether nav tree node is expanded.");
-
- }
-
- /** Returns the text link of this node. */
- public HtmlAnchor getLabelLink(){
- // Until I come up with something smarter, let it be so:
- String xPath = ".//td[contains(@id,':text')]/a";
- return (HtmlAnchor) this.elem.getFirstByXPath( xPath );
- }
-
- /** Returns the arrow's link. */
- public HtmlAnchor getArrowLink(){
- String xPath = ".//td[contains(@id,':handles')]//a[contains(@id,':handle')]";
- return (HtmlAnchor) this.elem.getFirstByXPath( xPath );
- }
-
- /** Clicks the link of the this node. */
- public void click() throws IOException {
- this.getLabelLink().click();
- }
-
-
- }// class NavTreeNode()
-
-
-
-
- protected final TabMenu tabMenu = new TabMenu();
-
- /**
- * Inner class to encapsulate tab menu operations.
- */
- protected class TabMenu {
-
- public TabContentBox getTabContentBox() throws HtmlElementNotFoundException {
-
- HtmlElement contentElement = (HtmlElement) client.getElement("content");
- HtmlElement tabContentBox = (HtmlElement) contentElement.getFirstByXPath("div[@class='tabmenubox']");
- if( null == tabContentBox )
- throw new HtmlElementNotFoundException("Tab content box not found using div[@class='tabmenubox'] XPath");
-
- return new TabContentBox(tabContentBox);
- }
-
- public ClickableElement getTab( String label ) throws HtmlElementNotFoundException {
-
- DomElement element = (DomElement)client.getElement("tabmenu");
- String xPath = "ul/li/span[normalize-space(string())='"+label+"'] | ul/li/a[normalize-space(string())='"+label+"']";
- ClickableElement tabContent = element.getFirstByXPath(xPath);
-
-
- if( null == tabContent )
- throw new HtmlElementNotFoundException("Tab '"+label+"' not found using XPath '"+xPath+"'");
-
- return tabContent;
-
- }
-
- /** Returns true if the tab with given label is active (it's content is shown). */
- public boolean isTabActive( String label ) throws IOException, HtmlElementNotFoundException {
-
- StyledElement tabContent = getTab(label);
- return "span".equals( tabContent.getTagName() )
- && tabContent.getClassAttribute().contains("active");
- }
-
- /** Returns true if the tab with given label is disabled (grayed and can't be activated). */
- public boolean isTabDisabled( String label ) throws HtmlElementNotFoundException {
- StyledElement tabContent = getTab(label);
- return "span".equals( tabContent.getTagName() )
- && tabContent.getClassAttribute().contains("disabled");
- }
-
- /** Shotcut - getTab(label).click(); Not necesarilly clicks an anchor. */
- public void clickTab( String label ) throws IOException, ActionNotAvailableException, HtmlElementNotFoundException {
-
- StyledElement tabContent = getTab(label);
- if( !( tabContent instanceof ClickableElement ) )
- throw new ActionNotAvailableException("Tab element <"+tabContent.getTagName()+"> is not clickable: "+label);
-
- ((ClickableElement)tabContent).click();
-
- }
-
- }
-
-
- /**
- * Base class for parts that will check their validity before performing actions.
- * Not necessary if we pay attention to validity, but why not check it -
- * performance is not a question for us.
- *
- * TODO: Instead, use the Page returned from click() etc.
- */
- protected class PageContextAwareElement {
- private URL validForURL;
- private String validForDate;
-
- /** Store the context identifiing attributes upon creation. */
- public PageContextAwareElement() {
- // TODO: Shouldn't we store the elements's page instead of current?
- this.validForDate = client.getContentPage().getWebResponse().getResponseHeaderValue("Date");
- this.validForURL = client.getContentPage().getWebResponse().getUrl();
- }
-
- /**
- * Checks whether this element is still valid in the current web page context,
- * i.e. whether we are still on the page in which this element existed.
- * @throws org.jboss.jopr.jsfunit.exceptions.ActionOutOfSyncException
- */
- public void checkIfStillValid() throws ActionOutOfSyncException {
-
- String validForDate_ = client.getContentPage().getWebResponse().getResponseHeaderValue("Date");
- URL validForURL_ = client.getContentPage().getWebResponse().getUrl();
-
- if( !validForDate_.equals(this.validForDate) ||
- !validForURL_.equals(this.validForURL) )
- {
- throw new ActionOutOfSyncException(
- "This element wrapper was created from another page and is not valid now.");
- }
- }
-
- }
-
- /** Better try... */
- protected class PageAware {
- private Page validForPage;
- public PageAware(){
- this.validForPage = client.getContentPage();
- }
- public void checkIfStillValid() throws PageHasChangedException {
- if( !client.getContentPage().equals( this.validForPage ) )
- throw new PageHasChangedException(
- "This element wrapper was created from another page and is not valid now.",
- client.getContentPage(), this.validForPage );
- }
- }
-
-
- /**
- * Inner class for manipulation with tab content box.
- */
- protected class TabContentBox extends PageAware {
-
- private HtmlElement element;
- public HtmlElement getElement() { return element; }
-
- public TabContentBox(HtmlElement element) {
- super();
- this.element = element;
- }
-
- /**
- * Returns first table under given header.
- *
- * Unfortunately, headers are not H2 or similar, but DIV class="instructionalText".
- * To be revised later.
- *
- * @return
- */
- public ContentTable getTableUnderHeader( String headerText ) throws ActionOutOfSyncException
- {
- checkIfStillValid();
-
- String xPath = "*[contains(normalize-space(), '"+headerText+"')]/following::table";
- // [@id='resourceSummaryForm:dataTable'] - is this reliable?
- HtmlTable tableElement = (HtmlTable) element.getFirstByXPath(xPath);
- return new ContentTable(tableElement);
- }
-
- /**
- * Returns first table in the content box.
- * @param headerText
- * @return
- * @throws org.jboss.jopr.jsfunit.exceptions.ActionOutOfSyncException
- */
- public ContentTable getFirstTable() throws ActionOutOfSyncException
- {
- checkIfStillValid();
-
- String xPath = ".//form//table[contains( normalize-space(@id), ':dataTable')]";
- // [@id='resourceSummaryForm:dataTable'] - is this reliable?
- HtmlTable tableElement = (HtmlTable) element.getFirstByXPath(xPath);
- return new ContentTable(tableElement);
- }
-
-
- /**
- * Finds first button with given label inside this box.
- * @param label
- * @return
- * @throws org.jboss.jopr.jsfunit.exceptions.HtmlElementNotFoundException
- * @throws org.jboss.jopr.jsfunit.exceptions.ActionOutOfSyncException
- */
- public HtmlButtonInput getButtonByLabel( String label )
- throws HtmlElementNotFoundException, ActionOutOfSyncException {
-
- checkIfStillValid();
-
- HtmlButtonInput button = this.element.getFirstByXPath(".//input[normalize-space(@value)='"+label+"']");
- if( null == button )
- throw new HtmlElementNotFoundException("Button labelled '"+label+"' not found.");
-
- return button;
-
- }
-
- }// inner class TabContentBox
-
-
-
- /**
- * Contains convenience methods for accessing content tables in EmbJopr.
- */
- protected class ContentTable {
-
- public static final String ID_CATEGORY_DATA_TABLE = "categorySummaryForm:dataTable";
- public static final String ID_RESOURCE_DATA_TABLE = "resourceSummaryForm:dataTable";
-
- private HtmlTable element;
- public HtmlTable getElement() { return element; }
-
- /**
- * Creates a data table wrapper for the given table element.
- */
- public ContentTable( HtmlTable element ) {
- this.element = element;
- }
-
- /**
- * Creates a data table wrapper for first found element with one of these IDs:
- * ID_CATEGORY_DATA_TABLE, ID_RESOURCE_DATA_TABLE
- *
- * This method assumes there's only one "data table" per page.
- * If not, it simply returns the first in the order of IDs searched.
- * You can always specify the element using ContentTable( HtmlTable element ).
- */
- public ContentTable() throws HtmlElementNotFoundException {
-
- // Find the data table - try some known IDs.
- String[] elemIDs = { ID_CATEGORY_DATA_TABLE, ID_RESOURCE_DATA_TABLE };
- Element elem = null;
- for( String elemID : elemIDs ){
- elem = client.getElement(elemID);
- if( null != elem )
- break;
- }
- if( null == elem )
- throw new HtmlElementNotFoundException(
- "Can't find the content table element, searched IDs: "
- + elemIDs.toString() );
-
- this.element = (HtmlTable)elem;
- }
-
-
- // Columns maps
- private List<String> colLabels = null;
- private Map<String, Integer> colIndexes = null;
- //private boolean analyzedButNotFound = false;
-
-
-
- /**
- * Returns the first row that contains given text, or throws HtmlElementNotFoundException.
- * @param text
- * @return
- * @throws org.jboss.jopr.jsfunit.exceptions.HtmlElementNotFoundException
- * when no row contains specified text.
- */
- public ContentTableRow getFirstRowContainingText( String text )
- throws HtmlElementNotFoundException
- {
- if( 0 == element.getRowCount() )
- throw new HtmlElementNotFoundException("Table has no rows.");
-
- // TODO: Escape the single quotes. By doubling?
- // http://books.google.com/books?id=jzqFMlM0gb0C&pg=PA308&lpg=PA308&dq=xquery+escape+quote&source=bl&ots=DIKQ92AhHh&sig=A7adGlif6jfYKtJXGc4eZbXYeCQ&hl=cs&ei=LYCcSYKLO5ir-gazwfjtBA&sa=X&oi=book_result&resnum=8&ct=result
- String xPath = ".//tr[contains(string(), '"+text+"')]";
- HtmlTableRow elm = (HtmlTableRow) element.getFirstByXPath(xPath);
- if( null == elm )
- throw new HtmlElementNotFoundException(xPath);
- return new ContentTableRow(elm, this);
- }
-
-
-
- /**
- * Returns wrapper of the table row which contains a link with given label,
- * or null when the no such row is found.
- */
- public ContentTableRow findFirstRowContainingLink( String linkLabel )
- {
- if( 0 == element.getRowCount() )
- return null;
-
- String xPath = ".//tr[.//a[normalize-space()='"+linkLabel+"']]";
- HtmlTableRow elm = (HtmlTableRow) element.getFirstByXPath(xPath);
- if( null == elm )
- return null;
- return new ContentTableRow(elm, this);
- }
-
- public List<ContentTableRow> getRows(){
- if( 0 == element.getRowCount() )
- return Collections.EMPTY_LIST;
-
- String xPath = "./tbody/tr";
- List<HtmlTableRow> trList = (List) element.getByXPath(xPath);
- List<ContentTableRow> rows = new ArrayList(trList.size());
- for (HtmlTableRow tr : trList) {
- rows.add( new ContentTableRow(tr, this));
- }
- return rows;
- }
-
- /**
- * Returns wrapper of the table row which contains a link with given label.
- * @throws org.jboss.jopr.jsfunit.exceptions.HtmlElementNotFoundException
- * when no row with such label found.
- */
- public ContentTableRow getFirstRowContainingLink( String linkLabel )
- throws HtmlElementNotFoundException
- {
- if( 0 == element.getRowCount() )
- throw new HtmlElementNotFoundException("Table has no rows.");
-
- String xPath = ".//tr[.//a[normalize-space()='"+linkLabel+"']]";
- HtmlTableRow elm = (HtmlTableRow) element.getFirstByXPath(xPath);
- if( null == elm )
- throw new HtmlElementNotFoundException(
- "Can't find row containing link '"+linkLabel+"' using XPath: "+xPath);
- return new ContentTableRow(elm, this);
- }
-
- /**
- * Creates a list of columns headers
- * and a label => col index map.
- */
- public void analyzeColumns() throws HtmlElementNotFoundException
- {
-
- /*if( this.analyzedButNotFound )
- throw new HtmlElementNotFoundException("Table has no column headers.");
- /**/ // Give it another chance, JavaScript could change it.
-
- // Get all TH from the first THEAD row that contains TH.
- String xPath = "./thead/tr[th and position()=1]/th";
- List<HtmlTableHeaderCell> colHeaders = (List<HtmlTableHeaderCell>) this.element.getByXPath(xPath);
-
- if( 0 == colHeaders.size() ){
- //this.analyzedButNotFound = true;
- throw new HtmlElementNotFoundException("Table has no column headers.");
- }
-
- List<String> colLabels_ = new ArrayList(colHeaders.size());
- Map<String, Integer> colIndexes_ = new HashMap(colHeaders.size());
-
- //for( HtmlTableHeaderCell th : colHeaders ){
- for( int i = 0; i < colHeaders.size(); i++ ) {
- HtmlTableHeaderCell th = colHeaders.get(i);
- String sHeader = th.getTextContent();
- colLabels_.add( sHeader );
- colIndexes_.put( sHeader, i );
- }
-
- this.colLabels = colLabels_;
- this.colIndexes = colIndexes_;
-
- }
-
- /**
- * Returns an index of the column with given name in the TH header,
- * or throws HtmlElementNotFound in two cases:
- * 1) Table does not have column headers
- * 2) No header with such name was found.
- *
- * @param colName
- * @return
- * @throws org.jboss.jopr.jsfunit.exceptions.HtmlElementNotFoundException
- */
- public int getColumnIndexByName( String colName ) throws HtmlElementNotFoundException {
- if( null == this.colIndexes )
- this.analyzeColumns();
-
- Integer index = this.colIndexes.get(colName);
- if( null == index )
- throw new HtmlElementNotFoundException("No column named '"+colName+"'.");
-
- return index;
- }
-
- }// inner class ContentTable
-
-
-
-
-
- /**
- * Provides extra method that parses text-like info table (with one column).
- */
- protected class ContentInfoTable extends ContentTable {
-
- public ContentInfoTable(HtmlTable element) {
- super(element);
- }
-
- /**
- * Parses the content of the table for properties.
- * @return
- */
- public Properties getProperties()
- {
- Properties props = new Properties();
-
- // The template has label in span/strong and the value as text in td.
- String xPath = ".//tr/td[span/strong]";
- List<HtmlTableCell> cells = (List<HtmlTableCell>) this.getElement().getByXPath(xPath);
- for( HtmlTableCell cell : cells ){
- String[] parts = cell.getTextContent().split(":");
- props.put(parts[0], parts[1]);
- }
- return props;
- }
-
- }// inner class ContentInfoTable
-
-
-
- /**
- * Row of a content table.
- * Contains convenience methods for accessing content table rows in EmbJopr.
- */
- protected class ContentTableRow {
-
- private HtmlTableRow element;
- public HtmlTableRow getElement() { return element; }
-
- private ContentTable containingTable;
-
- private ContentTableRow(HtmlTableRow elm, ContentTable containingTable) {
- this.element = elm;
- this.containingTable = containingTable;
- }
-
- /**
- * Finds a <button> or <input type="button"> with the given label.
- * @param label The label of the button. Compared to a trimmed label text of the button.
- * @returns the button element - either HtmlButtonInput or HtmlButton.
- * @throws org.jboss.jopr.jsfunit.exceptions.HtmlElementNotFoundException
- */
- public ClickableElement getButtonByLabel( String label ) throws HtmlElementNotFoundException
- {
- String xPath = ".//input[@type='button' and normalize-space(@value) = '"+label+"']" +
- " || .//button[normalize-space() = '"+label+"']";
- HtmlElement elm = this.element.getFirstByXPath(xPath);
- if( null == elm )
- throw new HtmlElementNotFoundException("Can't find the button using xPath: "+xPath);
- if( !(elm instanceof HtmlButton ) && !(elm instanceof HtmlButtonInput) )
- throw new HtmlElementNotFoundException("Element is not a button, but: "+elm.getClass().getName());
-
- return (ClickableElement)elm;
- }
-
-
- /**
- * Gives the (first) link from the cell of this row, from the column with given header.
- * @param colName
- * @return
- * @throws org.jboss.jopr.jsfunit.exceptions.HtmlElementNotFoundException
- * in two cases:
- * 1) Table has no column of given name
- * 2) There's no link in that cell.
- */
- public HtmlAnchor getFirstLinkFromColumn(String colName) throws HtmlElementNotFoundException
- {
- HtmlTableCell cell = this.getCellByColumnName(colName);
-
- String xPath = ".//a";
- HtmlAnchor link = (HtmlAnchor) this.element.getFirstByXPath(xPath);
-
- if( null == link )
- throw new HtmlElementNotFoundException("No link found in column '"+colName+"'");
-
- return link;
- }
-
-
- /**
- * Returns the link with given label.
- * @param string
- */
- public HtmlAnchor getLinkByLabel(String linkLabel) throws HtmlElementNotFoundException {
- String xPath = ".//a[normalize-space()='"+linkLabel+"']";
- HtmlAnchor link = (HtmlAnchor) this.element.getFirstByXPath(xPath);
- if( null == link ){
- StringBuilder sb = new StringBuilder();
- List<HtmlElement> linksFound = this.element.getHtmlElementsByTagName("a");
- for( HtmlElement linkFound : linksFound ){
- sb.append("'").append( ((HtmlAnchor)linkFound).getTextContent() ).append("', ");
- }
- String availLinks = StringUtils.removeEnd( sb.toString(), ", " );
-
- throw new HtmlElementNotFoundException("Can't find link using '"+xPath+"', available: "+availLinks);
- }
- return link;
- }
-
- /**
- * Returns the cell of this table from given index,
- * or throws IndexOutOfBoundsException.
- *
- * TODO: May throw IndexOutOfBoundsException - leave unchecked?
- *
- * @param index
- * @return
- */
- public HtmlTableCell getCell( int index ){
- HtmlTableCell cell = this.element.getCell(index);
- return cell;
- }
-
- /**
- * Returns this row's cell element from the column with specified name.
- * @param colName Name of the column.
- * @throws org.jboss.jopr.jsfunit.exceptions.HtmlElementNotFoundException
- * if no such column exists in the table.
- */
- public HtmlTableCell getCellByColumnName( String colName ) throws HtmlElementNotFoundException
- {
- int index = this.containingTable.getColumnIndexByName(colName);
- return getCell(index);
- }
-
- /** Shortcut - returns text content of this row's cell from given column. */
- public String getCellTextByColumnName( String colName ) throws HtmlElementNotFoundException {
- return this.getCellByColumnName(colName).getTextContent();
- }
-
-
- }// inner class ContentTableRow
-
-
-
-
- /**
- * Pagination control
- * Not tested yet.
- */
- public class ContentBoxPagination {
-
- //private HtmlElement element;
- //public HtmlElement getElement() { return element; }
-
- private static final String ID_PAGE_CONTROLS = "categorySummaryForm:dataTableScroller";
- private static final String ID_PAGE_SIZE_SELECT = "categorySummaryForm:currentPageSize";
- private static final String ID_PAGINATION_TOTAL_ITEMS = "paginationTotalItems";
-
- protected HtmlDivision getPageContols(){
- return (HtmlDivision) client.getElement(ID_PAGE_CONTROLS);
- }
-
- protected HtmlSelect getPageSizeSelect(){
- return (HtmlSelect) client.getElement(ID_PAGE_SIZE_SELECT);
- }
-
- public int getTotalItemsCount() throws ActionNotAvailableException
- {
- Element e = client.getElement(ID_PAGINATION_TOTAL_ITEMS);
- String textContent = e.getTextContent();
- String[] parts = textContent.split(":");
- if( parts.length < 2 )
- throw new ActionNotAvailableException("Total pagination items count expected after 'Total:' or similar.");
-
- String countStr = parts[1].trim();
- try{
- return NumberUtils.createInteger( countStr );
- }catch(NumberFormatException ex ){
- throw new ActionNotAvailableException("Can't parse pagination items count from '"+countStr+"'", ex);
- }
- }
-
- protected HtmlSpan getGoSpan( String spanLabel ) throws HtmlElementNotFoundException {
- String xPath = ".//span[normalize-space() = '"+spanLabel+"']";
- HtmlSpan span = getPageContols().getFirstByXPath(xPath);
- if( null == span )
- throw new HtmlElementNotFoundException(
- "Span with '"+spanLabel+"' not found using XPath '"+xPath+"'");
- return span;
- }
-
- protected HtmlTableCell getGoPage( int pageNumber ) throws HtmlElementNotFoundException{
- String xPath = ".//td[normalize-space() = '"+pageNumber+"']";
- HtmlElement td = getPageContols().getFirstByXPath(xPath);
- if( null == td )
- throw new HtmlElementNotFoundException(
- "Page number "+pageNumber+" not found. Try 1 - "+this.getPageCount());
- return (HtmlTableCell) td;
- }
-
-
- public boolean goFirst() throws IOException, HtmlElementNotFoundException{
- // TODO: Compare old and new page object reference?
- HtmlSpan goSpan = getGoSpan("First");
- goSpan.click();
- return !"".equals( ((HtmlTableCell)goSpan.getParentNode()).getOnClickAttribute() );
- }
-
- public boolean goPrev() throws IOException, HtmlElementNotFoundException{
- HtmlSpan goSpan = getGoSpan("Prev");
- goSpan.click();
- return !"".equals( ((HtmlTableCell)goSpan.getParentNode()).getOnClickAttribute() );
- }
-
- public boolean goNext() throws IOException, HtmlElementNotFoundException{
- HtmlSpan goSpan = getGoSpan("Next");
- goSpan.click();
- return !"".equals( ((HtmlTableCell)goSpan.getParentNode()).getOnClickAttribute() );
- }
-
- public boolean goLast() throws IOException, HtmlElementNotFoundException{
- HtmlSpan goSpan = getGoSpan("Last");
- goSpan.click();
- return !"".equals( ((HtmlTableCell)goSpan.getParentNode()).getOnClickAttribute() );
- }
-
- public void goPage( int pageNumber ) throws IOException, HtmlElementNotFoundException{
- getGoPage(pageNumber).click();
- }
-
-
- public boolean isPageActive( int pageNumber ) throws IOException, HtmlElementNotFoundException{
- return !getGoPage(pageNumber).getStyleAttribute().contains("-inact");
- }
-
- public int getPageCount(){
- String xPath = ".//td[ count(./*) = 0 and normalize-space() > 0 ]";
- List<?> elements = getPageContols().getByXPath(xPath);
- return elements.size();
- }
-
- public int getItemsPerPage() throws HtmlElementNotFoundException, ActionNotAvailableException {
- String selectText = getPageSizeSelect().asText();
- try {
- return NumberUtils.createInteger( selectText );
- }
- catch( NumberFormatException ex ){
- throw new ActionNotAvailableException("Can't parse 'items per page' from '"+selectText+"'.", ex);
- }
- }
- public void setItemsPerPage( int num ) throws HtmlElementNotFoundException {
- String optionValue = ""+num;
- HtmlSelect pageSizeSelect = getPageSizeSelect();
-
- try{
- pageSizeSelect.getOptionByValue(optionValue);
- }
- catch( ElementNotFoundException ex ){
- // Print out available options.
- StringBuilder sb = new StringBuilder(pageSizeSelect.getOptionSize());
- for( HtmlOption opt : pageSizeSelect.getOptions() ){
- sb.append(" ").append(opt.getValueAttribute());
- }
- String possibleOptions = sb.toString().trim().replace(" ", ", ");
-
- throw new HtmlElementNotFoundException("Specified option is invalid. Try one of: "+possibleOptions, ex);
- }
-
- pageSizeSelect.setSelectedAttribute(optionValue, true);
- }
-
- }// ContentBoxPagination
-
-
-
-
- /** Calls Thread.sleep(ms), ignores the InterruptedException. */
- @SuppressWarnings("empty-statement")
- public static void sleep( int ms ) {
- try {
- Thread.sleep(3000);
- } catch (InterruptedException ex) {
- ; // We don't care, that's the purpose of this method.
- }
- }
-
-
}// ApplicationTestBaseAS5
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ApplicationsPageTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ApplicationsPageTest.java 2009-03-11 00:46:33 UTC (rev 207)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ApplicationsPageTest.java 2009-03-11 02:04:08 UTC (rev 208)
@@ -28,6 +28,7 @@
import org.jboss.jopr.jsfunit.AppConstants.DeployableTypes;
import org.jboss.jopr.jsfunit.ApplicationTestBaseAS5;
import org.jboss.jopr.jsfunit.exceptions.EmbJoprTestException;
+import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.*;
@@ -51,14 +52,14 @@
public void testNavigationToApplications() throws EmbJoprTestException, IOException {
// Wait until the tree is loaded via AJAX.
- // TODO: navTree.waitForNavTreeLoaded();
- sleep(2000);
+ // TODO: ejtt.navTree.waitForNavTreeLoaded();
+ ejtt.sleep(2000);
// Navigate to apps summary tab
- NavTreeNode appsNode = navTree.getNodeByLabel(NAV_APPLICATIONS);
+ NavTreeNode appsNode = ejtt.navTree.getNodeByLabel(NAV_APPLICATIONS);
assertNotNull(appsNode);
appsNode.click();
- tabMenu.clickTab("Summary");
+ ejtt.tabMenu.clickTab("Summary");
// Check text bits appearance.
String text = client.getElement("content").getTextContent();
@@ -78,31 +79,31 @@
public void testAppsPagination() throws EmbJoprTestException, IOException {
// Navigate to apps summary tab
- NavTreeNode appsNode = navTree.getNodeByLabel(NAV_APPLICATIONS);
+ NavTreeNode appsNode = ejtt.navTree.getNodeByLabel(NAV_APPLICATIONS);
assertNotNull(appsNode);
appsNode.click();
- tabMenu.clickTab("Summary");
+ ejtt.tabMenu.clickTab("Summary");
- sleep(1000);
+ ejtt.sleep(1000);
// Get and check total items count.
- int itemsCount = new ContentBoxPagination().getTotalItemsCount();
+ int itemsCount = ejtt.tabMenu.getTabContentBox().getPagination().getTotalItemsCount();
// Returns null, skipping.
//Number serverCount = (Number) server.getManagedBeanValue("#{paginationDataModel.size}");
//assertEquals("Items count reported in page differs from server's.", serverCount, itemsCount);
// Check whether trinomial equation fits
- int itemsPerPage = new ContentBoxPagination().getItemsPerPage();
+ int itemsPerPage = ejtt.tabMenu.getTabContentBox().getPagination().getItemsPerPage();
int expectedPages = itemsCount / itemsPerPage;
if( itemsCount % itemsPerPage > 0 )
expectedPages++;
- int pageCount = new ContentBoxPagination().getPageCount();
+ int pageCount = ejtt.tabMenu.getTabContentBox().getPagination().getPageCount();
assertEquals("Expected number of pages: "+itemsCount+" / "+itemsPerPage, expectedPages, pageCount);
// ------- FAILS HERE because of EMBJOPR-61. --------- //
int page = 0;
- while( new ContentBoxPagination().goNext() ){
+ while( ejtt.tabMenu.getTabContentBox().getPagination().goNext() ){
page++;
if( page > expectedPages )
@@ -110,7 +111,7 @@
" - to "+page+"th page, expected only "+expectedPages+".");
// Get rows.
- ContentTable table = tabMenu.getTabContentBox().getFirstTable();
+ ContentTable table = ejtt.tabMenu.getTabContentBox().getFirstTable();
List<ContentTableRow> rows = table.getRows();
// Check the number of rows listed against what set in combo.
@@ -144,10 +145,10 @@
public void testAppsListing() throws EmbJoprTestException, IOException {
// Navigate to apps summary tab
- NavTreeNode appsNode = navTree.getNodeByLabel(NAV_APPLICATIONS);
+ NavTreeNode appsNode = ejtt.navTree.getNodeByLabel(NAV_APPLICATIONS);
assertNotNull(appsNode);
appsNode.click();
- tabMenu.clickTab("Summary");
+ ejtt.tabMenu.clickTab("Summary");
@@ -161,10 +162,10 @@
// ------- FAILS HERE because of EMBJOPR-61. --------- //
int max = 100;
- while( max-- > 0 && new ContentBoxPagination().goNext() ){
+ while( max-- > 0 && ejtt.tabMenu.getTabContentBox().getPagination().goNext() ){
// Get rows.
- ContentTable table = tabMenu.getTabContentBox().getFirstTable();
+ ContentTable table = ejtt.tabMenu.getTabContentBox().getFirstTable();
List<ContentTableRow> rows = table.getRows();
// For all rows...
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EarTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EarTest.java 2009-03-11 00:46:33 UTC (rev 207)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EarTest.java 2009-03-11 02:04:08 UTC (rev 208)
@@ -36,6 +36,7 @@
import org.apache.commons.lang.StringUtils;
import org.jboss.jopr.jsfunit.AppConstants.DeployableTypes;
import org.jboss.jopr.jsfunit.exceptions.*;
+import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.*;
import org.w3c.dom.Node;
@@ -132,7 +133,7 @@
verify the archive has been deployed successfully.
*/
- public void DISABLEDtestBadEarRedeploy() throws IOException {
+ public void DISABLEDtestBadEarRedeploy() throws IOException, HtmlElementNotFoundException {
String earFilePath = System.getProperty(SYSPROP_TESTDATA_DIR) + "/ear/"+EAR_MALFORMED_APP_FILENAME;
deployEar(earFilePath);
@@ -161,7 +162,7 @@
{
// JBossAS Servers node
- NavTreeNode nodeServers = navTree.getNodeByLabel("JBossAS Servers");
+ NavTreeNode nodeServers = ejtt.getNavTree().getNodeByLabel("JBossAS Servers");
nodeServers.click();
{
@@ -175,7 +176,7 @@
client.getPageAsText().contains("UP"));
// Check whether the server is listed. If not, Exception is thrown.
ContentTableRow row =
- tabMenu.getTabContentBox().getTableUnderHeader("JBoss Application Server")
+ ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("JBoss Application Server")
.getFirstRowContainingLink("JBoss App Server:default");
// Click the server link
//HtmlAnchor link row.getLinkByLabel("JBoss App Server:default");
@@ -200,7 +201,7 @@
// TODO: This page reports "Version:5.0 CR1" - EMBJOPR-77
- navTree.getNodeByLabel("Applications").click();
+ ejtt.getNavTree().getNodeByLabel("Applications").click();
}
@@ -209,15 +210,16 @@
{
// Whooo-hooo! So much to click through!
- tabMenu.clickTab("Summary");
+ ejtt.getTabMenu().clickTab("Summary");
// TODO: Pagination options: EMBJOPR-78
// resourceDataScroller.xhtml, TableManager.java, "pageSizes".
// There's at least one Application with State == UP.
- //ContentTable table = tabMenu.getTabContentBox().getTableUnderHeader("Different types of Applications");
- ContentTable table = new ContentTable((HtmlTable)client.getElement("categorySummaryForm:dataTable"));
+ //ContentTable table = ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("Different types of Applications");
+ HtmlTable tableElement = (HtmlTable)client.getElement("categorySummaryForm:dataTable");
+ ContentTable table = ejtt.getTabMenu().getTabContentBox().getTable(tableElement);
ContentTableRow row = table.getFirstRowContainingText("UP");
// Go further - try to click on any Application that is up.
@@ -228,7 +230,7 @@
{
// Go back to applications Sumary screen.
- navTree.getNodeByLabel("Applications").click();
+ ejtt.getNavTree().getNodeByLabel("Applications").click();
}
@@ -238,27 +240,27 @@
String earFilePath = System.getProperty(SYSPROP_TESTDATA_DIR) + "/ear/"+BASIC_EAR;
deployEar( earFilePath );
- navTree.getNodeByLabel(NAV_EAR).click();
+ ejtt.getNavTree().getNodeByLabel(NAV_EAR).click();
- ContentTableRow earRow = new ContentTable().getFirstRowContainingLink(BASIC_EAR);
+ ContentTableRow earRow = ejtt.getDefaultContentTable().getFirstRowContainingLink(BASIC_EAR);
assertTrue("Page doesn't list "+BASIC_EAR+" in Summary tab.", earRow != null );
// Go to the summary through listed item.
earRow.getLinkByLabel(BASIC_EAR).click();
// Check that we have the summary tab for the selected EAR.
assertTrue( "EAR name ("+BASIC_EAR+" not found in the content box.",
- tabMenu.getTabContentBox().getElement().getTextContent().contains(BASIC_EAR) );
+ ejtt.getTabMenu().getTabContentBox().getElement().getTextContent().contains(BASIC_EAR) );
// Go to the summary through nav tree node.
- NavTreeNode earNode = navTree.getNodeByLabel(NAV_EAR);
+ NavTreeNode earNode = ejtt.getNavTree().getNodeByLabel(NAV_EAR);
if( !earNode.isExpanded() ){
log.info("Expanding.");
earNode.getArrowLink().click();
Thread.sleep(2000);
}
- navTree.getNodeByLabel(BASIC_EAR).click();
+ ejtt.getNavTree().getNodeByLabel(BASIC_EAR).click();
// Check that we have the summary tab for the selected EAR.
- tabMenu.getTabContentBox().getElement().getTextContent().contains(BASIC_EAR);
+ ejtt.getTabMenu().getTabContentBox().getElement().getTextContent().contains(BASIC_EAR);
undeployEar(BASIC_EAR);
@@ -294,14 +296,14 @@
new ActiveConditionChecker(new DescribedCondition("EAR appears in Summary tab list") {
public boolean isTrue() throws Exception {
// Refresh, then check.
- navTree.getNodeByLabel(NAV_EAR).click();
- ContentTableRow earRow = new ContentTable().findFirstRowContainingLink(BASIC_EAR);
+ ejtt.getNavTree().getNodeByLabel(NAV_EAR).click();
+ ContentTableRow earRow = ejtt.getDefaultContentTable().findFirstRowContainingLink(BASIC_EAR);
return null != earRow;
}
}).dumpPageOnTimeout(this).throwOnTimeout().waitWithTimeout(2000, 5);
- ContentTableRow earRow = new ContentTable().getFirstRowContainingLink(BASIC_EAR);
+ ContentTableRow earRow = ejtt.getDefaultContentTable().getFirstRowContainingLink(BASIC_EAR);
// Wait until the Status is "UP".
// TODO: Replace with ActiveConditionChecker.
@@ -313,8 +315,8 @@
break;
// Refresh page after 1 second.
- navTree.getNodeByLabel(NAV_EAR).click();
- earRow = new ContentTable().getFirstRowContainingLink(BASIC_EAR);
+ ejtt.getNavTree().getNodeByLabel(NAV_EAR).click();
+ earRow = ejtt.getDefaultContentTable().getFirstRowContainingLink(BASIC_EAR);
// We don't want an infinite loop by mistake.
if( maxLoops-- <= 0 ){
@@ -329,8 +331,8 @@
// Check the values in info table(s)
// General Properties
- ContentInfoTable infoTable = new ContentInfoTable(
- tabMenu.getTabContentBox().getTableUnderHeader("General Properties").getElement() );
+ HtmlTable genpropTable = ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("General Properties").getElement();
+ ContentInfoTable infoTable = ejtt.getContentInfoTable( genpropTable );
Properties props = infoTable.getProperties();
assertEquals(BASIC_EAR, props.getProperty("Name").trim());
@@ -340,8 +342,8 @@
// Resource Traits
- infoTable = new ContentInfoTable(
- tabMenu.getTabContentBox().getTableUnderHeader("Resource Traits").getElement() );
+ infoTable = ejtt.getContentInfoTable(
+ ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("Resource Traits").getElement() );
props = infoTable.getProperties();
@@ -350,9 +352,9 @@
assertEquals("no", props.getProperty("Exploded?").trim());
- // Metrics Summary
- infoTable = new ContentInfoTable(
- tabMenu.getTabContentBox().getTableUnderHeader("Metrics Summary").getElement() );
+ // Metrics Summary
+ HtmlTable summaryTable = ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("Metrics Summary").getElement();
+ infoTable = ejtt.getContentInfoTable(summaryTable);
// (nothing here yet)
@@ -376,10 +378,10 @@
String earFilePath = System.getProperty(SYSPROP_TESTDATA_DIR) + "/ear/"+BASIC_EAR;
deployEar( earFilePath );
- navTree.getNodeByLabel(NAV_EAR).click();
+ ejtt.getNavTree().getNodeByLabel(NAV_EAR).click();
waitActivelyForDeployment(DeployableTypes.EAR, BASIC_EAR, 3000, 15);
- ContentTableRow earRow = new ContentTable().getFirstRowContainingLink(BASIC_EAR);
+ ContentTableRow earRow = ejtt.getDefaultContentTable().getFirstRowContainingLink(BASIC_EAR);
// TODO: Finish
@@ -407,9 +409,9 @@
waitActivelyForDeployment( DeployableTypes.EAR, EAR_UNPACKED, 5000, 18 );
- navTree.getNodeByLabel(NAV_EAR).click();
+ ejtt.getNavTree().getNodeByLabel(NAV_EAR).click();
- ContentTableRow earRow = new ContentTable().getFirstRowContainingLink(EAR_UNPACKED);
+ ContentTableRow earRow = ejtt.getDefaultContentTable().getFirstRowContainingLink(EAR_UNPACKED);
// TODO: Finish
@@ -470,8 +472,8 @@
throws HtmlElementNotFoundException, IOException
{
// Refresh / go to the appropriate page.
- navTree.getNodeByLabel( type.getNavTreeLabel() ).click();
- ContentTableRow earRow = new ContentTable().findFirstRowContainingLink(deployableName);
+ ejtt.getNavTree().getNodeByLabel( type.getNavTreeLabel() ).click();
+ ContentTableRow earRow = ejtt.getDefaultContentTable().findFirstRowContainingLink(deployableName);
if( null == earRow ){
log.debug("Row with "+deployableName+" not present.");
return false;
@@ -632,7 +634,7 @@
undeletableFiles.add( path.getAbsolutePath() );
}
- private void deployEar( String earFilePath ) throws IOException
+ private void deployEar( String earFilePath ) throws IOException, HtmlElementNotFoundException
{
if( !(new File(earFilePath)).exists())
throw new FileNotFoundException(earFilePath);
@@ -640,7 +642,7 @@
log.info("Deploying: "+earFilePath);
// Navigate to Enterprise Archives
- navTree.getNodeLink(NAV_EAR).click();
+ ejtt.getNavTree().getNodeLink(NAV_EAR).click();
// click on the "Add new resource" button
client.click("actionHeaderForm:addNewContent"); // 404 if setThrowExceptionOnFailingStatusCode(true) above
@@ -650,7 +652,7 @@
fileInput.setContentType("application/ear");
fileInput.setValueAttribute(earFilePath);
client.click("createContentForm:addButton");
- sleep( 2000 );
+ ejtt.sleep( 2000 );
// Log the message
logServerMessage("Something went wrong with deploy: ");
@@ -660,9 +662,9 @@
{
// Navigate to Enterprise Archives
- navTree.getNodeLink(NAV_EAR).click();
+ ejtt.getNavTree().getNodeLink(NAV_EAR).click();
- tabMenu.clickTab("Summary");
+ ejtt.getTabMenu().clickTab("Summary");
HtmlButtonInput deleteButton = getAppDeleteButton( earFileName );
deleteButton.click();
@@ -671,7 +673,7 @@
logServerMessage("Something went wrong with undeploy: ");
// Sleep for 3 sec.
- sleep( 3000 );
+ ejtt.sleep( 3000 );
}
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-03-11 00:46:33 UTC (rev 207)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java 2009-03-11 02:04:08 UTC (rev 208)
@@ -47,7 +47,7 @@
* Using instance instead of static methods is necessary
* if we want to subclass this tools for AS 4 tests in the future.
*/
- protected final NavTree navTree = new NavTree();
+ public final NavTree navTree = new NavTree();
/**
* Single tab menu instance.
@@ -55,13 +55,21 @@
* Using instance instead of static methods is necessary
* if we want to subclass this tools for AS 4 tests in the future.
*/
- protected final TabMenu tabMenu = new TabMenu();
+ public final TabMenu tabMenu = new TabMenu();
+
+ public NavTree getNavTree() { return navTree; }
+ public TabMenu getTabMenu() { return tabMenu; }
+
+
+
+
+
/**
* Inner class to encapsulate navigation tree operations.
*
@@ -70,7 +78,7 @@
*
* Instead, all these methods call client methods.
*/
- protected class NavTree {
+ public class NavTree {
public static final String ID_NAV_TREE_FORM = "navTreeForm";
@@ -171,7 +179,7 @@
* Represents nav tree node.
* Contains convenience methods to work with the node.
*/
- protected class NavTreeNode {
+ public class NavTreeNode {
/** Keeps the table element of this node. */
private HtmlElement elem;
@@ -227,7 +235,7 @@
/**
* Inner class to encapsulate tab menu operations.
*/
- protected class TabMenu {
+ public class TabMenu {
public TabContentBox getTabContentBox() throws HtmlElementNotFoundException {
@@ -289,7 +297,7 @@
*
* TODO: Instead, use the Page returned from click() etc.
*/
- protected class PageContextAwareElement {
+ public class PageContextAwareElement {
private URL validForURL;
private String validForDate;
@@ -319,12 +327,13 @@
}
}
+
/**
* Base class for parts that will check their validity before performing actions.
* Not necessary if we pay attention to validity, but why not check it.
*/
- protected class PageAware {
+ public class PageAware {
private Page validForPage;
@@ -347,10 +356,13 @@
}
+
+
+
/**
* Inner class for manipulation with tab content box.
*/
- protected class TabContentBox extends PageAware {
+ public class TabContentBox extends PageAware {
private HtmlElement element;
public HtmlElement getElement() { return element; }
@@ -360,13 +372,20 @@
this.element = element;
}
+
/**
+ * Returns pagination wrapper.
+ */
+ public ContentBoxPagination getPagination(){
+ return new ContentBoxPagination();
+ }
+
+
+ /**
* Returns first table under given header.
*
* Unfortunately, headers are not H2 or similar, but DIV class="instructionalText".
* To be revised later.
- *
- * @return
*/
public ContentTable getTableUnderHeader( String headerText ) throws ActionOutOfSyncException
{
@@ -380,9 +399,6 @@
/**
* Returns first table in the content box.
- * @param headerText
- * @return
- * @throws org.jboss.jopr.jsfunit.exceptions.ActionOutOfSyncException
*/
public ContentTable getFirstTable() throws ActionOutOfSyncException
{
@@ -396,6 +412,27 @@
/**
+ * Returns table backed by the given table element.
+ */
+ public ContentTable getTable(HtmlTable table)
+ {
+ return new ContentTable(table);
+ }
+
+
+ /**
+ * Creates a data table wrapper for first found element with one of these IDs:
+ * ID_CATEGORY_DATA_TABLE, ID_RESOURCE_DATA_TABLE
+ *
+ * @see ContentTable#ContentTable()
+ */
+ public ContentTable getDefaultTable() throws HtmlElementNotFoundException{
+ return new ContentTable();
+ }
+
+
+
+ /**
* Finds first button with given label inside this box.
* @param label
* @return
@@ -422,7 +459,7 @@
/**
* Contains convenience methods for accessing content tables in EmbJopr.
*/
- protected class ContentTable {
+ public class ContentTable {
public static final String ID_CATEGORY_DATA_TABLE = "categorySummaryForm:dataTable";
public static final String ID_RESOURCE_DATA_TABLE = "resourceSummaryForm:dataTable";
@@ -603,13 +640,28 @@
}// inner class ContentTable
+ /**
+ * Creates a data table wrapper for first found element with one of these IDs:
+ * ID_CATEGORY_DATA_TABLE, ID_RESOURCE_DATA_TABLE
+ *
+ * This is a shortcut for ejtt.getTabMenu().getTabContentBox().getDefaultTable(),
+ * which we can do because it searches the element using ID.
+ *
+ * @see ContentTable#ContentTable()
+ */
+ public ContentTable getDefaultContentTable() throws HtmlElementNotFoundException{
+ return new ContentTable();
+ }
+
+
+
/**
* Provides extra method that parses text-like info table (with one column).
*/
- protected class ContentInfoTable extends ContentTable {
+ public class ContentInfoTable extends ContentTable {
public ContentInfoTable(HtmlTable element) {
super(element);
@@ -635,13 +687,20 @@
}// inner class ContentInfoTable
+ /**
+ * This is a shortcut for ejtt.getTabMenu().getTabContentBox().getContentInfoTable(tableElement).
+ */
+ public ContentInfoTable getContentInfoTable(HtmlTable tableElement) {
+ return new ContentInfoTable(tableElement);
+ }
+
/**
* Row of a content table.
* Contains convenience methods for accessing content table rows in EmbJopr.
*/
- protected class ContentTableRow {
+ public class ContentTableRow {
private HtmlTableRow element;
public HtmlTableRow getElement() { return element; }
@@ -755,7 +814,7 @@
/**
* Pagination control
- * Not tested yet.
+ * Not much tested yet.
*/
public class ContentBoxPagination {
@@ -766,11 +825,11 @@
private static final String ID_PAGE_SIZE_SELECT = "categorySummaryForm:currentPageSize";
private static final String ID_PAGINATION_TOTAL_ITEMS = "paginationTotalItems";
- protected HtmlDivision getPageContols(){
+ public HtmlDivision getPageContols(){
return (HtmlDivision) client.getElement(ID_PAGE_CONTROLS);
}
- protected HtmlSelect getPageSizeSelect(){
+ public HtmlSelect getPageSizeSelect(){
return (HtmlSelect) client.getElement(ID_PAGE_SIZE_SELECT);
}
@@ -891,7 +950,7 @@
public HtmlAnchor getLinkInsideForm(String formId, String linkLabel) throws HtmlElementNotFoundException
{
HtmlForm form = (HtmlForm)client.getElement(formId);
- String xPath = ".//a[contains(normalize-space(), '"+linkLabel+"']";
+ String xPath = ".//a[contains(normalize-space(), '"+linkLabel+"')]";
HtmlAnchor link = form.getFirstByXPath(xPath);
if( null == link )
throw new HtmlElementNotFoundException("Can't find row containing link '"+linkLabel+"' using XPath: "+xPath);
More information about the embjopr-commits
mailing list