mirror of
https://github.com/pcvolkmer/etl-processor.git
synced 2025-04-20 17:56:50 +00:00
test: add test for max retry attempts
This commit is contained in:
parent
61e5273158
commit
408b121f26
@ -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.MockBean
|
||||||
import org.springframework.boot.test.mock.mockito.MockBeans
|
import org.springframework.boot.test.mock.mockito.MockBeans
|
||||||
import org.springframework.context.ApplicationContext
|
import org.springframework.context.ApplicationContext
|
||||||
|
import org.springframework.retry.support.RetryTemplate
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder
|
import org.springframework.security.crypto.password.PasswordEncoder
|
||||||
import org.springframework.security.provisioning.InMemoryUserDetailsManager
|
import org.springframework.security.provisioning.InMemoryUserDetailsManager
|
||||||
import org.springframework.test.context.ContextConfiguration
|
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<RuntimeException> {
|
||||||
|
retryTemplate.execute<Void, RuntimeException> {
|
||||||
|
assertThat(it.retryCount).isLessThan(maxRetryAttempts)
|
||||||
|
throw RuntimeException()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user