Merge pull request #1758 from Georgetown-University-Libraries/ds3594m

[DS-3594] Unit Test Clean Up for PostGres
This commit is contained in:
Terry Brady
2017-05-31 11:11:59 -07:00
committed by GitHub
4 changed files with 36 additions and 30 deletions

View File

@@ -97,7 +97,7 @@ public class ChecksumHistoryDAOImplTest
qry.setInteger("id", checkId);
qry.setDate("date", matchDate);
qry.setString("result", ChecksumResultCode.CHECKSUM_MATCH.name());
qry.setString("bitstream", bs.getID().toString()); // FIXME identifier not being set???
qry.setParameter("bitstream", bs.getID()); // FIXME identifier not being set???
qry.executeUpdate();
// Row with nonmatching result code
@@ -107,7 +107,7 @@ public class ChecksumHistoryDAOImplTest
qry.setInteger("id", checkId);
qry.setDate("date", noMatchDate);
qry.setString("result", ChecksumResultCode.CHECKSUM_NO_MATCH.name());
qry.setString("bitstream", bs.getID().toString());
qry.setParameter("bitstream", bs.getID()); // FIXME identifier not being set???
qry.executeUpdate();
// Create one newer row
@@ -117,7 +117,7 @@ public class ChecksumHistoryDAOImplTest
qry.setInteger("id", checkId);
qry.setDate("date", new java.sql.Date(futureDate.getTime()));
qry.setString("result", ChecksumResultCode.CHECKSUM_MATCH.name());
qry.setString("bitstream", bs.getID().toString());
qry.setParameter("bitstream", bs.getID()); // FIXME identifier not being set???
qry.executeUpdate();
// Test!

View File

@@ -122,7 +122,7 @@ public class InstallItemTest extends AbstractUnitTest
public void testInstallItem_validHandle() throws Exception
{
context.turnOffAuthorisationSystem();
String handle = "123456789/567";
String handle = "123456789/56789";
WorkspaceItem is = workspaceItemService.create(context, collection, false);
//Test assigning a specified handle to an item
@@ -149,7 +149,7 @@ public class InstallItemTest extends AbstractUnitTest
authorizeService.isAdmin((Context) any); result = true;
}};
String handle = "123456789/567";
String handle = "123456789/56789";
WorkspaceItem is = workspaceItemService.create(context, collection, false);
WorkspaceItem is2 = workspaceItemService.create(context, collection, false);
@@ -170,7 +170,7 @@ public class InstallItemTest extends AbstractUnitTest
public void testRestoreItem() throws Exception
{
context.turnOffAuthorisationSystem();
String handle = "123456789/567";
String handle = "123456789/56789";
WorkspaceItem is = workspaceItemService.create(context, collection, false);
//get current date
@@ -240,7 +240,7 @@ public class InstallItemTest extends AbstractUnitTest
{
//create a dummy WorkspaceItem
context.turnOffAuthorisationSystem();
String handle = "123456789/567";
String handle = "123456789/56789";
WorkspaceItem is = workspaceItemService.create(context, collection, false);
// Set "today" as "dc.date.issued"
@@ -274,7 +274,7 @@ public class InstallItemTest extends AbstractUnitTest
{
//create a dummy WorkspaceItem with no dc.date.issued
context.turnOffAuthorisationSystem();
String handle = "123456789/567";
String handle = "123456789/56789";
WorkspaceItem is = workspaceItemService.create(context, collection, false);
Item result = installItemService.installItem(context, is, handle);
@@ -293,7 +293,7 @@ public class InstallItemTest extends AbstractUnitTest
{
//create a dummy WorkspaceItem
context.turnOffAuthorisationSystem();
String handle = "123456789/567";
String handle = "123456789/56789";
WorkspaceItem is = workspaceItemService.create(context, collection, false);
// Set "today" as "dc.date.issued"

View File

@@ -107,28 +107,30 @@ public class ItemTest extends AbstractDSpaceObjectTest
@Override
public void destroy()
{
// try {
context.turnOffAuthorisationSystem();
//Get new instances, god knows what happended before
// it = itemService.find(context, it.getID());
// collection = collectionService.find(context, collection.getID());
// owningCommunity = communityService.find(context, owningCommunity.getID());
//
// communityService.delete(context, owningCommunity);
// context.commit();
// context.restoreAuthSystemState();
it = null;
collection = null;
owningCommunity = null;
context.turnOffAuthorisationSystem();
try {
itemService.delete(context, it);
} catch(Exception e){
}
try {
collectionService.delete(context, collection);
} catch(Exception e){
}
try {
communityService.delete(context, owningCommunity);
} catch(Exception e){
}
context.restoreAuthSystemState();
it = null;
collection = null;
owningCommunity = null;
try {
super.destroy();
// } catch (SQLException | AuthorizeException | IOException ex) {
// if(context.isValid())
// {
// context.abort();
// }
// log.error("Error in destroy", ex);
// fail("Error in destroy: " + ex.getMessage());
// }
} catch(Exception e){
}
}

View File

@@ -206,6 +206,10 @@ public class GroupTest extends AbstractUnitTest {
List<String> names = new ArrayList<>();
List<String> sortedNames = new ArrayList<>();
for (Group group : groups) {
// Ignore any unnamed groups. This is only necessary when running unit tests via a persistent database (e.g. Postgres) as unnamed groups may be created by other tests.
if (group.getName() == null) {
continue;
}
names.add(group.getName());
sortedNames.add(group.getName());
}