提交 58863d88 编写于 作者: K kohsuke

use the latest version of htmlunit

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@24869 71c3de6d-444a-0410-be80-ed276b4c234a
上级 21176da7
......@@ -151,7 +151,7 @@ THE SOFTWARE.
<dependency>
<groupId>org.jvnet.hudson</groupId>
<artifactId>htmlunit</artifactId>
<version>2.2-hudson-11</version>
<version>2.6-hudson-1</version>
<exclusions>
<exclusion>
<!-- hides JDK DOM classes in Eclipse -->
......@@ -210,7 +210,7 @@ THE SOFTWARE.
</goals>
<configuration>
<scriptpath>
<!-- load helpers from core -->
<!-- load helpers from hg core -->
<element>${project.basedir}/../core/src/build-script</element>
</scriptpath>
<source>${project.basedir}/src/build-script/unitTest.groovy</source>
......
......@@ -23,6 +23,8 @@
*/
package org.jvnet.hudson.test;
import com.gargoylesoftware.htmlunit.DefaultCssErrorHandler;
import com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest;
import hudson.CloseProofOutputStream;
import hudson.FilePath;
import hudson.Functions;
......@@ -106,6 +108,9 @@ import javax.servlet.ServletContextEvent;
import junit.framework.TestCase;
import net.sourceforge.htmlunit.corejs.javascript.Context;
import net.sourceforge.htmlunit.corejs.javascript.ContextFactory;
import net.sourceforge.htmlunit.corejs.javascript.ContextFactory.Listener;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.io.FileUtils;
import org.apache.commons.beanutils.PropertyUtils;
......@@ -121,6 +126,7 @@ import org.kohsuke.stapler.MetaClassLoader;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.Stapler;
import org.mortbay.jetty.MimeTypes;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.bio.SocketConnector;
import org.mortbay.jetty.security.HashUserRealm;
......@@ -128,10 +134,7 @@ import org.mortbay.jetty.security.UserRealm;
import org.mortbay.jetty.webapp.Configuration;
import org.mortbay.jetty.webapp.WebAppContext;
import org.mortbay.jetty.webapp.WebXmlConfiguration;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.ContextFactory;
import org.mozilla.javascript.tools.debugger.Dim;
import org.mozilla.javascript.ContextFactory.Listener;
import org.w3c.css.sac.CSSException;
import org.w3c.css.sac.CSSParseException;
import org.w3c.css.sac.ErrorHandler;
......@@ -149,7 +152,6 @@ import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlInput;
import com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine;
import com.gargoylesoftware.htmlunit.javascript.host.Stylesheet;
import com.gargoylesoftware.htmlunit.javascript.host.XMLHttpRequest;
/**
* Base class for all Hudson test cases.
......@@ -303,7 +305,7 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
@Override
protected void runTest() throws Throwable {
System.out.println("=== Starting "+ getClass().getSimpleName() + "." + getName());
new JavaScriptEngine(null); // ensure that ContextFactory is initialized
// new JavaScriptEngine(null); // ensure that ContextFactory is initialized
ContextFactory.getGlobal().addListener(rhinoContextListener);
try {
......@@ -347,6 +349,7 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
context.setClassLoader(getClass().getClassLoader());
context.setConfigurations(new Configuration[]{new WebXmlConfiguration(),new NoListenerConfiguration()});
server.setHandler(context);
context.setMimeTypes(MIME_TYPES);
SocketConnector connector = new SocketConnector();
server.addConnector(connector);
......@@ -566,7 +569,9 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
// this can be too late, depending on when this method is invoked.
Functions.DEBUG_YUI = true;
return org.mozilla.javascript.tools.debugger.Main.mainEmbedded("Rhino debugger: "+getName());
// TODO: port this back later
// return net.sourceforge.htmlunit.corejs.javascript.tools.debugger.Main.mainEmbedded("Rhino debugger: "+getName());
return null;
}
/**
......@@ -1021,6 +1026,29 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
return true;
}
});
setCssErrorHandler(new ErrorHandler() {
final ErrorHandler defaultHandler = new DefaultCssErrorHandler();
public void warning(CSSParseException exception) throws CSSException {
if (!ignore(exception))
defaultHandler.warning(exception);
}
public void error(CSSParseException exception) throws CSSException {
if (!ignore(exception))
defaultHandler.error(exception);
}
public void fatalError(CSSParseException exception) throws CSSException {
if (!ignore(exception))
defaultHandler.fatalError(exception);
}
private boolean ignore(CSSParseException e) {
return e.getURI().contains("/yui/");
}
});
}
/**
......@@ -1195,29 +1223,6 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
}
}
// we don't care CSS errors in YUI
final ErrorHandler defaultHandler = Stylesheet.CSS_ERROR_HANDLER;
Stylesheet.CSS_ERROR_HANDLER = new ErrorHandler() {
public void warning(CSSParseException exception) throws CSSException {
if(!ignore(exception))
defaultHandler.warning(exception);
}
public void error(CSSParseException exception) throws CSSException {
if(!ignore(exception))
defaultHandler.error(exception);
}
public void fatalError(CSSParseException exception) throws CSSException {
if(!ignore(exception))
defaultHandler.fatalError(exception);
}
private boolean ignore(CSSParseException e) {
return e.getURI().contains("/yui/");
}
};
// suppress INFO output from Spring, which is verbose
Logger.getLogger("org.springframework").setLevel(Level.WARNING);
......@@ -1243,4 +1248,9 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
* Specify this to a TCP/IP port number to have slaves started with the debugger.
*/
public static int SLAVE_DEBUG_PORT = Integer.getInteger(HudsonTestCase.class.getName()+".slaveDebugPort",-1);
public static final MimeTypes MIME_TYPES = new MimeTypes();
static {
MIME_TYPES.addMimeMapping("js","application/javascript");
}
}
......@@ -23,10 +23,10 @@
*/
package org.jvnet.hudson.test.rhino;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.debug.DebugFrame;
import org.mozilla.javascript.debug.DebuggableScript;
import net.sourceforge.htmlunit.corejs.javascript.Context;
import net.sourceforge.htmlunit.corejs.javascript.Scriptable;
import net.sourceforge.htmlunit.corejs.javascript.debug.DebugFrame;
import net.sourceforge.htmlunit.corejs.javascript.debug.DebuggableScript;
import java.util.SortedMap;
import java.util.TreeMap;
......
......@@ -23,10 +23,10 @@
*/
package org.jvnet.hudson.test.rhino;
import org.mozilla.javascript.debug.Debugger;
import org.mozilla.javascript.debug.DebuggableScript;
import org.mozilla.javascript.debug.DebugFrame;
import org.mozilla.javascript.Context;
import net.sourceforge.htmlunit.corejs.javascript.Context;
import net.sourceforge.htmlunit.corejs.javascript.debug.DebugFrame;
import net.sourceforge.htmlunit.corejs.javascript.debug.DebuggableScript;
import net.sourceforge.htmlunit.corejs.javascript.debug.Debugger;
import org.jvnet.hudson.test.HudsonTestCase;
import java.util.List;
......
......@@ -218,7 +218,7 @@ public class QueueTest extends HudsonTestCase {
// View for build should group duplicates
WebClient wc = new WebClient();
String buildPage = wc.getPage(build, "").asText();
String buildPage = wc.getPage(build, "").asText().replace('\n',' ');
assertTrue("Build page should combine duplicates and show counts: " + buildPage,
buildPage.contains("Started by user anonymous (2 times) "
+ "Started by an SCM change (3 times) "
......
......@@ -35,7 +35,7 @@ public class ListScmBrowsersTest extends HudsonTestCase {
for (HtmlSelect select : selects) {
Set<String> title = new HashSet<String>();
for(HtmlOption o : select.getOptions()) {
assertTrue("Duplicate entry: "+o.asText(),title.add(o.asText()));
assertTrue("Duplicate entry: "+o.getText(),title.add(o.getText()));
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册