Add containsKey to ServletResponseHttpHeaders
Issue: SPR-13668
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.http.server;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -29,10 +29,13 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.mock.web.test.MockHttpServletResponse;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class ServletServerHttpResponseTests {
|
||||
|
||||
@@ -40,12 +43,14 @@ public class ServletServerHttpResponseTests {
|
||||
|
||||
private MockHttpServletResponse mockResponse;
|
||||
|
||||
|
||||
@Before
|
||||
public void create() throws Exception {
|
||||
mockResponse = new MockHttpServletResponse();
|
||||
response = new ServletServerHttpResponse(mockResponse);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void setStatusCode() throws Exception {
|
||||
response.setStatusCode(HttpStatus.NOT_FOUND);
|
||||
@@ -73,7 +78,7 @@ public class ServletServerHttpResponseTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getHeadersFromHttpServletResponse() {
|
||||
public void preExistingHeadersFromHttpServletResponse() {
|
||||
|
||||
String headerName = "Access-Control-Allow-Origin";
|
||||
String headerValue = "localhost:8080";
|
||||
@@ -82,7 +87,8 @@ public class ServletServerHttpResponseTests {
|
||||
this.response = new ServletServerHttpResponse(this.mockResponse);
|
||||
|
||||
assertEquals(headerValue, this.response.getHeaders().getFirst(headerName));
|
||||
assertEquals(Arrays.asList(headerValue), this.response.getHeaders().get(headerName));
|
||||
assertEquals(Collections.singletonList(headerValue), this.response.getHeaders().get(headerName));
|
||||
assertTrue(this.response.getHeaders().containsKey(headerName));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user