Conditionally (and recursively) remove the test directory of the forked GemFire/Geode server process.
This commit is contained in:
@@ -36,7 +36,6 @@ import org.apache.geode.cache.server.CacheServer;
|
||||
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.data.gemfire.tests.process.ProcessWrapper;
|
||||
import org.springframework.data.gemfire.tests.util.FileSystemUtils;
|
||||
import org.springframework.data.gemfire.tests.util.SocketUtils;
|
||||
import org.springframework.data.gemfire.util.ArrayUtils;
|
||||
import org.springframework.lang.NonNull;
|
||||
@@ -172,7 +171,7 @@ public abstract class ClientServerIntegrationTestsSupport extends IntegrationTes
|
||||
it.stop(duration);
|
||||
|
||||
if (it.isNotRunning() && isDeleteDirectoryOnExit()) {
|
||||
FileSystemUtils.deleteRecursive(it.getWorkingDirectory());
|
||||
removeRecursiveDirectory(it.getWorkingDirectory());
|
||||
}
|
||||
|
||||
return it.isRunning();
|
||||
|
||||
@@ -55,8 +55,15 @@ import org.springframework.lang.Nullable;
|
||||
* and bootstrap Apache Geode or VMware GemFire Server {@link Cache} and {@link ClientCache} applications.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see java.io.File
|
||||
* @see java.net.InetAddress
|
||||
* @see org.apache.geode.cache.Cache
|
||||
* @see org.apache.geode.cache.client.ClientCache
|
||||
* @see org.springframework.context.ApplicationContext
|
||||
* @see org.springframework.context.annotation.Bean
|
||||
* @see org.springframework.context.annotation.Configuration
|
||||
* @see org.springframework.context.event.ContextRefreshedEvent
|
||||
* @see org.springframework.context.event.EventListener
|
||||
* @see org.springframework.data.gemfire.config.annotation.CacheServerApplication
|
||||
* @see org.springframework.data.gemfire.config.annotation.ClientCacheApplication
|
||||
* @see org.springframework.data.gemfire.config.annotation.EnablePdx
|
||||
@@ -70,6 +77,8 @@ import org.springframework.lang.Nullable;
|
||||
@SuppressWarnings("unused")
|
||||
public abstract class ForkingClientServerIntegrationTestsSupport extends ClientServerIntegrationTestsSupport {
|
||||
|
||||
protected static final String REMOVE_TEST_DIRECTORY_PROPERTY = "spring.data.gemfire.test.directory.remove";
|
||||
|
||||
private static ProcessWrapper gemfireServer;
|
||||
|
||||
public static @NonNull ProcessWrapper startGemFireServer(@NonNull Class<?> gemfireServerMainClass,
|
||||
@@ -222,7 +231,15 @@ public abstract class ForkingClientServerIntegrationTestsSupport extends ClientS
|
||||
|
||||
@AfterClass
|
||||
public static void stopGemFireServer() {
|
||||
|
||||
getGemFireServerProcess().ifPresent(ForkingClientServerIntegrationTestsSupport::stop);
|
||||
|
||||
if (Boolean.parseBoolean(System.getProperty(REMOVE_TEST_DIRECTORY_PROPERTY, Boolean.TRUE.toString()))) {
|
||||
getGemFireServerProcess()
|
||||
.map(ProcessWrapper::getWorkingDirectory)
|
||||
.ifPresent(IntegrationTestsSupport::removeRecursiveDirectory);
|
||||
}
|
||||
|
||||
setGemFireServerProcess(null);
|
||||
}
|
||||
|
||||
@@ -242,9 +259,7 @@ public abstract class ForkingClientServerIntegrationTestsSupport extends ClientS
|
||||
|
||||
@EnablePdx
|
||||
@ClientCacheApplication
|
||||
public static class BaseGemFireClientConfiguration extends ClientServerIntegrationTestsConfiguration {
|
||||
|
||||
}
|
||||
public static class BaseGemFireClientConfiguration extends ClientServerIntegrationTestsConfiguration { }
|
||||
|
||||
@EnablePdx
|
||||
@CacheServerApplication(name = "ForkingClientServerIntegrationTestsSupport")
|
||||
|
||||
Reference in New Issue
Block a user