Skip to content

Commit

Permalink
test: close context (#518)
Browse files Browse the repository at this point in the history
* test: close context

* Update discovery-client/src/test/groovy/io/micronaut/discovery/consul/MockConfigurationDiscoverySpec.groovy

Co-authored-by: Tim Yates <[email protected]>

---------

Co-authored-by: Tim Yates <[email protected]>
  • Loading branch information
sdelamo and timyates authored Oct 6, 2023
1 parent f14ec25 commit 8c495cd
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ class EagerInitSpec extends Specification {

void 'test run with eager init'() {
given:
def context = ApplicationContext.builder().eagerInitSingletons(true).eagerInitConfiguration(true)
ApplicationContext context = ApplicationContext.builder().eagerInitSingletons(true).eagerInitConfiguration(true)
.start()

expect: "context starts up successfully"
context != null

cleanup:
context.close()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ not:
env.getRequiredProperty('datasource.driver', String) == 'java.SomeDriver'
!env.getProperty('not.there', Boolean).isPresent()
!env.getProperty('also.not.there', Boolean).isPresent()

cleanup:
applicationContext.close()
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ class MockConfigurationDiscoverySpec extends Specification {

then:"The value is retrieved again"
environment.getProperty('must.override1', String).get() == 'changed'

cleanup:
applicationContext.close()
}

void "test multiple environment precedence"() {
Expand Down Expand Up @@ -161,6 +164,8 @@ class MockConfigurationDiscoverySpec extends Specification {
expect:
!result.isPresent()

cleanup:
applicationContext.close()
}

private void writeValue(String env, String name, String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class EurekaClientConfigSpec extends Specification {
expect:
serviceInstances == result

cleanup:
applicationContext.close()

where:
value | result
'localhost:8087' | [newServiceInstance("http://$value")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@ class EurekaHealthIndicatorSpec extends Specification {

cleanup:
eurekaServer?.stop()
applicationContext.close()
}
}

0 comments on commit 8c495cd

Please sign in to comment.