@@ -358,18 +358,20 @@ public Properties getRuntimeProperties() {
358358 runtimeProperties .setProperty (Environment .HBM2DDL_AUTO , "update" );
359359 }
360360
361- try {
362- File tempappdir = File .createTempFile ("appdir-for-unit-tests-" , "" );
363- tempappdir .delete (); // so we can make it into a directory
364- tempappdir .mkdir (); // turn it into a directory
365- tempappdir .deleteOnExit (); // clean up when we're done with tests
366-
367- runtimeProperties .setProperty (OpenmrsConstants .APPLICATION_DATA_DIRECTORY_RUNTIME_PROPERTY , tempappdir
368- .getAbsolutePath ());
369- OpenmrsUtil .setApplicationDataDirectory (tempappdir .getAbsolutePath ());
370- }
371- catch (IOException e ) {
372- log .error ("Unable to create temp dir" , e );
361+ String appDataDir = OpenmrsUtil .getApplicationDataDirectory ();
362+ if (appDataDir == null || !appDataDir .contains ("appdir-for-unit-tests-" )) {
363+ try {
364+ File tempappdir = File .createTempFile ("appdir-for-unit-tests-" , "" );
365+ tempappdir .delete (); // so we can make it into a directory
366+ tempappdir .mkdir (); // turn it into a directory
367+ tempappdir .deleteOnExit (); // clean up when we're done with tests
368+
369+ runtimeProperties .setProperty (OpenmrsConstants .APPLICATION_DATA_DIRECTORY_RUNTIME_PROPERTY , tempappdir
370+ .getAbsolutePath ());
371+ OpenmrsUtil .setApplicationDataDirectory (tempappdir .getAbsolutePath ());
372+ } catch (IOException e ) {
373+ log .error ("Unable to create temp dir" , e );
374+ }
373375 }
374376
375377 return runtimeProperties ;
0 commit comments