|
33 | 33 | import io.awspring.cloud.sqs.listener.QueueNotFoundStrategy;
|
34 | 34 | import io.awspring.cloud.sqs.listener.errorhandler.AsyncErrorHandler;
|
35 | 35 | import io.awspring.cloud.sqs.listener.interceptor.AsyncMessageInterceptor;
|
36 |
| -import io.awspring.cloud.sqs.operations.BatchingSqsClientAdapter; |
37 | 36 | import io.awspring.cloud.sqs.operations.SqsTemplate;
|
38 | 37 | import io.awspring.cloud.sqs.support.converter.MessagingMessageConverter;
|
39 | 38 | import io.awspring.cloud.sqs.support.converter.SqsMessagingMessageConverter;
|
|
61 | 60 | *
|
62 | 61 | * @author Tomaz Fernandes
|
63 | 62 | * @author Wei Jiang
|
64 |
| - * @author Heechul Kang |
65 | 63 | */
|
66 | 64 | class SqsAutoConfigurationTest {
|
67 | 65 |
|
@@ -305,166 +303,6 @@ void configuresMessageConverter() {
|
305 | 303 | });
|
306 | 304 | }
|
307 | 305 |
|
308 |
| - @Test |
309 |
| - void sqsBatchAutoConfigurationIsDisabledByDefault() { |
310 |
| - this.contextRunner.run(context -> { |
311 |
| - assertThat(context).hasSingleBean(SqsAsyncClient.class); |
312 |
| - SqsAsyncClient client = context.getBean(SqsAsyncClient.class); |
313 |
| - assertThat(client).isNotInstanceOf(BatchingSqsClientAdapter.class); |
314 |
| - }); |
315 |
| - } |
316 |
| - |
317 |
| - @Test |
318 |
| - void sqsBatchAutoConfigurationIsEnabled() { |
319 |
| - this.contextRunner.withPropertyValues("spring.cloud.aws.sqs.batch.enabled:true").run(context -> { |
320 |
| - assertThat(context.getBeansOfType(SqsAsyncClient.class)).hasSize(2); |
321 |
| - |
322 |
| - SqsAsyncClient primary = context.getBean(SqsAsyncClient.class); |
323 |
| - assertThat(primary).isInstanceOf(BatchingSqsClientAdapter.class); |
324 |
| - |
325 |
| - assertThat(context).hasBean("sqsAsyncClient"); |
326 |
| - assertThat(context).hasBean("batchSqsAsyncClient"); |
327 |
| - }); |
328 |
| - } |
329 |
| - |
330 |
| - @Test |
331 |
| - void sqsBatchConfigurationProperties() { |
332 |
| - this.contextRunner.withPropertyValues("spring.cloud.aws.sqs.batch.enabled:true", |
333 |
| - "spring.cloud.aws.sqs.batch.max-number-of-messages:5", |
334 |
| - "spring.cloud.aws.sqs.batch.send-batch-frequency:PT0.5S").run(context -> { |
335 |
| - SqsAsyncClient client = context.getBean(SqsAsyncClient.class); |
336 |
| - assertThat(client).isInstanceOf(BatchingSqsClientAdapter.class); |
337 |
| - }); |
338 |
| - } |
339 |
| - |
340 |
| - @Test |
341 |
| - void sqsBatchConfigurationPropertiesWithAllSettings() { |
342 |
| - this.contextRunner.withPropertyValues("spring.cloud.aws.sqs.batch.enabled:true", |
343 |
| - "spring.cloud.aws.sqs.batch.max-number-of-messages:8", |
344 |
| - "spring.cloud.aws.sqs.batch.send-batch-frequency:PT1S", |
345 |
| - "spring.cloud.aws.sqs.batch.visibility-timeout:PT30S", |
346 |
| - "spring.cloud.aws.sqs.batch.wait-time-seconds:PT5S", |
347 |
| - "spring.cloud.aws.sqs.batch.system-attribute-names:SentTimestamp,ApproximateReceiveCount", |
348 |
| - "spring.cloud.aws.sqs.batch.attribute-names:attr1,attr2").run(context -> { |
349 |
| - assertThat(context).hasSingleBean(SqsProperties.class); |
350 |
| - SqsProperties sqsProperties = context.getBean(SqsProperties.class); |
351 |
| - SqsProperties.Batch batchConfig = sqsProperties.getBatch(); |
352 |
| - |
353 |
| - assertThat(batchConfig.isEnabled()).isTrue(); |
354 |
| - assertThat(batchConfig.getMaxNumberOfMessages()).isEqualTo(8); |
355 |
| - assertThat(batchConfig.getSendBatchFrequency()).isEqualTo(Duration.ofSeconds(1)); |
356 |
| - assertThat(batchConfig.getVisibilityTimeout()).isEqualTo(Duration.ofSeconds(30)); |
357 |
| - assertThat(batchConfig.getWaitTimeSeconds()).isEqualTo(Duration.ofSeconds(5)); |
358 |
| - assertThat(batchConfig.getSystemAttributeNames()).containsExactly( |
359 |
| - software.amazon.awssdk.services.sqs.model.MessageSystemAttributeName.SENT_TIMESTAMP, |
360 |
| - software.amazon.awssdk.services.sqs.model.MessageSystemAttributeName.APPROXIMATE_RECEIVE_COUNT); |
361 |
| - assertThat(batchConfig.getAttributeNames()).containsExactly("attr1", "attr2"); |
362 |
| - |
363 |
| - SqsAsyncClient client = context.getBean(SqsAsyncClient.class); |
364 |
| - assertThat(client).isInstanceOf(BatchingSqsClientAdapter.class); |
365 |
| - }); |
366 |
| - } |
367 |
| - |
368 |
| - @Test |
369 |
| - void sqsBatchConfigurationPropertiesWithDefaults() { |
370 |
| - this.contextRunner.withPropertyValues("spring.cloud.aws.sqs.batch.enabled:false").run(context -> { |
371 |
| - assertThat(context).hasSingleBean(SqsProperties.class); |
372 |
| - SqsProperties sqsProperties = context.getBean(SqsProperties.class); |
373 |
| - SqsProperties.Batch batchConfig = sqsProperties.getBatch(); |
374 |
| - |
375 |
| - assertThat(batchConfig.isEnabled()).isFalse(); |
376 |
| - assertThat(batchConfig.getMaxNumberOfMessages()).isNull(); |
377 |
| - assertThat(batchConfig.getSendBatchFrequency()).isNull(); |
378 |
| - assertThat(batchConfig.getVisibilityTimeout()).isNull(); |
379 |
| - assertThat(batchConfig.getWaitTimeSeconds()).isNull(); |
380 |
| - assertThat(batchConfig.getSystemAttributeNames()).isNull(); |
381 |
| - assertThat(batchConfig.getAttributeNames()).isNull(); |
382 |
| - assertThat(batchConfig.getScheduledExecutorPoolSize()).isEqualTo(5); |
383 |
| - |
384 |
| - assertThat(context).hasSingleBean(SqsAsyncClient.class); |
385 |
| - SqsAsyncClient client = context.getBean(SqsAsyncClient.class); |
386 |
| - assertThat(client).isNotInstanceOf(BatchingSqsClientAdapter.class); |
387 |
| - }); |
388 |
| - } |
389 |
| - |
390 |
| - @Test |
391 |
| - void sqsBatchConfigurationWithVisibilityTimeout() { |
392 |
| - this.contextRunner.withPropertyValues("spring.cloud.aws.sqs.batch.enabled:true", |
393 |
| - "spring.cloud.aws.sqs.batch.visibility-timeout:PT60S").run(context -> { |
394 |
| - assertThat(context).hasSingleBean(SqsProperties.class); |
395 |
| - SqsProperties sqsProperties = context.getBean(SqsProperties.class); |
396 |
| - SqsProperties.Batch batchConfig = sqsProperties.getBatch(); |
397 |
| - |
398 |
| - assertThat(batchConfig.isEnabled()).isTrue(); |
399 |
| - assertThat(batchConfig.getVisibilityTimeout()).isEqualTo(Duration.ofSeconds(60)); |
400 |
| - }); |
401 |
| - } |
402 |
| - |
403 |
| - @Test |
404 |
| - void sqsBatchConfigurationWithWaitTimeSeconds() { |
405 |
| - this.contextRunner.withPropertyValues("spring.cloud.aws.sqs.batch.enabled:true", |
406 |
| - "spring.cloud.aws.sqs.batch.wait-time-seconds:PT20S").run(context -> { |
407 |
| - assertThat(context).hasSingleBean(SqsProperties.class); |
408 |
| - SqsProperties sqsProperties = context.getBean(SqsProperties.class); |
409 |
| - SqsProperties.Batch batchConfig = sqsProperties.getBatch(); |
410 |
| - |
411 |
| - assertThat(batchConfig.isEnabled()).isTrue(); |
412 |
| - assertThat(batchConfig.getWaitTimeSeconds()).isEqualTo(Duration.ofSeconds(20)); |
413 |
| - }); |
414 |
| - } |
415 |
| - |
416 |
| - @Test |
417 |
| - void sqsBatchConfigurationWithAttributeNames() { |
418 |
| - this.contextRunner |
419 |
| - .withPropertyValues("spring.cloud.aws.sqs.batch.enabled:true", |
420 |
| - "spring.cloud.aws.sqs.batch.attribute-names:MessageGroupId,MessageDeduplicationId") |
421 |
| - .run(context -> { |
422 |
| - assertThat(context).hasSingleBean(SqsProperties.class); |
423 |
| - SqsProperties sqsProperties = context.getBean(SqsProperties.class); |
424 |
| - SqsProperties.Batch batchConfig = sqsProperties.getBatch(); |
425 |
| - |
426 |
| - assertThat(batchConfig.isEnabled()).isTrue(); |
427 |
| - assertThat(batchConfig.getAttributeNames()).containsExactly("MessageGroupId", |
428 |
| - "MessageDeduplicationId"); |
429 |
| - }); |
430 |
| - } |
431 |
| - |
432 |
| - @Test |
433 |
| - void sqsBatchConfigurationWithDefaultScheduledExecutorPoolSize() { |
434 |
| - this.contextRunner.withPropertyValues("spring.cloud.aws.sqs.batch.enabled:true").run(context -> { |
435 |
| - assertThat(context).hasSingleBean(SqsProperties.class); |
436 |
| - SqsProperties sqsProperties = context.getBean(SqsProperties.class); |
437 |
| - SqsProperties.Batch batchConfig = sqsProperties.getBatch(); |
438 |
| - |
439 |
| - assertThat(batchConfig.isEnabled()).isTrue(); |
440 |
| - assertThat(batchConfig.getScheduledExecutorPoolSize()).isEqualTo(5); |
441 |
| - |
442 |
| - assertThat(context).hasBean("sqsBatchingScheduledExecutor"); |
443 |
| - }); |
444 |
| - } |
445 |
| - |
446 |
| - @Test |
447 |
| - void sqsBatchConfigurationWithCustomScheduledExecutorPoolSize() { |
448 |
| - this.contextRunner.withPropertyValues("spring.cloud.aws.sqs.batch.enabled:true", |
449 |
| - "spring.cloud.aws.sqs.batch.scheduled-executor-pool-size:10").run(context -> { |
450 |
| - assertThat(context).hasSingleBean(SqsProperties.class); |
451 |
| - SqsProperties sqsProperties = context.getBean(SqsProperties.class); |
452 |
| - SqsProperties.Batch batchConfig = sqsProperties.getBatch(); |
453 |
| - |
454 |
| - assertThat(batchConfig.isEnabled()).isTrue(); |
455 |
| - assertThat(batchConfig.getScheduledExecutorPoolSize()).isEqualTo(10); |
456 |
| - |
457 |
| - assertThat(context).hasBean("sqsBatchingScheduledExecutor"); |
458 |
| - }); |
459 |
| - } |
460 |
| - |
461 |
| - @Test |
462 |
| - void sqsBatchConfigurationWithBatchDisabledDoesNotCreateScheduledExecutor() { |
463 |
| - this.contextRunner.withPropertyValues("spring.cloud.aws.sqs.batch.enabled:false").run(context -> { |
464 |
| - assertThat(context).doesNotHaveBean("sqsBatchingScheduledExecutor"); |
465 |
| - }); |
466 |
| - } |
467 |
| - |
468 | 306 | @Configuration(proxyBeanMethods = false)
|
469 | 307 | static class CustomComponentsConfiguration {
|
470 | 308 |
|
|
0 commit comments