1
1
/*
2
- * Copyright 2002-2014 the original author or authors.
2
+ * Copyright 2002-2015 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
17
17
package org .springframework .http .server ;
18
18
19
19
import java .nio .charset .Charset ;
20
- import java .util .Arrays ;
20
+ import java .util .Collections ;
21
21
import java .util .List ;
22
22
23
23
import org .junit .Before ;
29
29
import org .springframework .mock .web .test .MockHttpServletResponse ;
30
30
import org .springframework .util .FileCopyUtils ;
31
31
32
- import static org .junit .Assert .*;
32
+ import static org .junit .Assert .assertArrayEquals ;
33
+ import static org .junit .Assert .assertEquals ;
34
+ import static org .junit .Assert .assertTrue ;
33
35
34
36
/**
35
37
* @author Arjen Poutsma
38
+ * @author Rossen Stoyanchev
36
39
*/
37
40
public class ServletServerHttpResponseTests {
38
41
39
42
private ServletServerHttpResponse response ;
40
43
41
44
private MockHttpServletResponse mockResponse ;
42
45
46
+
43
47
@ Before
44
48
public void create () throws Exception {
45
49
mockResponse = new MockHttpServletResponse ();
46
50
response = new ServletServerHttpResponse (mockResponse );
47
51
}
48
52
53
+
49
54
@ Test
50
55
public void setStatusCode () throws Exception {
51
56
response .setStatusCode (HttpStatus .NOT_FOUND );
@@ -73,7 +78,7 @@ public void getHeaders() throws Exception {
73
78
}
74
79
75
80
@ Test
76
- public void getHeadersFromHttpServletResponse () {
81
+ public void preExistingHeadersFromHttpServletResponse () {
77
82
78
83
String headerName = "Access-Control-Allow-Origin" ;
79
84
String headerValue = "localhost:8080" ;
@@ -82,7 +87,8 @@ public void getHeadersFromHttpServletResponse() {
82
87
this .response = new ServletServerHttpResponse (this .mockResponse );
83
88
84
89
assertEquals (headerValue , this .response .getHeaders ().getFirst (headerName ));
85
- assertEquals (Arrays .asList (headerValue ), this .response .getHeaders ().get (headerName ));
90
+ assertEquals (Collections .singletonList (headerValue ), this .response .getHeaders ().get (headerName ));
91
+ assertTrue (this .response .getHeaders ().containsKey (headerName ));
86
92
}
87
93
88
94
@ Test
0 commit comments