Author: ozizka(a)redhat.com
Date: 2009-04-24 12:46:46 -0400 (Fri, 24 Apr 2009)
New Revision: 332
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/HelloJoprTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ApplicationsPageTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/JBossASNodeTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ServerNodeSummaryTest.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:
Several tests adapted to recent changes.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/HelloJoprTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/HelloJoprTest.java 2009-04-24
14:48:00 UTC (rev 331)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/HelloJoprTest.java 2009-04-24
16:46:46 UTC (rev 332)
@@ -41,6 +41,8 @@
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.cactus.ServletTestCase;
+import org.jboss.jopr.jsfunit.exceptions.HtmlElementNotFoundException;
+import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit;
import org.jboss.jsfunit.framework.WebClientSpec;
import org.jboss.jsfunit.jsfsession.JSFClientSession;
import org.jboss.jsfunit.jsfsession.JSFServerSession;
@@ -95,13 +97,19 @@
return new TestSuite( HelloJoprTest.class );
}
- public void testDeployWAR() throws IOException
+ public void testDeployWAR() throws IOException, HtmlElementNotFoundException
{
- // click the nave tree
- HtmlAnchor warLink = getNavTreeLink("Web Application (WAR)");
+
+ EmbJoprTestToolkit ejtt = new EmbJoprTestToolkit(client, server);
+
+ // Click the nav tree.
+ String linkLabel = "Web Application (WAR)s";
+ //HtmlAnchor warLink = getNavTreeLink(linkLabel);
+ HtmlAnchor warLink = ejtt.navTree.getNodeLink(linkLabel);
warLink.click();
// click on the "Add new resource" button
+ DebugUtils.writeFile("target/testDeployWAR-beforeAdd.html",
client.getPageAsText());///
client.click("actionHeaderForm:addNewContent"); // 404 if
setThrowExceptionOnFailingStatusCode(true) above
// upload hellothere.war
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-04-24
14:48:00 UTC (rev 331)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ApplicationsPageTest.java 2009-04-24
16:46:46 UTC (rev 332)
@@ -22,8 +22,10 @@
package org.jboss.jopr.jsfunit.as5;
+import java.io.File;
import java.io.IOException;
import java.util.*;
+import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.jboss.jopr.jsfunit.AppConstants.DeployableTypes;
import org.jboss.jopr.jsfunit.ApplicationTestBaseAS5;
@@ -80,6 +82,18 @@
*/
public void testAppsPagination() throws EmbJoprTestException, IOException {
+ // Deploy enough apps.
+ // TODO: Create test which would only deploy many apps at once
(hotdeploy/embjopr/both?).
+ // TODO: Undeploy.
+ for (int i = 0; i < 8; i++) {
+ // Deploy the same APP multiple times.
+ String fileSrcPath = ejtt.getTestDataDir() +"/ear/"+ BASIC_EAR;
+ String fileDestPath = ejtt.getTempDir() +
"/appPagination/appPagination"+i+".ear";
+ FileUtils.copyFile( new File(fileSrcPath), new File(fileDestPath) );
+ ejtt.deployment.deployViaEmbJoprRepeatedly( DeployableTypes.EAR, fileDestPath );
+ }
+
+
// Navigate to apps summary tab
NavTreeNode appsNode = ejtt.navTree.getNodeByLabel(NAV_APPLICATIONS);
assertNotNull(appsNode);
@@ -147,6 +161,18 @@
*/
public void testAppsListing() throws EmbJoprTestException, IOException {
+ // Deploy enough apps.
+ // TODO: Create test which would only deploy many apps at once
(hotdeploy/embjopr/both?).
+ // TODO: Undeploy.
+ for (int i = 0; i < 8; i++) {
+ // Deploy the same APP multiple times.
+ String fileSrcPath = ejtt.getTestDataDir() +"/ear/"+ BASIC_EAR;
+ String fileDestPath = ejtt.getTempDir() +
"/appPagination/testAppsListing"+i+".ear";
+ FileUtils.copyFile( new File(fileSrcPath), new File(fileDestPath) );
+ ejtt.deployment.deployViaEmbJoprRepeatedly( DeployableTypes.EAR, fileDestPath );
+ }
+
+
// Navigate to apps summary tab
NavTreeNode appsNode = ejtt.navTree.getNodeByLabel(NAV_APPLICATIONS);
assertNotNull(appsNode);
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/JBossASNodeTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/JBossASNodeTest.java 2009-04-24
14:48:00 UTC (rev 331)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/JBossASNodeTest.java 2009-04-24
16:46:46 UTC (rev 332)
@@ -134,6 +134,8 @@
// Refresh the page
+ // TODO: Do it several times avoid accidentally same value.
+
((HtmlPage)client.getContentPage()).refresh();
// Read new values.
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ServerNodeSummaryTest.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ServerNodeSummaryTest.java 2009-04-24
14:48:00 UTC (rev 331)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ServerNodeSummaryTest.java 2009-04-24
16:46:46 UTC (rev 332)
@@ -1,8 +1,5 @@
package org.jboss.jopr.jsfunit.as5;
-import java.io.FileNotFoundException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import org.jboss.jopr.jsfunit.exceptions.HtmlElementNotFoundException;
import org.jboss.jopr.jsfunit.exceptions.ActionOutOfSyncException;
import com.gargoylesoftware.htmlunit.html.*;
@@ -13,7 +10,6 @@
import java.net.InetAddress;
import java.net.URL;
import java.net.UnknownHostException;
-import org.jboss.jopr.jsfunit.DebugUtils;
import org.jboss.jopr.jsfunit.exceptions.EmbJoprTestException;
import org.jboss.jopr.jsfunit.EmbjoprTestCase;
@@ -96,6 +92,10 @@
try{
navTree.clickRootNode();
+
+ if( tabMenu.isTabDisabled("Control") )
+ fail("Root (server) node's Control tab is disabled.");
+
tabMenu.clickTab("Control");
TabContentBox box = tabMenu.getTabContentBox();
@@ -122,6 +122,10 @@
try{
navTree.clickRootNode();
+
+ if( tabMenu.isTabDisabled("Control") )
+ fail("Root (server) node's Control tab is disabled.");
+
tabMenu.clickTab("Control");
TabContentBox box = tabMenu.getTabContentBox();
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-24
14:48:00 UTC (rev 331)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/WarTest.java 2009-04-24
16:46:46 UTC (rev 332)
@@ -1142,7 +1142,7 @@
// Check whether the WAR is listed in EmbJopr.
log.debug("Looking for listed WAR: "+warFileName);
- boolean listed = ejtt.deployment.isDeployedAccordingToEmbJopr(DeployableTypes.WAR,
warFileName, isJBoss4);
+ boolean listed = ejtt.deployment.isDeployedAccordingToEmbJopr(DeployableTypes.WAR,
warFileName, true);
if( listed )
return true;
else
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-24
14:48:00 UTC (rev 331)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java 2009-04-24
16:46:46 UTC (rev 332)
@@ -1295,8 +1295,12 @@
/** Returns the HTML Select element of page size selection. */
public HtmlSelect getPageSizeSelect() throws HtmlElementNotFoundException {
//return (HtmlSelect) client.getElement(ID_PAGE_SIZE_SELECT);
- return (HtmlSelect) getTabMenu().getTabContentBox().getElement()
- .getFirstByXPath(".//select[contains(@id,
'SummaryForm:currentPageSize')]");
+ String xPath = ".//select[contains(@id,
'SummaryForm:currentPageSize')]";
+ HtmlSelect select = (HtmlSelect) getTabMenu().getTabContentBox().getElement()
+ .getFirstByXPath(xPath);
+ if( null == select )
+ throw new HtmlElementNotFoundException("Can't find page size <select>
using: "+xPath, currentTest);
+ return select;
}
/** Returns total items count, taken from the "Total: N" element. */
@@ -1562,6 +1566,63 @@
+
+ public void deployViaEmbJoprRepeatedly( final AppConstants.DeployableTypes type, final
String filePath )
+ throws IOException, HtmlElementNotFoundException, EmbJoprTestException
+ {
+
+ if( !(new File(filePath)).exists())
+ throw new FileNotFoundException(filePath);
+
+ File appFile = new File(filePath);
+ final String fileName = appFile.getName();
+
+ try {
+
+ // Try it 5x in 5 second interval.
+ new ActiveConditionChecker( new DescribedCondition(type.name()+"
'"+fileName+"' succesfuly deployed") {
+ public boolean isTrue() throws Exception {
+ deployViaEmbJopr( type, filePath );
+
+ // Check whether deployment ended with success message.
+ /* Now broken, EmbJopr reports an error even when deployed successfully:
+ * Failed to create Resource hellothere.war - cause:
+ java.lang.RuntimeException:java.lang.NullPointerException
+ -> java.lang.NullPointerException:null
+ * See EMBJOPR-116
+ */
+ /*
+ if( server.getFacesMessages().hasNext() ){
+ FacesMessage msg = server.getFacesMessages().next();
+ if( msg.getSeverity() == FacesMessage.SEVERITY_INFO )
+ return true;
+ else
+ ejtt.logServerMessage("Deployment error: ");
+ }
+ */
+
+ // Check whether the WAR is listed in EmbJopr.
+ log.debug("Looking for listed WAR: "+fileName);
+ boolean listed = deployment.isDeployedAccordingToEmbJopr(DeployableTypes.WAR,
fileName, true);
+ if( listed )
+ return true;
+ else
+ return false;
+ }
+ }).dumpPageOnTimeout(currentTest).throwOnTimeout().waitWithTimeout(5000, 8);
+
+ }
+ catch( Exception ex ){
+ throw new EmbJoprTestException(ex.getClass().getName()+":
"+ex.getMessage(), ex);
+ }
+
+
+
+ }
+
+
+
+
/**
* Undeploys the deployable using EmbJopr's web UI.
*