diff --git a/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/security/auth/cloud/AutoConfiguredCloudSecurityContextIntegrationTests.java b/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/security/auth/cloud/AutoConfiguredCloudSecurityContextIntegrationTests.java index cfe7f59e..76ab2231 100644 --- a/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/security/auth/cloud/AutoConfiguredCloudSecurityContextIntegrationTests.java +++ b/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/security/auth/cloud/AutoConfiguredCloudSecurityContextIntegrationTests.java @@ -19,6 +19,7 @@ package org.springframework.boot.data.geode.security.auth.cloud; import java.io.IOException; import java.util.Properties; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.runner.RunWith; import org.springframework.boot.SpringApplication; @@ -29,6 +30,7 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.data.gemfire.config.annotation.CacheServerApplication; import org.springframework.data.gemfire.config.annotation.EnableLocator; import org.springframework.data.gemfire.config.annotation.EnableLogging; +import org.springframework.data.gemfire.support.GemfireBeanFactoryLocatorProxy; import org.springframework.test.context.junit4.SpringRunner; /** @@ -76,6 +78,12 @@ public class AutoConfiguredCloudSecurityContextIntegrationTests public static void startGemFireServer() throws IOException { startGemFireServer(GemFireServerConfiguration.class, "-Dspring.profiles.active=security-cloud"); loadVcapApplicationProperties(); + GemfireBeanFactoryLocatorProxy.clean(); + } + + @AfterClass + public static void cleanUpBeanFactoryLocatorReferences() { + GemfireBeanFactoryLocatorProxy.clean(); } @SpringBootApplication diff --git a/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/security/auth/local/AutoConfiguredLocalSecurityContextIntegrationTests.java b/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/security/auth/local/AutoConfiguredLocalSecurityContextIntegrationTests.java index d6cc0527..ba96aa11 100644 --- a/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/security/auth/local/AutoConfiguredLocalSecurityContextIntegrationTests.java +++ b/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/security/auth/local/AutoConfiguredLocalSecurityContextIntegrationTests.java @@ -18,6 +18,7 @@ package org.springframework.boot.data.geode.security.auth.local; import java.io.IOException; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.runner.RunWith; import org.springframework.boot.SpringApplication; @@ -27,6 +28,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Import; import org.springframework.data.gemfire.config.annotation.CacheServerApplication; import org.springframework.data.gemfire.config.annotation.EnableLogging; +import org.springframework.data.gemfire.support.GemfireBeanFactoryLocatorProxy; import org.springframework.data.gemfire.tests.integration.config.ClientServerIntegrationTestsConfiguration; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; @@ -64,10 +66,18 @@ public class AutoConfiguredLocalSecurityContextIntegrationTests @BeforeClass public static void startGemFireServer() throws IOException { + + GemfireBeanFactoryLocatorProxy.clean(); + startGemFireServer(GemFireServerConfiguration.class, "-Dspring.profiles.active=security-local-server"); } + @AfterClass + public static void cleanUpBeanFactoryLocatorReferences() { + GemfireBeanFactoryLocatorProxy.clean(); + } + @SpringBootApplication @EnableLogging(logLevel = GEMFIRE_LOG_LEVEL) @Import(ClientServerIntegrationTestsConfiguration.class) diff --git a/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/security/support/SecurityManagerProxyIntegrationTests.java b/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/security/support/SecurityManagerProxyIntegrationTests.java index 54b1c97a..baa3b79f 100644 --- a/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/security/support/SecurityManagerProxyIntegrationTests.java +++ b/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/security/support/SecurityManagerProxyIntegrationTests.java @@ -20,12 +20,15 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import org.apache.geode.cache.GemFireCache; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.data.gemfire.config.annotation.EnableSecurity; import org.springframework.data.gemfire.config.annotation.PeerCacheApplication; +import org.springframework.data.gemfire.support.GemfireBeanFactoryLocatorProxy; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -49,6 +52,12 @@ public class SecurityManagerProxyIntegrationTests { private static final String GEMFIRE_LOG_LEVEL = "error"; + @BeforeClass + @AfterClass + public static void cleanUpBeanFactoryLocatorReferences() { + GemfireBeanFactoryLocatorProxy.clean(); + } + @Autowired private org.apache.geode.security.SecurityManager mockSecurityManager; diff --git a/geode-spring-boot-starter/src/test/java/org/springframework/data/gemfire/support/GemfireBeanFactoryLocatorProxy.java b/geode-spring-boot-starter/src/test/java/org/springframework/data/gemfire/support/GemfireBeanFactoryLocatorProxy.java index 1bd188b8..85ae9cf1 100644 --- a/geode-spring-boot-starter/src/test/java/org/springframework/data/gemfire/support/GemfireBeanFactoryLocatorProxy.java +++ b/geode-spring-boot-starter/src/test/java/org/springframework/data/gemfire/support/GemfireBeanFactoryLocatorProxy.java @@ -1,11 +1,36 @@ +/* + * Copyright 2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + package org.springframework.data.gemfire.support; +import org.springframework.beans.factory.BeanFactory; + /** - * The GemfireBeanFactoryLocatorProxy class... + * The {@link GemfireBeanFactoryLocatorProxy} class is an extension of {@link GemfireBeanFactoryLocator} + * used to clean up all Spring {@link BeanFactory} references. * * @author John Blum + * @see org.springframework.beans.factory.BeanFactory + * @see org.springframework.data.gemfire.support.GemfireBeanFactoryLocator * @since 1.0.0 */ -public class GemfireBeanFactoryLocatorProxy { +// TODO: remove this class once and refactor the SDG GemfireBeanFactoryLocator! +public class GemfireBeanFactoryLocatorProxy extends GemfireBeanFactoryLocator { + public static void clean() { + BEAN_FACTORIES.clear(); + } }