mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Use case-insensitive comparator in HttpHeadersAssert
Closes gh-36349
This commit is contained in:
@@ -47,7 +47,9 @@ public class HttpHeadersAssert extends AbstractObjectAssert<HttpHeadersAssert, H
|
||||
public HttpHeadersAssert(HttpHeaders actual) {
|
||||
super(actual, HttpHeadersAssert.class);
|
||||
as("HTTP headers");
|
||||
// Use case-insensitive comparator until https://github.com/assertj/assertj/issues/4157
|
||||
this.namesAssert = Assertions.assertThat(actual.headerNames())
|
||||
.usingElementComparator(String.CASE_INSENSITIVE_ORDER)
|
||||
.as("HTTP header names");
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -31,8 +31,6 @@ import org.springframework.http.HttpStatus.Series;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.http.HttpHeadersAssert;
|
||||
import org.springframework.test.http.MediaTypeAssert;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.function.SingletonSupplier;
|
||||
|
||||
/**
|
||||
@@ -65,9 +63,9 @@ public abstract class AbstractHttpServletResponseAssert<R extends HttpServletRes
|
||||
}
|
||||
|
||||
private static HttpHeaders getHttpHeaders(HttpServletResponse response) {
|
||||
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
response.getHeaderNames().forEach(name -> headers.put(name, new ArrayList<>(response.getHeaders(name))));
|
||||
return new HttpHeaders(headers);
|
||||
return headers;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user