Polish
This commit is contained in:
parent
eacb6b13f3
commit
579c6feb93
|
|
@ -54,7 +54,7 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
|
||||||
public void runWithSystemPropertiesShouldSetAndRemoveProperties() {
|
public void runWithSystemPropertiesShouldSetAndRemoveProperties() {
|
||||||
String key = "test." + UUID.randomUUID().toString();
|
String key = "test." + UUID.randomUUID().toString();
|
||||||
assertThat(System.getProperties().containsKey(key)).isFalse();
|
assertThat(System.getProperties().containsKey(key)).isFalse();
|
||||||
get().withSystemProperties(key + "=value").run((loaded) -> {
|
get().withSystemProperties(key + "=value").run((context) -> {
|
||||||
assertThat(System.getProperties()).containsEntry(key, "value");
|
assertThat(System.getProperties()).containsEntry(key, "value");
|
||||||
});
|
});
|
||||||
assertThat(System.getProperties().containsKey(key)).isFalse();
|
assertThat(System.getProperties().containsKey(key)).isFalse();
|
||||||
|
|
@ -66,8 +66,8 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
|
||||||
String key = "test." + UUID.randomUUID().toString();
|
String key = "test." + UUID.randomUUID().toString();
|
||||||
assertThat(System.getProperties().containsKey(key)).isFalse();
|
assertThat(System.getProperties().containsKey(key)).isFalse();
|
||||||
get().withSystemProperties(key + "=value")
|
get().withSystemProperties(key + "=value")
|
||||||
.withUserConfiguration(FailingConfig.class).run((loaded) -> {
|
.withUserConfiguration(FailingConfig.class).run((context) -> {
|
||||||
assertThat(loaded).hasFailed();
|
assertThat(context).hasFailed();
|
||||||
});
|
});
|
||||||
assertThat(System.getProperties().containsKey(key)).isFalse();
|
assertThat(System.getProperties().containsKey(key)).isFalse();
|
||||||
}
|
}
|
||||||
|
|
@ -79,7 +79,7 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
|
||||||
System.setProperty(key, "value");
|
System.setProperty(key, "value");
|
||||||
try {
|
try {
|
||||||
assertThat(System.getProperties().getProperty(key)).isEqualTo("value");
|
assertThat(System.getProperties().getProperty(key)).isEqualTo("value");
|
||||||
get().withSystemProperties(key + "=newValue").run((loaded) -> {
|
get().withSystemProperties(key + "=newValue").run((context) -> {
|
||||||
assertThat(System.getProperties()).containsEntry(key, "newValue");
|
assertThat(System.getProperties()).containsEntry(key, "newValue");
|
||||||
});
|
});
|
||||||
assertThat(System.getProperties().getProperty(key)).isEqualTo("value");
|
assertThat(System.getProperties().getProperty(key)).isEqualTo("value");
|
||||||
|
|
@ -96,7 +96,7 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
|
||||||
System.setProperty(key, "value");
|
System.setProperty(key, "value");
|
||||||
try {
|
try {
|
||||||
assertThat(System.getProperties().getProperty(key)).isEqualTo("value");
|
assertThat(System.getProperties().getProperty(key)).isEqualTo("value");
|
||||||
get().withSystemProperties(key + "=").run((loaded) -> {
|
get().withSystemProperties(key + "=").run((context) -> {
|
||||||
assertThat(System.getProperties()).doesNotContainKey(key);
|
assertThat(System.getProperties()).doesNotContainKey(key);
|
||||||
});
|
});
|
||||||
assertThat(System.getProperties().getProperty(key)).isEqualTo("value");
|
assertThat(System.getProperties().getProperty(key)).isEqualTo("value");
|
||||||
|
|
@ -109,8 +109,8 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
|
||||||
@Test
|
@Test
|
||||||
public void runWithMultiplePropertyValuesShouldAllAllValues() throws Exception {
|
public void runWithMultiplePropertyValuesShouldAllAllValues() throws Exception {
|
||||||
get().withPropertyValues("test.foo=1").withPropertyValues("test.bar=2")
|
get().withPropertyValues("test.foo=1").withPropertyValues("test.bar=2")
|
||||||
.run((loaded) -> {
|
.run((context) -> {
|
||||||
Environment environment = loaded.getEnvironment();
|
Environment environment = context.getEnvironment();
|
||||||
assertThat(environment.getProperty("test.foo")).isEqualTo("1");
|
assertThat(environment.getProperty("test.foo")).isEqualTo("1");
|
||||||
assertThat(environment.getProperty("test.bar")).isEqualTo("2");
|
assertThat(environment.getProperty("test.bar")).isEqualTo("2");
|
||||||
});
|
});
|
||||||
|
|
@ -120,8 +120,8 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
|
||||||
public void runWithPropertyValuesWhenHasExistingShouldReplaceValue()
|
public void runWithPropertyValuesWhenHasExistingShouldReplaceValue()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
get().withPropertyValues("test.foo=1").withPropertyValues("test.foo=2")
|
get().withPropertyValues("test.foo=1").withPropertyValues("test.foo=2")
|
||||||
.run((loaded) -> {
|
.run((context) -> {
|
||||||
Environment environment = loaded.getEnvironment();
|
Environment environment = context.getEnvironment();
|
||||||
assertThat(environment.getProperty("test.foo")).isEqualTo("2");
|
assertThat(environment.getProperty("test.foo")).isEqualTo("2");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -129,7 +129,7 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
|
||||||
@Test
|
@Test
|
||||||
public void runWithConfigurationsShouldRegisterConfigurations() throws Exception {
|
public void runWithConfigurationsShouldRegisterConfigurations() throws Exception {
|
||||||
get().withUserConfiguration(FooConfig.class)
|
get().withUserConfiguration(FooConfig.class)
|
||||||
.run((loaded) -> assertThat(loaded).hasBean("foo"));
|
.run((context) -> assertThat(context).hasBean("foo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -137,23 +137,23 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
|
||||||
throws Exception {
|
throws Exception {
|
||||||
get().withUserConfiguration(FooConfig.class)
|
get().withUserConfiguration(FooConfig.class)
|
||||||
.withConfiguration(UserConfigurations.of(BarConfig.class))
|
.withConfiguration(UserConfigurations.of(BarConfig.class))
|
||||||
.run((loaded) -> assertThat(loaded).hasBean("foo").hasBean("bar"));
|
.run((context) -> assertThat(context).hasBean("foo").hasBean("bar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void runWithFailedContextShouldReturnFailedAssertableContext()
|
public void runWithFailedContextShouldReturnFailedAssertableContext()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
get().withUserConfiguration(FailingConfig.class)
|
get().withUserConfiguration(FailingConfig.class)
|
||||||
.run((loaded) -> assertThat(loaded).hasFailed());
|
.run((context) -> assertThat(context).hasFailed());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void runWithClassLoaderShouldSetClassLoader() throws Exception {
|
public void runWithClassLoaderShouldSetClassLoader() throws Exception {
|
||||||
get().withClassLoader(
|
get().withClassLoader(
|
||||||
new HidePackagesClassLoader(Gson.class.getPackage().getName()))
|
new HidePackagesClassLoader(Gson.class.getPackage().getName()))
|
||||||
.run((loaded) -> {
|
.run((context) -> {
|
||||||
try {
|
try {
|
||||||
ClassUtils.forName(Gson.class.getName(), loaded.getClassLoader());
|
ClassUtils.forName(Gson.class.getName(), context.getClassLoader());
|
||||||
fail("Should have thrown a ClassNotFoundException");
|
fail("Should have thrown a ClassNotFoundException");
|
||||||
}
|
}
|
||||||
catch (ClassNotFoundException e) {
|
catch (ClassNotFoundException e) {
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ public class WebApplicationContextRunnerTests extends
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contextShouldHaveMockServletContext() throws Exception {
|
public void contextShouldHaveMockServletContext() throws Exception {
|
||||||
get().run((loaded) -> assertThat(loaded.getServletContext())
|
get().run((context) -> assertThat(context.getServletContext())
|
||||||
.isInstanceOf(MockServletContext.class));
|
.isInstanceOf(MockServletContext.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue