Skip to content

Commit da39308

Browse files
committed
Add reset After method to test
To reset access helper to default
1 parent dd8ec85 commit da39308

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

dspace-server-webapp/src/test/java/org/dspace/app/rest/ItemOrderedAccessStatusRestRepositoryIT.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.dspace.core.Constants;
3535
import org.dspace.eperson.Group;
3636
import org.dspace.services.ConfigurationService;
37+
import org.junit.After;
3738
import org.junit.Before;
3839
import org.junit.Test;
3940
import org.springframework.beans.factory.annotation.Autowired;
@@ -58,7 +59,19 @@ public void setup() throws Exception {
5859
// already been created by the time the test method runs.
5960
ReflectionTestUtils.setField(accessStatusService, "helper", null);
6061
((AccessStatusServiceImpl) accessStatusService).init();
62+
}
6163

64+
@After
65+
public void reset() throws Exception {
66+
configurationService.setProperty(
67+
"plugin.single.org.dspace.access.status.AccessStatusHelper",
68+
"org.dspace.access.status.DefaultAccessStatusHelper"
69+
);
70+
// This is needed because the AccessStatusHelper is a plugin that is created and set in the
71+
// AccessStatusServiceImpl.init method. AccessStatusService is a spring managed bean, and the context has
72+
// already been created by the time the test method runs.
73+
ReflectionTestUtils.setField(accessStatusService, "helper", null);
74+
((AccessStatusServiceImpl) accessStatusService).init();
6275
}
6376

6477
@Test

0 commit comments

Comments
 (0)