Author: ozizka(a)redhat.com
Date: 2009-04-29 17:41:34 -0400 (Wed, 29 Apr 2009)
New Revision: 367
Modified:
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:
EarTest#testEarRedeployDifferentName()
Updated EAR tests
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-04-29
16:16:09 UTC (rev 366)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EarTest.java 2009-04-29
21:41:34 UTC (rev 367)
@@ -37,6 +37,7 @@
import javax.servlet.http.HttpServletRequest;
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.commons.lang.math.RandomUtils;
@@ -701,7 +702,7 @@
try {
// Loop, wait for the app to appear.
log.info("Waiting for EAR to appear.");
- ejtt.deployment.waitActivelyForDeployment( DeployableTypes.EAR, EAR_UNPACKED, 5000,
8, this);
+ ejtt.deployment.waitActivelyForDeployment( DeployableTypes.EAR, EAR_UNPACKED, 5000,
12, this);
ejtt.getNavTree().getNodeByLabel(NAV_EAR).click();
@@ -1020,22 +1021,22 @@
- public void testEarRedeployDifferentVersion() throws IOException, EmbJoprTestException
+ public void testEarRedeployDifferentName() throws IOException, EmbJoprTestException
{
final String DEPLOYABLE_NAME = EAR_WITH_WAR_COUNTER;
final String DEPLOYABLE_NAME2 = EAR_WITH_WAR_COUNTER_20;
// Deploy the EAR.
- String appFilePath = ejtt.getTestDataDir() +
"/"+DeployableTypes.EAR.getDataDir()+"/"+DEPLOYABLE_NAME;
- ejtt.deployment.deployViaEmbJopr( DeployableTypes.EAR, appFilePath );
+ String appFilePath = ejtt.getTestDataDir() +
"/"+APP_TYPE.getDataDir()+"/"+DEPLOYABLE_NAME;
+ ejtt.deployment.deployViaEmbJopr( APP_TYPE, appFilePath );
- String appFilePath2 = ejtt.getTestDataDir() +
"/"+DeployableTypes.EAR.getDataDir()+"/"+DEPLOYABLE_NAME2;
+ String appFilePath2 = ejtt.getTestDataDir() +
"/"+APP_TYPE.getDataDir()+"/"+DEPLOYABLE_NAME2;
try {
ejtt.getNavTree().getNodeByLabel(NAV_EAR).click();
- ejtt.deployment.waitActivelyForDeployment(DeployableTypes.EAR, DEPLOYABLE_NAME, 3000,
15);
+ ejtt.deployment.waitActivelyForDeployment(APP_TYPE, DEPLOYABLE_NAME, 3000, 15);
// Navigate to the Configuration tab
ContentTableRow earRow =
ejtt.getDefaultContentTable().getFirstRowContainingLink(DEPLOYABLE_NAME);
@@ -1057,7 +1058,7 @@
checkClientAndServerMessages( msg, msg, FacesMessage.SEVERITY_WARN );
// Check that the old app is deployed.
- ejtt.deployment.waitActivelyForDeployment(DeployableTypes.EAR, DEPLOYABLE_NAME, 3000,
15);
+ ejtt.deployment.waitActivelyForDeployment(APP_TYPE, DEPLOYABLE_NAME, 3000, 15);
}
finally {
@@ -1078,19 +1079,85 @@
+ public void testEarRedeployDifferentVersion() throws IOException, EmbJoprTestException
+ {
+ final String DEPLOYABLE_NAME = EAR_WITH_WAR_COUNTER;
+ final String DEPLOYABLE_NAME2 = EAR_WITH_WAR_COUNTER_20;
+ // Copy new version to tmp dir under old ver's filename.
+ String srcFilePath = ejtt.getTestDataDir()
+"/"+APP_TYPE.getDataDir()+"/"+DEPLOYABLE_NAME2;
+ String destFilePath = ejtt.getTempDir() +"/"+DEPLOYABLE_NAME;
+ FileUtils.copyFile(new File(srcFilePath), new File(destFilePath));
+ // Deploy the EAR.
+ String appFilePath = destFilePath;
+ ejtt.deployment.deployViaEmbJopr( APP_TYPE, appFilePath );
+ String appFilePath2 = ejtt.getTestDataDir() +
"/"+APP_TYPE.getDataDir()+"/"+DEPLOYABLE_NAME2;
+ try {
+ ejtt.getNavTree().getNodeByLabel(NAV_EAR).click();
+ ejtt.deployment.waitActivelyForDeployment(APP_TYPE, DEPLOYABLE_NAME, 3000, 15);
+ // Navigate to the Configuration tab
+ ContentTableRow earRow =
ejtt.getDefaultContentTable().getFirstRowContainingLink(DEPLOYABLE_NAME);
+ earRow.getLinkByLabel(DEPLOYABLE_NAME).click();
+ ejtt.tabMenu.clickContentTab();
+ String xPath = ".//table//input[@type='file']";
+ HtmlFileInput fileInput =
ejtt.tabMenu.getTabContentBox().getElement().getFirstByXPath(xPath);
+ fileInput.setValueAttribute(appFilePath2);
+ xPath = ".//table//input[@type='submit']";
+ HtmlSubmitInput submit =
ejtt.tabMenu.getTabContentBox().getElement().getFirstByXPath(xPath);
+ submit.click();
+ // We should get:
+ // The specified file must have the same name as the existing
+ // deployed EAR File (EarWithWar-Counter.ear).
+ String msg = "The specified file must have the same name " +
+ "as the existing deployed EAR File";
+ checkClientAndServerMessages( msg, msg, FacesMessage.SEVERITY_WARN );
+ // Check that the old app is deployed.
+ ejtt.deployment.waitActivelyForDeployment(APP_TYPE, DEPLOYABLE_NAME, 3000, 15);
+ }
+ finally {
+ try {
+ undeployEar( DEPLOYABLE_NAME );
+ }catch( Exception ex ){
+ log.error("Caught exception when undeploying: "+ex, ex);
+ }
+ try {
+ undeployEar( DEPLOYABLE_NAME2 );
+ }catch( Exception ex ){
+ log.error("Caught exception when undeploying: "+ex, ex);
+ }
+ }
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/**
* Waits for the deployable to be in the UP State.
*
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-29
16:16:09 UTC (rev 366)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java 2009-04-29
21:41:34 UTC (rev 367)
@@ -1053,7 +1053,7 @@
List<HtmlTableCell> cells = (List<HtmlTableCell>)
this.getElement().getByXPath(xPath);
for( HtmlTableCell cell : cells ){
String cellText = cell.getTextContent();
- String[] parts = cellText.split(":");
+ String[] parts = cellText.split(":", 2);
if( parts.length != 2 ){
log.warn("Cell text not in format 'Name: Value': "+cellText);
continue;