Skip to content

Commit 3002813

Browse files
committed
Clean up warnings in spring-test
1 parent 3cfa4ed commit 3002813

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

spring-test/src/test/java/org/springframework/test/context/groovy/GroovyControlGroupTests.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
import org.springframework.beans.testfixture.beans.Employee;
2222
import org.springframework.beans.testfixture.beans.Pet;
23-
import org.springframework.context.ApplicationContext;
23+
import org.springframework.context.ConfigurableApplicationContext;
2424
import org.springframework.context.support.GenericGroovyApplicationContext;
2525

2626
import static org.assertj.core.api.Assertions.assertThat;
@@ -42,22 +42,23 @@ class GroovyControlGroupTests {
4242

4343
@Test
4444
void verifyScriptUsingGenericGroovyApplicationContext() {
45-
ApplicationContext ctx = new GenericGroovyApplicationContext(getClass(), "context.groovy");
45+
try (ConfigurableApplicationContext ctx = new GenericGroovyApplicationContext(getClass(), "context.groovy")) {
46+
String foo = ctx.getBean("foo", String.class);
47+
assertThat(foo).isEqualTo("Foo");
4648

47-
String foo = ctx.getBean("foo", String.class);
48-
assertThat(foo).isEqualTo("Foo");
49+
String bar = ctx.getBean("bar", String.class);
50+
assertThat(bar).isEqualTo("Bar");
4951

50-
String bar = ctx.getBean("bar", String.class);
51-
assertThat(bar).isEqualTo("Bar");
52+
Pet pet = ctx.getBean(Pet.class);
53+
assertThat(pet).as("pet").isNotNull();
54+
assertThat(pet.getName()).isEqualTo("Dogbert");
5255

53-
Pet pet = ctx.getBean(Pet.class);
54-
assertThat(pet).as("pet").isNotNull();
55-
assertThat(pet.getName()).isEqualTo("Dogbert");
56+
Employee employee = ctx.getBean(Employee.class);
57+
assertThat(employee).as("employee").isNotNull();
58+
assertThat(employee.getName()).isEqualTo("Dilbert");
59+
assertThat(employee.getCompany()).isEqualTo("???");
60+
}
5661

57-
Employee employee = ctx.getBean(Employee.class);
58-
assertThat(employee).as("employee").isNotNull();
59-
assertThat(employee.getName()).isEqualTo("Dilbert");
60-
assertThat(employee.getCompany()).isEqualTo("???");
6162
}
6263

6364
}

0 commit comments

Comments
 (0)