diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java index 11b9b881af7..8a1af79ce16 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java @@ -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 { + + } + }