mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-05 00:56:58 +08:00
Merge branch '3.1.x' into 3.2.x
Closes gh-40612
This commit is contained in:
commit
2183b47e62
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -38,7 +38,6 @@ import org.springframework.http.RequestEntity;
|
|||
import org.springframework.http.client.ClientHttpRequest;
|
||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
||||
import org.springframework.http.client.JettyClientHttpRequestFactory;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.mock.env.MockEnvironment;
|
||||
import org.springframework.mock.http.client.MockClientHttpRequest;
|
||||
|
@ -86,16 +85,15 @@ class TestRestTemplateTests {
|
|||
|
||||
@Test
|
||||
void doNotReplaceCustomRequestFactory() {
|
||||
RestTemplateBuilder builder = new RestTemplateBuilder()
|
||||
.requestFactory(HttpComponentsClientHttpRequestFactory.class);
|
||||
RestTemplateBuilder builder = new RestTemplateBuilder().requestFactory(TestClientHttpRequestFactory.class);
|
||||
TestRestTemplate testRestTemplate = new TestRestTemplate(builder);
|
||||
assertThat(testRestTemplate.getRestTemplate().getRequestFactory())
|
||||
.isInstanceOf(HttpComponentsClientHttpRequestFactory.class);
|
||||
.isInstanceOf(TestClientHttpRequestFactory.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void useTheSameRequestFactoryClassWithBasicAuth() {
|
||||
JettyClientHttpRequestFactory customFactory = new JettyClientHttpRequestFactory();
|
||||
TestClientHttpRequestFactory customFactory = new TestClientHttpRequestFactory();
|
||||
RestTemplateBuilder builder = new RestTemplateBuilder().requestFactory(() -> customFactory);
|
||||
TestRestTemplate testRestTemplate = new TestRestTemplate(builder).withBasicAuth("test", "test");
|
||||
RestTemplate restTemplate = testRestTemplate.getRestTemplate();
|
||||
|
@ -387,4 +385,8 @@ class TestRestTemplateTests {
|
|||
|
||||
}
|
||||
|
||||
static class TestClientHttpRequestFactory extends SimpleClientHttpRequestFactory {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user