Skip to content

Commit 3fc2786

Browse files
artembilangaryrussell
authored andcommitted
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**
1 parent cb53861 commit 3fc2786

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
@@ -25,6 +25,7 @@
2525
import java.time.ZonedDateTime;
2626
import java.time.format.DateTimeFormatter;
2727
import java.util.Calendar;
28+
import java.util.Locale;
2829

2930
import org.junit.Test;
3031
import org.junit.runner.RunWith;
@@ -46,8 +47,7 @@
4647
import org.springframework.mock.web.MockHttpServletRequest;
4748
import org.springframework.mock.web.MockHttpServletResponse;
4849
import org.springframework.test.annotation.DirtiesContext;
49-
import org.springframework.test.context.ContextConfiguration;
50-
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
50+
import org.springframework.test.context.junit4.SpringRunner;
5151
import org.springframework.util.LinkedMultiValueMap;
5252
import org.springframework.util.MultiValueMap;
5353
import org.springframework.web.client.RestTemplate;
@@ -61,10 +61,10 @@
6161
/**
6262
* @author Artem Bilan
6363
* @author Gary Russell
64+
*
6465
* @since 3.0
6566
*/
66-
@ContextConfiguration
67-
@RunWith(SpringJUnit4ClassRunner.class)
67+
@RunWith(SpringRunner.class)
6868
@DirtiesContext
6969
public class HttpProxyScenarioTests {
7070

@@ -86,8 +86,9 @@ public class HttpProxyScenarioTests {
8686

8787
@Test
8888
public void testHttpProxyScenario() throws Exception {
89-
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.RFC_1123_DATE_TIME;
9089
ZoneId GMT = ZoneId.of("GMT");
90+
DateTimeFormatter dateTimeFormatter =
91+
DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US).withZone(GMT);
9192

9293
Calendar c = Calendar.getInstance();
9394
c.set(Calendar.MILLISECOND, 0);
@@ -129,7 +130,7 @@ public void testHttpProxyScenario() throws Exception {
129130
assertThat(httpHeaders.getFirst("If-Unmodified-Since")).isEqualTo(ifUnmodifiedSinceValue);
130131
assertThat(httpHeaders.getFirst("Connection")).isEqualTo("Keep-Alive");
131132

132-
MultiValueMap<String, String> responseHeaders = new LinkedMultiValueMap<String, String>(httpHeaders);
133+
MultiValueMap<String, String> responseHeaders = new LinkedMultiValueMap<>(httpHeaders);
133134
responseHeaders.set("Connection", "close");
134135
responseHeaders.set("Content-Disposition", contentDispositionValue);
135136
return new ResponseEntity<>(responseHeaders, HttpStatus.OK);
@@ -186,7 +187,7 @@ public void testHttpMultipartProxyScenario() throws Exception {
186187
assertThat(entity.getBody()).isInstanceOf(byte[].class);
187188
assertThat(new String((byte[]) entity.getBody())).isEqualTo("foo");
188189

189-
MultiValueMap<String, String> responseHeaders = new LinkedMultiValueMap<String, String>(httpHeaders);
190+
MultiValueMap<String, String> responseHeaders = new LinkedMultiValueMap<>(httpHeaders);
190191
responseHeaders.set("Connection", "close");
191192
responseHeaders.set("Content-Type", "text/plain");
192193
return new ResponseEntity<Object>(responseHeaders, HttpStatus.OK);

0 commit comments

Comments
 (0)