|
41 | 41 | * @author Phillip Webb
|
42 | 42 | * @author Jon Schneider
|
43 | 43 | * @author Artsiom Yudovin
|
| 44 | + * @author Leo Li |
44 | 45 | */
|
45 | 46 | class PropertiesMeterFilterTests {
|
46 | 47 |
|
@@ -275,6 +276,71 @@ void configureWhenHasHigherMaximumExpectedValueAndLowerShouldSetMaximumExpectedV
|
275 | 276 | .getMaximumExpectedValueAsDouble()).isEqualTo(Duration.ofMillis(10000).toNanos());
|
276 | 277 | }
|
277 | 278 |
|
| 279 | + @Test |
| 280 | + void configureWhenHasExpiryShouldSetExpiryToValue() { |
| 281 | + PropertiesMeterFilter filter = new PropertiesMeterFilter( |
| 282 | + createProperties("distribution.expiry[spring.boot]=5ms")); |
| 283 | + assertThat(filter.configure(createMeterId("spring.boot"), DistributionStatisticConfig.DEFAULT).getExpiry()) |
| 284 | + .isEqualTo(Duration.ofMillis(5)); |
| 285 | + } |
| 286 | + |
| 287 | + @Test |
| 288 | + void configureWhenHasHigherExpiryShouldSetExpiryToValue() { |
| 289 | + PropertiesMeterFilter filter = new PropertiesMeterFilter(createProperties("distribution.expiry.spring=5ms")); |
| 290 | + assertThat(filter.configure(createMeterId("spring.boot"), DistributionStatisticConfig.DEFAULT).getExpiry()) |
| 291 | + .isEqualTo(Duration.ofMillis(5)); |
| 292 | + } |
| 293 | + |
| 294 | + @Test |
| 295 | + void configureWhenHasHigherExpiryAndLowerShouldSetExpiryToHigher() { |
| 296 | + PropertiesMeterFilter filter = new PropertiesMeterFilter( |
| 297 | + createProperties("distribution.expiry.spring=5ms", "distribution.expiry[spring.boot]=10ms")); |
| 298 | + assertThat(filter.configure(createMeterId("spring.boot"), DistributionStatisticConfig.DEFAULT).getExpiry()) |
| 299 | + .isEqualTo(Duration.ofMillis(10)); |
| 300 | + } |
| 301 | + |
| 302 | + @Test |
| 303 | + void configureWhenAllExpirySetShouldSetExpiryToValue() { |
| 304 | + PropertiesMeterFilter filter = new PropertiesMeterFilter(createProperties("distribution.expiry.all=5ms")); |
| 305 | + assertThat(filter.configure(createMeterId("spring.boot"), DistributionStatisticConfig.DEFAULT).getExpiry()) |
| 306 | + .isEqualTo(Duration.ofMillis(5)); |
| 307 | + } |
| 308 | + |
| 309 | + @Test |
| 310 | + void configureWhenHasBufferLengthShouldSetBufferLengthToValue() { |
| 311 | + PropertiesMeterFilter filter = new PropertiesMeterFilter( |
| 312 | + createProperties("distribution.buffer-length.spring.boot=3")); |
| 313 | + assertThat( |
| 314 | + filter.configure(createMeterId("spring.boot"), DistributionStatisticConfig.DEFAULT).getBufferLength()) |
| 315 | + .isEqualTo(3); |
| 316 | + } |
| 317 | + |
| 318 | + @Test |
| 319 | + void configureWhenHasHigherBufferLengthShouldSetBufferLengthToValue() { |
| 320 | + PropertiesMeterFilter filter = new PropertiesMeterFilter( |
| 321 | + createProperties("distribution.buffer-length.spring=3")); |
| 322 | + assertThat( |
| 323 | + filter.configure(createMeterId("spring.boot"), DistributionStatisticConfig.DEFAULT).getBufferLength()) |
| 324 | + .isEqualTo(3); |
| 325 | + } |
| 326 | + |
| 327 | + @Test |
| 328 | + void configureWhenHasHigherBufferLengthAndLowerShouldSetBufferLengthToHigher() { |
| 329 | + PropertiesMeterFilter filter = new PropertiesMeterFilter( |
| 330 | + createProperties("distribution.buffer-length.spring=2", "distribution.buffer-length.spring.boot=3")); |
| 331 | + assertThat( |
| 332 | + filter.configure(createMeterId("spring.boot"), DistributionStatisticConfig.DEFAULT).getBufferLength()) |
| 333 | + .isEqualTo(3); |
| 334 | + } |
| 335 | + |
| 336 | + @Test |
| 337 | + void configureWhenAllBufferLengthSetShouldSetBufferLengthToValue() { |
| 338 | + PropertiesMeterFilter filter = new PropertiesMeterFilter(createProperties("distribution.buffer-length.all=3")); |
| 339 | + assertThat( |
| 340 | + filter.configure(createMeterId("spring.boot"), DistributionStatisticConfig.DEFAULT).getBufferLength()) |
| 341 | + .isEqualTo(3); |
| 342 | + } |
| 343 | + |
278 | 344 | private Id createMeterId(String name) {
|
279 | 345 | Meter.Type meterType = Type.TIMER;
|
280 | 346 | return createMeterId(name, meterType);
|
|
0 commit comments