Skip to content

Commit eb9fffe

Browse files
committed
Merge branch '4.3.x'
2 parents 2c3fb97 + 7b622b9 commit eb9fffe

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright 2013-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.cloud.openfeign;
18+
19+
import okhttp3.OkHttpClient;
20+
import org.junit.jupiter.api.AfterEach;
21+
import org.junit.jupiter.api.BeforeEach;
22+
import org.junit.jupiter.api.Test;
23+
24+
import org.springframework.boot.WebApplicationType;
25+
import org.springframework.boot.builder.SpringApplicationBuilder;
26+
import org.springframework.context.ConfigurableApplicationContext;
27+
28+
import static org.assertj.core.api.Assertions.assertThat;
29+
30+
class OkHttpMaxRequestsTests {
31+
32+
private ConfigurableApplicationContext context;
33+
34+
@BeforeEach
35+
void setUp() {
36+
this.context = new SpringApplicationBuilder()
37+
.properties("spring.cloud.openfeign.okhttp.enabled=true",
38+
"spring.cloud.openfeign.httpclient.hc5.enabled=false",
39+
"spring.cloud.openfeign.httpclient.max-connections=101",
40+
"spring.cloud.openfeign.httpclient.max-connections-per-route=51")
41+
.web(WebApplicationType.NONE)
42+
.sources(FeignAutoConfiguration.class)
43+
.run();
44+
}
45+
46+
@AfterEach
47+
void tearDown() {
48+
if (context != null) {
49+
context.close();
50+
}
51+
}
52+
53+
@Test
54+
void shouldConfigureDispatcherLimits() {
55+
OkHttpClient httpClient = context.getBean(OkHttpClient.class);
56+
57+
assertThat(httpClient.dispatcher().getMaxRequests()).isEqualTo(101);
58+
assertThat(httpClient.dispatcher().getMaxRequestsPerHost()).isEqualTo(51);
59+
}
60+
61+
}

0 commit comments

Comments
 (0)