Author: ozizka(a)redhat.com
Date: 2009-02-18 22:37:07 -0500 (Wed, 18 Feb 2009)
New Revision: 158
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EarTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EjbTest.java
Log:
Application tests updated
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java 2009-02-19
02:57:30 UTC (rev 157)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java 2009-02-19
03:37:07 UTC (rev 158)
@@ -33,6 +33,8 @@
public static final String NAV_RAR = "Resource Adaptor (RAR)s";
public static final String NAV_WAR = "Web Application (WAR)s";
+ public static final String EAR_MALFORMED_APP_FILENAME =
"malformed-application-xml.ear";
+
// Test Archives
public static final String BASIC_JAR = "deployment-ejb.jar";
public static final String BASIC_EAR = "eardeployment.ear";
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java 2009-02-19
02:57:30 UTC (rev 157)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java 2009-02-19
03:37:07 UTC (rev 158)
@@ -21,14 +21,21 @@
*/
package org.jboss.jopr.jsfunit;
-import com.gargoylesoftware.htmlunit.html.*;
-import java.io.IOException;
+import java.util.List;
import java.util.Set;
-import javax.management.JMException;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
+import javax.management.*;
import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.jopr.jsfunit.exceptions.*;
+import com.gargoylesoftware.htmlunit.html.*;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+
+
/**
* This is the base test class for Embedded Jopr Application tests.
*
@@ -38,10 +45,10 @@
public abstract class ApplicationTestBaseAS5 extends EmbjoprTestCase
implements AppConstants {
- protected String label = null;
- protected final String serviceName = null;
- protected final String xmlElementName = null;
- protected final String templateHtmlSelectValue = null;
+ //protected String label = null;
+ //protected final String serviceName = null;
+ //protected final String xmlElementName = null;
+ //protected final String templateHtmlSelectValue = null;
@@ -55,8 +62,9 @@
* This method should query the JMX server and decide whether the given
* MBean displays deployed resource.
*
- *
* TODO: Move to EmbJoprTestCase?
+ * TODO: Consider using MBean jboss.management.local:j2eeType=J2EEServer,name=Local,
+ * which has attribute String[] deployedObjects
*
* @param deploymentMBean Name of the MBean to examine. Differs between AS4 and 5.
* @return true if the MBean indicates that the resource is deployed, false otherwise.
@@ -143,5 +151,548 @@
throw new RuntimeException(e);
}
}
+
+
+
+
+
+
-}
+
+
+ /* ---- Copied from ServerNodeSummaryTest.java, before moving to EmbjoprTestCase.java
--- */
+
+
+ /**
+ * 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 {
+
+ private void clickRootNode() throws IOException, EmbJoprTestException {
+ DomElement element = (DomElement)client.getElement("navTreeForm");
+ if( null == element )
+ throw new HtmlElementNotFoundException("Can't find #navTreeForm.");
+
+ // ID changes upon core build?
+ //HtmlAnchor rootNodeLink =
element.getFirstByXPath("//a[@id='navTreeForm:navTree:2::homeLink']");
+
+ // 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, 'navTreeForm: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 NavTreeNode getNodeByLabel( String label ){
+
+ DomElement element = (DomElement)client.getElement("navTreeForm");
+
+ // A table which has an anchor containing given text.
+ String xPath = "//table[//a[contains(@id,'typeSummaryLink') and string()
= '"+label+"']]";
+ HtmlTable nodeTable = element.getFirstByXPath( xPath );
+ return new NavTreeNode(nodeTable);
+
+ }
+
+
+ /**
+ * Need a standard JSFUnit API to replace this code.
+ */
+ public HtmlAnchor getNodeLink(String linkLabel)
+ {
+ return getLinkInsideForm("navTreeForm", 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.
+ */
+ 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);
+ }
+
+
+ // TODO: DRY - see NavTreeNode::isExpanded()
+ public boolean isNodeExpanded( String linkLabel ) throws EmbJoprTestException
+ {
+ ClickableElement nodeArrow = getNodeArrow(linkLabel);
+
+ HtmlElement img =
(HtmlElement)nodeArrow.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.");
+
+ }
+
+ }// 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;
+ }
+
+
+ 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.");
+
+ }
+
+ 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 );
+ }
+
+ public HtmlAnchor getArrowLink(){
+ String xPath =
"//td[contains(@id,':handles')]//a[contains(@id,':handle')]";
+ return (HtmlAnchor) this.elem.getFirstByXPath( xPath );
+ }
+
+ 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 EmbJoprTestException {
+
+ 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 EmbJoprTestException("Tab '"+label+" not found using
XPath '"+xPath+"'");
+
+ return tabContent;
+
+ }
+
+ public boolean isTabActive( String label ) throws IOException, EmbJoprTestException {
+
+ StyledElement tabContent = getTab(label);
+ return "span".equals( tabContent.getTagName() )
+ && tabContent.getClassAttribute().contains("active");
+ }
+
+
+ public boolean isTabDisabled( String label ) throws EmbJoprTestException {
+ StyledElement tabContent = getTab(label);
+ return "span".equals( tabContent.getTagName() )
+ && tabContent.getClassAttribute().contains("disabled");
+ }
+
+ public void clickTab( String label ) throws IOException, EmbJoprTestException {
+
+ StyledElement tabContent = getTab(label);
+
+ //if( !"a".equals( tabContent.getTagName() ) )
+ //if( !( tabContent instanceof HtmlAnchor ) )
+ // throw new AssertException("Tab is not an anchor: "+label);
+
+ if( !( tabContent instanceof ClickableElement ) )
+ throw new EmbJoprTestException("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.
+ */
+ 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 tab content box was created from another page and is not valid
now.");
+ }
+ }
+
+ }
+
+
+
+ /**
+ * Inner class for manipulation with tab content box.
+ */
+ protected class TabContentBox extends PageContextAwareElement {
+
+ 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(string(),
'"+headerText+"']/following::table";
+ // [@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[@value =
'"+label+"']");
+ if( null == button )
+ throw new HtmlElementNotFoundException("Button labelled
'"+label+"' not found.");
+
+ return button;
+
+ }
+
+ }// inner class TabContentBox
+
+
+
+ /**
+ * Row of a content table.
+ * Contains convenience methods for accessing content tables in EmbJopr.
+ */
+ protected class ContentTable {
+
+ private HtmlTable element;
+ public HtmlTable getElement() { return element; }
+
+ public ContentTable( HtmlTable element) {
+ this.element = element;
+ }
+
+ // 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&...
+ String xPath = "//tr[contains(string(), '"+text+"')]";
+ HtmlTableRow elm = (HtmlTableRow) element.getFirstByXPath(xPath);
+ if( null == elm )
+ throw new HtmlElementNotFoundException(xPath);
+ return new ContentTableRow(elm, this);
+ }
+
+ public ContentTableRow getFirstRowContainingLink( String linkLabel )
+ throws HtmlElementNotFoundException
+ {
+ if( 0 == element.getRowCount() )
+ throw new HtmlElementNotFoundException("Table has no rows.");
+
+ String xPath = "//tr[//a[string() = '"+linkLabel+"']]";
+ HtmlTableRow elm = (HtmlTableRow) element.getFirstByXPath(xPath);
+ if( null == elm )
+ throw new HtmlElementNotFoundException(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 pos()=0]/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
+
+
+
+ /**
+ * 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 @value =
'"+label+"']" +
+ " || //button[ string() = '"+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[string()='"+linkLabel+"']";
+ HtmlAnchor link = (HtmlAnchor) this.element.getFirstByXPath(xPath);
+ if( null == link )
+ throw new HtmlElementNotFoundException(xPath);
+ 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;
+ }
+
+ public HtmlTableCell getCellByColumnName( String colName ) throws
HtmlElementNotFoundException
+ {
+ if( null == this.containingTable.colIndexes ){
+ //throw new HtmlElementNotFoundException("Table does not have columns analyzed
yet.");
+ this.containingTable.analyzeColumns();
+ }
+
+ int index = this.containingTable.colIndexes.get(colName);
+ return getCell(index);
+ }
+
+ public String getCellTextByColumnName( String colName ) throws
HtmlElementNotFoundException {
+ return this.getCellByColumnName(colName).getTextContent();
+ }
+
+
+ }// inner class ContentTableRow
+
+
+}// ApplicationTestBaseAS5
+
+
+
+
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-02-19
02:57:30 UTC (rev 157)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EarTest.java 2009-02-19
03:37:07 UTC (rev 158)
@@ -27,7 +27,10 @@
import java.io.IOException;
import junit.framework.Test;
import junit.framework.TestSuite;
-import javax.faces.application.FacesMessage;
+import org.jboss.jopr.jsfunit.exceptions.ActionOutOfSyncException;
+import org.jboss.jopr.jsfunit.exceptions.EmbJoprTestException;
+import org.jboss.jopr.jsfunit.exceptions.HtmlElementNotFoundException;
+import org.w3c.dom.Node;
@@ -52,53 +55,196 @@
/*
* testName: testBasicEarDeployment
- * assertion: verify basic deployment of Enterprise Archive
+ * assertion: verify basic deployment of Enterprise Archive
* test Strategy: Navigate to Enterprise Applications.
* Add a new resource. Verify the resource was successfully
* deployed. Undeploy the archive for test clean up purposes.
*
*/
- public void testBasicEarDeployment() throws IOException
+ public void testBasicEarDeployment() throws IOException, EmbJoprTestException
{
- // Navigate to Enterprise Archives
- HtmlAnchor earLink = getNavTreeLink(NAV_EAR);
- earLink.click();
- // click on the "Add new resource" button
- client.click("actionHeaderForm:addNewContent"); // 404 if
setThrowExceptionOnFailingStatusCode(true) above
+ String earFilePath = System.getProperty("jsfunit.testdata") +
"/ear/"+BASIC_EAR;
+ deployEar( earFilePath );
- // upload hellothere.war
- HtmlFileInput fileInput =
(HtmlFileInput)client.getElement("createContentForm:file");
- fileInput.setContentType("application/ear");
- fileInput.setValueAttribute(System.getProperty("jsfunit.testdata") +
"/ear/eardeployment.ear");
- client.click("createContentForm:addButton");
+ String expectedMessage = BASIC_EAR + " created successfully";
- // assert that the success message appeared on the client side
- assertTrue(client.getPageAsText().contains("eardeployment.ear created
successfully"));
+ checkClientAndServerMessages(expectedMessage, expectedMessage, false);
- // assert text and sevrity level for FacesMessage on server side
- assertTrue(server.getFacesMessages().hasNext());
- FacesMessage successMessage = server.getFacesMessages().next();
- assertTrue(FacesMessage.SEVERITY_INFO.equals(successMessage.getSeverity()));
- assertTrue(successMessage.getDetail().contains("eardeployment.ear created
successfully"));
-
// Use JMX to assert that the EAR components really did deploy successfully
- assertTrue("JMX doesn't report EAR as exposed: eardeployment.ear",
isEarDeployed("eardeployment.ear"));
+ assertTrue("JMX doesn't report EAR as exposed: eardeployment.ear",
isEarDeployed(BASIC_EAR));
assertTrue("JMX doesn't report EJB sessiona.jar as exposed.",
isEJBDeployed("sessiona.jar"));
assertTrue("JMX doesn't report EJB sessionb.jar as exposed.",
isEJBDeployed("sessionb.jar"));
// Undeploy the EAR
- HtmlButtonInput deleteButton = getAppDeleteButton("eardeployment.ear");
- deleteButton.click();
+ undeployEar( BASIC_EAR );
- assertTrue(client.getPageAsText().contains("Successfully deleted Enterprise
Application (EAR) 'eardeployment.ear'."));
+ expectedMessage = "Successfully deleted Enterprise Application (EAR)
'"+BASIC_EAR+"'.";
+ assertTrue(client.getPageAsText().contains( expectedMessage ));
// This assert doesn't work. The JXM view is not consistent with the mananaged
view.
// JBAS-XXXX
//assertFalse(isEarDeployed("eardeployment.ear"));
//assertFalse(isEJBDeployed("sessiona.jar"));
//assertFalse(isEJBDeployed("sessionb.jar"));
+
}
+ /**
+ * assertion:
+
+ Verify an .ear that contained a bad deployment descriptor
+ fails deployment, fixed using console, and can then be
+ successfully deployed.
+ test Strategy:
+
+ Deploy an .ear that is known to have a bad deployment
+ descriptor. Verify the console shows deployment failed.
+ Edit the .ear resource to fix the achive. Redeploy and
+ verify the archive has been deployed successfully.
+
+ */
+ public void testBadEarRedeploy() throws IOException {
+
+ String earFilePath = System.getProperty("jsfunit.testdata") +
"/ear/"+EAR_MALFORMED_APP_FILENAME;
+ deployEar(earFilePath);
+
+ checkClientAndServerMessages("Failed to create Resource", "Failed to
create Resource", true);
+
+ }
+
+ /**
+ * assertion:
+
+ Verify the navigation sequence to Enterprise Applications.
+
+ test Strategy:
+
+ From the root of the navigation tree:
+ Click JBossAS Servers ==> JBoss App Server:${config}
+ ==> Applications ==> Enterprise Application
+
+ * @param earFilePath
+ * @throws java.io.IOException
+ */
+ public void testNavigationToEar() throws IOException, HtmlElementNotFoundException,
ActionOutOfSyncException
+ {
+
+ NavTreeNode nodeServers = navTree.getNodeByLabel("JBossAS Servers");
+ nodeServers.click();
+ // --- click ---
+
+ {
+ String headerText = "JBossAS Server";
+
+ assertTrue("Page doesn't contain the header: "+headerText,
+ client.getPageAsText().contains(headerText));
+
+ assertTrue("EmbJopr should list at least one server (the one it is running
on)" +
+ " and that should be in the UP sate.",
+ client.getPageAsText().contains("UP"));
+ // Check whether the server is listed. If not, Exception is thrown.
+ ContentTableRow row =
+ tabMenu.getTabContentBox().getTableUnderHeader("JBoss Application
Server")
+ .getFirstRowContainingLink("JBoss App Server:default");
+ // Click the server link
+ //HtmlAnchor link row.getLinkByLabel("JBoss App Server:default");
+ Node firstLink =
row.getCellByColumnName("Name").getElementsByTagName("a").item(0);
+ if( null == firstLink || !(firstLink instanceof HtmlAnchor) )
+ throw new HtmlElementNotFoundException("Can't find the server link.");
+
+ ((HtmlAnchor)firstLink).click();
+ }
+ // --- click ---
+
+ {
+ String pageText = client.getPageAsText();
+
+ String headerText = "JBoss App Server:default";
+ assertTrue("Page doesn't contain the header: "+headerText,
+ pageText.contains(headerText));
+
+ headerText = "General Properties";
+ assertTrue("Page doesn't contain the header: "+headerText,
+ pageText.contains(headerText));
+
+ // TODO: This page reports "Version:5.0 CR1" - EMBJOPR-77
+
+ navTree.getNodeByLabel("Applications").click();
+
+ }
+ // --- click ---
+
+
+ {
+ // Whooo-hooo! So much to click through!
+
+ // 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"));
+ ContentTableRow row = table.getFirstRowContainingText("UP");
+
+ // Go further - try to click on any Application that is up.
+ HtmlAnchor link = row.getFirstLinkFromColumn("Name");
+ link.click();
+ }
+ // --- click ---
+
+
+ {
+ navTree.getNodeByLabel("Applications").click();
+ }
+ // --- click ---
+
+
+ {
+ navTree.getNodeByLabel(NAV_EAR).click();
+ }
+ // --- click ---
+
+
+
+
+
+ }// testNavigationToEar()
+
+
+
+ private void deployEar( String earFilePath ) throws IOException
+ {
+
+ // Navigate to Enterprise Archives
+ navTree.getNodeLink(NAV_EAR).click();
+
+ // click on the "Add new resource" button
+ client.click("actionHeaderForm:addNewContent"); // 404 if
setThrowExceptionOnFailingStatusCode(true) above
+
+ // upload hellothere.war
+ HtmlFileInput fileInput =
(HtmlFileInput)client.getElement("createContentForm:file");
+ fileInput.setContentType("application/ear");
+ fileInput.setValueAttribute(earFilePath);
+ client.click("createContentForm:addButton");
+ }
+
+ private void undeployEar( String earFileName ) throws IOException, EmbJoprTestException
+ {
+
+ // Navigate to Enterprise Archives
+ navTree.getNodeLink(NAV_EAR).click();
+
+ tabMenu.clickTab("Summary");
+
+ HtmlButtonInput deleteButton = getAppDeleteButton( earFileName );
+ deleteButton.click();
+
+
+ }
+
+
+
}
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EjbTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EjbTest.java 2009-02-19
02:57:30 UTC (rev 157)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EjbTest.java 2009-02-19
03:37:07 UTC (rev 158)
@@ -73,6 +73,9 @@
// click on the "Add new resource" button
client.click("actionHeaderForm:addNewContent"); // 404 if
setThrowExceptionOnFailingStatusCode(true) above
+ // TODO: "/ejb/BASIC_JAR" causes exceptions in seam:
+ //
http://wwwapps.rdu.redhat.com/w3xpastebin/pastebin.php?show=9842
+
String filePath = System.getProperty("jsfunit.testdata") +
"/ejb/"+BASIC_JAR;
log.info("Uploading EJB archive: "+filePath);
File uploadFile = new File(filePath);