Author: ozizka(a)redhat.com
Date: 2009-08-13 12:12:20 -0400 (Thu, 13 Aug 2009)
New Revision: 672
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
Log:
* EmbjoprTestCase - cleanup code added to tearUp().
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-08-12
23:31:36 UTC (rev 671)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-08-13
16:12:20 UTC (rev 672)
@@ -23,10 +23,10 @@
package org.jboss.jopr.jsfunit;
import com.gargoylesoftware.htmlunit.BrowserVersion;
+import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.*;
import java.io.IOException;
import java.util.*;
-import java.util.logging.Level;
import org.jboss.logging.*;
import org.apache.cactus.ServletTestCase;
import org.jboss.jsfunit.framework.WebClientSpec;
@@ -36,7 +36,6 @@
import javax.faces.application.FacesMessage;
//import org.jboss.jmx.adaptor.rmi.RMIAdaptor; // Needs dependency: jmx-adaptor-plugin
import java.util.regex.Pattern;
-import javax.xml.xpath.XPathException;
import org.jboss.profileservice.spi.ProfileService;
import org.jboss.profileservice.spi.NoSuchDeploymentException;
import javax.naming.InitialContext;
@@ -70,6 +69,8 @@
protected boolean isJBoss4;
+ protected WebClient webClient;
+
protected JSFClientSession client;
protected JSFServerSession server;
@@ -128,30 +129,31 @@
// Browser branch and version
- BrowserVersion browser = BrowserVersion.FIREFOX_3;
+ BrowserVersion browserVersion = BrowserVersion.FIREFOX_3;
String browserProp = System.getProperty("htmlunit.browser");
if( "ff3".equals(browserProp) || "firefox3".equals(browserProp)
){
- browser = BrowserVersion.FIREFOX_3;
+ browserVersion = BrowserVersion.FIREFOX_3;
}else
if( "ff2".equals(browserProp) || "firefox2".equals(browserProp)
){
- browser = BrowserVersion.FIREFOX_2;
+ browserVersion = BrowserVersion.FIREFOX_2;
}else
if( "ie7".equals(browserProp) ||
"internetexplorer7".equals(browserProp) ){
- browser = BrowserVersion.INTERNET_EXPLORER_7_0;
+ browserVersion = BrowserVersion.INTERNET_EXPLORER_7_0;
}else
if( "ie6".equals(browserProp) ||
"internetexplorer6".equals(browserProp) ){
- browser = BrowserVersion.INTERNET_EXPLORER_6_0;
+ browserVersion = BrowserVersion.INTERNET_EXPLORER_6_0;
}
- log.info("Simulating browser: "+browser.getNickName() +
"('htmlunit.browser' sysprop: "+browserProp+")");
+ log.info("Simulating browser: "+browserVersion.getNickName() +
"('htmlunit.browser' sysprop: "+browserProp+")");
// Initial JSF request
- WebClientSpec wcSpec = new WebClientSpec("/", browser);
+ WebClientSpec wcSpec = new WebClientSpec("/", browserVersion);
+
// This is temporary because embedded Jopr can't find /js/rhq.js
wcSpec.getWebClient().setThrowExceptionOnFailingStatusCode(true);
@@ -160,6 +162,8 @@
wcSpec.setInitialRequestStrategy(new JoprLoginStrategy( this.getLoginUser(),
this.getLoginPass())); // logs in
+ this.webClient = wcSpec.getWebClient();
+
JSFSession jsfSession = new JSFSession(wcSpec);
this.client = jsfSession.getJSFClientSession();
this.server = jsfSession.getJSFServerSession();
@@ -170,6 +174,15 @@
@Override
protected void tearDown() throws Exception {
+
+ // Clean up.
+ this.webClient.closeAllWindows();
+ this.webClient.getCache().clear();
+ this.webClient.getCookieManager().clearCookies();
+ this.webClient = null;
+ this.client = null;
+ this.server = null;
+
// Denounce this test in the JBoss log.
log.info("------ END OF TEST "+this.getName()+" - took
"+((System.currentTimeMillis() - this.testStartTime)/1000)+" seconds.
-------");
}
Show replies by date