Author: ozizka(a)redhat.com
Date: 2009-04-02 15:20:48 -0400 (Thu, 02 Apr 2009)
New Revision: 272
Added:
trunk/jsfunit/src/test/resources/
trunk/jsfunit/testdata/war/hellothere-DUD.war
trunk/jsfunit/testdata/war/hellothere-DUD_RETRY.war
trunk/jsfunit/testdata/war/hellothere-RESTART.war
trunk/jsfunit/testdata/war/hellothere-STOP_START.war
trunk/jsfunit/testdata/war/hellothere02.war
trunk/jsfunit/testdata/war/hellothere03.war
trunk/jsfunit/testdata/war/hellothere04.war
trunk/jsfunit/testdata/war/hellothere05.war
trunk/jsfunit/testdata/war/hellothere06.war
trunk/jsfunit/testdata/war/hellothere07.war
trunk/jsfunit/testdata/war/hellothere08.war
trunk/jsfunit/testdata/war/hellothere09.war
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/WarTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java
Log:
WAR tests updated;
WAR tests added for Stop-Start and Restart operations.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java 2009-04-02
15:55:55 UTC (rev 271)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java 2009-04-02
19:20:48 UTC (rev 272)
@@ -26,6 +26,7 @@
public static final String SYSPROP_DEPLOY_DIR = "jsfunit.deploy.dir";
public static final String SYSPROP_TESTDATA_DIR = "jsfunit.testdata";
+ public static final String SYSPROP_TEMP_DIR = "jsfunit.tempdir";
@@ -116,6 +117,19 @@
public static final String EAR_UNPACKED_ZIP = "unpacked-ear1.ear.zip";
public static final String BASIC_WAR = "hellothere.war";
+ public static final String BASIC_WAR_02 = "hellothere02.war";
+ public static final String BASIC_WAR_03 = "hellothere03.war";
+ public static final String BASIC_WAR_04 = "hellothere04.war";
+ public static final String BASIC_WAR_05 = "hellothere05.war";
+ public static final String BASIC_WAR_06 = "hellothere06.war";
+ public static final String BASIC_WAR_07 = "hellothere07.war";
+ public static final String BASIC_WAR_08 = "hellothere08.war";
+ public static final String BASIC_WAR_09 = "hellothere09.war";
+ public static final String BASIC_WAR_DUD = "hellothere-DUD.war";
+ public static final String BASIC_WAR_DUD_RETRY =
"hellothere-DUD_RETRY.war";
+ public static final String BASIC_WAR_STOPSTART =
"hellothere-STOP_START.war";
+ public static final String BASIC_WAR_RESTART = "hellothere-RESTART.war";
+
public static final String WAR_UNPACKED = "unpacked-web1.war";
public static final String WAR_UNPACKED_ZIP = "unpacked-web1.war.zip";
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/WarTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/WarTest.java 2009-04-02
15:55:55 UTC (rev 271)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/WarTest.java 2009-04-02
19:20:48 UTC (rev 272)
@@ -31,10 +31,10 @@
import com.gargoylesoftware.htmlunit.html.*;
import java.io.*;
import java.util.Properties;
-import javax.faces.application.FacesMessage;
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.apache.commons.lang.math.RandomUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.math.NumberUtils;
import org.jboss.jopr.jsfunit.exceptions.*;
import org.jboss.jopr.jsfunit.util.ActiveConditionChecker;
import org.jboss.jopr.jsfunit.util.DescribedCondition;
@@ -75,8 +75,10 @@
throws IOException, HtmlElementNotFoundException, ActionNotAvailableException
{
- String filePath = ejtt.getTestDataDir() + "/war/"+BASIC_WAR;
+ final String DEPLOYABLE_NAME = BASIC_WAR;
+ String filePath = ejtt.getTestDataDir() + "/war/"+DEPLOYABLE_NAME;
+
try {
deployWAR( filePath );
@@ -85,7 +87,7 @@
checkClientAndServerMessages(expectedMessage, expectedMessage, false);
// Use JMX to assert that the WAR really did deploy successfully
- assertTrue("WAR was not deployed according to JMX",
isWarDeployed(BASIC_WAR));
+ assertTrue("WAR was not deployed according to JMX",
isWarDeployed(DEPLOYABLE_NAME));
// use HtmlUnit to test the newly deployed war in a new WebClient session
// note that I have full access to the FacesContext and the previous request
@@ -99,16 +101,16 @@
}
finally {
- //undeployWAR(BASIC_WAR);
+ //undeployWAR(DEPLOYABLE_NAME);
// Undeploy the WAR
- HtmlButtonInput deleteButton = getAppDeleteButton(BASIC_WAR);
+ HtmlButtonInput deleteButton = getAppDeleteButton(DEPLOYABLE_NAME);
deleteButton.click();
// This assert doesn't work. jopr does remove the WAR, but for some
// reason, JBoss doesn't undeploy the MBeans
// JBAS-XXXX
- //assertFalse(isWarDeployed(BASIC_WAR));
+ //assertFalse(isWarDeployed(DEPLOYABLE_NAME));
}
}
@@ -118,16 +120,19 @@
- public void DISABLEDtestBadWarRedeploy() throws IOException,
HtmlElementNotFoundException, ActionNotAvailableException {
+ public void XtestBadWarRedeploy() throws IOException, HtmlElementNotFoundException,
ActionNotAvailableException {
+ final String DEPLOYABLE_NAME = AppConstants.WAR_FILENAME_MALFORMED_APP;
+
try {
- String filePath = ejtt.getTestDataDir() +
"/war/"+AppConstants.WAR_FILENAME_MALFORMED_APP;
+
+ String filePath = ejtt.getTestDataDir() + "/war/"+DEPLOYABLE_NAME;
deployWAR(filePath);
checkClientAndServerMessages("Failed to create Resource", "Failed to
create Resource", true);
}
finally {
- undeployWAR(BASIC_WAR);
+ undeployWAR(DEPLOYABLE_NAME);
}
}
@@ -136,8 +141,11 @@
-
- public void testNavigationToWar() throws IOException, HtmlElementNotFoundException,
ActionOutOfSyncException, ActionNotAvailableException, EmbJoprTestException,
InterruptedException, ActionOutOfSyncException
+ /**
+ * Various ways to navigate to a WAR application:
+ * Nav tree, apps listing, WARs listing.
+ */
+ public void XtestNavigationToWar() throws IOException, HtmlElementNotFoundException,
ActionOutOfSyncException, ActionNotAvailableException, EmbJoprTestException,
InterruptedException, ActionOutOfSyncException
{
// JBossAS Servers node
@@ -187,7 +195,6 @@
// Applications node
{
- // Whooo-hooo! So much to click through!
ejtt.getTabMenu().clickTab("Summary");
@@ -216,37 +223,39 @@
// Concrete appliction node.
{
+ final String DEPLOYABLE_NAME = BASIC_WAR_02;
+
// Deploy the WAR.
- String filePath = ejtt.getTestDataDir() + "/war/"+BASIC_WAR;
+ String filePath = ejtt.getTestDataDir() + "/war/"+DEPLOYABLE_NAME;
deployWarRepeatedly( filePath );
ejtt.getNavTree().getNodeByLabel(NAV_WAR).click();
// Get to the app through listing.
- log.debug("Looking for row with: "+BASIC_WAR);
+ log.debug("Looking for row with: "+DEPLOYABLE_NAME);
// Commented out: we would have to click trough pages.
- //ContentTableRow row =
ejtt.getDefaultContentTable().getFirstRowContainingLink(BASIC_WAR);
+ //ContentTableRow row =
ejtt.getDefaultContentTable().getFirstRowContainingLink(DEPLOYABLE_NAME);
ContentTableRow row = ejtt.getTabMenu().getTabContentBox()
- .findLinkRowInDataTableUsingPagination(BASIC_WAR);
+ .findLinkRowInDataTableUsingPagination(DEPLOYABLE_NAME);
- assertTrue("Page doesn't list "+BASIC_WAR+" in Summary tab.",
row != null );
+ assertTrue("Page doesn't list "+DEPLOYABLE_NAME+" in Summary
tab.", row != null );
// Go to the summary through listed item.
- row.getLinkByLabel(BASIC_WAR).click();
+ row.getLinkByLabel(DEPLOYABLE_NAME).click();
/**/
// Other way to get to app: through nav tree.
ejtt.getNavTree().getNodeArrow(NAV_WAR).click();
- ejtt.navTree.waitUntilNodeLoadedByAjax(BASIC_WAR, 500, 15);
- ejtt.navTree.getNodeByLabel(BASIC_WAR).click();
+ ejtt.navTree.waitUntilNodeLoadedByAjax(DEPLOYABLE_NAME, 500, 15);
+ ejtt.navTree.getNodeByLabel(DEPLOYABLE_NAME).click();
/**/
// Check that we have the summary tab for the selected WAR.
- assertTrue( "WAR name "+BASIC_WAR+" not found in the content
box.",
- ejtt.getTabMenu().getTabContentBox().getElement().getTextContent().contains(BASIC_WAR)
);
+ assertTrue( "WAR name "+DEPLOYABLE_NAME+" not found in the content
box.",
+ ejtt.getTabMenu().getTabContentBox().getElement().getTextContent().contains(DEPLOYABLE_NAME)
);
// Go to the summary through nav tree node.
NavTreeNode appNode = ejtt.getNavTree().getNodeByLabel(NAV_WAR);
@@ -255,11 +264,11 @@
appNode.getArrowLink().click();
Thread.sleep(2000);
}
- ejtt.getNavTree().getNodeByLabel(BASIC_WAR).click();
+ ejtt.getNavTree().getNodeByLabel(DEPLOYABLE_NAME).click();
// Check that we have the summary tab for the selected WAR.
- ejtt.getTabMenu().getTabContentBox().getElement().getTextContent().contains(BASIC_WAR);
+ ejtt.getTabMenu().getTabContentBox().getElement().getTextContent().contains(DEPLOYABLE_NAME);
- undeployWAR(BASIC_WAR);
+ undeployWAR(DEPLOYABLE_NAME);
}
@@ -277,12 +286,14 @@
*
* FAILS because of: EMBJOPR-110
*/
- public void testWarSummaryTab() throws EmbJoprTestException, IOException, Exception {
+ public void XtestWarSummaryTab() throws EmbJoprTestException, IOException, Exception {
final int DEPLOY_TIMEOUT_SEC = 120;
+ final String DEPLOYABLE_NAME = BASIC_WAR_03;
+
// Deploy the WAR
- String appFilePath = System.getProperty(SYSPROP_TESTDATA_DIR) +
"/war/"+BASIC_WAR;
+ String appFilePath = System.getProperty(SYSPROP_TESTDATA_DIR) +
"/war/"+DEPLOYABLE_NAME;
deployWarRepeatedly( appFilePath );
try {
@@ -294,14 +305,14 @@
public boolean isTrue() throws Exception {
// Refresh, then check.
ejtt.getNavTree().getNodeByLabel(NAV_WAR).click();
- ContentTableRow appRow =
ejtt.getDefaultContentTable().findFirstRowContainingLink(BASIC_WAR);
+ ContentTableRow appRow =
ejtt.getDefaultContentTable().findFirstRowContainingLink(DEPLOYABLE_NAME);
return null != appRow;
}
}).dumpPageOnTimeout(this).throwOnTimeout().waitWithTimeout(2000, 5);
/**/
- ContentTableRow appRow =
ejtt.getDefaultContentTable().getFirstRowContainingLink(BASIC_WAR);
+ ContentTableRow appRow =
ejtt.getDefaultContentTable().getFirstRowContainingLink(DEPLOYABLE_NAME);
// Wait until the Status is "UP".
// TODO: Replace with ActiveConditionChecker.
@@ -314,16 +325,16 @@
// Refresh page after 1 second.
ejtt.getNavTree().getNodeByLabel(NAV_WAR).click();
- appRow = ejtt.getDefaultContentTable().getFirstRowContainingLink(BASIC_WAR);
+ appRow = ejtt.getDefaultContentTable().getFirstRowContainingLink(DEPLOYABLE_NAME);
// We don't want an infinite loop by mistake.
if( maxLoops-- <= 0 ){
- throw new EmbJoprTestException("WAR "+BASIC_WAR+" not UP after
"+DEPLOY_TIMEOUT_SEC+" seconds.");
+ throw new EmbJoprTestException("WAR "+DEPLOYABLE_NAME+" not UP after
"+DEPLOY_TIMEOUT_SEC+" seconds.");
}
} while( true );
// FAILS because of EMBJOPR-80.
- appRow.getLinkByLabel(BASIC_WAR).click();
+ appRow.getLinkByLabel(DEPLOYABLE_NAME).click();
// Check the values in info table(s)
@@ -334,7 +345,7 @@
Properties props = infoTable.getProperties();
log.info("General Properties: "+props.toString());
- assertEquals(BASIC_WAR, props.getProperty("Name").trim());
+ assertEquals(DEPLOYABLE_NAME, props.getProperty("Name").trim());
//assertEquals("?", props.getProperty("Version")); // TODO: Where
does RHQ get the version from?
@@ -346,7 +357,7 @@
log.debug("Path: "+props.getProperty("Path"));///
- String path = ejtt.getDeployDir()+"/"+BASIC_WAR;
+ String path = ejtt.getDeployDir()+"/"+DEPLOYABLE_NAME;
assertEquals(path, props.getProperty("Path").trim()); // EMBJOPR-110 here
assertEquals("no", props.getProperty("Exploded?").trim());
@@ -359,7 +370,7 @@
}
finally {
// Undeploy the WAR
- undeployWAR( BASIC_WAR );
+ undeployWAR( DEPLOYABLE_NAME );
}
}// testWarSummary()
@@ -375,20 +386,22 @@
*
* FAILS because some of the values are read-only. EMBJOPR-96
*/
- public void testWarConfigurationTab() throws IOException, EmbJoprTestException,
HtmlElementNotFoundException, Exception {
+ public void XtestWarConfigurationTab() throws IOException, EmbJoprTestException,
HtmlElementNotFoundException, Exception {
+ final String DEPLOYABLE_NAME = BASIC_WAR_04;
+
// Deploy the WAR.
- String filePath = ejtt.getTestDataDir() +"/war/"+ BASIC_WAR;
+ String filePath = ejtt.getTestDataDir() +"/war/"+ DEPLOYABLE_NAME;
deployWarRepeatedly( filePath );
try {
ejtt.getNavTree().getNodeByLabel(NAV_WAR).click();
- ejtt.deployment.waitActivelyForDeployment(DeployableTypes.WAR, BASIC_WAR,
DEPLOY_UP_STATE_WAIT_CHECK_INTERVAL, DEPLOY_UP_STATE_WAIT_CHECK_RETRIES, this);
+ ejtt.deployment.waitActivelyForDeployment(DeployableTypes.WAR, DEPLOYABLE_NAME,
DEPLOY_UP_STATE_WAIT_CHECK_INTERVAL, DEPLOY_UP_STATE_WAIT_CHECK_RETRIES, this);
// Navigate to the Configuration tab
- ContentTableRow appRow =
ejtt.getDefaultContentTable().getFirstRowContainingLink(BASIC_WAR);
- appRow.getLinkByLabel(BASIC_WAR).click();
+ ContentTableRow appRow =
ejtt.getDefaultContentTable().getFirstRowContainingLink(DEPLOYABLE_NAME);
+ appRow.getLinkByLabel(DEPLOYABLE_NAME).click();
ejtt.tabMenu.clickConfigurationTab();
// Read properties.
@@ -416,7 +429,7 @@
}
finally {
- undeployWAR(BASIC_WAR);
+ undeployWAR(DEPLOYABLE_NAME);
}
}
@@ -430,21 +443,23 @@
*
* FAILS because some of the values are read-only. EMBJOPR-96
*/
- public void testWarConfigurationTabCancel() throws IOException, EmbJoprTestException {
+ public void XtestWarConfigurationTabCancel() throws IOException, EmbJoprTestException {
+ final String DEPLOYABLE_NAME = BASIC_WAR_05;
+
// Deploy the WAR.
- String filePath = ejtt.getTestDataDir() +"/war/"+ BASIC_WAR;
+ String filePath = ejtt.getTestDataDir() +"/war/"+ DEPLOYABLE_NAME;
deployWarRepeatedly( filePath );
try {
ejtt.getNavTree().getNodeByLabel(NAV_WAR).click();
- ejtt.deployment.waitActivelyForDeployment(DeployableTypes.WAR, BASIC_WAR,
+ ejtt.deployment.waitActivelyForDeployment(DeployableTypes.WAR, DEPLOYABLE_NAME,
DEPLOY_UP_STATE_WAIT_CHECK_INTERVAL, DEPLOY_UP_STATE_WAIT_CHECK_RETRIES, this);
// Navigate to the Configuration tab
- ContentTableRow row =
ejtt.getDefaultContentTable().getFirstRowContainingLink(BASIC_WAR);
- row.getLinkByLabel(BASIC_WAR).click();
+ ContentTableRow row =
ejtt.getDefaultContentTable().getFirstRowContainingLink(DEPLOYABLE_NAME);
+ row.getLinkByLabel(DEPLOYABLE_NAME).click();
ejtt.tabMenu.clickConfigurationTab();
@@ -470,7 +485,7 @@
}
finally {
- undeployWAR(BASIC_WAR);
+ undeployWAR(DEPLOYABLE_NAME);
}
}
@@ -479,24 +494,26 @@
/**
- * Redeploys WAR.
+ * Redeploys WAR, using WAR's Content tab upload form.
*
* Fails because of: EMBJOPR-109
*/
- public void testWarRedeployment() throws IOException, EmbJoprTestException {
+ public void XtestWarRedeployment() throws IOException, EmbJoprTestException {
+ final String DEPLOYABLE_NAME = BASIC_WAR_06;
+
// Deploy the WAR.
- String appFilePath = ejtt.getTestDataDir() +"/war/"+ BASIC_WAR;
+ String appFilePath = ejtt.getTestDataDir() +"/war/"+ DEPLOYABLE_NAME;
deployWarRepeatedly( appFilePath );
try {
ejtt.getNavTree().getNodeByLabel(NAV_WAR).click();
- ejtt.deployment.waitActivelyForDeployment(DeployableTypes.WAR, BASIC_WAR,
DEPLOY_UP_STATE_WAIT_CHECK_INTERVAL, DEPLOY_UP_STATE_WAIT_CHECK_RETRIES, this);
+ ejtt.deployment.waitActivelyForDeployment(DeployableTypes.WAR, DEPLOYABLE_NAME,
DEPLOY_UP_STATE_WAIT_CHECK_INTERVAL, DEPLOY_UP_STATE_WAIT_CHECK_RETRIES, this);
// Navigate to the Configuration tab
- ContentTableRow row =
ejtt.getDefaultContentTable().getFirstRowContainingLink(BASIC_WAR);
- row.getLinkByLabel(BASIC_WAR).click();
+ ContentTableRow row =
ejtt.getDefaultContentTable().getFirstRowContainingLink(DEPLOYABLE_NAME);
+ row.getLinkByLabel(DEPLOYABLE_NAME).click();
ejtt.tabMenu.clickContentTab();
String xPath = ".//table//input[@type='file']";
@@ -510,7 +527,7 @@
finally {
try {
DebugUtils.writeFile("target/redeployment.html",
client.getPageAsText());///
- undeployWAR(BASIC_WAR); // EMBJOPR-109 here
+ undeployWAR(DEPLOYABLE_NAME); // EMBJOPR-109 here
}catch( Exception ex ){
log.error("Exception caught in finally: "+ex.getMessage(), ex);
}
@@ -519,26 +536,116 @@
}
+ /**
+ * Deploys the WAR, undeploys it and deploys again.
+ * All these actions are done using EmbJopr.
+ *
+ * Fails because of EMBJOPR-125
+ */
+ public void testWarDeployUndeployDeploy() throws IOException, EmbJoprTestException {
+ final String DEPLOYABLE_NAME = BASIC_WAR_DUD;
+
+
+ // Deploy the WAR.
+ String appFilePath = ejtt.getTestDataDir() +"/war/"+ DEPLOYABLE_NAME;
+ deployWarRepeatedly( appFilePath );
+
+ try {
+
+ // Undeploy.
+ log.info("Undeploying "+DEPLOYABLE_NAME);
+ undeployWAR(DEPLOYABLE_NAME);
+ //DebugUtils.writeFile("target/DUD-undeploy.html",
client.getPageAsText());///
+ assertFalse( "Deployable "+DEPLOYABLE_NAME+" shouldn't be listed as
deployed after undeployment.",
+ ejtt.deployment.isDeployedAccordingToEmbJopr(DeployableTypes.WAR, DEPLOYABLE_NAME,
false) );
+
+ // Deploy the same war again.
+ log.info("Deploying "+DEPLOYABLE_NAME+" again.");
+ deployWAR( appFilePath );
+ //DebugUtils.writeFile("target/DUD-deploy.html",
client.getPageAsText());///
+ // EMBJOPR-125 here.
+ assertTrue( "Deployable "+DEPLOYABLE_NAME+" should be listed as
deployed after deployment.",
+ ejtt.deployment.isDeployedAccordingToEmbJopr(DeployableTypes.WAR, DEPLOYABLE_NAME,
false) );
+
+ }
+ finally {
+ try {
+ DebugUtils.writeFile("target/testDeployUndeployDeploy-finally.html",
client.getPageAsText());///
+ undeployWAR(DEPLOYABLE_NAME);
+ }catch( Exception ex ){
+ log.error("Exception caught in finally: "+ex.getMessage(), ex);
+ }
+ }
+
+ }
+
+
+
/**
+ * Deploys the WAR, undeploys it and deploys again.
+ * All these actions are done using EmbJopr.
+ */
+ public void XtestWarDeployUndeployDeployRetryOnErrors() throws IOException,
EmbJoprTestException {
+
+ final String DEPLOYABLE_NAME = BASIC_WAR_DUD_RETRY;
+
+
+ // Deploy the WAR.
+ String appFilePath = ejtt.getTestDataDir() +"/war/"+ DEPLOYABLE_NAME;
+ deployWarRepeatedly( appFilePath );
+
+ try {
+
+ // Undeploy.
+ log.info("Undeploying "+DEPLOYABLE_NAME);
+ undeployWAR(DEPLOYABLE_NAME); // EMBJOPR-109 here
+ DebugUtils.writeFile("target/DUD_RETRY-undeploy.html",
client.getPageAsText());///
+ assertFalse( "Deployable "+DEPLOYABLE_NAME+" shouldn't be listed as
deployed after undeployment.",
+ ejtt.deployment.isDeployedAccordingToEmbJopr(DeployableTypes.WAR, DEPLOYABLE_NAME,
false) );
+
+ // Deploy the same war again.
+ log.info("Deploying "+DEPLOYABLE_NAME+" again.");
+ deployWarRepeatedly( appFilePath );
+ DebugUtils.writeFile("target/DUD_RETRY-deploy.html",
client.getPageAsText());///
+ assertTrue( "Deployable "+DEPLOYABLE_NAME+" should be listed as
deployed after deployment.",
+ ejtt.deployment.isDeployedAccordingToEmbJopr(DeployableTypes.WAR, DEPLOYABLE_NAME,
false) );
+
+ }
+ finally {
+ try {
+ DebugUtils.writeFile("target/testDeployUndeployDeployRetryOnErrors-finally.html",
client.getPageAsText());///
+ undeployWAR(DEPLOYABLE_NAME); // EMBJOPR-109 here
+ }catch( Exception ex ){
+ log.error("Exception caught in finally: "+ex.getMessage(), ex);
+ }
+ }
+
+ }
+
+
+
+ /**
* Deploys exploded WAR and checks whether it is reported as exploded.
*
* DISABLED - Badly written test, to be fixed. TODO: Hot-deploy
*/
public void DISABLEDtestUnzippedWarReportedAsExploded() throws IOException,
EmbJoprTestException {
+ final String DEPLOYABLE_NAME = BASIC_WAR_07;
+
// Deploy the WAR.
- String WARFilePath = ejtt.getTestDataDir() + "/war/"+BASIC_WAR;
+ String WARFilePath = ejtt.getTestDataDir() + "/war/"+DEPLOYABLE_NAME;
deployWarRepeatedly( WARFilePath );
try {
// Wait for WAR to be deployed and UP
ejtt.getNavTree().getNodeByLabel(NAV_WAR).click();
- ejtt.deployment.waitActivelyForDeployment(DeployableTypes.WAR, BASIC_WAR,
DEPLOY_UP_STATE_WAIT_CHECK_INTERVAL, DEPLOY_UP_STATE_WAIT_CHECK_RETRIES, this);
+ ejtt.deployment.waitActivelyForDeployment(DeployableTypes.WAR, DEPLOYABLE_NAME,
DEPLOY_UP_STATE_WAIT_CHECK_INTERVAL, DEPLOY_UP_STATE_WAIT_CHECK_RETRIES, this);
// Click the WAR link
ejtt.getTabMenu().getTabContentBox().getFirstTable()
- .getFirstRowContainingText(BASIC_WAR).getFirstLinkFromColumn("Name").click();
+ .getFirstRowContainingText(DEPLOYABLE_NAME).getFirstLinkFromColumn("Name").click();
DebugUtils.writeFile("target/res_traits.html", client.getPageAsText());///
@@ -552,7 +659,7 @@
}
finally {
- undeployWAR(BASIC_WAR);
+ undeployWAR(DEPLOYABLE_NAME);
}
}
@@ -563,20 +670,22 @@
/**
* Checks WAR metrics tab.
*/
- public void testWarMetricsTab() throws IOException, EmbJoprTestException {
+ public void XtestWarMetricsTab() throws IOException, EmbJoprTestException {
+ final String DEPLOYABLE_NAME = BASIC_WAR_08;
+
// Deploy the WAR.
- String WARFilePath = ejtt.getTestDataDir() + "/war/"+BASIC_WAR;
+ String WARFilePath = ejtt.getTestDataDir() + "/war/"+DEPLOYABLE_NAME;
deployWarRepeatedly( WARFilePath );
try {
ejtt.getNavTree().getNodeByLabel(NAV_WAR).click();
- ejtt.deployment.waitActivelyForDeployment(DeployableTypes.WAR, BASIC_WAR,
DEPLOY_UP_STATE_WAIT_CHECK_INTERVAL, DEPLOY_UP_STATE_WAIT_CHECK_RETRIES, this);
+ ejtt.deployment.waitActivelyForDeployment(DeployableTypes.WAR, DEPLOYABLE_NAME,
DEPLOY_UP_STATE_WAIT_CHECK_INTERVAL, DEPLOY_UP_STATE_WAIT_CHECK_RETRIES, this);
// Navigate to the Metrics tab
- ContentTableRow row =
ejtt.getDefaultContentTable().getFirstRowContainingLink(BASIC_WAR);
- row.getLinkByLabel(BASIC_WAR).click();
+ ContentTableRow row =
ejtt.getDefaultContentTable().getFirstRowContainingLink(DEPLOYABLE_NAME);
+ row.getLinkByLabel(DEPLOYABLE_NAME).click();
ejtt.tabMenu.clickMetricsTab();
// Resource Traits
@@ -589,13 +698,13 @@
log.debug("Trait Values: "+ props.toString());
- String path = ejtt.getDeployDir()+"/"+BASIC_WAR;
+ String path = ejtt.getDeployDir()+"/"+DEPLOYABLE_NAME;
assertEquals(path, props.getProperty("Path").trim());
}
finally {
- undeployWAR(BASIC_WAR);
+ undeployWAR(DEPLOYABLE_NAME);
}
}
@@ -606,21 +715,23 @@
*
* FAILS because some of the values are read-only. EMBJOPR-96
*/
- public void testWarMetricsTabRefreshButton() throws IOException, EmbJoprTestException,
HtmlElementNotFoundException, Exception {
+ public void XtestWarMetricsTabRefreshButton() throws IOException, EmbJoprTestException,
HtmlElementNotFoundException, Exception {
+ final String DEPLOYABLE_NAME = BASIC_WAR_09;
+
// Deploy the WAR.
- String WARFilePath = ejtt.getTestDataDir() + "/war/"+BASIC_WAR;
+ String WARFilePath = ejtt.getTestDataDir() + "/war/"+DEPLOYABLE_NAME;
deployWarRepeatedly( WARFilePath );
try {
ejtt.getNavTree().getNodeByLabel(NAV_WAR).click();
- ejtt.deployment.waitActivelyForDeployment(DeployableTypes.WAR, BASIC_WAR,
+ ejtt.deployment.waitActivelyForDeployment(DeployableTypes.WAR, DEPLOYABLE_NAME,
DEPLOY_UP_STATE_WAIT_CHECK_INTERVAL, DEPLOY_UP_STATE_WAIT_CHECK_RETRIES, this);
// Navigate to the Metrics tab
- ContentTableRow row =
ejtt.getDefaultContentTable().getFirstRowContainingLink(BASIC_WAR);
- row.getLinkByLabel(BASIC_WAR).click();
+ ContentTableRow row =
ejtt.getDefaultContentTable().getFirstRowContainingLink(DEPLOYABLE_NAME);
+ row.getLinkByLabel(DEPLOYABLE_NAME).click();
ejtt.tabMenu.clickMetricsTab();
// Click the Refresh button.
@@ -629,12 +740,12 @@
// Check that we are still on the right tab.
assertTrue("Metrics tab is active",
ejtt.tabMenu.isTabActive("Metrics") );
- assertTrue("Page contains WAR name",
client.getPageAsText().contains(BASIC_WAR) );
+ assertTrue("Page contains WAR name",
client.getPageAsText().contains(DEPLOYABLE_NAME) );
assertTrue("Page contains 'Refresh'",
client.getPageAsText().contains("Refresh") );
}
finally {
- undeployWAR(BASIC_WAR);
+ undeployWAR(DEPLOYABLE_NAME);
}
}
@@ -664,14 +775,24 @@
* Should we wait more? Or is it caused by failures of some previous tests?
*
*/
- public void testDeployUnpackedWar() throws IOException, EmbJoprTestException {
+ public void XtestDeployUnpackedWar() throws IOException, EmbJoprTestException {
// Deploy the unpacked WAR.
// We have to use hotdeploy - can't upload a directory.
- log.info("Unzipping war/"+WAR_UNPACKED_ZIP);
- ejtt.deployment.unzipToDeployDir("war/"+WAR_UNPACKED_ZIP, "");
+ //ejtt.deployment.unzipToDeployDir("war/"+WAR_UNPACKED_ZIP, "");
+ String archivePath = ejtt.getTestDataDir()+"/war/"+WAR_UNPACKED_ZIP;
+ String tempDir = ejtt.getTempDir();
+ String destDir = ejtt.getDeployDir();
+ log.info("Unzipping "+archivePath+" to "+tempDir);
+ ejtt.deployment.unzipArchive( archivePath, tempDir );
+
+ log.info("Moving "+tempDir+"/"+WAR_UNPACKED+" to
"+destDir+"/"+WAR_UNPACKED);
+ ejtt.deployment.moveDir(tempDir+"/"+WAR_UNPACKED,
destDir+"/"+WAR_UNPACKED);
+
+
+
try {
// Loop, wait for the app to appear.
log.info("Waiting for WAR to appear.");
@@ -700,13 +821,184 @@
+ public void testStopAndStartWar() throws IOException, EmbJoprTestException
+ {
+ final String DEPLOYABLE_NAME = BASIC_WAR_STOPSTART;
+ // Get the HTTP port and the URL of the test page.
+ HttpServletRequest tmpRequest =
(HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
+ int port = tmpRequest.getLocalPort();
+ String context = StringUtils.chomp( DEPLOYABLE_NAME, ".war" ); // Eventually
remove ".war" suffix.
+ String testPageUrl =
"http://localhost:"+port+"/"+context+"/hello.jsp";
+ // Create web client we will use to check the web app.
+ WebClient webClient = new WebClient();
+ // We'll get 404 after stopping the app.
+ webClient.setThrowExceptionOnFailingStatusCode(false);
+ HtmlPage page;
+ // Deploy the WAR.
+ String WARFilePath = ejtt.getTestDataDir() + "/war/"+DEPLOYABLE_NAME;
+ deployWarRepeatedly( WARFilePath );
+ try {
+ // Wait until app is UP
+ ejtt.getNavTree().getNodeByLabel(NAV_WAR).click();
+ ejtt.deployment.waitActivelyForDeployment(DeployableTypes.WAR, DEPLOYABLE_NAME,
+ DEPLOY_UP_STATE_WAIT_CHECK_INTERVAL, DEPLOY_UP_STATE_WAIT_CHECK_RETRIES, this);
+
+ // Assert that the app is running.
+ page = (HtmlPage)webClient.getPage(testPageUrl);
+ assertEquals( "HTTP status of "+testPageUrl+" should be 200", 200,
page.getWebResponse().getStatusCode() );
+ assertTrue("Page should contain 'HELLO WORLD'",
page.asText().contains("HELLO WORLD"));
+
+ // Refresh the page several times to increase the counter.
+ page.refresh();
+ page.refresh();
+
+ // Get the counter number.
+ Integer count1 =
NumberUtils.createInteger(page.getBody().getHtmlElementById("count").getTextContent());
+
+
+
+ // Navigate to the web app, then to it's Control tab.
+ ContentTableRow row =
ejtt.getDefaultContentTable().getFirstRowContainingLink(DEPLOYABLE_NAME);
+ row.getLinkByLabel(DEPLOYABLE_NAME).click();
+ ejtt.getTabMenu().clickControlTab();
+
+ // Click the Stop button.
+ ejtt.tabMenu.getTabContentBox().getButtonByLabel("Stop").click();
+
+ // Check the latest message.
+ /*
+ HtmlTable operationHistoryTable =
ejtt.getTabMenu().getTabContentBox().getOperationHistoryTable().getElement();
+ HtmlTableRow tr = operationHistoryTable.getFirstByXPath("tr[contains(@class,
'rich-table-firstrow')]");
+ assertTrue( tr.getTextContent().contains("Success") );
+ /**/
+ assertTrue(
ejtt.getTabMenu().getTabContentBox().getOperationHistoryTable().wasLastOperationSuccesful()
);
+
+
+ // Assert that the app is stopped.
+ page = (HtmlPage)webClient.getPage(testPageUrl);
+ assert( 200 != page.getWebResponse().getStatusCode() );
+
+
+ // Click the Start button.
+ ejtt.tabMenu.getTabContentBox().getButtonByLabel("Start").click();
+
+ // Check the latest message. TODO: EJTT class for ops history table?
+ HtmlTable operationHistoryTable =
ejtt.getTabMenu().getTabContentBox().getOperationHistoryTable().getElement();
+ HtmlTableRow tr = operationHistoryTable.getFirstByXPath("tr[contains(@class,
'rich-table-firstrow')]");
+ assertTrue( tr.getTextContent().contains("Success") );
+
+
+ // Assert that the app is running.
+ page = (HtmlPage)webClient.getPage(testPageUrl);
+ assert( 200 == page.getWebResponse().getStatusCode() );
+ assertTrue(page.asText().contains("HELLO WORLD"));
+
+ // Get the counter number.
+ Integer count2 =
NumberUtils.createInteger(page.getBody().getHtmlElementById("count").getTextContent());
+
+ assertTrue( "Counter is reset upon app restart, thus should be lower
after.", count1 > count2 );
+
+
+ }
+ finally {
+ undeployWAR(DEPLOYABLE_NAME);
+ }
+ }
+
+
/**
+ * Restarts the WAR in Control tab and checks whether it was really restarted.
+ */
+ public void testRestartWar() throws IOException, EmbJoprTestException
+ {
+ final String DEPLOYABLE_NAME = BASIC_WAR_RESTART;
+
+ // Get the HTTP port and the URL of the test page.
+ HttpServletRequest tmpRequest =
(HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
+ int port = tmpRequest.getLocalPort();
+ String context = StringUtils.chomp( DEPLOYABLE_NAME, ".war" ); // Eventually
remove ".war" suffix.
+ String testPageUrl =
"http://localhost:"+port+"/"+context+"/hello.jsp";
+
+ // Create web client we will use to check the web app.
+ WebClient webClient = new WebClient();
+ webClient.setThrowExceptionOnFailingStatusCode(false);
+ HtmlPage page;
+
+
+ // Deploy the WAR.
+ String WARFilePath = ejtt.getTestDataDir() + "/war/"+DEPLOYABLE_NAME;
+ deployWarRepeatedly( WARFilePath );
+
+ try {
+
+ // Wait until app is UP
+ ejtt.getNavTree().getNodeByLabel(NAV_WAR).click();
+ ejtt.deployment.waitActivelyForDeployment(DeployableTypes.WAR, DEPLOYABLE_NAME,
+ DEPLOY_UP_STATE_WAIT_CHECK_INTERVAL, DEPLOY_UP_STATE_WAIT_CHECK_RETRIES, this);
+
+ // Assert that the app is running.
+ page = (HtmlPage)webClient.getPage(testPageUrl);
+ assertEquals( "HTTP status of "+testPageUrl+" should be 200", 200,
page.getWebResponse().getStatusCode() );
+ assertTrue("Page should contain 'HELLO WORLD'",
page.asText().contains("HELLO WORLD"));
+
+ // Refresh the page several times to increase the counter.
+ page.refresh();
+ page.refresh();
+
+ // Get the counter number.
+ Integer count1 =
NumberUtils.createInteger(page.getBody().getHtmlElementById("count").getTextContent());
+
+
+
+ // Navigate to the web app, then to it's Control tab.
+ ContentTableRow row =
ejtt.getDefaultContentTable().getFirstRowContainingLink(DEPLOYABLE_NAME);
+ row.getLinkByLabel(DEPLOYABLE_NAME).click();
+ ejtt.getTabMenu().clickControlTab();
+
+ // Click the Restart button.
+ ejtt.tabMenu.getTabContentBox().getButtonByLabel("Restart").click();
+
+ // Check the latest message. TODO: EJTT class for ops history table?
+ HtmlTable operationHistoryTable =
ejtt.getTabMenu().getTabContentBox().getOperationHistoryTable().getElement();
+ HtmlTableRow tr = operationHistoryTable.getFirstByXPath("tr[contains(@class,
'rich-table-firstrow')]");
+ assertTrue( tr.getTextContent().contains("Success") );
+
+
+ // Assert that the app is running.
+ page = (HtmlPage)webClient.getPage(testPageUrl);
+ assert( 200 == page.getWebResponse().getStatusCode() );
+ assertTrue(page.asText().contains("HELLO WORLD"));
+
+ // Get the counter number.
+ Integer count2 =
NumberUtils.createInteger(page.getBody().getHtmlElementById("count").getTextContent());
+
+ assertTrue( "Counter is reset upon app restart, thus should be lower
after.", count1 > count2 );
+
+ }
+ finally {
+ undeployWAR(DEPLOYABLE_NAME);
+ }
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+ /**
* Deploys WAR.
*/
private void deployWAR( String warFilePath )
@@ -747,10 +1039,13 @@
throws IOException, HtmlElementNotFoundException, EmbJoprTestException
{
+ File warFile = new File(warFilePath);
+ final String warFileName = warFile.getName();
+
try {
// Try it 5x in 5 second interval.
- new ActiveConditionChecker( new DescribedCondition("WAR
'"+warFilePath+"' succesfuly deployed") {
+ new ActiveConditionChecker( new DescribedCondition("WAR
'"+warFileName+"' succesfuly deployed") {
public boolean isTrue() throws Exception {
deployWAR(warFilePath);
@@ -772,9 +1067,8 @@
*/
// Check whether the WAR is listed in EmbJopr.
- File file = new File(warFilePath);
- log.debug("Looking for listed WAR: "+file.getName());
- boolean listed = ejtt.deployment.isDeployedAccordingToEmbJopr(DeployableTypes.WAR,
file.getName(), isJBoss4);
+ log.debug("Looking for listed WAR: "+warFileName);
+ boolean listed = ejtt.deployment.isDeployedAccordingToEmbJopr(DeployableTypes.WAR,
warFileName, isJBoss4);
if( listed )
return true;
else
@@ -784,7 +1078,7 @@
}
catch( Exception ex ){
- throw new EmbJoprTestException(ex.getMessage(), ex);
+ throw new EmbJoprTestException(ex.getClass().getName()+": "+ex.getMessage(),
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-04-02
15:55:55 UTC (rev 271)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java 2009-04-02
19:20:48 UTC (rev 272)
@@ -93,6 +93,10 @@
return System.getProperty(AppConstants.SYSPROP_TESTDATA_DIR);
}
+ public String getTempDir() {
+ return System.getProperty(AppConstants.SYSPROP_TESTDATA_DIR);
+ }
+
public String getDeployDir() {
return System.getProperty(AppConstants.SYSPROP_DEPLOY_DIR);
}
@@ -624,6 +628,15 @@
return new ContentTable();
}
+ /**
+ * Returns the operation history table from the Content tab.
+ */
+ public OperationsHistoryTable getOperationHistoryTable() throws
HtmlElementNotFoundException
+ {
+ //HtmlTable table = (HtmlTable)
client.getElement("operationHistoryForm:dataTable");
+ //return new OperationsHistoryTable(table);
+ return new OperationsHistoryTable();
+ }
/**
@@ -715,7 +728,7 @@
public static final String ID_CATEGORY_DATA_TABLE =
"categorySummaryForm:dataTable";
public static final String ID_RESOURCE_DATA_TABLE =
"resourceSummaryForm:dataTable";
- private HtmlTable element;
+ protected HtmlTable element;
public HtmlTable getElement() { return element; }
/**
@@ -971,6 +984,45 @@
+ public class OperationsHistoryTable extends ContentTable {
+
+ public OperationsHistoryTable() throws HtmlElementNotFoundException {
+
+ // Find the ops history table.
+ String elemID = "operationHistoryForm:dataTable";
+ Element elem = client.getElement(elemID);
+ if( null == elem ){
+ throw new HtmlElementNotFoundException(
+ "Can't find the ops history table element, searched ID: " +
elemID);
+ }
+
+ this.element = (HtmlTable)elem;
+ }
+
+ public OperationsHistoryTable(HtmlTable element) {
+ super(element);
+ }
+
+
+ public boolean wasLastOperationSuccesful() throws HtmlElementNotFoundException
+ {
+ if( 0 == this.getRows().size() )
+ throw new HtmlElementNotFoundException(
+ "Operation table has no rows (no operations are listed).");
+
+ String xPath = "tr[contains(@class, 'rich-table-firstrow')]";
+ HtmlTableRow tr = this.element.getFirstByXPath(xPath);
+ if( null == tr ){
+ throw new HtmlElementNotFoundException(
+ "Operation status row not recognized; used XPath: "+xPath);
+ }
+ return tr.getTextContent().contains("Success");
+ }
+
+
+ }
+
+
/**
* Row of a content table.
* Contains convenience methods for accessing content table rows in EmbJopr.
@@ -1422,10 +1474,10 @@
- /** Convenience method, setting mustBeUP to true. */
+ /** Convenience method, setting mustBeUP to false. */
public boolean isDeployedAccordingToEmbJopr( DeployableTypes type, String
deployableName )
throws HtmlElementNotFoundException, IOException, ActionNotAvailableException{
- return isDeployedAccordingToEmbJopr( type, deployableName, true );
+ return isDeployedAccordingToEmbJopr( type, deployableName, false );
}
/**
@@ -1527,7 +1579,7 @@
selfEjtt.refreshPage();
}
// If found, return true.
- return isDeployedAccordingToEmbJopr(type, name);
+ return isDeployedAccordingToEmbJopr(type, name, true);
// If found, return true.
}
}).throwOnTimeout();
@@ -1587,7 +1639,7 @@
throws FileNotFoundException, IOException
{
- String destDir = getTestDataDir()+"/"+relativeDestDir;
+ String destDir = getDeployDir()+"/"+relativeDestDir;
String archivePath = getTestDataDir()+"/"+relativeArchivePath;
log.info("Unzipping '"+archivePath+"' to
'"+destDir+"'.");
@@ -1640,10 +1692,19 @@
}
+ public void moveDir( String from, String to )
+ {
+ File dirFrom = new File(from);
+ File dirTo = new File(to);
+ dirFrom.renameTo(dirTo);
+ }
- public void deleteFromDeployDir( String deployableName ) throws IOException,
EmbJoprTestException{
+
+ public void deleteFromDeployDir( String deployableName ) throws IOException,
EmbJoprTestException
+ {
+
String deployDir = getDeployDir();
File dirToDelete = new File( deployDir, deployableName);
Added: trunk/jsfunit/testdata/war/hellothere-DUD.war
===================================================================
(Binary files differ)
Property changes on: trunk/jsfunit/testdata/war/hellothere-DUD.war
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jsfunit/testdata/war/hellothere-DUD_RETRY.war
===================================================================
(Binary files differ)
Property changes on: trunk/jsfunit/testdata/war/hellothere-DUD_RETRY.war
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jsfunit/testdata/war/hellothere-RESTART.war
===================================================================
(Binary files differ)
Property changes on: trunk/jsfunit/testdata/war/hellothere-RESTART.war
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jsfunit/testdata/war/hellothere-STOP_START.war
===================================================================
(Binary files differ)
Property changes on: trunk/jsfunit/testdata/war/hellothere-STOP_START.war
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jsfunit/testdata/war/hellothere02.war
===================================================================
(Binary files differ)
Property changes on: trunk/jsfunit/testdata/war/hellothere02.war
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jsfunit/testdata/war/hellothere03.war
===================================================================
(Binary files differ)
Property changes on: trunk/jsfunit/testdata/war/hellothere03.war
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jsfunit/testdata/war/hellothere04.war
===================================================================
(Binary files differ)
Property changes on: trunk/jsfunit/testdata/war/hellothere04.war
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jsfunit/testdata/war/hellothere05.war
===================================================================
(Binary files differ)
Property changes on: trunk/jsfunit/testdata/war/hellothere05.war
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jsfunit/testdata/war/hellothere06.war
===================================================================
(Binary files differ)
Property changes on: trunk/jsfunit/testdata/war/hellothere06.war
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jsfunit/testdata/war/hellothere07.war
===================================================================
(Binary files differ)
Property changes on: trunk/jsfunit/testdata/war/hellothere07.war
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jsfunit/testdata/war/hellothere08.war
===================================================================
(Binary files differ)
Property changes on: trunk/jsfunit/testdata/war/hellothere08.war
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jsfunit/testdata/war/hellothere09.war
===================================================================
(Binary files differ)
Property changes on: trunk/jsfunit/testdata/war/hellothere09.war
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream