未验证 提交 37ed68dc 编写于 作者: J Jeff Thompson 提交者: GitHub

Merge pull request #3793 from halkeye/JENKINS-55062-FixAssetsForRestarting

JENKINS-55062 - set resURL and rootURL for restarting template to load from the right places
......@@ -25,12 +25,14 @@ THE SOFTWARE.
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:x="jelly:xml" xmlns:f="/lib/form">
<j:new var="h" className="hudson.Functions" />
<st:statusCode value="503"/><!-- SERVICE NOT AVAILABLE -->
<st:setHeader name="Expires" value="0"/>
<st:setHeader name="Cache-Control" value="no-cache,no-store,must-revalidate"/>
<!-- response contentType header -->
<st:contentType value="text/html;charset=UTF-8"/>
<!-- get default/commong page variable -->
${h.initPageVariables(context)}
<x:doctype name="html"/>
<html lang="${request.getLocale().toLanguageTag()}">
<head data-rooturl="${rootURL}" data-resurl="${resURL}" resURL="${resURL}">
......@@ -60,4 +62,4 @@ THE SOFTWARE.
<script>safeRedirector(window.location.href);</script>
</body>
</html>
</j:jelly>
\ No newline at end of file
</j:jelly>
......@@ -25,12 +25,14 @@ THE SOFTWARE.
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:x="jelly:xml" xmlns:f="/lib/form">
<j:new var="h" className="hudson.Functions" />
<st:statusCode value="503"/><!-- SERVICE NOT AVAILABLE -->
<st:setHeader name="Expires" value="0"/>
<st:setHeader name="Cache-Control" value="no-cache,no-store,must-revalidate"/>
<!-- response contentType header -->
<st:contentType value="text/html;charset=UTF-8"/>
<!-- get default/commong page variable -->
${h.initPageVariables(context)}
<x:doctype name="html"/>
<html lang="${request.getLocale().toLanguageTag()}">
<head data-rooturl="${rootURL}" data-resurl="${resURL}" resURL="${resURL}">
......
package hudson.util;
import com.gargoylesoftware.htmlunit.Page;
import org.hamcrest.CoreMatchers;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public class HudsonIsLoading {
@Rule
public JenkinsRule j = new JenkinsRule();
@Test
@Issue("JENKINS-55062")
public void withPrefix() throws Exception {
j.jenkins.servletContext.setAttribute("app", new HudsonIsLoading());
JenkinsRule.WebClient wc = j.createWebClient();
wc.getOptions().setThrowExceptionOnFailingStatusCode(false); // this is a failure page already
wc.getOptions().setJavaScriptEnabled(false);
Page p = wc.goTo("", "text/html");
assertTrue( p.isHtmlPage() );
String body = p.getWebResponse().getContentAsString();
assertThat(body, CoreMatchers.containsString("data-resurl=\""));
assertThat(body, CoreMatchers.containsString("data-rooturl=\""));
assertThat(body, CoreMatchers.containsString("resURL=\""));
}
}
package hudson.util;
import com.gargoylesoftware.htmlunit.Page;
import org.hamcrest.CoreMatchers;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;
import static org.junit.Assert.*;
public class HudsonIsRestarting {
@Rule
public JenkinsRule j = new JenkinsRule();
@Test
@Issue("JENKINS-55062")
public void withPrefix() throws Exception {
j.jenkins.servletContext.setAttribute("app", new HudsonIsRestarting());
JenkinsRule.WebClient wc = j.createWebClient();
wc.getOptions().setThrowExceptionOnFailingStatusCode(false); // this is a failure page already
wc.getOptions().setJavaScriptEnabled(false);
Page p = wc.goTo("", "text/html");
assertTrue( p.isHtmlPage() );
String body = p.getWebResponse().getContentAsString();
assertThat(body, CoreMatchers.containsString("data-resurl=\""));
assertThat(body, CoreMatchers.containsString("data-rooturl=\""));
assertThat(body, CoreMatchers.containsString("resURL=\""));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册