@ -103,32 +103,32 @@ class DockerComposeLifecycleManagerTests {
}
@Test
void start up WhenEnabledFalseDoesNotStart( ) {
void start WhenEnabledFalseDoesNotStart( ) {
this . properties . setEnabled ( false ) ;
EventCapturingListener listener = new EventCapturingListener ( ) ;
this . eventListeners . add ( listener ) ;
set u pRunningServices( ) ;
this . lifecycleManager . start up ( ) ;
set U pRunningServices( ) ;
this . lifecycleManager . start ( ) ;
assertThat ( listener . getEvent ( ) ) . isNull ( ) ;
then ( this . dockerCompose ) . should ( never ( ) ) . hasDefinedServices ( ) ;
}
@Test
void start up WhenInTestDoesNotStart( ) {
void start WhenInTestDoesNotStart( ) {
given ( this . skipCheck . shouldSkip ( any ( ) , any ( ) ) ) . willReturn ( true ) ;
EventCapturingListener listener = new EventCapturingListener ( ) ;
this . eventListeners . add ( listener ) ;
set u pRunningServices( ) ;
this . lifecycleManager . start up ( ) ;
set U pRunningServices( ) ;
this . lifecycleManager . start ( ) ;
assertThat ( listener . getEvent ( ) ) . isNull ( ) ;
then ( this . dockerCompose ) . should ( never ( ) ) . hasDefinedServices ( ) ;
}
@Test
void start up WhenHasNoDefinedServicesDoesNothing( ) {
void start WhenHasNoDefinedServicesDoesNothing( ) {
EventCapturingListener listener = new EventCapturingListener ( ) ;
this . eventListeners . add ( listener ) ;
this . lifecycleManager . start up ( ) ;
this . lifecycleManager . start ( ) ;
assertThat ( listener . getEvent ( ) ) . isNull ( ) ;
then ( this . dockerCompose ) . should ( ) . hasDefinedServices ( ) ;
then ( this . dockerCompose ) . should ( never ( ) ) . up ( any ( ) ) ;
@ -138,27 +138,27 @@ class DockerComposeLifecycleManagerTests {
}
@Test
void start up WhenLifecycleStartAndStopAndHasNoRunningServicesDoesStartupAndShutdown ( ) {
void start WhenLifecycleStartAndStopAndHasNoRunningServicesDoesUpAndStop ( ) {
this . properties . setLifecycleManagement ( LifecycleManagement . START_AND_STOP ) ;
EventCapturingListener listener = new EventCapturingListener ( ) ;
this . eventListeners . add ( listener ) ;
given ( this . dockerCompose . hasDefinedServices ( ) ) . willReturn ( true ) ;
this . lifecycleManager . start up ( ) ;
this . lifecycleManager . start ( ) ;
this . shutdownHandlers . run ( ) ;
assertThat ( listener . getEvent ( ) ) . isNotNull ( ) ;
then ( this . dockerCompose ) . should ( ) . up ( any ( ) ) ;
then ( this . dockerCompose ) . should ( never ( ) ) . start ( any ( ) ) ;
then ( this . dockerCompose ) . should ( ) . down ( any ( ) ) ;
then ( this . dockerCompose ) . should ( never ( ) ) . stop ( any ( ) ) ;
then ( this . dockerCompose ) . should ( ) . stop ( any ( ) ) ;
then ( this . dockerCompose ) . should ( never ( ) ) . down ( any ( ) ) ;
}
@Test
void start up WhenLifecycleStartAndStopAndHasRunningServicesDoesNoStartupOrShutdown ( ) {
void start WhenLifecycleStartAndStopAndHasRunningServicesDoesNothing ( ) {
this . properties . setLifecycleManagement ( LifecycleManagement . START_AND_STOP ) ;
EventCapturingListener listener = new EventCapturingListener ( ) ;
this . eventListeners . add ( listener ) ;
set u pRunningServices( ) ;
this . lifecycleManager . start up ( ) ;
set U pRunningServices( ) ;
this . lifecycleManager . start ( ) ;
this . shutdownHandlers . run ( ) ;
assertThat ( listener . getEvent ( ) ) . isNotNull ( ) ;
then ( this . dockerCompose ) . should ( never ( ) ) . up ( any ( ) ) ;
@ -168,12 +168,12 @@ class DockerComposeLifecycleManagerTests {
}
@Test
void start upWhenLifecycleNoneDoesNoStartupOrShutdown ( ) {
void start WhenLifecycleNoneDoesNothing ( ) {
this . properties . setLifecycleManagement ( LifecycleManagement . NONE ) ;
EventCapturingListener listener = new EventCapturingListener ( ) ;
this . eventListeners . add ( listener ) ;
set u pRunningServices( ) ;
this . lifecycleManager . start up ( ) ;
set U pRunningServices( ) ;
this . lifecycleManager . start ( ) ;
this . shutdownHandlers . run ( ) ;
assertThat ( listener . getEvent ( ) ) . isNotNull ( ) ;
then ( this . dockerCompose ) . should ( never ( ) ) . up ( any ( ) ) ;
@ -183,12 +183,12 @@ class DockerComposeLifecycleManagerTests {
}
@Test
void start up WhenLifecycleStartOnlyDoesStartupAndNoShutdown ( ) {
void start WhenLifecycleStartOnlyDoesOnly Start( ) {
this . properties . setLifecycleManagement ( LifecycleManagement . START_ONLY ) ;
EventCapturingListener listener = new EventCapturingListener ( ) ;
this . eventListeners . add ( listener ) ;
given ( this . dockerCompose . hasDefinedServices ( ) ) . willReturn ( true ) ;
this . lifecycleManager . start up ( ) ;
this . lifecycleManager . start ( ) ;
this . shutdownHandlers . run ( ) ;
assertThat ( listener . getEvent ( ) ) . isNotNull ( ) ;
then ( this . dockerCompose ) . should ( ) . up ( any ( ) ) ;
@ -199,97 +199,97 @@ class DockerComposeLifecycleManagerTests {
}
@Test
void start upWhenStartupCommandStartDoesStartupUsingStartAndShutdown ( ) {
void start WhenStartCommandStartDoesStartAndStop ( ) {
this . properties . setLifecycleManagement ( LifecycleManagement . START_AND_STOP ) ;
this . properties . getStart up ( ) . setCommand ( Start up Command. START ) ;
this . properties . getStart ( ) . setCommand ( Start Command. START ) ;
EventCapturingListener listener = new EventCapturingListener ( ) ;
this . eventListeners . add ( listener ) ;
given ( this . dockerCompose . hasDefinedServices ( ) ) . willReturn ( true ) ;
this . lifecycleManager . start up ( ) ;
this . lifecycleManager . start ( ) ;
this . shutdownHandlers . run ( ) ;
assertThat ( listener . getEvent ( ) ) . isNotNull ( ) ;
then ( this . dockerCompose ) . should ( never ( ) ) . up ( any ( ) ) ;
then ( this . dockerCompose ) . should ( ) . start ( any ( ) ) ;
then ( this . dockerCompose ) . should ( ) . down ( any ( ) ) ;
then ( this . dockerCompose ) . should ( never ( ) ) . stop ( any ( ) ) ;
then ( this . dockerCompose ) . should ( ) . stop ( any ( ) ) ;
then ( this . dockerCompose ) . should ( never ( ) ) . down ( any ( ) ) ;
}
@Test
void start upWhenShutdownCommandStopDoesStartupAndShutdownUsingStop ( ) {
void start WhenStopCommandDownDoesStartAndDown ( ) {
this . properties . setLifecycleManagement ( LifecycleManagement . START_AND_STOP ) ;
this . properties . getS hutdown( ) . setCommand ( ShutdownCommand . STOP ) ;
this . properties . getS top( ) . setCommand ( StopCommand . DOWN ) ;
EventCapturingListener listener = new EventCapturingListener ( ) ;
this . eventListeners . add ( listener ) ;
given ( this . dockerCompose . hasDefinedServices ( ) ) . willReturn ( true ) ;
this . lifecycleManager . start up ( ) ;
this . lifecycleManager . start ( ) ;
this . shutdownHandlers . run ( ) ;
assertThat ( listener . getEvent ( ) ) . isNotNull ( ) ;
then ( this . dockerCompose ) . should ( ) . up ( any ( ) ) ;
then ( this . dockerCompose ) . should ( never ( ) ) . start ( any ( ) ) ;
then ( this . dockerCompose ) . should ( never ( ) ) . down ( any ( ) ) ;
then ( this . dockerCompose ) . should ( ) . stop ( any ( ) ) ;
then ( this . dockerCompose ) . should ( never ( ) ) . stop ( any ( ) ) ;
then ( this . dockerCompose ) . should ( ) . down ( any ( ) ) ;
}
@Test
void start upWhenHasShutdown TimeoutUsesDuration( ) {
void start WhenHasStop TimeoutUsesDuration( ) {
this . properties . setLifecycleManagement ( LifecycleManagement . START_AND_STOP ) ;
Duration timeout = Duration . ofDays ( 1 ) ;
this . properties . getS hutdown ( ) . setTimeout ( timeout ) ;
this . properties . getS top ( ) . setTimeout ( timeout ) ;
EventCapturingListener listener = new EventCapturingListener ( ) ;
this . eventListeners . add ( listener ) ;
given ( this . dockerCompose . hasDefinedServices ( ) ) . willReturn ( true ) ;
this . lifecycleManager . start up ( ) ;
this . lifecycleManager . start ( ) ;
this . shutdownHandlers . run ( ) ;
assertThat ( listener . getEvent ( ) ) . isNotNull ( ) ;
then ( this . dockerCompose ) . should ( ) . down ( timeout ) ;
then ( this . dockerCompose ) . should ( ) . stop ( timeout ) ;
}
@Test
void start up WhenHasIgnoreLabelIgnoresService( ) {
void start WhenHasIgnoreLabelIgnoresService( ) {
EventCapturingListener listener = new EventCapturingListener ( ) ;
this . eventListeners . add ( listener ) ;
set u pRunningServices( Map . of ( "org.springframework.boot.ignore" , "true" ) ) ;
this . lifecycleManager . start up ( ) ;
set U pRunningServices( Map . of ( "org.springframework.boot.ignore" , "true" ) ) ;
this . lifecycleManager . start ( ) ;
this . shutdownHandlers . run ( ) ;
assertThat ( listener . getEvent ( ) ) . isNotNull ( ) ;
assertThat ( listener . getEvent ( ) . getRunningServices ( ) ) . isEmpty ( ) ;
}
@Test
void start up WaitsUntilReady( ) {
void start WaitsUntilReady( ) {
EventCapturingListener listener = new EventCapturingListener ( ) ;
this . eventListeners . add ( listener ) ;
set u pRunningServices( ) ;
this . lifecycleManager . start up ( ) ;
set U pRunningServices( ) ;
this . lifecycleManager . start ( ) ;
this . shutdownHandlers . run ( ) ;
then ( this . serviceReadinessChecks ) . should ( ) . waitUntilReady ( this . runningServices ) ;
}
@Test
void start up GetsDockerComposeWithActiveProfiles( ) {
void start GetsDockerComposeWithActiveProfiles( ) {
this . properties . getProfiles ( ) . setActive ( Set . of ( "my-profile" ) ) ;
set u pRunningServices( ) ;
this . lifecycleManager . start up ( ) ;
set U pRunningServices( ) ;
this . lifecycleManager . start ( ) ;
assertThat ( this . activeProfiles ) . containsExactly ( "my-profile" ) ;
}
@Test
void start up PublishesEvent( ) {
void start PublishesEvent( ) {
EventCapturingListener listener = new EventCapturingListener ( ) ;
this . eventListeners . add ( listener ) ;
set u pRunningServices( ) ;
this . lifecycleManager . start up ( ) ;
set U pRunningServices( ) ;
this . lifecycleManager . start ( ) ;
DockerComposeServicesReadyEvent event = listener . getEvent ( ) ;
assertThat ( event ) . isNotNull ( ) ;
assertThat ( event . getSource ( ) ) . isEqualTo ( this . applicationContext ) ;
assertThat ( event . getRunningServices ( ) ) . isEqualTo ( this . runningServices ) ;
}
private void set u pRunningServices( ) {
set u pRunningServices( Collections . emptyMap ( ) ) ;
private void set U pRunningServices( ) {
set U pRunningServices( Collections . emptyMap ( ) ) ;
}
private void set u pRunningServices( Map < String , String > labels ) {
private void set U pRunningServices( Map < String , String > labels ) {
given ( this . dockerCompose . hasDefinedServices ( ) ) . willReturn ( true ) ;
given ( this . dockerCompose . hasRunningServices ( ) ) . willReturn ( true ) ;
RunningService runningService = mock ( RunningService . class ) ;