|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2019 the original author or authors. |
| 2 | + * Copyright 2002-2020 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.
|
|
20 | 20 | import java.util.Collections;
|
21 | 21 | import java.util.HashMap;
|
22 | 22 | import java.util.Map;
|
| 23 | +import java.util.function.Consumer; |
23 | 24 | import java.util.function.Predicate;
|
24 | 25 |
|
25 | 26 | import org.junit.jupiter.api.BeforeEach;
|
|
36 | 37 | import org.springframework.http.HttpHeaders;
|
37 | 38 | import org.springframework.http.HttpStatus;
|
38 | 39 | import org.springframework.http.MediaType;
|
| 40 | +import org.springframework.http.codec.ClientCodecConfigurer; |
39 | 41 |
|
40 | 42 | import static org.assertj.core.api.Assertions.assertThat;
|
41 | 43 | import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
@@ -231,6 +233,23 @@ public void mutateDoesCopy() {
|
231 | 233 | builder1a.defaultCookies(cookies -> assertThat(cookies.size()).isEqualTo(2));
|
232 | 234 | }
|
233 | 235 |
|
| 236 | + @Test |
| 237 | + void cloneBuilder() { |
| 238 | + Consumer<ClientCodecConfigurer> codecsConfig = c -> {}; |
| 239 | + ExchangeFunction exchangeFunction = request -> Mono.empty(); |
| 240 | + WebClient.Builder builder = WebClient.builder().baseUrl("https://example.org") |
| 241 | + .exchangeFunction(exchangeFunction) |
| 242 | + .filter((request, next) -> Mono.empty()) |
| 243 | + .codecs(codecsConfig); |
| 244 | + |
| 245 | + WebClient.Builder clonedBuilder = builder.clone(); |
| 246 | + |
| 247 | + assertThat(clonedBuilder).extracting("baseUrl").isEqualTo("https://example.org"); |
| 248 | + assertThat(clonedBuilder).extracting("filters").isNotNull(); |
| 249 | + assertThat(clonedBuilder).extracting("strategiesConfigurers").isNotNull(); |
| 250 | + assertThat(clonedBuilder).extracting("exchangeFunction").isEqualTo(exchangeFunction); |
| 251 | + } |
| 252 | + |
234 | 253 | @Test
|
235 | 254 | public void withStringAttribute() {
|
236 | 255 | Map<String, Object> actual = new HashMap<>();
|
|
0 commit comments