Add static destroy() method to destroy the Singleton TestProperties instance.
This commit is contained in:
@@ -70,6 +70,15 @@ public class TestProperties implements Iterable<String> {
|
||||
return testPropertiesReference;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the managed {@literal Singleton} {@link TestProperties} instance.
|
||||
*/
|
||||
public static void destroy() {
|
||||
testPropertiesReference.clearSystemProperties();
|
||||
testPropertiesReference.clear();
|
||||
testPropertiesReference = null;
|
||||
}
|
||||
|
||||
private final Properties testProperties;
|
||||
|
||||
/**
|
||||
|
||||
@@ -69,6 +69,23 @@ public class TestPropertiesIntegrationTests {
|
||||
assertThat(properties).isSameAs(TestProperties.getInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void destroySingleTestPropertiesInstance() {
|
||||
|
||||
TestProperties testProperties = TestProperties.getInstance()
|
||||
.set("port", "12345");
|
||||
|
||||
assertThat(testProperties).isNotNull();
|
||||
assertThat(testProperties.get("port")).isEqualTo("12345");
|
||||
|
||||
TestProperties.destroy();
|
||||
|
||||
TestProperties newTestProperties = TestProperties.getInstance();
|
||||
|
||||
assertThat(newTestProperties).isNotSameAs(testProperties);
|
||||
assertThat(newTestProperties).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTestPropertiesResourceIsCorrect() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user