mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 23:13:10 +00:00
Final removal of JMockit. Move last tests to Mockito. Cleanup unused tests & resources
This commit is contained in:
@@ -481,12 +481,6 @@
|
||||
<groupId>org.dspace</groupId>
|
||||
<artifactId>dspace-services</artifactId>
|
||||
</dependency>
|
||||
<!-- Keep jmockit before junit -->
|
||||
<dependency>
|
||||
<groupId>org.jmockit</groupId>
|
||||
<artifactId>jmockit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
@@ -1,32 +0,0 @@
|
||||
# Configure authority control for Unit Testing (in DSpaceControlledVocabularyTest)
|
||||
# (This overrides default, commented out settings in dspace.cfg)
|
||||
plugin.selfnamed.org.dspace.content.authority.ChoiceAuthority = \
|
||||
org.dspace.content.authority.DCInputAuthority, \
|
||||
org.dspace.content.authority.DSpaceControlledVocabulary
|
||||
|
||||
# Configure some more Plugins for PluginTest class
|
||||
# NOTE: Plugins are just *interfaces*. So, here we are defining some plugins
|
||||
# based on java.util.List interface and giving them names.
|
||||
# (These are used by PluginTest)
|
||||
plugin.named.java.util.List = \
|
||||
java.util.ArrayList = MyArrayList, \
|
||||
java.util.LinkedList = MyLinkedList, \
|
||||
java.util.AttributeList = MyAttributeList
|
||||
|
||||
# Define a single Map plugin (used by PluginTest)
|
||||
plugin.single.java.util.Map = java.util.HashMap
|
||||
|
||||
# Define a sequence of Collection plugins (used by PluginTest)
|
||||
plugin.sequence.java.util.Collection = \
|
||||
java.util.ArrayList, \
|
||||
java.util.LinkedList, \
|
||||
java.util.Stack, \
|
||||
java.util.TreeSet
|
||||
|
||||
# Enable a test authority control on dc.language.iso field
|
||||
choices.plugin.dc.language.iso = common_iso_languages
|
||||
choices.presentation.dc.language.iso = select
|
||||
authority.controlled.dc.language.iso = true
|
||||
|
||||
# use the testing assetstore.dir
|
||||
assetstore.dir = ${dspace.dir}/assetstore
|
@@ -21,92 +21,18 @@
|
||||
autowire="byType"
|
||||
scope="singleton"/>
|
||||
|
||||
<!-- provider for using the versioned handle identifier instead of the default one. -->
|
||||
<!--<bean id="org.dspace.identifier.HandleIdentifierProvider" class="org.dspace.identifier.VersionedHandleIdentifierProvider"-->
|
||||
<!--scope="singleton">-->
|
||||
<!--<property name="configurationService" ref="org.dspace.services.ConfigurationService"/>-->
|
||||
<!--</bean>-->
|
||||
|
||||
<!-- provider to mint and register DOIs with DSpace.
|
||||
To mint DOIs you need a registration agency. The DOIIdentifierProvider
|
||||
maintains the doi database table and handling of DSpaceObject. It uses
|
||||
a DOIConnector that handles all API calls to your DOI registration
|
||||
agency. Please configure a DOIConnector as well! -->
|
||||
|
||||
<!-- In order to mint DOIs with DSpace, get an agreement with a DOI registration
|
||||
agency, take a look into dspace.cfg, and uncomment this.
|
||||
-->
|
||||
<bean id="org.dspace.identifier.DOIIdentifierProvider"
|
||||
class="org.dspace.identifier.DOIIdentifierProvider"
|
||||
scope="singleton">
|
||||
<property name="configurationService"
|
||||
ref="org.dspace.services.ConfigurationService"/>
|
||||
<property name="DOIConnector"
|
||||
ref="org.dspace.identifier.doi.DOIConnector"/>
|
||||
<!-- NOTE: A DOIConnector is not configured here because it is mocked in the tests themselves -->
|
||||
<!--<property name="DOIConnector"
|
||||
ref="org.dspace.identifier.doi.DOIConnector"/>-->
|
||||
</bean>
|
||||
|
||||
<!-- The DOIConnector will handle the API calls to your DOI registration
|
||||
agency for the DOIIdentifierProvider. If your registration agency
|
||||
tells you to use the DataCite API directly, you can use the
|
||||
DataCiteConnector. If your registration agency is not part of DataCite
|
||||
or provides their own API, you have to implement a DOIConnector.
|
||||
e.g. EZID is part of DataCite but provides their own APIs. The following
|
||||
DataCiteConnector won't work if EZID is your registration agency.
|
||||
-->
|
||||
<!-- Uncomment this to use the DataCite API directly as DOIConnector.
|
||||
<bean id="org.dspace.identifier.doi.DOIConnector"
|
||||
class="org.dspace.identifier.doi.DataCiteConnector"
|
||||
scope="singleton">
|
||||
<property name='DATACITE_SCHEME' value='https'/>
|
||||
<property name='DATACITE_HOST' value='test.datacite.org'/>
|
||||
<property name='DATACITE_DOI_PATH' value='/mds/doi/' />
|
||||
<property name='DATACITE_METADATA_PATH' value='/mds/metadata/' />
|
||||
<property name='disseminationCrosswalkName' value="DataCite" />
|
||||
</bean>
|
||||
-->
|
||||
<bean id="org.dspace.identifier.doi.DOIConnector" class="org.dspace.identifier.MockDOIConnector"/>
|
||||
|
||||
<!-- Provider to mint and register DOIs using EZID as the registrar.
|
||||
-->
|
||||
<!--
|
||||
Set generateDataciteXML to true to send metadata in DataCite xml schema for EZID DOI mint requests.
|
||||
When generateDataciteXML is enabled, EZIDIdentifierProvider uses
|
||||
dspace.cfg:crosswalk.dissemination.DataCite.stylesheet XSL configuration for metadata mapping
|
||||
-->
|
||||
<!-- Uncomment to enable DOI using EZID
|
||||
<bean id="org.dspace.identifier.EZIDIdentifierProvider"
|
||||
class="org.dspace.identifier.EZIDIdentifierProvider"
|
||||
scope='singleton'>
|
||||
<description>Uses the EZID service to provide DOI identifiers from DataCite</description>
|
||||
<property name="configurationService"
|
||||
ref="org.dspace.services.ConfigurationService"/>
|
||||
<property name='requestFactory'>
|
||||
<bean class='org.dspace.identifier.ezid.EZIDRequestFactory'>
|
||||
<property name='EZID_SCHEME' value='https'/>
|
||||
<property name='EZID_HOST' value='ezid.cdlib.org'/>
|
||||
<property name='EZID_PATH' value=''/>
|
||||
</bean>
|
||||
</property>
|
||||
<property name='crosswalk'>
|
||||
<map>
|
||||
<entry key='datacite.creator' value='dc.contributor.author'/>
|
||||
<entry key='datacite.title' value='dc.title'/>
|
||||
<entry key='datacite.publisher' value='dc.publisher'/>
|
||||
<entry key='datacite.publicationyear' value='dc.date.issued'/>
|
||||
</map>
|
||||
</property>
|
||||
<property name='crosswalkTransform'>
|
||||
<description>How to compute the crosswalked value from the original. Default is plain copy.</description>
|
||||
<map>
|
||||
<entry key='datacite.publicationyear'>
|
||||
<bean class='org.dspace.identifier.ezid.DateToYear'/>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
<property name='generateDataciteXML' value='false'/>
|
||||
<property name='disseminationCrosswalkName' value='DataCite'/>
|
||||
|
||||
</bean>
|
||||
-->
|
||||
|
||||
</beans>
|
||||
|
@@ -1,2 +0,0 @@
|
||||
<?xml version='1.0'?>
|
||||
<solr/>
|
@@ -11,16 +11,18 @@ import static org.junit.Assert.fail;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.authorize.factory.AuthorizeServiceFactory;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.I18nUtil;
|
||||
import org.dspace.discovery.MockIndexEventConsumer;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.eperson.factory.EPersonServiceFactory;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.dspace.storage.rdbms.DatabaseUtils;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -86,9 +88,6 @@ public class AbstractUnitTest extends AbstractDSpaceTest {
|
||||
fail("Error initializing database: " + se.getMessage()
|
||||
+ (se.getCause() == null ? "" : ": " + se.getCause().getMessage()));
|
||||
}
|
||||
|
||||
// Initialize mock indexer (which does nothing, since Solr isn't running)
|
||||
new MockIndexEventConsumer();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,6 +126,10 @@ public class AbstractUnitTest extends AbstractDSpaceTest {
|
||||
EPersonServiceFactory.getInstance().getGroupService().initDefaultGroupNames(context);
|
||||
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
// Ensure all tests run with Solr indexing disabled
|
||||
disableSolrIndexing();
|
||||
|
||||
} catch (AuthorizeException ex) {
|
||||
log.error("Error creating initial eperson or default groups", ex);
|
||||
fail("Error creating initial eperson or default groups in AbstractUnitTest init()");
|
||||
@@ -160,7 +163,7 @@ public class AbstractUnitTest extends AbstractDSpaceTest {
|
||||
protected void cleanupContext(Context c) throws SQLException {
|
||||
// If context still valid, abort it
|
||||
if (c != null && c.isValid()) {
|
||||
c.complete();
|
||||
c.abort();
|
||||
}
|
||||
|
||||
// Cleanup Context object by setting it to null
|
||||
@@ -168,4 +171,23 @@ public class AbstractUnitTest extends AbstractDSpaceTest {
|
||||
c = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method which ensures Solr indexing is DISABLED in all Tests. We turn this off because
|
||||
* Solr is NOT used in the dspace-api test framework. Instead, Solr/Discovery indexing is
|
||||
* exercised in the dspace-server Integration Tests (which use an embedded Solr).
|
||||
*/
|
||||
protected static void disableSolrIndexing() {
|
||||
// Get our currently configured list of event consumers
|
||||
ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
String[] consumers = configurationService.getArrayProperty("event.dispatcher.default.consumers");
|
||||
|
||||
// Remove "discovery" from the configured consumers (if it exists).
|
||||
// This turns off Discovery/Solr indexing after any object changes.
|
||||
if (ArrayUtils.contains(consumers, "discovery")) {
|
||||
consumers = ArrayUtils.removeElement(consumers, "discovery");
|
||||
configurationService.setProperty("event.dispatcher.default.consumers", consumers);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -308,6 +308,7 @@ public class ItemTest extends AbstractDSpaceObjectTest {
|
||||
// Test 7: We should not find our item in this list
|
||||
assertFalse("List should not contain non-discoverable items", added);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of findInArchiveOrWithdrawnNonDiscoverableModifiedSince method, of class Item.
|
||||
*/
|
||||
@@ -1188,6 +1189,8 @@ public class ItemTest extends AbstractDSpaceObjectTest {
|
||||
doNothing().when(authorizeServiceSpy).authorizeAction(context, item, Constants.REMOVE, true);
|
||||
// Allow Item DELETE perms
|
||||
doNothing().when(authorizeServiceSpy).authorizeAction(context, item, Constants.DELETE);
|
||||
// Allow Item WRITE perms (required to first delete identifiers)
|
||||
doNothing().when(authorizeServiceSpy).authorizeAction(context, item, Constants.WRITE);
|
||||
|
||||
UUID id = item.getID();
|
||||
itemService.delete(context, item);
|
||||
|
@@ -23,7 +23,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.AbstractUnitTest;
|
||||
import org.dspace.AbstractIntegrationTest;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.authorize.ResourcePolicy;
|
||||
import org.dspace.authorize.factory.AuthorizeServiceFactory;
|
||||
@@ -67,7 +67,6 @@ import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
//import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
/**
|
||||
* Basic integration testing for the AIP Backup and Restore feature
|
||||
@@ -75,7 +74,7 @@ import org.junit.rules.TemporaryFolder;
|
||||
*
|
||||
* @author Tim Donohue
|
||||
*/
|
||||
public class ITDSpaceAIP extends AbstractUnitTest {
|
||||
public class ITDSpaceAIP extends AbstractIntegrationTest {
|
||||
/**
|
||||
* log4j category
|
||||
*/
|
||||
|
@@ -1,32 +0,0 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.discovery;
|
||||
|
||||
import mockit.Mock;
|
||||
import mockit.MockUp;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.event.Event;
|
||||
|
||||
/**
|
||||
* Dummy Discovery IndexEventConsumer. It essentially does nothing,
|
||||
* as Discovery/Solr is not actively running during unit testing.
|
||||
*
|
||||
* @author tdonohue
|
||||
*/
|
||||
public class MockIndexEventConsumer
|
||||
extends MockUp<IndexEventConsumer> {
|
||||
@Mock
|
||||
public void consume(Context ctx, Event event) throws Exception {
|
||||
//do nothing - Solr is not running during unit testing, so we cannot index test content in Solr
|
||||
}
|
||||
|
||||
@Mock
|
||||
public void end(Context ctx) throws Exception {
|
||||
//do nothing - Solr is not running during unit testing, so we cannot index test content in Solr
|
||||
}
|
||||
}
|
@@ -13,6 +13,7 @@ import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.Assume.assumeNotNull;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
@@ -36,6 +37,7 @@ import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.content.service.CommunityService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.content.service.WorkspaceItemService;
|
||||
import org.dspace.identifier.doi.DOIConnector;
|
||||
import org.dspace.identifier.factory.IdentifierServiceFactory;
|
||||
import org.dspace.identifier.service.DOIService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
@@ -48,7 +50,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests for {@link DataCiteIdentifierProvider}.
|
||||
* Tests for {@link DOIIdentifierProvider}.
|
||||
*
|
||||
* @author Mark H. Wood
|
||||
* @author Pascal-Nicolas Becker
|
||||
@@ -75,7 +77,7 @@ public class DOIIdentifierProviderTest
|
||||
private static Community community;
|
||||
private static Collection collection;
|
||||
|
||||
private static MockDOIConnector connector;
|
||||
private static DOIConnector connector;
|
||||
private DOIIdentifierProvider provider;
|
||||
|
||||
public DOIIdentifierProviderTest() {
|
||||
@@ -111,7 +113,7 @@ public class DOIIdentifierProviderTest
|
||||
config.setProperty(DOIIdentifierProvider.CFG_NAMESPACE_SEPARATOR,
|
||||
NAMESPACE_SEPARATOR);
|
||||
|
||||
connector = new MockDOIConnector();
|
||||
connector = mock(DOIConnector.class);
|
||||
|
||||
provider = DSpaceServicesFactory.getInstance().getServiceManager()
|
||||
.getServiceByName(DOIIdentifierProvider.class.getName(),
|
||||
@@ -140,7 +142,6 @@ public class DOIIdentifierProviderTest
|
||||
public void destroy() {
|
||||
community = null;
|
||||
collection = null;
|
||||
connector.reset();
|
||||
connector = null;
|
||||
provider = null;
|
||||
super.destroy();
|
||||
@@ -261,8 +262,7 @@ public class DOIIdentifierProviderTest
|
||||
|
||||
@Test
|
||||
public void testSupports_valid_String() {
|
||||
String[] validDOIs = new String[]
|
||||
{
|
||||
String[] validDOIs = new String[] {
|
||||
"10.5072/123abc-lkj/kljl",
|
||||
PREFIX + "/" + NAMESPACE_SEPARATOR + "lkjljasd1234",
|
||||
DOI.SCHEME + "10.5072/123abc-lkj/kljl",
|
||||
@@ -277,8 +277,7 @@ public class DOIIdentifierProviderTest
|
||||
|
||||
@Test
|
||||
public void testDoes_not_support_invalid_String() {
|
||||
String[] invalidDOIs = new String[]
|
||||
{
|
||||
String[] invalidDOIs = new String[] {
|
||||
"11.5072/123abc-lkj/kljl",
|
||||
"http://hdl.handle.net/handle/10.5072/123abc-lkj/kljl",
|
||||
"",
|
||||
|
@@ -1,124 +0,0 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.identifier;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import mockit.Mock;
|
||||
import mockit.MockUp;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.identifier.doi.DOIConnector;
|
||||
import org.dspace.identifier.doi.DOIIdentifierException;
|
||||
|
||||
/**
|
||||
* @author Pascal-Nicolas Becker (p dot becker at tu hyphen berlin dot de)
|
||||
*/
|
||||
public class MockDOIConnector
|
||||
extends MockUp<DOIConnector>
|
||||
implements org.dspace.identifier.doi.DOIConnector {
|
||||
|
||||
public Map<String, UUID> reserved;
|
||||
public Map<String, UUID> registered;
|
||||
|
||||
public MockDOIConnector() {
|
||||
reserved = new HashMap<String, UUID>();
|
||||
registered = new HashMap<String, UUID>();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
reserved.clear();
|
||||
registered.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Mock
|
||||
public boolean isDOIReserved(Context context, String doi)
|
||||
throws DOIIdentifierException {
|
||||
return reserved.containsKey(doi);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Mock
|
||||
public boolean isDOIRegistered(Context context, String doi)
|
||||
throws DOIIdentifierException {
|
||||
return registered.containsKey(doi);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Mock
|
||||
public void deleteDOI(Context context, String doi)
|
||||
throws DOIIdentifierException {
|
||||
if (reserved.remove(doi) == null) {
|
||||
throw new DOIIdentifierException("Trying to delete a DOI that was "
|
||||
+ "never reserved!", DOIIdentifierException.DOI_DOES_NOT_EXIST);
|
||||
}
|
||||
registered.remove(doi);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Mock
|
||||
public void reserveDOI(Context context, DSpaceObject dso, String doi)
|
||||
throws DOIIdentifierException {
|
||||
UUID itemId = reserved.get(doi);
|
||||
if (null != itemId) {
|
||||
if (dso.getID().equals(itemId)) {
|
||||
return;
|
||||
} else {
|
||||
throw new DOIIdentifierException("Trying to reserve a DOI that "
|
||||
+ "is reserved for another object.",
|
||||
DOIIdentifierException.MISMATCH);
|
||||
}
|
||||
}
|
||||
reserved.put(doi, dso.getID());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Mock
|
||||
public void registerDOI(Context context, DSpaceObject dso, String doi)
|
||||
throws DOIIdentifierException {
|
||||
if (!reserved.containsKey(doi)) {
|
||||
throw new DOIIdentifierException("Trying to register an unreserverd "
|
||||
+ "DOI.", DOIIdentifierException.RESERVE_FIRST);
|
||||
}
|
||||
|
||||
if (!reserved.get(doi).equals(dso.getID())) {
|
||||
throw new DOIIdentifierException("Trying to register a DOI that is"
|
||||
+ " reserved for another item.", DOIIdentifierException.MISMATCH);
|
||||
}
|
||||
|
||||
if (registered.containsKey(doi)) {
|
||||
if (registered.get(doi).equals(dso.getID())) {
|
||||
return;
|
||||
} else {
|
||||
throw new DOIIdentifierException("Trying to register a DOI that "
|
||||
+ "is registered for another item.",
|
||||
DOIIdentifierException.MISMATCH);
|
||||
}
|
||||
}
|
||||
|
||||
registered.put(doi, dso.getID());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Mock
|
||||
public void updateMetadata(Context context, DSpaceObject dso, String doi)
|
||||
throws DOIIdentifierException {
|
||||
if (!reserved.containsKey(doi)) {
|
||||
throw new DOIIdentifierException("Trying to update a DOI that is not "
|
||||
+ "registered!", DOIIdentifierException.DOI_DOES_NOT_EXIST);
|
||||
}
|
||||
if (!reserved.get(doi).equals(dso.getID())) {
|
||||
throw new DOIIdentifierException("Trying to update metadata of an "
|
||||
+ "unreserved DOI.", DOIIdentifierException.DOI_DOES_NOT_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -10,14 +10,11 @@ package org.dspace.statistics.util;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import mockit.Mock;
|
||||
import mockit.MockUp;
|
||||
import org.dspace.AbstractDSpaceTest;
|
||||
import org.dspace.core.factory.CoreServiceFactory;
|
||||
import org.dspace.service.ClientInfoService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.dspace.statistics.SolrLoggerServiceImpl;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -335,30 +332,5 @@ public class SpiderDetectorServiceImplTest extends AbstractDSpaceTest {
|
||||
public void cleanup() throws Exception {
|
||||
spiderDetectorService = null;
|
||||
configurationService.setProperty("usage-statistics.bots.case-insensitive", false);
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Dummy SolrLogger for testing.
|
||||
*
|
||||
* @author mwood
|
||||
*/
|
||||
static public class MockSolrLogger
|
||||
extends MockUp<SolrLoggerServiceImpl> {
|
||||
@Mock
|
||||
public void $init() {
|
||||
}
|
||||
|
||||
@Mock
|
||||
public void $clinit() {
|
||||
}
|
||||
|
||||
@Mock
|
||||
public boolean isUseProxies() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -81,8 +81,8 @@ public class MultiFormatDateParserTest {
|
||||
{"Should parse: yyyyMM", "195701", "yyyyMM", true},
|
||||
{"Should parse: yyyy", "1957", "yyyy", true},
|
||||
{"Should parse: yyyy-MM-dd'T'HH:mm:ss'Z'", "1957-01-27T12:34:56Z", "yyyy-MM-dd'T'HH:mm:ss'Z'", true},
|
||||
{"Should parse: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "1957-01-27T12:34:56.789Z", "yyyy-MM-dd'T'HH:mm:ss" +
|
||||
".SSS'Z'", true},
|
||||
{"Should parse: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "1957-01-27T12:34:56.789Z", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",
|
||||
true},
|
||||
{"Shouldn't parse: yyyy/MM/ddHH:mm:ss", "1957/01/2720:06:20", "yyyy/MM/ddHH:mm:ss", false}
|
||||
});
|
||||
}
|
||||
|
@@ -289,8 +289,8 @@ public class BasicWorkflowAuthorizationIT
|
||||
|
||||
int i = 0;
|
||||
// check item policies
|
||||
for (int action : new int[] {Constants.READ, Constants.WRITE, Constants.ADD, Constants.REMOVE, Constants
|
||||
.DELETE}) {
|
||||
for (int action : new int[] {Constants.READ, Constants.WRITE, Constants.ADD, Constants.REMOVE,
|
||||
Constants.DELETE}) {
|
||||
Assert.assertTrue("testReviewerPermissions 1-" + i++,
|
||||
authorizeService.authorizeActionBoolean(context, member, item, action, false));
|
||||
}
|
||||
|
@@ -6,8 +6,8 @@
|
||||
# http://www.dspace.org/license/
|
||||
#
|
||||
# Defines the test folder where the unit tests will be run
|
||||
# (Used by AbstractDSpaceTest)
|
||||
test.folder = ./target/testing/
|
||||
test.folder.assetstore = ./target/testing/dspace/assetstore
|
||||
|
||||
#Path for a test file to create bitstreams
|
||||
# Path of the test bitstream (to use in BitstreamTest and elsewhere)
|
||||
test.bitstream = ./target/testing/dspace/assetstore/ConstitutionofIreland.pdf
|
||||
|
@@ -350,11 +350,6 @@
|
||||
<artifactId>json-path-assert</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency> <!-- Keep jmockit before junit -->
|
||||
<groupId>org.jmockit</groupId>
|
||||
<artifactId>jmockit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
@@ -0,0 +1,3 @@
|
||||
<?xml version='1.0'?>
|
||||
<!-- This empty configuration is required to start EmbeddedSolrServer for Integration Tests (see MockSolrServer) -->
|
||||
<solr/>
|
@@ -1,124 +0,0 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.identifier;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import mockit.Mock;
|
||||
import mockit.MockUp;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.identifier.doi.DOIConnector;
|
||||
import org.dspace.identifier.doi.DOIIdentifierException;
|
||||
|
||||
/**
|
||||
* @author Pascal-Nicolas Becker (p dot becker at tu hyphen berlin dot de)
|
||||
*/
|
||||
public class MockDOIConnector
|
||||
extends MockUp<DOIConnector>
|
||||
implements DOIConnector {
|
||||
|
||||
public Map<String, UUID> reserved;
|
||||
public Map<String, UUID> registered;
|
||||
|
||||
public MockDOIConnector() {
|
||||
reserved = new HashMap<String, UUID>();
|
||||
registered = new HashMap<String, UUID>();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
reserved.clear();
|
||||
registered.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Mock
|
||||
public boolean isDOIReserved(Context context, String doi)
|
||||
throws DOIIdentifierException {
|
||||
return reserved.containsKey(doi);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Mock
|
||||
public boolean isDOIRegistered(Context context, String doi)
|
||||
throws DOIIdentifierException {
|
||||
return registered.containsKey(doi);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Mock
|
||||
public void deleteDOI(Context context, String doi)
|
||||
throws DOIIdentifierException {
|
||||
if (reserved.remove(doi) == null) {
|
||||
throw new DOIIdentifierException("Trying to delete a DOI that was "
|
||||
+ "never reserved!", DOIIdentifierException.DOI_DOES_NOT_EXIST);
|
||||
}
|
||||
registered.remove(doi);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Mock
|
||||
public void reserveDOI(Context context, DSpaceObject dso, String doi)
|
||||
throws DOIIdentifierException {
|
||||
UUID itemId = reserved.get(doi);
|
||||
if (null != itemId) {
|
||||
if (dso.getID().equals(itemId)) {
|
||||
return;
|
||||
} else {
|
||||
throw new DOIIdentifierException("Trying to reserve a DOI that "
|
||||
+ "is reserved for another object.",
|
||||
DOIIdentifierException.MISMATCH);
|
||||
}
|
||||
}
|
||||
reserved.put(doi, dso.getID());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Mock
|
||||
public void registerDOI(Context context, DSpaceObject dso, String doi)
|
||||
throws DOIIdentifierException {
|
||||
if (!reserved.containsKey(doi)) {
|
||||
throw new DOIIdentifierException("Trying to register an unreserverd "
|
||||
+ "DOI.", DOIIdentifierException.RESERVE_FIRST);
|
||||
}
|
||||
|
||||
if (!reserved.get(doi).equals(dso.getID())) {
|
||||
throw new DOIIdentifierException("Trying to register a DOI that is"
|
||||
+ " reserved for another item.", DOIIdentifierException.MISMATCH);
|
||||
}
|
||||
|
||||
if (registered.containsKey(doi)) {
|
||||
if (registered.get(doi).equals(dso.getID())) {
|
||||
return;
|
||||
} else {
|
||||
throw new DOIIdentifierException("Trying to register a DOI that "
|
||||
+ "is registered for another item.",
|
||||
DOIIdentifierException.MISMATCH);
|
||||
}
|
||||
}
|
||||
|
||||
registered.put(doi, dso.getID());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Mock
|
||||
public void updateMetadata(Context context, DSpaceObject dso, String doi)
|
||||
throws DOIIdentifierException {
|
||||
if (!reserved.containsKey(doi)) {
|
||||
throw new DOIIdentifierException("Trying to update a DOI that is not "
|
||||
+ "registered!", DOIIdentifierException.DOI_DOES_NOT_EXIST);
|
||||
}
|
||||
if (!reserved.get(doi).equals(dso.getID())) {
|
||||
throw new DOIIdentifierException("Trying to update metadata of an "
|
||||
+ "unreserved DOI.", DOIIdentifierException.DOI_DOES_NOT_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -197,12 +197,6 @@
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- Keep jmockit before junit -->
|
||||
<dependency>
|
||||
<groupId>org.jmockit</groupId>
|
||||
<artifactId>jmockit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
@@ -270,11 +270,6 @@ just adding new jar in the classloader</description>
|
||||
<artifactId>json-path-assert</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jmockit</groupId>
|
||||
<artifactId>jmockit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
26
pom.xml
26
pom.xml
@@ -29,7 +29,6 @@
|
||||
<jaxb-api.version>2.3.1</jaxb-api.version>
|
||||
<jaxb-runtime.version>2.3.1</jaxb-runtime.version>
|
||||
<javax-annotation.version>1.3.2</javax-annotation.version>
|
||||
<jmockit.version>1.48</jmockit.version>
|
||||
<errorprone.version>2.3.4</errorprone.version>
|
||||
<log4j.version>2.11.2</log4j.version>
|
||||
<slf4j.version>1.7.25</slf4j.version>
|
||||
@@ -155,7 +154,7 @@
|
||||
<configuration>
|
||||
<!-- Allow for the ability to pass JVM memory flags for Unit Tests. Since
|
||||
maven-surefire-plugin forks a new JVM, it ignores MAVEN_OPTS.-->
|
||||
<argLine>${test.argLine} -javaagent:${settings.localRepository}/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar ${surefireJacoco}</argLine>
|
||||
<argLine>${test.argLine} ${surefireJacoco}</argLine>
|
||||
<!-- tests whose name starts by Abstract will be ignored -->
|
||||
<excludes>
|
||||
<exclude>**/Abstract*</exclude>
|
||||
@@ -177,7 +176,7 @@
|
||||
<configuration>
|
||||
<!-- Allow for the ability to pass JVM memory flags for Unit Tests. Since
|
||||
maven-failsafe-plugin forks a new JVM, it ignores MAVEN_OPTS.-->
|
||||
<argLine>${test.argLine} -javaagent:${settings.localRepository}/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar ${failsafeJacoco}</argLine>
|
||||
<argLine>${test.argLine} ${failsafeJacoco}</argLine>
|
||||
<excludes>
|
||||
<exclude>**/Abstract*</exclude>
|
||||
</excludes>
|
||||
@@ -1514,14 +1513,7 @@
|
||||
<version>${errorprone.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- JMockit, JUnit and Hamcrest are used for Unit/Integration tests -->
|
||||
<!-- Keep jmockit before junit -->
|
||||
<dependency>
|
||||
<groupId>org.jmockit</groupId>
|
||||
<artifactId>jmockit</artifactId>
|
||||
<version>${jmockit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- JUnit, Mockito and Hamcrest are used for Unit/Integration tests -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
@@ -1540,6 +1532,12 @@
|
||||
<version>1.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>2.28.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- H2 is an in-memory database used for Unit/Integration tests -->
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
@@ -1602,12 +1600,6 @@
|
||||
<version>3.0.1u2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>2.28.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- Converge miscellaneous transitive dependencies. -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml</groupId>
|
||||
|
Reference in New Issue
Block a user