Skip to content

Commit 1ee05cc

Browse files
committed
Update contribution
Closes gh-35698
1 parent 8e046b8 commit 1ee05cc

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

spring-test/src/main/java/org/springframework/test/web/servlet/client/DefaultRestTestClientBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public RestTestClient build() {
166166
}
167167

168168
return new DefaultRestTestClient(
169-
this.restClientBuilder, this.entityResultConsumer, this);
169+
this.restClientBuilder, this.entityResultConsumer, new DefaultRestTestClientBuilder<>(this));
170170
}
171171

172172

spring-test/src/test/java/org/springframework/test/web/servlet/client/DefaultRestTestClientBuilderTests.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,24 @@
2020

2121
import static org.assertj.core.api.Assertions.assertThat;
2222

23+
/**
24+
* Unit tests for {@link RestTestClient.Builder}.
25+
*/
2326
class DefaultRestTestClientBuilderTests {
2427

2528
@Test
26-
void testMutateHasNoSideEffects() {
27-
RestTestClient baseTestClient = new DefaultRestTestClientBuilder().baseUrl("http://localhost").build();
28-
baseTestClient.mutate().defaultHeader("foo", "bar").build();
29-
baseTestClient.mutate().defaultHeaders(headers -> assertThat(headers.containsHeader("foo")).isFalse());
29+
void mutateOriginalBuilderHasNoSideEffects() {
30+
RestTestClient.Builder<?> builder = new DefaultRestTestClientBuilder<>().baseUrl("http://localhost");
31+
RestTestClient client = builder.build();
32+
builder.defaultHeader("foo", "bar");
33+
client.mutate().defaultHeaders(headers -> assertThat(headers.containsHeader("foo")).isFalse());
34+
}
35+
36+
@Test
37+
void mutateSameClientTwiceHasNoSideEffects() {
38+
RestTestClient client = new DefaultRestTestClientBuilder<>().baseUrl("http://localhost").build();
39+
client.mutate().defaultHeader("foo", "bar").build();
40+
client.mutate().defaultHeaders(headers -> assertThat(headers.containsHeader("foo")).isFalse());
3041
}
3142

3243
}

0 commit comments

Comments
 (0)