diff --git a/spring-boot-test/src/test/java/org/springframework/boot/test/context/runner/AbstractApplicationContextRunnerTests.java b/spring-boot-test/src/test/java/org/springframework/boot/test/context/runner/AbstractApplicationContextRunnerTests.java index 15bc03d3fac..1d9c9390282 100644 --- a/spring-boot-test/src/test/java/org/springframework/boot/test/context/runner/AbstractApplicationContextRunnerTests.java +++ b/spring-boot-test/src/test/java/org/springframework/boot/test/context/runner/AbstractApplicationContextRunnerTests.java @@ -54,7 +54,7 @@ public abstract class AbstractApplicationContextRunnerTests { + get().withSystemProperties(key + "=value").run((context) -> { assertThat(System.getProperties()).containsEntry(key, "value"); }); assertThat(System.getProperties().containsKey(key)).isFalse(); @@ -66,8 +66,8 @@ public abstract class AbstractApplicationContextRunnerTests { - assertThat(loaded).hasFailed(); + .withUserConfiguration(FailingConfig.class).run((context) -> { + assertThat(context).hasFailed(); }); assertThat(System.getProperties().containsKey(key)).isFalse(); } @@ -79,7 +79,7 @@ public abstract class AbstractApplicationContextRunnerTests { + get().withSystemProperties(key + "=newValue").run((context) -> { assertThat(System.getProperties()).containsEntry(key, "newValue"); }); assertThat(System.getProperties().getProperty(key)).isEqualTo("value"); @@ -96,7 +96,7 @@ public abstract class AbstractApplicationContextRunnerTests { assertThat(System.getProperties()).doesNotContainKey(key); }); assertThat(System.getProperties().getProperty(key)).isEqualTo("value"); @@ -109,8 +109,8 @@ public abstract class AbstractApplicationContextRunnerTests { - Environment environment = loaded.getEnvironment(); + .run((context) -> { + Environment environment = context.getEnvironment(); assertThat(environment.getProperty("test.foo")).isEqualTo("1"); assertThat(environment.getProperty("test.bar")).isEqualTo("2"); }); @@ -120,8 +120,8 @@ public abstract class AbstractApplicationContextRunnerTests { - Environment environment = loaded.getEnvironment(); + .run((context) -> { + Environment environment = context.getEnvironment(); assertThat(environment.getProperty("test.foo")).isEqualTo("2"); }); } @@ -129,7 +129,7 @@ public abstract class AbstractApplicationContextRunnerTests assertThat(loaded).hasBean("foo")); + .run((context) -> assertThat(context).hasBean("foo")); } @Test @@ -137,23 +137,23 @@ public abstract class AbstractApplicationContextRunnerTests assertThat(loaded).hasBean("foo").hasBean("bar")); + .run((context) -> assertThat(context).hasBean("foo").hasBean("bar")); } @Test public void runWithFailedContextShouldReturnFailedAssertableContext() throws Exception { get().withUserConfiguration(FailingConfig.class) - .run((loaded) -> assertThat(loaded).hasFailed()); + .run((context) -> assertThat(context).hasFailed()); } @Test public void runWithClassLoaderShouldSetClassLoader() throws Exception { get().withClassLoader( new HidePackagesClassLoader(Gson.class.getPackage().getName())) - .run((loaded) -> { + .run((context) -> { try { - ClassUtils.forName(Gson.class.getName(), loaded.getClassLoader()); + ClassUtils.forName(Gson.class.getName(), context.getClassLoader()); fail("Should have thrown a ClassNotFoundException"); } catch (ClassNotFoundException e) { diff --git a/spring-boot-test/src/test/java/org/springframework/boot/test/context/runner/WebApplicationContextRunnerTests.java b/spring-boot-test/src/test/java/org/springframework/boot/test/context/runner/WebApplicationContextRunnerTests.java index b461d3070dd..b851fe6488c 100644 --- a/spring-boot-test/src/test/java/org/springframework/boot/test/context/runner/WebApplicationContextRunnerTests.java +++ b/spring-boot-test/src/test/java/org/springframework/boot/test/context/runner/WebApplicationContextRunnerTests.java @@ -35,7 +35,7 @@ public class WebApplicationContextRunnerTests extends @Test public void contextShouldHaveMockServletContext() throws Exception { - get().run((loaded) -> assertThat(loaded.getServletContext()) + get().run((context) -> assertThat(context.getServletContext()) .isInstanceOf(MockServletContext.class)); }