From 408b121f269b49da1b2dbfa4c3d7190b6df6b010 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Thu, 29 Feb 2024 08:47:17 +0100 Subject: [PATCH] test: add test for max retry attempts --- .../processor/config/AppConfigurationTest.kt | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/integrationTest/kotlin/dev/dnpm/etl/processor/config/AppConfigurationTest.kt b/src/integrationTest/kotlin/dev/dnpm/etl/processor/config/AppConfigurationTest.kt index d37c251..46a756b 100644 --- a/src/integrationTest/kotlin/dev/dnpm/etl/processor/config/AppConfigurationTest.kt +++ b/src/integrationTest/kotlin/dev/dnpm/etl/processor/config/AppConfigurationTest.kt @@ -38,6 +38,7 @@ import org.springframework.boot.test.context.SpringBootTest import org.springframework.boot.test.mock.mockito.MockBean import org.springframework.boot.test.mock.mockito.MockBeans import org.springframework.context.ApplicationContext +import org.springframework.retry.support.RetryTemplate import org.springframework.security.crypto.password.PasswordEncoder import org.springframework.security.provisioning.InMemoryUserDetailsManager import org.springframework.test.context.ContextConfiguration @@ -276,4 +277,30 @@ class AppConfigurationTest { } + @Nested + @TestPropertySource( + properties = [ + "app.rest.uri=http://localhost:9000", + "app.max-retry-attempts=5" + ] + ) + inner class AppConfigurationRetryTest(private val context: ApplicationContext) { + + private val maxRetryAttempts = 5 + + @Test + fun shouldUseRetryTemplateWithConfiguredMaxAttempts() { + val retryTemplate = context.getBean(RetryTemplate::class.java) + assertThat(retryTemplate).isNotNull + + assertThrows { + retryTemplate.execute { + assertThat(it.retryCount).isLessThan(maxRetryAttempts) + throw RuntimeException() + } + } + } + + } + } \ No newline at end of file