Author: ozizka(a)redhat.com
Date: 2009-03-13 18:37:38 -0400 (Fri, 13 Mar 2009)
New Revision: 226
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EarTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/ActiveConditionChecker.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java
Log:
Added tests for EAR.
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-13
21:20:31 UTC (rev 225)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EarTest.java 2009-03-13
22:37:38 UTC (rev 226)
@@ -289,7 +289,7 @@
* junit.framework.ComparisonFailure: expected:<eardeployment.ear> but
was:<ondra-redhat>
at org.jboss.jopr.jsfunit.as5.EarTest.testEarSummaryTab(EarTest.java:323)
*/
- public void DISABLEDtestEarSummaryTab() throws EmbJoprTestException, IOException,
Exception {
+ public void testEarSummaryTab() throws EmbJoprTestException, IOException, Exception {
final int DEPLOY_TIMEOUT_SEC = 10;
@@ -297,75 +297,80 @@
String earFilePath = System.getProperty(SYSPROP_TESTDATA_DIR) +
"/ear/"+BASIC_EAR;
deployEar( earFilePath );
- // Wait until the EAR appears...
- new ActiveConditionChecker(new DescribedCondition("EAR appears in Summary tab
list") {
- public boolean isTrue() throws Exception {
- // Refresh, then check.
- ejtt.getNavTree().getNodeByLabel(NAV_EAR).click();
- ContentTableRow earRow =
ejtt.getDefaultContentTable().findFirstRowContainingLink(BASIC_EAR);
- return null != earRow;
- }
- }).dumpPageOnTimeout(this).throwOnTimeout().waitWithTimeout(2000, 5);
-
+ try {
- ContentTableRow earRow =
ejtt.getDefaultContentTable().getFirstRowContainingLink(BASIC_EAR);
+ // Wait until the EAR appears...
+ new ActiveConditionChecker(new DescribedCondition("EAR appears in Summary tab
list") {
+ public boolean isTrue() throws Exception {
+ // Refresh, then check.
+ ejtt.getNavTree().getNodeByLabel(NAV_EAR).click();
+ ContentTableRow earRow =
ejtt.getDefaultContentTable().findFirstRowContainingLink(BASIC_EAR);
+ return null != earRow;
+ }
+ }).dumpPageOnTimeout(this).throwOnTimeout().waitWithTimeout(2000, 5);
- // Wait until the Status is "UP".
- // TODO: Replace with ActiveConditionChecker.
- int maxLoops = DEPLOY_TIMEOUT_SEC;
- do {
- String statusText = earRow.getCellTextByColumnName("Status");
- log.debug("EAR Status: "+statusText);
- if( "UP".equals(statusText) )
- break;
- // Refresh page after 1 second.
- ejtt.getNavTree().getNodeByLabel(NAV_EAR).click();
- earRow = ejtt.getDefaultContentTable().getFirstRowContainingLink(BASIC_EAR);
+ ContentTableRow earRow =
ejtt.getDefaultContentTable().getFirstRowContainingLink(BASIC_EAR);
- // We don't want an infinite loop by mistake.
- if( maxLoops-- <= 0 ){
- throw new EmbJoprTestException("EAR "+BASIC_EAR+" not UP after
"+DEPLOY_TIMEOUT_SEC+" seconds.");
- }
- } while( true );
+ // Wait until the Status is "UP".
+ // TODO: Replace with ActiveConditionChecker.
+ int maxLoops = DEPLOY_TIMEOUT_SEC;
+ do {
+ String statusText = earRow.getCellTextByColumnName("Status");
+ log.debug("EAR Status: "+statusText);
+ if( "UP".equals(statusText) )
+ break;
- // FAILS because of EMBJOPR-80.
- earRow.getLinkByLabel(BASIC_EAR).click();
+ // Refresh page after 1 second.
+ ejtt.getNavTree().getNodeByLabel(NAV_EAR).click();
+ earRow = ejtt.getDefaultContentTable().getFirstRowContainingLink(BASIC_EAR);
+ // We don't want an infinite loop by mistake.
+ if( maxLoops-- <= 0 ){
+ throw new EmbJoprTestException("EAR "+BASIC_EAR+" not UP after
"+DEPLOY_TIMEOUT_SEC+" seconds.");
+ }
+ } while( true );
- // Check the values in info table(s)
+ // FAILS because of EMBJOPR-80.
+ earRow.getLinkByLabel(BASIC_EAR).click();
- // General Properties
- 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());
- //assertEquals("?", props.getProperty("Version")); // TODO: Where
does RHQ get the version from?
- // TODO: Fill JIRA? Description of EAR should be taken from application.xml
<display-name>
- //assertEquals("JBossTest Ear Deployment Testsuite",
props.getProperty("Description"));
+ // Check the values in info table(s)
+ // General Properties
+ HtmlTable genpropTable =
ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("General
Properties").getElement();
+ ContentInfoTable infoTable = ejtt.getContentInfoTable( genpropTable );
+ Properties props = infoTable.getProperties();
- // Resource Traits
- infoTable = ejtt.getContentInfoTable(
- ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("Resource
Traits").getElement() );
- props = infoTable.getProperties();
+ assertEquals(BASIC_EAR, props.getProperty("Name").trim());
+ //assertEquals("?", props.getProperty("Version")); // TODO: Where
does RHQ get the version from?
+ // TODO: Fill JIRA? Description of EAR should be taken from application.xml
<display-name>
+ //assertEquals("JBossTest Ear Deployment Testsuite",
props.getProperty("Description"));
- String path = System.getProperty(SYSPROP_DEPLOY_DIR)+"/"+BASIC_EAR;
- assertEquals(path, props.getProperty("Path").trim());
-
- assertEquals("no", props.getProperty("Exploded?").trim());
+ // Resource Traits
+ infoTable = ejtt.getContentInfoTable(
+ ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("Resource
Traits").getElement() );
+ props = infoTable.getProperties();
- // Metrics Summary
- HtmlTable summaryTable =
ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("Metrics
Summary").getElement();
- infoTable = ejtt.getContentInfoTable(summaryTable);
- // (nothing here yet)
+ String path = ejtt.getDeployDir()+"/"+BASIC_EAR;
+ assertEquals(path, props.getProperty("Path").trim());
- // Undeploy the EAR
- undeployEar( BASIC_EAR );
+ assertEquals("no", props.getProperty("Exploded?").trim());
+ // Metrics Summary
+ HtmlTable summaryTable =
ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("Metrics
Summary").getElement();
+ infoTable = ejtt.getContentInfoTable(summaryTable);
+ // (nothing here yet)
+
+
+ }
+ finally {
+ // Undeploy the EAR
+ undeployEar( BASIC_EAR );
+ }
+
}// testEarSummary()
@@ -373,12 +378,12 @@
/**
* Changes EAR configuration, and checks whether the changes were saved.
*
- * PASSED.
+ * FAILS because some of the values are read-only. EMBJOPR-96
*/
public void testEarConfigurationTab() throws IOException, EmbJoprTestException {
// Deploy the EAR.
- String earFilePath = System.getProperty(SYSPROP_TESTDATA_DIR) +
"/ear/"+BASIC_EAR;
+ String earFilePath = ejtt.getTestDataDir() +"/ear/"+ BASIC_EAR;
deployEar( earFilePath );
try {
@@ -401,7 +406,7 @@
log.info("Res ./ URL: "+ObjectUtils.toString(resUrl));
resUrl =
this.getClass().getResource("/org/jboss/jopr/jsfunit/as5/props/ear-conf-basic.properties");
log.info("Res full URL: "+ObjectUtils.toString(resUrl));
-
+
Enumeration<URL> resources =
this.getClass().getClassLoader().getResources("ear-conf-basic.properties");
while( resources.hasMoreElements() ){
log.info("Resources URL: "+ObjectUtils.toString( resources.nextElement()
));
@@ -428,9 +433,10 @@
// TODO: We don't see the success message! EMBJOPR-89
//checkClientAndServerMessages("successfully", "successfully",
false);
+ // FAILS because some of the values are read-only. EMBJOPR-96
checkForm(props);
- // TODO: Finish
+ // TODO: Finish when the properties are marked read-only.
}
finally {
@@ -440,7 +446,154 @@
}
+
/**
+ * Changes EAR configuration, and checks whether the changes were saved.
+ *
+ * FAILS because some of the values are read-only. EMBJOPR-96
+ */
+ public void testEarRedeployment() throws IOException, EmbJoprTestException {
+
+ // Deploy the EAR.
+ String earFilePath = ejtt.getTestDataDir() +"/ear/"+ BASIC_EAR;
+ deployEar( earFilePath );
+
+ try {
+
+ ejtt.getNavTree().getNodeByLabel(NAV_EAR).click();
+ waitActivelyForDeployment(DeployableTypes.EAR, BASIC_EAR, 3000, 15);
+
+ // Navigate to the Configuration tab
+ ContentTableRow earRow =
ejtt.getDefaultContentTable().getFirstRowContainingLink(BASIC_EAR);
+ earRow.getLinkByLabel(BASIC_EAR).click();
+ ejtt.tabMenu.clickControlTab();
+
+ String xPath = ".//table//input[@type='file']";
+ HtmlFileInput fileInput =
ejtt.tabMenu.getTabContentBox().getElement().getFirstByXPath(xPath);
+ fileInput.setValueAttribute(earFilePath);
+ xPath = ".//table//input[@type='submit']";
+ HtmlSubmitInput submit =
ejtt.tabMenu.getTabContentBox().getElement().getFirstByXPath(xPath);
+ submit.click();
+
+
+
+ }
+ finally {
+ undeployEar(BASIC_EAR);
+ }
+
+ }
+
+
+
+ /**
+ * Deploys exploded EAR and checks whether it is reported as exploded.
+ *
+ * FAILS: EMBJOPR-95
+ */
+ public void testUnzippedEarReportedAsExploded() throws IOException, EmbJoprTestException
{
+
+ // Deploy the EAR.
+ String earFilePath = ejtt.getTestDataDir() + "/ear/"+BASIC_EAR;
+ deployEar( earFilePath );
+
+ try {
+ // Wait for EAR to be deployed and UP
+ ejtt.getNavTree().getNodeByLabel(NAV_EAR).click();
+ waitActivelyForDeployment(DeployableTypes.EAR, BASIC_EAR, 3000, 15);
+
+ ContentTable table =
ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("Resource Traits");
+ ContentInfoTable infoTable =
ejtt.getTabMenu().getTabContentBox().getContentInfoTable(table.getElement());
+ Properties properties = infoTable.getProperties();
+ assertEquals("'Exploded?' should be 'yes'", "yes",
properties.getProperty("Exploded?").toLowerCase() );
+
+ }
+ finally {
+ undeployEar(BASIC_EAR);
+ }
+
+ }
+
+
+
+
+ /**
+ * Checks EAR metrics tab.
+ */
+ public void testEarMetricsTab() throws IOException, EmbJoprTestException {
+
+ // Deploy the EAR.
+ String earFilePath = ejtt.getTestDataDir() + "/ear/"+BASIC_EAR;
+ deployEar( earFilePath );
+
+ try {
+
+ ejtt.getNavTree().getNodeByLabel(NAV_EAR).click();
+ waitActivelyForDeployment(DeployableTypes.EAR, BASIC_EAR, 3000, 15);
+
+ // Navigate to the Metrics tab
+ ContentTableRow earRow =
ejtt.getDefaultContentTable().getFirstRowContainingLink(BASIC_EAR);
+ earRow.getLinkByLabel(BASIC_EAR).click();
+ ejtt.tabMenu.clickMetricsTab();
+
+ // Resource Traits
+
+ // Check the Path.
+ ContentInfoTable infoTable = ejtt.getContentInfoTable(
+ ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("Resource
Traits").getElement() );
+ Properties props = infoTable.getProperties();
+
+ String path = ejtt.getDeployDir()+"/"+BASIC_EAR;
+ assertEquals(path, props.getProperty("Path").trim());
+
+
+ }
+ finally {
+ undeployEar(BASIC_EAR);
+ }
+
+ }
+
+
+ /**
+ * Changes EAR configuration, and checks whether the changes were saved.
+ *
+ * FAILS because some of the values are read-only. EMBJOPR-96
+ */
+ public void testEarMetricsTabRefreshButton() throws IOException, EmbJoprTestException {
+
+ // Deploy the EAR.
+ String earFilePath = ejtt.getTestDataDir() + "/ear/"+BASIC_EAR;
+ deployEar( earFilePath );
+
+ try {
+
+ ejtt.getNavTree().getNodeByLabel(NAV_EAR).click();
+ waitActivelyForDeployment(DeployableTypes.EAR, BASIC_EAR, 3000, 15);
+
+ // Navigate to the Metrics tab
+ ContentTableRow earRow =
ejtt.getDefaultContentTable().getFirstRowContainingLink(BASIC_EAR);
+ earRow.getLinkByLabel(BASIC_EAR).click();
+ ejtt.tabMenu.clickMetricsTab();
+
+ // Click the Refresh button.
+ // Can this change to submit? Perhaps set an ID and use ejtt.getClickableById().
+ ejtt.tabMenu.getTabContentBox().getButtonByLabel("Refresh").click();
+
+ // Check that we are still on the right tab.
+ assertTrue("Metrics tab is active",
ejtt.tabMenu.isTabActive("Metrics") );
+ assertTrue("Page contains EAR name",
client.getPageAsText().contains(BASIC_EAR) );
+ assertTrue("Page contains 'Refresh'",
client.getPageAsText().contains("Refresh") );
+
+ }
+ finally {
+ undeployEar(BASIC_EAR);
+ }
+
+ }
+
+
+ /**
* Deploys an exploded EAR application.
*
* PASSED.
@@ -480,13 +633,14 @@
+
+
+
/**
* Waits for the deployable to be in the UP State.
*
* @param type Type of deployable - EAR, WAR, SAR, ...
* @param name Name of the deployable, like 'hello.war'.
- * @throws org.jboss.jopr.jsfunit.exceptions.EmbJoprTestException
- * @throws java.io.IOException
*/
private void waitActivelyForDeployment(
final DeployableTypes type, final String name,
@@ -656,7 +810,7 @@
// TODO: Move to utils
private void deleteFromDeployDir( String deployableName ) throws IOException{
- String deployDir = System.getProperty(SYSPROP_DEPLOY_DIR);
+ String deployDir = ejtt.getDeployDir();
File dirToDelete = new File( deployDir, deployableName);
// Just not to delete something accidentally...
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/ActiveConditionChecker.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/ActiveConditionChecker.java 2009-03-13
21:20:31 UTC (rev 225)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/ActiveConditionChecker.java 2009-03-13
22:37:38 UTC (rev 226)
@@ -28,9 +28,12 @@
@SuppressWarnings("empty-statement")
public boolean waitWithTimeout( int msInterval, int retries ) throws Exception {
+ log.info("Waiting for condition: "+condition.getDescription());
+
while( retries-- > 0 ){
if( this.condition.isTrue() )
return true;
+ log.info(" Condition not satisfied, "+retries+" left. Sleeping for
"+msInterval+" ms.");
try {
Thread.sleep(msInterval);
} catch (InterruptedException ex){
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-13
21:20:31 UTC (rev 225)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java 2009-03-13
22:37:38 UTC (rev 226)
@@ -74,6 +74,9 @@
return System.getProperty(AppConstants.SYSPROP_TESTDATA_DIR);
}
+ public String getDeployDir() {
+ return System.getProperty(AppConstants.SYSPROP_DEPLOY_DIR);
+ }
/**
@@ -327,19 +330,34 @@
/** Returns true if the tab with given label is active (it's content is shown). */
public boolean isTabActive( String label ) throws IOException,
HtmlElementNotFoundException {
+ return isTabActive( getTabByLabel(label) );
+ }
- StyledElement tabContent = getTabByLabel(label);
- return "span".equals( tabContent.getTagName() )
- && tabContent.getClassAttribute().contains("active");
+ /** Returns true if the tab with given ID is active (it's content is shown). */
+ public boolean isTabActiveByID( String id ) throws IOException,
HtmlElementNotFoundException {
+ return isTabActive( getTabByID(id) );
}
/** 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 = getTabByLabel(label);
- return "span".equals( tabContent.getTagName() )
- && tabContent.getClassAttribute().contains("disabled");
+ return isTabDisabled( getTabByLabel(label) );
}
+ /** Returns true if the tab with given ID is disabled (grayed and can't be
activated). */
+ public boolean isTabDisabledByID( String id ) throws HtmlElementNotFoundException {
+ return isTabDisabled( getTabByID(id) );
+ }
+
+ public boolean isTabActive( StyledElement tab ){
+ return "span".equals( tab.getTagName() )
+ && tab.getClassAttribute().contains("active");
+ }
+
+ public boolean isTabDisabled( StyledElement tab ){
+ return "span".equals( tab.getTagName() )
+ && tab.getClassAttribute().contains("disabled");
+ }
+
/** Shotcut - getTab(label).click(); Not necesarilly clicks an anchor. */
public void clickTab( String label ) throws IOException, ActionNotAvailableException,
HtmlElementNotFoundException {
@@ -516,6 +534,14 @@
}
+ /**
+ * Returns content info table based on given table element.
+ */
+ public ContentInfoTable getContentInfoTable(HtmlTable tableElement) {
+ return new ContentInfoTable(tableElement);
+ }
+
+
}// inner class TabContentBox