mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-12 20:43:18 +00:00
Fix dspace-api unit tests to align with code style
This commit is contained in:
@@ -41,6 +41,12 @@ import org.junit.runner.RunWith;
|
||||
@Ignore
|
||||
@RunWith(JMockit.class)
|
||||
public class AbstractDSpaceTest {
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
protected AbstractDSpaceTest() { }
|
||||
|
||||
/**
|
||||
* log4j category
|
||||
*/
|
||||
|
@@ -266,7 +266,10 @@ public class IPMatcherTest {
|
||||
|
||||
|
||||
private ArrayList<String> getAllIp4Except(ArrayList<String> exceptions) {
|
||||
int d1 = 0, d2 = 0, d3 = 0, d4 = 0;
|
||||
int d1 = 0;
|
||||
int d2 = 0;
|
||||
int d3 = 0;
|
||||
int d4 = 0;
|
||||
ArrayList<String> ips = new ArrayList<String>();
|
||||
for (d1 = 0; d1 <= 255; d1 += increment) {
|
||||
for (d2 = 0; d2 <= 255; d2 += increment) {
|
||||
@@ -285,7 +288,10 @@ public class IPMatcherTest {
|
||||
|
||||
private void verifyAllIp4Except(ArrayList<String> exceptions, boolean asserted, IPMatcher ipMatcher)
|
||||
throws IPMatcherException {
|
||||
int d1 = 0, d2 = 0, d3 = 0, d4 = 0;
|
||||
int d1 = 0;
|
||||
int d2 = 0;
|
||||
int d3 = 0;
|
||||
int d4 = 0;
|
||||
for (d1 = 0; d1 <= 255; d1 += increment) {
|
||||
for (d2 = 0; d2 <= 255; d2 += increment) {
|
||||
for (d3 = 0; d3 <= 255; d3 += increment) {
|
||||
|
@@ -584,9 +584,8 @@ public class BundleTest extends AbstractDSpaceObjectTest {
|
||||
@Test
|
||||
public void testInheritCollectionDefaultPolicies() throws AuthorizeException, SQLException {
|
||||
//TODO: we would need a method to get policies from collection, probably better!
|
||||
List<ResourcePolicy> defaultCollectionPolicies = authorizeService.getPoliciesActionFilter(context, collection,
|
||||
Constants
|
||||
.DEFAULT_BITSTREAM_READ);
|
||||
List<ResourcePolicy> defaultCollectionPolicies =
|
||||
authorizeService.getPoliciesActionFilter(context, collection, Constants.DEFAULT_BITSTREAM_READ);
|
||||
Iterator<ResourcePolicy> it = defaultCollectionPolicies.iterator();
|
||||
|
||||
bundleService.inheritCollectionDefaultPolicies(context, b, collection);
|
||||
|
@@ -120,16 +120,19 @@ public class ItemTest extends AbstractDSpaceObjectTest {
|
||||
try {
|
||||
itemService.delete(context, it);
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
try {
|
||||
collectionService.delete(context, collection);
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
try {
|
||||
communityService.delete(context, owningCommunity);
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
context.restoreAuthSystemState();
|
||||
@@ -139,6 +142,7 @@ public class ItemTest extends AbstractDSpaceObjectTest {
|
||||
try {
|
||||
super.destroy();
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1396,9 +1400,8 @@ public class ItemTest extends AbstractDSpaceObjectTest {
|
||||
|
||||
Collection c = createCollection();
|
||||
|
||||
List<ResourcePolicy> defaultCollectionPolicies = authorizeService.getPoliciesActionFilter(context, c,
|
||||
Constants
|
||||
.DEFAULT_BITSTREAM_READ);
|
||||
List<ResourcePolicy> defaultCollectionPolicies =
|
||||
authorizeService.getPoliciesActionFilter(context, c, Constants.DEFAULT_BITSTREAM_READ);
|
||||
List<ResourcePolicy> newPolicies = new ArrayList<ResourcePolicy>();
|
||||
for (ResourcePolicy collRp : defaultCollectionPolicies) {
|
||||
ResourcePolicy rp = resourcePolicyService.clone(context, collRp);
|
||||
|
@@ -13,6 +13,12 @@ package org.dspace.core;
|
||||
* @author mwood
|
||||
*/
|
||||
public class CoreHelpers {
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
private CoreHelpers() { }
|
||||
|
||||
/**
|
||||
* Expose a Context's DBConnection.
|
||||
*
|
||||
|
@@ -27,9 +27,6 @@ import org.junit.Test;
|
||||
*/
|
||||
public class I18nUtilTest extends AbstractDSpaceTest {
|
||||
|
||||
public I18nUtilTest() {
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() {
|
||||
}
|
||||
@@ -147,12 +144,10 @@ public class I18nUtilTest extends AbstractDSpaceTest {
|
||||
// Assert our overridden default.locale is set in I18nUtil
|
||||
assertEquals("Default locale", new Locale("en", "US", "UTF-8"), I18nUtil.getDefaultLocale());
|
||||
|
||||
String key, expResult, result;
|
||||
|
||||
// Test for a stock key
|
||||
key = "jsp.general.home";
|
||||
expResult = "DSpace Home";
|
||||
result = I18nUtil.getMessage(key);
|
||||
String key = "jsp.general.home";
|
||||
String expResult = "DSpace Home";
|
||||
String result = I18nUtil.getMessage(key);
|
||||
assertEquals("Returns the translation of the key if it is defined",
|
||||
expResult, result);
|
||||
|
||||
@@ -168,13 +163,12 @@ public class I18nUtilTest extends AbstractDSpaceTest {
|
||||
@Test
|
||||
public void testGetMessage_String_Locale() {
|
||||
System.out.println("getMessage");
|
||||
String key, expResult, result;
|
||||
Locale locale = Locale.US;
|
||||
|
||||
// Test for a stock key
|
||||
key = "jsp.general.home";
|
||||
expResult = "DSpace Home";
|
||||
result = I18nUtil.getMessage(key, locale);
|
||||
String key = "jsp.general.home";
|
||||
String expResult = "DSpace Home";
|
||||
String result = I18nUtil.getMessage(key, locale);
|
||||
assertEquals("Returns the translation of the key if it is defined",
|
||||
expResult, result);
|
||||
|
||||
|
@@ -44,7 +44,8 @@ public class PasswordHashTest extends AbstractDSpaceTest {
|
||||
@Test
|
||||
public void testConstructors()
|
||||
throws DecoderException {
|
||||
PasswordHash h1, h3;
|
||||
PasswordHash h1;
|
||||
PasswordHash h3;
|
||||
|
||||
// Test null inputs, as from NULL database columns (old EPerson using
|
||||
// unsalted hash, for example).
|
||||
|
@@ -7,7 +7,6 @@
|
||||
*/
|
||||
package org.dspace.statistics.util;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
@@ -69,8 +69,8 @@ public class BasicWorkflowAuthorizationIT
|
||||
protected ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
||||
protected InstallItemService installItemService = ContentServiceFactory.getInstance().getInstallItemService();
|
||||
protected WorkspaceItemService workspaceItemService = ContentServiceFactory.getInstance().getWorkspaceItemService();
|
||||
protected BasicWorkflowItemService basicWorkflowItemService = BasicWorkflowServiceFactory.getInstance()
|
||||
.getBasicWorkflowItemService();
|
||||
protected BasicWorkflowItemService basicWorkflowItemService =
|
||||
BasicWorkflowServiceFactory.getInstance().getBasicWorkflowItemService();
|
||||
protected BasicWorkflowService basicWorkflowService = BasicWorkflowServiceFactory.getInstance()
|
||||
.getBasicWorkflowService();
|
||||
protected EPersonService ePersonService = EPersonServiceFactory.getInstance().getEPersonService();
|
||||
|
@@ -72,8 +72,8 @@ public class BasicWorkflowAuthorizationRolesIT
|
||||
protected ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
||||
protected InstallItemService installItemService = ContentServiceFactory.getInstance().getInstallItemService();
|
||||
protected WorkspaceItemService workspaceItemService = ContentServiceFactory.getInstance().getWorkspaceItemService();
|
||||
protected BasicWorkflowItemService basicWorkflowItemService = BasicWorkflowServiceFactory.getInstance()
|
||||
.getBasicWorkflowItemService();
|
||||
protected BasicWorkflowItemService basicWorkflowItemService =
|
||||
BasicWorkflowServiceFactory.getInstance().getBasicWorkflowItemService();
|
||||
protected BasicWorkflowService basicWorkflowService = BasicWorkflowServiceFactory.getInstance()
|
||||
.getBasicWorkflowService();
|
||||
protected EPersonService ePersonService = EPersonServiceFactory.getInstance().getEPersonService();
|
||||
@@ -90,7 +90,7 @@ public class BasicWorkflowAuthorizationRolesIT
|
||||
protected EPerson member;
|
||||
protected WorkspaceItem wsi;
|
||||
|
||||
protected enum ROLE {ADMIN, SUB, STEP1, STEP2, STEP3;}
|
||||
protected enum ROLE { ADMIN, SUB, STEP1, STEP2, STEP3 }
|
||||
|
||||
protected HashMap<ROLE, Group> roleGroups = new HashMap<>();
|
||||
protected HashMap<ROLE, EPerson> roleEPersons = new HashMap<>();
|
||||
|
Reference in New Issue
Block a user