Author: ozizka(a)redhat.com
Date: 2009-11-04 21:53:08 -0500 (Wed, 04 Nov 2009)
New Revision: 837
Modified:
trunk/jsfunit/pom.xml
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/MultipleUserLoginTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/EarTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/war/WarTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/hmlunit/
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/hmlunit/HtmlPageBumper.java
Log:
* Rewritten version of EmbJopr TS, working with HTMLUnit 2.6. Now waiting for JSFUnit to
catch up :)
Modified: trunk/jsfunit/pom.xml
===================================================================
--- trunk/jsfunit/pom.xml 2009-11-05 02:25:22 UTC (rev 836)
+++ trunk/jsfunit/pom.xml 2009-11-05 02:53:08 UTC (rev 837)
@@ -103,19 +103,19 @@
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<scope>compile</scope>
- <version>2.3</version>
+ <version>2.6</version>
</dependency>
<dependency>
<groupId>rhino</groupId>
<artifactId>js</artifactId>
<scope>compile</scope>
- <version>1.7R1</version>
+ <version>1.7R2</version>
</dependency>
<dependency>
<groupId>org.jboss.jsfunit</groupId>
<artifactId>jboss-jsfunit-core</artifactId>
- <version>1.0.0.GA</version>
+ <version>1.1.0.GA</version>
<scope>compile</scope>
<exclusions>
<exclusion>
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-11-05
02:25:22 UTC (rev 836)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-11-05
02:53:08 UTC (rev 837)
@@ -139,13 +139,13 @@
browserVersion = BrowserVersion.FIREFOX_2;
}else
if( "ie7".equals(browserProp) ||
"internetexplorer7".equals(browserProp) ){
- browserVersion = BrowserVersion.INTERNET_EXPLORER_7_0;
+ browserVersion = BrowserVersion.INTERNET_EXPLORER_7;
}else
if( "ie6".equals(browserProp) ||
"internetexplorer6".equals(browserProp) ){
- browserVersion = BrowserVersion.INTERNET_EXPLORER_6_0;
+ browserVersion = BrowserVersion.INTERNET_EXPLORER_6;
}
- log.info("Simulating browser: "+browserVersion.getNickName() +
"('htmlunit.browser' sysprop: "+browserProp+")");
+ log.info("Simulating browser: "+browserVersion.getNickname() +
"('htmlunit.browser' sysprop: "+browserProp+")");
@@ -163,6 +163,7 @@
wcSpec.setInitialRequestStrategy(new JoprLoginStrategy( this.getLoginUser(),
this.getLoginPass())); // logs in
this.webClient = wcSpec.getWebClient();
+ //this.webClient.addWebWindowListener(null);/// TODO
JSFSession jsfSession = new JSFSession(wcSpec);
this.client = jsfSession.getJSFClientSession();
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/MultipleUserLoginTest.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/MultipleUserLoginTest.java 2009-11-05
02:25:22 UTC (rev 836)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/MultipleUserLoginTest.java 2009-11-05
02:53:08 UTC (rev 837)
@@ -30,6 +30,7 @@
import java.util.List;
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.jboss.jopr.jsfunit.util.hmlunit.HtmlPageBumper;
import org.jboss.jsfunit.framework.WebClientSpec;
import org.jboss.jsfunit.framework.WebConversationFactory;
import org.jboss.jsfunit.jsfsession.JSFClientSession;
@@ -255,7 +256,7 @@
public static HtmlElement getElement(HtmlPage page, String elementName)
{
- List<HtmlElement> elements = page.getHtmlElementsByName(elementName);
+ List<HtmlElement> elements = new
HtmlPageBumper(page).getHtmlElementsByName(elementName);
if (elements.size() == 0)
{
throw new IllegalStateException("Component with name=" + elementName +
" was not found on the login page.");
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/EarTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/EarTest.java 2009-11-05
02:25:22 UTC (rev 836)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/EarTest.java 2009-11-05
02:53:08 UTC (rev 837)
@@ -40,6 +40,7 @@
import org.jboss.jopr.jsfunit.AppConstants.DeployableTypes;
import org.jboss.jopr.jsfunit.exceptions.*;
import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.*;
+import org.jboss.jopr.jsfunit.util.hmlunit.HtmlPageBumper;
import org.w3c.dom.Node;
@@ -891,7 +892,9 @@
page = (HtmlPage) page.refresh();
// Get the counter number.
- Integer count1 = NumberUtils.createInteger((
(HtmlElement)page.getBody().getHtmlElementById("count") ).getTextContent());
+ //Integer count1 = NumberUtils.createInteger((
(HtmlElement)page.getBody().getHtmlElementById("count") ).getTextContent());
+ HtmlElement countElm1 = new
HtmlPageBumper(page).getHtmlElementById("count");
+ Integer count1 = NumberUtils.createInteger( countElm1.getTextContent());
@@ -928,7 +931,9 @@
assertTrue(page.asText().contains("HELLO WORLD"));
// Get the counter number.
- Integer count2 = NumberUtils.createInteger((
(HtmlElement)page.getBody().getHtmlElementById("count") ).getTextContent());
+ //Integer count2 = NumberUtils.createInteger((
(HtmlElement)page.getBody().getHtmlElementById("count") ).getTextContent());
+ HtmlElement countElm = new
HtmlPageBumper(page).getHtmlElementById("count");
+ Integer count2 = NumberUtils.createInteger( countElm.getTextContent());
assertTrue( "Counter is reset upon app restart, thus should be lower
after.", count1 > count2 );
@@ -986,7 +991,9 @@
page = (HtmlPage) page.refresh();
// Get the counter number.
- Integer count1 = NumberUtils.createInteger(( (HtmlElement)
page.getBody().getHtmlElementById("count") ).getTextContent());
+ //Integer count1 = NumberUtils.createInteger(( (HtmlElement)
page.getBody().getHtmlElementById("count") ).getTextContent());
+ HtmlElement countElm1 = new
HtmlPageBumper(page).getHtmlElementById("count");
+ Integer count1 = NumberUtils.createInteger( countElm1.getTextContent());
@@ -1010,8 +1017,11 @@
assertTrue(page.asText().contains("HELLO WORLD"));
// Get the counter number.
- Integer count2 = NumberUtils.createInteger(( (HtmlElement)
page.getBody().getHtmlElementById("count") ).getTextContent());
+ //Integer count2 = NumberUtils.createInteger(( (HtmlElement)
page.getBody().getHtmlElementById("count") ).getTextContent());
+ HtmlElement countElm = new
HtmlPageBumper(page).getHtmlElementById("count");
+ Integer count2 = NumberUtils.createInteger( countElm.getTextContent());
+
assertTrue( "Counter is reset upon app restart, thus should be lower
after.", count1 > count2 );
}
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/war/WarTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/war/WarTest.java 2009-11-05
02:25:22 UTC (rev 836)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/war/WarTest.java 2009-11-05
02:53:08 UTC (rev 837)
@@ -43,6 +43,7 @@
import org.jboss.jopr.jsfunit.util.ActiveConditionChecker;
import org.jboss.jopr.jsfunit.util.DescribedCondition;
import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.*;
+import org.jboss.jopr.jsfunit.util.hmlunit.HtmlPageBumper;
import org.w3c.dom.Node;
/**
@@ -1016,7 +1017,7 @@
page = (HtmlPage) page.refresh();
// Get the counter number.
- String count1text = ( (HtmlElement)
page.getBody().getHtmlElementById("count") ).getTextContent();
+ String count1text = (new
HtmlPageBumper(page).getHtmlElementById("count")).getTextContent();
Integer count1 = NumberUtils.createInteger( count1text );
@@ -1054,7 +1055,7 @@
assertTrue(page.asText().contains("HELLO WORLD"));
// Get the counter number.
- String count2text = ( (HtmlElement)
page.getBody().getHtmlElementById("count") ).getTextContent();
+ String count2text = (new
HtmlPageBumper(page).getHtmlElementById("count")).getTextContent();
Integer count2 = NumberUtils.createInteger( count2text );
assertTrue( "Counter is reset upon app restart, thus should be lower after.
" +
@@ -1111,7 +1112,7 @@
page = (HtmlPage) page.refresh();
// Get the counter number.
- String count1text = ( (HtmlElement)
page.getBody().getHtmlElementById("count") ).getTextContent();
+ String count1text = (new
HtmlPageBumper(page).getHtmlElementById("count")).getTextContent();
Integer count1 = NumberUtils.createInteger( count1text );
@@ -1135,7 +1136,7 @@
assertTrue(page.asText().contains("HELLO WORLD"));
// Get the counter number.
- String count2text = ( (HtmlElement)
page.getBody().getHtmlElementById("count") ).getTextContent();
+ String count2text = (new
HtmlPageBumper(page).getHtmlElementById("count")).getTextContent();
Integer count2 = NumberUtils.createInteger( count2text );
assertTrue( "Counter is reset upon app restart, thus should be lower after.
" +
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-11-05
02:25:22 UTC (rev 836)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java 2009-11-05
02:53:08 UTC (rev 837)
@@ -4,9 +4,12 @@
import com.gargoylesoftware.htmlunit.ElementNotFoundException;
import com.gargoylesoftware.htmlunit.Page;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.util.*;
+import java.util.logging.Level;
import javax.management.MalformedObjectNameException;
import javax.naming.NamingException;
import org.jboss.jopr.jsfunit.exceptions.*;
@@ -20,6 +23,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.InetAddress;
+import java.net.URI;
import java.net.URL;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@@ -200,9 +204,25 @@
}
+
+ private URL getCurrentURL() throws EmbJoprTestException {
+ //return client.getContentPage().getWebResponse().getUrl(); // HTMLUnit 2.3
+ try {
+ URI uri = new URI(((HtmlPage) client.getContentPage()).getDocumentURI());
+ return uri.toURL();
+ }
+ catch (URISyntaxException ex) {
+ throw new EmbJoprTestException(ex);
+ }
+ catch (MalformedURLException ex){
+ throw new EmbJoprTestException(ex);
+ }
+ }
+
+
/**
* Inner class to encapsulate navigation tree operations.
*
@@ -215,7 +235,7 @@
public static final String ID_NAV_TREE_FORM = "navTreeForm";
- private void clickRootNode() throws IOException, EmbJoprTestException {
+ public void clickRootNode() throws IOException, EmbJoprTestException {
DomElement element = (DomElement)client.getElement(ID_NAV_TREE_FORM);
if( null == element )
throw new HtmlElementNotFoundException("Can't find
#"+ID_NAV_TREE_FORM+".", currentTest);
@@ -687,10 +707,10 @@
private String validForDate;
/** Store the context identifiing attributes upon creation. */
- public PageContextAwareElement() {
+ public PageContextAwareElement() throws EmbJoprTestException {
// 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();
+ this.validForURL = selfEjtt.getCurrentURL();
}
/**
@@ -698,10 +718,10 @@
* 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 {
+ public void checkIfStillValid() throws ActionOutOfSyncException, EmbJoprTestException
{
String validForDate_ =
client.getContentPage().getWebResponse().getResponseHeaderValue("Date");
- URL validForURL_ = client.getContentPage().getWebResponse().getUrl();
+ URL validForURL_ = selfEjtt.getCurrentURL();
if( !validForDate_.equals(this.validForDate) ||
!validForURL_.equals(this.validForURL) )
Property changes on: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/hmlunit
___________________________________________________________________
Name: svn:ignore
+ BrowserVersionFix.java
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/hmlunit/HtmlPageBumper.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/hmlunit/HtmlPageBumper.java 2009-11-05
02:25:22 UTC (rev 836)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/hmlunit/HtmlPageBumper.java 2009-11-05
02:53:08 UTC (rev 837)
@@ -31,7 +31,7 @@
return super.getElementById(elementId);
}
- public <E extends HtmlElement> E getHtmlElementByName(String name) throws
ElementNotFoundException {
+ public HtmlElement getHtmlElementByName(String name) throws ElementNotFoundException {
return super.getElementByName(name);
}