Skip to content

Commit 8961e26

Browse files
committed
Fix HttpProxyScenarioTests for proper date format
https://build.spring.io/browse/INT-MASTERSPRING40-663/ https://build.spring.io/browse/INT-FATS5IC-832/ **Cherry-pick to 5.1.x & 5.0.x** (cherry picked from commit 3fc2786)
1 parent 7635eef commit 8961e26

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

spring-integration-http/src/test/java/org/springframework/integration/http/HttpProxyScenarioTests.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.time.ZonedDateTime;
2929
import java.time.format.DateTimeFormatter;
3030
import java.util.Calendar;
31+
import java.util.Locale;
3132

3233
import org.junit.Test;
3334
import org.junit.runner.RunWith;
@@ -49,8 +50,7 @@
4950
import org.springframework.mock.web.MockHttpServletRequest;
5051
import org.springframework.mock.web.MockHttpServletResponse;
5152
import org.springframework.test.annotation.DirtiesContext;
52-
import org.springframework.test.context.ContextConfiguration;
53-
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
53+
import org.springframework.test.context.junit4.SpringRunner;
5454
import org.springframework.util.LinkedMultiValueMap;
5555
import org.springframework.util.MultiValueMap;
5656
import org.springframework.web.client.RestTemplate;
@@ -64,10 +64,10 @@
6464
/**
6565
* @author Artem Bilan
6666
* @author Gary Russell
67+
*
6768
* @since 3.0
6869
*/
69-
@ContextConfiguration
70-
@RunWith(SpringJUnit4ClassRunner.class)
70+
@RunWith(SpringRunner.class)
7171
@DirtiesContext
7272
public class HttpProxyScenarioTests {
7373

@@ -89,8 +89,9 @@ public class HttpProxyScenarioTests {
8989

9090
@Test
9191
public void testHttpProxyScenario() throws Exception {
92-
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.RFC_1123_DATE_TIME;
9392
ZoneId GMT = ZoneId.of("GMT");
93+
DateTimeFormatter dateTimeFormatter =
94+
DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US).withZone(GMT);
9495

9596
Calendar c = Calendar.getInstance();
9697
c.set(Calendar.MILLISECOND, 0);
@@ -132,7 +133,7 @@ public void testHttpProxyScenario() throws Exception {
132133
assertEquals(ifUnmodifiedSinceValue, httpHeaders.getFirst("If-Unmodified-Since"));
133134
assertEquals("Keep-Alive", httpHeaders.getFirst("Connection"));
134135

135-
MultiValueMap<String, String> responseHeaders = new LinkedMultiValueMap<String, String>(httpHeaders);
136+
MultiValueMap<String, String> responseHeaders = new LinkedMultiValueMap<>(httpHeaders);
136137
responseHeaders.set("Connection", "close");
137138
responseHeaders.set("Content-Disposition", contentDispositionValue);
138139
return new ResponseEntity<>(responseHeaders, HttpStatus.OK);
@@ -189,7 +190,7 @@ public void testHttpMultipartProxyScenario() throws Exception {
189190
assertThat(entity.getBody(), instanceOf(byte[].class));
190191
assertEquals("foo", new String((byte[]) entity.getBody()));
191192

192-
MultiValueMap<String, String> responseHeaders = new LinkedMultiValueMap<String, String>(httpHeaders);
193+
MultiValueMap<String, String> responseHeaders = new LinkedMultiValueMap<>(httpHeaders);
193194
responseHeaders.set("Connection", "close");
194195
responseHeaders.set("Content-Type", "text/plain");
195196
return new ResponseEntity<>(responseHeaders, HttpStatus.OK);

0 commit comments

Comments
 (0)