@@ -78,29 +78,39 @@ public void configureWhenBuilderCustomizerShouldApply() {
78
78
}
79
79
80
80
@ Test
81
- public void defaultTimeoutsShouldBeConfigured () {
81
+ public void configureWithNoTimeoutsApplyDefaults () {
82
82
this .contextRunner .run ((context ) -> {
83
83
assertThat (context ).hasSingleBean (RestClient .class );
84
84
RestClient restClient = context .getBean (RestClient .class );
85
85
assertTimeouts (restClient ,
86
- Duration .ofMillis (RestClientBuilder .DEFAULT_CONNECT_TIMEOUT_MILLIS ), Duration . ofMillis ( RestClientBuilder . DEFAULT_SOCKET_TIMEOUT_MILLIS )
87
- );
86
+ Duration .ofMillis (RestClientBuilder .DEFAULT_CONNECT_TIMEOUT_MILLIS ),
87
+ Duration . ofMillis ( RestClientBuilder . DEFAULT_SOCKET_TIMEOUT_MILLIS ) );
88
88
});
89
89
}
90
90
91
91
@ Test
92
- public void timeoutsCanBeConfigured () {
92
+ public void configureWithCustomTimeouts () {
93
93
this .contextRunner
94
94
.withPropertyValues ("spring.elasticsearch.rest.connection-timeout=15s" ,
95
95
"spring.elasticsearch.rest.read-timeout=1m" )
96
96
.run ((context ) -> {
97
97
assertThat (context ).hasSingleBean (RestClient .class );
98
98
RestClient restClient = context .getBean (RestClient .class );
99
- assertTimeouts (restClient , Duration .ofSeconds (15 ), Duration . ofMinutes ( 1 )
100
- );
99
+ assertTimeouts (restClient , Duration .ofSeconds (15 ),
100
+ Duration . ofMinutes ( 1 ) );
101
101
});
102
102
}
103
103
104
+ private static void assertTimeouts (RestClient restClient , Duration connectTimeout ,
105
+ Duration readTimeout ) {
106
+ Object client = ReflectionTestUtils .getField (restClient , "client" );
107
+ Object config = ReflectionTestUtils .getField (client , "defaultConfig" );
108
+ assertThat (config ).hasFieldOrPropertyWithValue ("socketTimeout" ,
109
+ Math .toIntExact (readTimeout .toMillis ()));
110
+ assertThat (config ).hasFieldOrPropertyWithValue ("connectTimeout" ,
111
+ Math .toIntExact (connectTimeout .toMillis ()));
112
+ }
113
+
104
114
@ Test
105
115
public void restClientCanQueryElasticsearchNode () {
106
116
this .contextRunner
@@ -121,15 +131,6 @@ public void restClientCanQueryElasticsearchNode() {
121
131
});
122
132
}
123
133
124
- private static void assertTimeouts (RestClient restClient , Duration connectTimeout , Duration readTimeout ) {
125
- Object client = ReflectionTestUtils .getField (restClient , "client" );
126
- Object config = ReflectionTestUtils .getField (client , "defaultConfig" );
127
- assertThat (config ).hasFieldOrPropertyWithValue ("socketTimeout" ,
128
- Math .toIntExact (readTimeout .toMillis ()));
129
- assertThat (config ).hasFieldOrPropertyWithValue ("connectTimeout" ,
130
- Math .toIntExact (connectTimeout .toMillis ()));
131
- }
132
-
133
134
@ Configuration (proxyBeanMethods = false )
134
135
static class CustomRestClientConfiguration {
135
136
0 commit comments