mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-16 06:23:10 +00:00
Cleaning up the cache of Builders after each test has ran
This commit is contained in:
@@ -192,6 +192,8 @@ public class AbstractIntegrationTestWithDatabase extends AbstractDSpaceIntegrati
|
|||||||
// Reload our ConfigurationService (to reset configs to defaults again)
|
// Reload our ConfigurationService (to reset configs to defaults again)
|
||||||
DSpaceServicesFactory.getInstance().getConfigurationService().reloadConfig();
|
DSpaceServicesFactory.getInstance().getConfigurationService().reloadConfig();
|
||||||
|
|
||||||
|
AbstractBuilder.cleanupBuilderCache();
|
||||||
|
|
||||||
// NOTE: we explicitly do NOT destroy our default eperson & admin as they
|
// NOTE: we explicitly do NOT destroy our default eperson & admin as they
|
||||||
// are cached and reused for all tests. This speeds up all tests.
|
// are cached and reused for all tests. This speeds up all tests.
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@@ -195,6 +195,10 @@ public abstract class AbstractBuilder<T, S> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void cleanupBuilderCache() {
|
||||||
|
abstractBuilderCleanupUtil.cleanupMap();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will ensure that the DSpaceObject contained within the Builder will be cleaned up properly
|
* This method will ensure that the DSpaceObject contained within the Builder will be cleaned up properly
|
||||||
* @throws Exception If something goes wrong
|
* @throws Exception If something goes wrong
|
||||||
|
@@ -46,6 +46,11 @@ public class AbstractBuilderCleanupUtil {
|
|||||||
* Constructor that will initialize the Map with a predefined order for deletion
|
* Constructor that will initialize the Map with a predefined order for deletion
|
||||||
*/
|
*/
|
||||||
public AbstractBuilderCleanupUtil() {
|
public AbstractBuilderCleanupUtil() {
|
||||||
|
initMap();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initMap() {
|
||||||
map.put(RelationshipBuilder.class.getName(), new LinkedList<>());
|
map.put(RelationshipBuilder.class.getName(), new LinkedList<>());
|
||||||
map.put(RelationshipTypeBuilder.class.getName(), new LinkedList<>());
|
map.put(RelationshipTypeBuilder.class.getName(), new LinkedList<>());
|
||||||
map.put(EntityTypeBuilder.class.getName(), new LinkedList<>());
|
map.put(EntityTypeBuilder.class.getName(), new LinkedList<>());
|
||||||
@@ -64,7 +69,6 @@ public class AbstractBuilderCleanupUtil {
|
|||||||
map.put(MetadataSchemaBuilder.class.getName(), new LinkedList<>());
|
map.put(MetadataSchemaBuilder.class.getName(), new LinkedList<>());
|
||||||
map.put(SiteBuilder.class.getName(), new LinkedList<>());
|
map.put(SiteBuilder.class.getName(), new LinkedList<>());
|
||||||
map.put(ProcessBuilder.class.getName(), new LinkedList<>());
|
map.put(ProcessBuilder.class.getName(), new LinkedList<>());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,4 +94,9 @@ public class AbstractBuilderCleanupUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void cleanupMap() {
|
||||||
|
this.map.clear();
|
||||||
|
initMap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user