提交 a4bd40d3 编写于 作者: J Jesse Glick

Try harder to set Jenkins root URL, since some tests rely on it.

上级 6ee5e03a
......@@ -188,6 +188,7 @@ import com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory;
import com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest;
import com.gargoylesoftware.htmlunit.xml.XmlPage;
import java.net.HttpURLConnection;
import jenkins.model.JenkinsLocationConfiguration;
/**
* Base class for all Jenkins test cases.
......@@ -330,7 +331,8 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
jenkins.servletContext.setAttribute("app", jenkins);
jenkins.servletContext.setAttribute("version","?");
WebAppMain.installExpressionFactory(new ServletContextEvent(jenkins.servletContext));
Mailer.descriptor().setHudsonUrl(getURL().toExternalForm());
Mailer.descriptor().setHudsonUrl(getURL().toExternalForm()); // for compatibility only
JenkinsLocationConfiguration.get().setUrl(getURL().toString()); // in case we are using older mailer plugin
// set a default JDK to be the one that the harness is using.
jenkins.getJDKs().add(new JDK("default",System.getProperty("java.home")));
......@@ -343,9 +345,6 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
// cause all the descriptors to reload.
// ideally we'd like to reset them to properly emulate the behavior, but that's not possible.
DescriptorImpl desc = Mailer.descriptor();
// prevent NPE with eclipse
if (desc != null) Mailer.descriptor().setHudsonUrl(null);
for( Descriptor d : jenkins.getExtensionList(Descriptor.class) )
d.load();
......
......@@ -204,6 +204,7 @@ import java.util.logging.Filter;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import jenkins.model.JenkinsLocationConfiguration;
import org.acegisecurity.GrantedAuthorityImpl;
import static org.hamcrest.Matchers.hasXPath;
......@@ -351,7 +352,8 @@ public class JenkinsRule implements TestRule, MethodRule, RootAction {
// ideally we'd like to reset them to properly emulate the behavior, but that's not possible.
Mailer.DescriptorImpl desc = Mailer.descriptor();
// prevent NPE with eclipse
if (desc != null) Mailer.descriptor().setHudsonUrl(null);
if (desc != null) Mailer.descriptor().setHudsonUrl(getURL().toString());
JenkinsLocationConfiguration.get().setUrl(getURL().toString());
for( Descriptor d : jenkins.getExtensionList(Descriptor.class) )
d.load();
}
......
......@@ -22,6 +22,7 @@ import org.jvnet.hudson.test.recipes.WithPluginManager;
import org.xml.sax.SAXException;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import jenkins.model.JenkinsLocationConfiguration;
public class UseRecipesWithJenkinsRuleTest {
......@@ -55,6 +56,10 @@ public class UseRecipesWithJenkinsRuleTest {
assertEquals(MyPluginManager.class, rule.jenkins.pluginManager.getClass());
}
@Test public void rightURL() throws Exception {
assertEquals(rule.getURL(), new URL(JenkinsLocationConfiguration.get().getUrl()));
}
private void verifyNotError(WebClient wc) throws IOException, SAXException {
HtmlPage p = wc.goTo("loginError");
URL url = p.getWebResponse().getUrl();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册