mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-10-06 23:19:03 +00:00
Return Builder from sslInfo() builder method for MockServerHttpRequest
Prior to this commit, the sslInfo() method in MockServerHttpRequest's BaseBuilder returned void, which prevented it from being used with the intended fluent Builder pattern. This commit changes the return type to the builder (B) for proper method chaining. Closes gh-35075
This commit is contained in:
+15
@@ -25,6 +25,7 @@ import org.junit.jupiter.api.Named;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.mockito.internal.util.MockUtil;
|
||||
|
||||
import org.springframework.http.HttpCookie;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
@@ -33,6 +34,7 @@ import org.springframework.web.util.UriComponentsBuilder;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.junit.jupiter.api.Named.named;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Tests for {@link MockServerHttpRequest}.
|
||||
@@ -66,6 +68,19 @@ class MockServerHttpRequestTests {
|
||||
assertThat(request.getURI().toString()).isEqualTo("/foo%20bar?a=b&name%20A=value%20A1&name%20A=value%20A2&name%20B=value%20B1");
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that {@code sslInfo()} can be used with the fluent builder pattern.
|
||||
*/
|
||||
@Test // gh-35075
|
||||
void sslInfo() {
|
||||
MockServerHttpRequest request = MockServerHttpRequest.get("/test")
|
||||
.sslInfo(mock())
|
||||
.build();
|
||||
|
||||
assertThat(request.getSslInfo()).as("is mock").satisfies(sslInfo -> MockUtil.isMock(sslInfo));
|
||||
assertThat(request.getURI().toString()).isEqualTo("/test");
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] {0}")
|
||||
@MethodSource
|
||||
void httpMethodNotNullOrEmpty(ThrowingCallable callable) {
|
||||
|
||||
Reference in New Issue
Block a user