Author: ozizka(a)redhat.com
Date: 2009-06-10 11:22:21 -0400 (Wed, 10 Jun 2009)
New Revision: 515
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/EarTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java
Log:
EarTest updated
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-06-10
15:21:20 UTC (rev 514)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/EarTest.java 2009-06-10
15:22:21 UTC (rev 515)
@@ -231,7 +231,6 @@
// Deploy first deployable - the correct one.
String earFilePath = ejtt.getTestDataDir() + "/ear/"+DEPLOYABLE_NAME;
- //deployEar(earFilePath);
ejtt.deployment.deployViaEmbJopr(APP_TYPE, earFilePath);
String expectedMessage = DEPLOYABLE_NAME + " created successfully";
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-06-10
15:21:20 UTC (rev 514)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java 2009-06-10
15:22:21 UTC (rev 515)
@@ -4,8 +4,10 @@
import com.gargoylesoftware.htmlunit.ElementNotFoundException;
import com.gargoylesoftware.htmlunit.Page;
+import java.net.UnknownHostException;
import java.util.*;
+import java.util.logging.Level;
import org.jboss.jopr.jsfunit.exceptions.*;
import com.gargoylesoftware.htmlunit.html.*;
import com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine;
@@ -16,6 +18,9 @@
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.net.Inet4Address;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
import java.net.URL;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@@ -122,6 +127,17 @@
.getExternalContext().getRequest() ).getLocalPort();
}
+ public InetAddress getEmbJoprIpAddress(){
+ String localAddr = ( (HttpServletRequest)FacesContext.getCurrentInstance()
+ .getExternalContext().getRequest() ).getLocalAddr();
+ try {
+ InetAddress ia = InetAddress.getByName(localAddr);
+ return ia;
+ } catch (UnknownHostException ex) {
+ throw new IllegalStateException("Error when creating EmbJopr's IP adress:
"+ex.toString());
+ }
+ }
+
/**
* @returns JavaScript object, as returned by JavaScriptEngine#execute().
*/
@@ -660,27 +676,45 @@
}
+ public static final String XPATH_TABLE_UNDER_HEADER_FORMAT =
"*[contains(normalize-space(), '%s')]/following::table";
+ // [@id='resourceSummaryForm:dataTable'] - is this reliable?
+
+
/**
* Returns first table under given header.
*
* Unfortunately, headers are not H2 or similar, but DIV
class="instructionalText".
* To be revised later.
*/
- public ContentTable getTableUnderHeader( String headerText ) throws
ActionOutOfSyncException, HtmlElementNotFoundException
+ public ContentTable getTableUnderHeader( String headerText, boolean throwIfNotFound )
throws ActionOutOfSyncException, HtmlElementNotFoundException
{
checkIfStillValid();
- String xPath = "*[contains(normalize-space(),
'"+headerText+"')]/following::table";
- // [@id='resourceSummaryForm:dataTable'] - is this reliable?
- HtmlTable tableElement = (HtmlTable) element.getFirstByXPath(xPath);
+ //String xPath = "*[contains(normalize-space(),
'"+headerText+"')]/following::table";
+ String xPath = String.format(XPATH_TABLE_UNDER_HEADER_FORMAT, headerText);
+ HtmlTable tableElement = (HtmlTable) element.getFirstByXPath( xPath );
if( null == tableElement ){
- throw new HtmlElementNotFoundException(
- "Table under header '"+headerText+"' not found using
XPath: "+xPath, currentTest);
+ if( throwIfNotFound ){
+ throw new HtmlElementNotFoundException(
+ "Table under header '"+headerText+"' not found using
XPath: "+xPath, currentTest);
+ }
+ else {
+ return null;
+ }
}
return new ContentTable(tableElement);
}
+ public ContentTable getTableUnderHeader( String headerText ) throws
ActionOutOfSyncException, HtmlElementNotFoundException {
+ return getTableUnderHeader(headerText, true );
+ }
+
+ public ContentTable findTableUnderHeader( String headerText ) throws
ActionOutOfSyncException, HtmlElementNotFoundException {
+ return getTableUnderHeader(headerText, false );
+ }
+
+
/**
* Returns first table in the content box.
*/
Show replies by date