Add static destroy() method to destroy the Singleton TestProperties instance.

This commit is contained in:
John Blum
2022-01-31 12:09:37 -08:00
parent a62f12d909
commit 58115c2168
2 changed files with 26 additions and 0 deletions

View File

@@ -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;
/**

View File

@@ -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() {