Lazily start resources on demand (if necessary outside of lifecycle)

See gh-32945
This commit is contained in:
Juergen Hoeller
2024-06-06 08:54:32 +02:00
parent c3a0eaa95e
commit c0bef2c693
2 changed files with 49 additions and 7 deletions

View File

@@ -261,4 +261,22 @@ class ReactorResourceFactoryTests {
assertThat(resourceFactory.isRunning()).isFalse();
}
@Test
void lazilyStartOnConnectionProviderAccess() {
assertThat(this.resourceFactory.isRunning()).isFalse();
this.resourceFactory.getConnectionProvider();
assertThat(this.resourceFactory.isRunning()).isTrue();
this.resourceFactory.stop();
assertThat(this.resourceFactory.isRunning()).isFalse();
}
@Test
void lazilyStartOnLoopResourcesAccess() {
assertThat(this.resourceFactory.isRunning()).isFalse();
this.resourceFactory.getLoopResources();
assertThat(this.resourceFactory.isRunning()).isTrue();
this.resourceFactory.stop();
assertThat(this.resourceFactory.isRunning()).isFalse();
}
}