fixed header value type

This commit is contained in:
Juergen Hoeller 2008-12-05 07:07:06 +00:00
parent 70b9dd6108
commit b3866a974a
3 changed files with 12 additions and 3 deletions

View File

@ -16,6 +16,7 @@
package org.springframework.mock.web;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
@ -58,6 +59,14 @@ class HeaderValueHolder {
return Collections.unmodifiableList(this.values);
}
public List<String> getStringValues() {
List<String> stringList = new ArrayList<String>(this.values.size());
for (Object value : this.values) {
stringList.add(value.toString());
}
return Collections.unmodifiableList(stringList);
}
public Object getValue() {
return (!this.values.isEmpty() ? this.values.get(0) : null);
}

View File

@ -678,9 +678,9 @@ public class MockHttpServletRequest implements HttpServletRequest {
return (header != null ? header.getValue().toString() : null);
}
public Enumeration<Object> getHeaders(String name) {
public Enumeration<String> getHeaders(String name) {
HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
return Collections.enumeration(header != null ? header.getValues() : Collections.emptyList());
return Collections.enumeration(header != null ? header.getStringValues() : new LinkedList<String>());
}
public Enumeration<String> getHeaderNames() {

View File

@ -307,7 +307,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
* @param name the name of the header
* @return the associated header values, or an empty List if none
*/
public List getHeaders(String name) {
public List<Object> getHeaders(String name) {
HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
return (header != null ? header.getValues() : Collections.emptyList());
}