Skip to content

Commit

Permalink
Merge branch '3.2.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
mhalbritter committed May 2, 2024
2 parents c44e477 + 2183b47 commit 6697db2
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -38,7 +38,6 @@
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;
Expand Down Expand Up @@ -86,16 +85,15 @@ void simple() {

@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();
Expand Down Expand Up @@ -387,4 +385,8 @@ interface TestRestTemplateCallback {

}

static class TestClientHttpRequestFactory extends SimpleClientHttpRequestFactory {

}

}

0 comments on commit 6697db2

Please sign in to comment.