mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-15 14:03:17 +00:00
#9806: Move cleanup of handle provider to destroy in VersionedHandleIdentifierProviderIT
(cherry picked from commit f6cabe648d
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
8f86801796
commit
ad7499f245
@@ -60,9 +60,6 @@ import org.dspace.content.virtual.VirtualMetadataConfiguration;
|
|||||||
import org.dspace.content.virtual.VirtualMetadataPopulator;
|
import org.dspace.content.virtual.VirtualMetadataPopulator;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.discovery.SolrSearchCore;
|
import org.dspace.discovery.SolrSearchCore;
|
||||||
import org.dspace.identifier.IdentifierProvider;
|
|
||||||
import org.dspace.identifier.IdentifierServiceImpl;
|
|
||||||
import org.dspace.identifier.VersionedHandleIdentifierProvider;
|
|
||||||
import org.dspace.kernel.ServiceManager;
|
import org.dspace.kernel.ServiceManager;
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
import org.dspace.versioning.Version;
|
import org.dspace.versioning.Version;
|
||||||
@@ -84,7 +81,6 @@ public class VersioningWithRelationshipsIT extends AbstractIntegrationTestWithDa
|
|||||||
ContentServiceFactory.getInstance().getItemService();
|
ContentServiceFactory.getInstance().getItemService();
|
||||||
private final SolrSearchCore solrSearchCore =
|
private final SolrSearchCore solrSearchCore =
|
||||||
DSpaceServicesFactory.getInstance().getServiceManager().getServicesByType(SolrSearchCore.class).get(0);
|
DSpaceServicesFactory.getInstance().getServiceManager().getServicesByType(SolrSearchCore.class).get(0);
|
||||||
private IdentifierServiceImpl identifierService;
|
|
||||||
protected Community community;
|
protected Community community;
|
||||||
protected Collection collection;
|
protected Collection collection;
|
||||||
protected EntityType publicationEntityType;
|
protected EntityType publicationEntityType;
|
||||||
@@ -101,22 +97,6 @@ public class VersioningWithRelationshipsIT extends AbstractIntegrationTestWithDa
|
|||||||
protected RelationshipType isIssueOfJournalVolume;
|
protected RelationshipType isIssueOfJournalVolume;
|
||||||
protected RelationshipType isProjectOfPerson;
|
protected RelationshipType isProjectOfPerson;
|
||||||
|
|
||||||
private void registerProvider(Class type) {
|
|
||||||
// Register our new provider
|
|
||||||
IdentifierProvider identifierProvider =
|
|
||||||
(IdentifierProvider) DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName(type.getName(), type);
|
|
||||||
if (identifierProvider == null) {
|
|
||||||
DSpaceServicesFactory.getInstance().getServiceManager().registerServiceClass(type.getName(), type);
|
|
||||||
identifierProvider = (IdentifierProvider) DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName(type.getName(), type);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Overwrite the identifier-service's providers with the new one to ensure only this provider is used
|
|
||||||
identifierService = DSpaceServicesFactory.getInstance().getServiceManager()
|
|
||||||
.getServicesByType(IdentifierServiceImpl.class).get(0);
|
|
||||||
identifierService.setProviders(new ArrayList<>());
|
|
||||||
identifierService.setProviders(List.of(identifierProvider));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
@@ -124,9 +104,6 @@ public class VersioningWithRelationshipsIT extends AbstractIntegrationTestWithDa
|
|||||||
|
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
|
|
||||||
registerProvider(VersionedHandleIdentifierProvider.class);
|
|
||||||
|
|
||||||
community = CommunityBuilder.createCommunity(context)
|
community = CommunityBuilder.createCommunity(context)
|
||||||
.withName("community")
|
.withName("community")
|
||||||
.build();
|
.build();
|
||||||
|
@@ -24,6 +24,7 @@ import org.dspace.content.Collection;
|
|||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.kernel.ServiceManager;
|
import org.dspace.kernel.ServiceManager;
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -57,13 +58,30 @@ public class VersionedHandleIdentifierProviderIT extends AbstractIntegrationTest
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
@Override
|
||||||
|
public void destroy() throws Exception {
|
||||||
|
super.destroy();
|
||||||
|
// After this test has finished running, refresh application context and
|
||||||
|
// set the expected 'default' versioned handle provider back to ensure other tests don't fail
|
||||||
|
DSpaceServicesFactory.getInstance().getServiceManager().getApplicationContext().refresh();
|
||||||
|
}
|
||||||
|
|
||||||
private void registerProvider(Class type) {
|
private void registerProvider(Class type) {
|
||||||
// Register our new provider
|
// Register our new provider
|
||||||
serviceManager.registerServiceClass(type.getName(), type);
|
|
||||||
IdentifierProvider identifierProvider =
|
IdentifierProvider identifierProvider =
|
||||||
(IdentifierProvider) serviceManager.getServiceByName(type.getName(), type);
|
(IdentifierProvider) DSpaceServicesFactory.getInstance().getServiceManager()
|
||||||
|
.getServiceByName(type.getName(), type);
|
||||||
|
if (identifierProvider == null) {
|
||||||
|
DSpaceServicesFactory.getInstance().getServiceManager().registerServiceClass(type.getName(), type);
|
||||||
|
identifierProvider = (IdentifierProvider) DSpaceServicesFactory.getInstance().getServiceManager()
|
||||||
|
.getServiceByName(type.getName(), type);
|
||||||
|
}
|
||||||
|
|
||||||
// Overwrite the identifier-service's providers with the new one to ensure only this provider is used
|
// Overwrite the identifier-service's providers with the new one to ensure only this provider is used
|
||||||
|
identifierService = DSpaceServicesFactory.getInstance().getServiceManager()
|
||||||
|
.getServicesByType(IdentifierServiceImpl.class).get(0);
|
||||||
|
identifierService.setProviders(new ArrayList<>());
|
||||||
identifierService.setProviders(List.of(identifierProvider));
|
identifierService.setProviders(List.of(identifierProvider));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user