diff --git a/test/src/main/java/org/jvnet/hudson/test/HudsonPageCreator.java b/test/src/main/java/org/jvnet/hudson/test/HudsonPageCreator.java new file mode 100644 index 0000000000..6bcdc385fc --- /dev/null +++ b/test/src/main/java/org/jvnet/hudson/test/HudsonPageCreator.java @@ -0,0 +1,26 @@ +package org.jvnet.hudson.test; + +import com.gargoylesoftware.htmlunit.DefaultPageCreator; +import com.gargoylesoftware.htmlunit.Page; +import com.gargoylesoftware.htmlunit.WebResponse; +import com.gargoylesoftware.htmlunit.WebWindow; +import com.gargoylesoftware.htmlunit.PageCreator; + +import java.io.IOException; + +/** + * {@link PageCreator} that understands JNLP file. + * + * @author Kohsuke Kawaguchi + */ +public class HudsonPageCreator extends DefaultPageCreator { + @Override + public Page createPage(WebResponse webResponse, WebWindow webWindow) throws IOException { + String contentType = webResponse.getContentType().toLowerCase(); + if(contentType.equals("application/x-java-jnlp-file")) + return createXmlPage(webResponse, webWindow); + return super.createPage(webResponse, webWindow); + } + + public static final HudsonPageCreator INSTANCE = new HudsonPageCreator(); +} diff --git a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java index 6c961b1f5a..92dd2a03f0 100644 --- a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java +++ b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java @@ -191,6 +191,7 @@ public abstract class HudsonTestCase extends TestCase { public class WebClient extends com.gargoylesoftware.htmlunit.WebClient { public WebClient() { setJavaScriptEnabled(false); + setPageCreator(HudsonPageCreator.INSTANCE); } /**