Add containsKey to ServletResponseHttpHeaders

Issue: SPR-13668
This commit is contained in:
Rossen Stoyanchev
2015-11-11 14:22:26 -05:00
parent cf4a417f71
commit 62af99a21c
2 changed files with 16 additions and 5 deletions

View File

@@ -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