Skip to content

Commit 8efe6d4

Browse files
committed
Conditionally (and recursively) remove the test directory of the forked GemFire/Geode server process.
1 parent 30428f7 commit 8efe6d4

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

spring-data-geode-test/src/main/java/org/springframework/data/gemfire/tests/integration/ClientServerIntegrationTestsSupport.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636

3737
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
3838
import org.springframework.data.gemfire.tests.process.ProcessWrapper;
39-
import org.springframework.data.gemfire.tests.util.FileSystemUtils;
4039
import org.springframework.data.gemfire.tests.util.SocketUtils;
4140
import org.springframework.data.gemfire.util.ArrayUtils;
4241
import org.springframework.lang.NonNull;
@@ -172,7 +171,7 @@ protected static boolean stop(@Nullable ProcessWrapper process, long duration) {
172171
it.stop(duration);
173172

174173
if (it.isNotRunning() && isDeleteDirectoryOnExit()) {
175-
FileSystemUtils.deleteRecursive(it.getWorkingDirectory());
174+
removeRecursiveDirectory(it.getWorkingDirectory());
176175
}
177176

178177
return it.isRunning();

spring-data-geode-test/src/main/java/org/springframework/data/gemfire/tests/integration/ForkingClientServerIntegrationTestsSupport.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,15 @@
5555
* and bootstrap Apache Geode or VMware GemFire Server {@link Cache} and {@link ClientCache} applications.
5656
*
5757
* @author John Blum
58+
* @see java.io.File
59+
* @see java.net.InetAddress
5860
* @see org.apache.geode.cache.Cache
5961
* @see org.apache.geode.cache.client.ClientCache
62+
* @see org.springframework.context.ApplicationContext
63+
* @see org.springframework.context.annotation.Bean
64+
* @see org.springframework.context.annotation.Configuration
65+
* @see org.springframework.context.event.ContextRefreshedEvent
66+
* @see org.springframework.context.event.EventListener
6067
* @see org.springframework.data.gemfire.config.annotation.CacheServerApplication
6168
* @see org.springframework.data.gemfire.config.annotation.ClientCacheApplication
6269
* @see org.springframework.data.gemfire.config.annotation.EnablePdx
@@ -70,6 +77,8 @@
7077
@SuppressWarnings("unused")
7178
public abstract class ForkingClientServerIntegrationTestsSupport extends ClientServerIntegrationTestsSupport {
7279

80+
protected static final String REMOVE_TEST_DIRECTORY_PROPERTY = "spring.data.gemfire.test.directory.remove";
81+
7382
private static ProcessWrapper gemfireServer;
7483

7584
public static @NonNull ProcessWrapper startGemFireServer(@NonNull Class<?> gemfireServerMainClass,
@@ -222,7 +231,15 @@ protected static int setAndGetPoolPortProperty(int port) {
222231

223232
@AfterClass
224233
public static void stopGemFireServer() {
234+
225235
getGemFireServerProcess().ifPresent(ForkingClientServerIntegrationTestsSupport::stop);
236+
237+
if (Boolean.parseBoolean(System.getProperty(REMOVE_TEST_DIRECTORY_PROPERTY, Boolean.TRUE.toString()))) {
238+
getGemFireServerProcess()
239+
.map(ProcessWrapper::getWorkingDirectory)
240+
.ifPresent(IntegrationTestsSupport::removeRecursiveDirectory);
241+
}
242+
226243
setGemFireServerProcess(null);
227244
}
228245

@@ -241,10 +258,8 @@ protected static synchronized Optional<ProcessWrapper> getGemFireServerProcess()
241258
}
242259

243260
@EnablePdx
244-
@ClientCacheApplication(logLevel = GEMFIRE_LOG_LEVEL)
245-
public static class BaseGemFireClientConfiguration extends ClientServerIntegrationTestsConfiguration {
246-
247-
}
261+
@ClientCacheApplication
262+
public static class BaseGemFireClientConfiguration extends ClientServerIntegrationTestsConfiguration { }
248263

249264
@EnablePdx
250265
@CacheServerApplication(name = "ForkingClientServerIntegrationTestsSupport", logLevel = GEMFIRE_LOG_LEVEL)

0 commit comments

Comments
 (0)