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