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 3fc278688c)
This commit is contained in:
@@ -28,6 +28,7 @@ import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -49,8 +50,7 @@ import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
@@ -64,10 +64,10 @@ import org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter;
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
@DirtiesContext
|
||||
public class HttpProxyScenarioTests {
|
||||
|
||||
@@ -89,8 +89,9 @@ public class HttpProxyScenarioTests {
|
||||
|
||||
@Test
|
||||
public void testHttpProxyScenario() throws Exception {
|
||||
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.RFC_1123_DATE_TIME;
|
||||
ZoneId GMT = ZoneId.of("GMT");
|
||||
DateTimeFormatter dateTimeFormatter =
|
||||
DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US).withZone(GMT);
|
||||
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.set(Calendar.MILLISECOND, 0);
|
||||
@@ -132,7 +133,7 @@ public class HttpProxyScenarioTests {
|
||||
assertEquals(ifUnmodifiedSinceValue, httpHeaders.getFirst("If-Unmodified-Since"));
|
||||
assertEquals("Keep-Alive", httpHeaders.getFirst("Connection"));
|
||||
|
||||
MultiValueMap<String, String> responseHeaders = new LinkedMultiValueMap<String, String>(httpHeaders);
|
||||
MultiValueMap<String, String> responseHeaders = new LinkedMultiValueMap<>(httpHeaders);
|
||||
responseHeaders.set("Connection", "close");
|
||||
responseHeaders.set("Content-Disposition", contentDispositionValue);
|
||||
return new ResponseEntity<>(responseHeaders, HttpStatus.OK);
|
||||
@@ -189,7 +190,7 @@ public class HttpProxyScenarioTests {
|
||||
assertThat(entity.getBody(), instanceOf(byte[].class));
|
||||
assertEquals("foo", new String((byte[]) entity.getBody()));
|
||||
|
||||
MultiValueMap<String, String> responseHeaders = new LinkedMultiValueMap<String, String>(httpHeaders);
|
||||
MultiValueMap<String, String> responseHeaders = new LinkedMultiValueMap<>(httpHeaders);
|
||||
responseHeaders.set("Connection", "close");
|
||||
responseHeaders.set("Content-Type", "text/plain");
|
||||
return new ResponseEntity<>(responseHeaders, HttpStatus.OK);
|
||||
|
||||
Reference in New Issue
Block a user