@@ -43,11 +43,11 @@ public void setUp() throws Exception {
4343 }
4444
4545 githubApi .stubFor (
46- get (urlEqualTo ("/repos/cloudbeers/yolo" ))
47- .willReturn (aResponse ()
48- .withStatus (200 )
49- .withHeader ("Content-Type" , "application/json" )
50- .withBodyFile ("body-cloudbeers-yolo-PucD6.json" ))
46+ get (urlEqualTo ("/repos/cloudbeers/yolo" ))
47+ .willReturn (aResponse ()
48+ .withStatus (200 )
49+ .withHeader ("Content-Type" , "application/json" )
50+ .withBodyFile ("body-cloudbeers-yolo-PucD6.json" ))
5151 );
5252 }
5353
@@ -57,8 +57,8 @@ void createProbeForPR(int number) throws IOException {
5757 final GHRepository repo = github .getRepository ("cloudbeers/yolo" );
5858 final PullRequestSCMHead head = new PullRequestSCMHead ("PR-" + number , "cloudbeers" , "yolo" , "b" , number , new BranchSCMHead ("master" ), new SCMHeadOrigin .Fork ("rsandell" ), ChangeRequestCheckoutStrategy .MERGE );
5959 probe = new GitHubSCMProbe (github , repo ,
60- head ,
61- new PullRequestSCMRevision (head , "a" , "b" ));
60+ head ,
61+ new PullRequestSCMRevision (head , "a" , "b" ));
6262 }
6363
6464 @ Issue ("JENKINS-54126" )
@@ -119,28 +119,45 @@ public void statWhenRoot404andThenIncorrectCached() throws Exception {
119119 // Without 4. this would return false and would stay false.
120120 assertTrue (probe .stat ("README.md" ).exists ());
121121
122+ // 5. Verify caching is working
123+ assertTrue (probe .stat ("README.md" ).exists ());
122124
123125 // Verify the expected requests were made
124- // 1.
125- githubApi .verify (RequestPatternBuilder .newRequestPattern (RequestMethod .GET , urlPathEqualTo ("/repos/cloudbeers/yolo/contents/" ))
126- .withHeader ("Cache-Control" , containing ("max-age" ))
126+ if (hudson .Functions .isWindows ()) {
127+ // On windows caching is disabled by default, so the work around doesn't happen
128+ githubApi .verify (3 , RequestPatternBuilder .newRequestPattern (RequestMethod .GET , urlPathEqualTo ("/repos/cloudbeers/yolo/contents/" ))
129+ .withHeader ("Cache-Control" , equalTo ("max-age=0" ))
130+ .withHeader ("If-Modified-Since" , absent ())
131+ .withHeader ("If-None-Match" , absent ())
132+ );
133+ } else {
134+ // 1.
135+ githubApi .verify (RequestPatternBuilder .newRequestPattern (RequestMethod .GET , urlPathEqualTo ("/repos/cloudbeers/yolo/contents/" ))
136+ .withHeader ("Cache-Control" , equalTo ("max-age=0" ))
127137 .withHeader ("If-None-Match" , absent ())
128138 .withHeader ("If-Modified-Since" , absent ())
129- );
139+ );
130140
131- // 3.
132- githubApi .verify (RequestPatternBuilder .newRequestPattern (RequestMethod .GET , urlPathEqualTo ("/repos/cloudbeers/yolo/contents/" ))
133- .withHeader ("Cache-Control" , containing ("max-age" ))
134- .withHeader ("If-None-Match" , absent ())
135- .withHeader ("If-Modified-Since" , containing ("GMT" ))
136- );
141+ // 3.
142+ githubApi .verify (RequestPatternBuilder .newRequestPattern (RequestMethod .GET , urlPathEqualTo ("/repos/cloudbeers/yolo/contents/" ))
143+ .withHeader ("Cache-Control" , containing ("max-age" ))
144+ .withHeader ("If-None-Match" , absent ())
145+ .withHeader ("If-Modified-Since" , containing ("GMT" ))
146+ );
137147
138- // 4.
139- githubApi .verify (RequestPatternBuilder .newRequestPattern (RequestMethod .GET , urlPathEqualTo ("/repos/cloudbeers/yolo/contents/" ))
140- .withHeader ("Cache-Control" , equalTo ("no-cache" ))
141- .withHeader ("If-Modified-Since" , absent ())
142- .withHeader ("If-None-Match" , absent ())
143- );
148+ // 4.
149+ githubApi .verify (RequestPatternBuilder .newRequestPattern (RequestMethod .GET , urlPathEqualTo ("/repos/cloudbeers/yolo/contents/" ))
150+ .withHeader ("Cache-Control" , equalTo ("no-cache" ))
151+ .withHeader ("If-Modified-Since" , absent ())
152+ .withHeader ("If-None-Match" , absent ())
153+ );
154+
155+ // 5.
156+ githubApi .verify (RequestPatternBuilder .newRequestPattern (RequestMethod .GET , urlPathEqualTo ("/repos/cloudbeers/yolo/contents/" ))
157+ .withHeader ("Cache-Control" , equalTo ("max-age=0" ))
158+ .withHeader ("If-None-Match" , equalTo ("\" d3be5b35b8d84ef7ac03c0cc9c94ed81\" " ))
159+ );
160+ }
144161 }
145162
146163}
0 commit comments