Fix test pollution

pull/8866/merge
Madhura Bhave 8 years ago
parent 189e07e9f3
commit 3d836f7730

@ -92,6 +92,7 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
assertThat(systemProperties.get("mySecret")).isEqualTo("******"); assertThat(systemProperties.get("mySecret")).isEqualTo("******");
assertThat(systemProperties.get("myCredentials")).isEqualTo("******"); assertThat(systemProperties.get("myCredentials")).isEqualTo("******");
assertThat(systemProperties.get("VCAP_SERVICES")).isEqualTo("******"); assertThat(systemProperties.get("VCAP_SERVICES")).isEqualTo("******");
clearSystemProperties("dbPassword", "apiKey", "mySecret", "myCredentials");
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -111,7 +112,8 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
assertThat(systemProperties.get("my.services.cleardb-free.credentials")) assertThat(systemProperties.get("my.services.cleardb-free.credentials"))
.isEqualTo("******"); .isEqualTo("******");
assertThat(systemProperties.get("foo.mycredentials.uri")).isEqualTo("******"); assertThat(systemProperties.get("foo.mycredentials.uri")).isEqualTo("******");
clearSystemProperties("my.services.amqp-free.credentials.uri", "credentials.http_api_uri",
"my.services.cleardb-free.credentials", "foo.mycredentials.uri");
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -126,6 +128,7 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
.get("systemProperties"); .get("systemProperties");
assertThat(systemProperties.get("dbPassword")).isEqualTo("123456"); assertThat(systemProperties.get("dbPassword")).isEqualTo("123456");
assertThat(systemProperties.get("apiKey")).isEqualTo("******"); assertThat(systemProperties.get("apiKey")).isEqualTo("******");
clearSystemProperties("dbPassword", "apiKey");
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -140,6 +143,7 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
.get("systemProperties"); .get("systemProperties");
assertThat(systemProperties.get("dbPassword")).isEqualTo("******"); assertThat(systemProperties.get("dbPassword")).isEqualTo("******");
assertThat(systemProperties.get("apiKey")).isEqualTo("123456"); assertThat(systemProperties.get("apiKey")).isEqualTo("123456");
clearSystemProperties("dbPassword", "apiKey");
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -158,6 +162,7 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
.get("systemProperties"); .get("systemProperties");
assertThat(systemProperties.get("dbPassword")).isEqualTo("123456"); assertThat(systemProperties.get("dbPassword")).isEqualTo("123456");
assertThat(systemProperties.get("apiKey")).isEqualTo("******"); assertThat(systemProperties.get("apiKey")).isEqualTo("******");
clearSystemProperties("dbPassword", "apiKey");
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -176,6 +181,7 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
.get("systemProperties"); .get("systemProperties");
assertThat(systemProperties.get("dbPassword")).isEqualTo("******"); assertThat(systemProperties.get("dbPassword")).isEqualTo("******");
assertThat(systemProperties.get("apiKey")).isEqualTo("123456"); assertThat(systemProperties.get("apiKey")).isEqualTo("123456");
clearSystemProperties("dbPassword", "apiKey");
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -195,6 +201,7 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
.get("systemProperties"); .get("systemProperties");
assertThat(systemProperties.get("dbPassword")).isEqualTo("******"); assertThat(systemProperties.get("dbPassword")).isEqualTo("******");
assertThat(systemProperties.get("apiKey")).isEqualTo("******"); assertThat(systemProperties.get("apiKey")).isEqualTo("******");
clearSystemProperties("dbPassword", "apiKey");
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -275,6 +282,12 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
assertThat(foo.get("bar")).isEqualTo("baz"); assertThat(foo.get("bar")).isEqualTo("baz");
} }
private void clearSystemProperties(String... properties) {
for (String property : properties) {
System.clearProperty(property);
}
}
@Configuration @Configuration
@EnableConfigurationProperties @EnableConfigurationProperties
public static class Config { public static class Config {

Loading…
Cancel
Save