From c77f9b183b5cc3a0ac8f61b9cd2c9be7061eff16 Mon Sep 17 00:00:00 2001 From: John Blum Date: Wed, 24 Mar 2021 02:17:32 -0700 Subject: [PATCH] Annotate Spring Geode Security Sample test class with Spring's @DirtiesContext annotation. This test uses GemFire/Geode SSL configuration and therefore needs to mark the ApplicationContext as dirty. --- .../BootGeodeSecurityClientApplicationIntegrationTests.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spring-geode-samples/boot/security/src/test/java/example/app/security/BootGeodeSecurityClientApplicationIntegrationTests.java b/spring-geode-samples/boot/security/src/test/java/example/app/security/BootGeodeSecurityClientApplicationIntegrationTests.java index 1bc35d31..8fe3d833 100644 --- a/spring-geode-samples/boot/security/src/test/java/example/app/security/BootGeodeSecurityClientApplicationIntegrationTests.java +++ b/spring-geode-samples/boot/security/src/test/java/example/app/security/BootGeodeSecurityClientApplicationIntegrationTests.java @@ -35,6 +35,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.dao.DataAccessResourceFailureException; import org.springframework.data.gemfire.GemfireTemplate; import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport; +import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; import example.app.security.client.BootGeodeSecurityClientApplication; @@ -50,6 +51,7 @@ import example.app.security.server.BootGeodeSecurityServerApplication; * @see org.apache.geode.security.NotAuthorizedException * @see org.apache.shiro.authz.UnauthorizedException * @see org.springframework.boot.test.context.SpringBootTest + * @see org.springframework.dao.DataAccessResourceFailureException * @see org.springframework.data.gemfire.GemfireTemplate * @see org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport * @see org.springframework.test.context.junit4.SpringRunner @@ -57,6 +59,7 @@ import example.app.security.server.BootGeodeSecurityServerApplication; * @see example.app.security.server.BootGeodeSecurityServerApplication * @since 1.3.0 */ +@DirtiesContext @RunWith(SpringRunner.class) @SpringBootTest(classes = BootGeodeSecurityClientApplication.class) public class BootGeodeSecurityClientApplicationIntegrationTests extends ForkingClientServerIntegrationTestsSupport { @@ -74,7 +77,8 @@ public class BootGeodeSecurityClientApplicationIntegrationTests extends ForkingC @Test public void dataReadNotAllowed() { - Exception exception = assertThrows(DataAccessResourceFailureException.class, () -> this.customersTemplate.get(2L)); + Exception exception = assertThrows(DataAccessResourceFailureException.class, + () -> this.customersTemplate.get(2L)); assertThat(exception).hasCauseInstanceOf(ServerOperationException.class); assertThat(exception.getCause()).hasMessageContaining("remote server");