Skip to content
Permalink
Browse files

Merge pull request #1746 from Georgetown-University-Libraries/ds3594

[DS-3594] Refine unit tests to run against postgres
  • Loading branch information...
terrywbrady committed May 31, 2017
2 parents 40b05ec + 593cc08 commit 094f775b6a6e047621ba4d96e31e07af663d1ff6
@@ -97,7 +97,7 @@ public void testDeleteByDateAndCode()
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 void testDeleteByDateAndCode()
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 void testDeleteByDateAndCode()
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!
@@ -122,7 +122,7 @@ public void testInstallItem_Context_InProgressSubmission() throws Exception
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 void testInstallItem_invalidHandle() throws Exception
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 void testInstallItem_invalidHandle() throws Exception
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 void testInstallItem_todayAsIssuedDate() throws Exception
{
//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 void testInstallItem_nullIssuedDate() throws Exception
{
//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 void testRestoreItem_todayAsIssuedDate() throws Exception
{
//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"
@@ -107,28 +107,30 @@ public void init()
@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){
}
}


@@ -206,6 +206,10 @@ public void findAllNameSort() throws SQLException {
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());
}

0 comments on commit 094f775

Please sign in to comment.
You can’t perform that action at this time.