Skip to content

Commit

Permalink
Followup on CR-BITMAG-372
Browse files Browse the repository at this point in the history
  • Loading branch information
jolf committed Jan 25, 2017
1 parent b186c99 commit 0186d79
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public ExtractedFileIDsResultSet getFileIDs(XMLGregorianCalendar minTimeStamp, X
try (ResultSet res = ps.executeQuery()){
int i = 0;
while(res.next() && (maxNumberOfResults == null || i < maxNumberOfResults)) {
results.insertFileID(res.getString(1), new Date(res.getLong(2)));
results.insertFileID(res.getString(DatabaseConstants.CS_FILE_ID), new Date(res.getLong(DatabaseConstants.CS_DATE)));
i++;
}

Expand Down Expand Up @@ -334,7 +334,7 @@ public List<String> extractFileIDsWithMaxChecksumDate(Long maxTimeStamp, String
try (ResultSet res = ps.executeQuery()) {
while(res.next() ) {
if(!res.wasNull()) {
results.add(res.getString(1));
results.add(res.getString(DatabaseConstants.CS_FILE_ID));
}
}
} finally {
Expand Down Expand Up @@ -362,9 +362,9 @@ public List<String> extractFileIDsWithMaxChecksumDate(Long maxTimeStamp, String
* @return The checksum entry extracted from the result set.
*/
private ChecksumEntry extractChecksumEntry(ResultSet resSet) throws SQLException {
String fileID = resSet.getString(1);
String checksum = resSet.getString(2);
Date date = new Date(resSet.getLong(3));
String fileID = resSet.getString(DatabaseConstants.CS_FILE_ID);
String checksum = resSet.getString(DatabaseConstants.CS_CHECKSUM);
Date date = new Date(resSet.getLong(DatabaseConstants.CS_DATE));
return new ChecksumEntry(fileID, checksum, date);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import java.util.Date;
import java.util.List;

import javax.xml.datatype.XMLGregorianCalendar;

import org.bitrepository.bitrepositoryelements.ChecksumDataForChecksumSpecTYPE;
import org.bitrepository.common.settings.Settings;
import org.bitrepository.common.settings.TestSettingsProvider;
Expand Down Expand Up @@ -300,6 +298,18 @@ public void testGetChecksumResult() {
addStep("Test with too new a lower limit", "Does not retrieve the file");
extractedChecksums = cache.getChecksumResult(CalendarUtils.getFromMillis(DEFAULT_DATE.getTime() + 1), CalendarUtils.getNow(), DEFAULT_FILE_ID, collectionID);
Assert.assertEquals(extractedChecksums.getEntries().size(), 0);

addStep("Test with exact date as both upper and lower limit", "Does not retrieve the file");
extractedChecksums = cache.getChecksumResult(CalendarUtils.getFromMillis(DEFAULT_DATE.getTime()), CalendarUtils.getFromMillis(DEFAULT_DATE.getTime()), DEFAULT_FILE_ID, collectionID);
Assert.assertEquals(extractedChecksums.getEntries().size(), 0);

addStep("Test with date limit from 1 millis before as lower and exact date a upper limit", "Does retrieve the file");
extractedChecksums = cache.getChecksumResult(CalendarUtils.getFromMillis(DEFAULT_DATE.getTime()-1), CalendarUtils.getFromMillis(DEFAULT_DATE.getTime()), DEFAULT_FILE_ID, collectionID);
Assert.assertEquals(extractedChecksums.getEntries().size(), 1);

addStep("Test with date limit from exact date as lower and 1 millis after date a upper limit", "Does not retrieve the file");
extractedChecksums = cache.getChecksumResult(CalendarUtils.getFromMillis(DEFAULT_DATE.getTime()), CalendarUtils.getFromMillis(DEFAULT_DATE.getTime()+1), DEFAULT_FILE_ID, collectionID);
Assert.assertEquals(extractedChecksums.getEntries().size(), 0);

addStep("Test with too old an upper limit", "Does not retrieve the file");
extractedChecksums = cache.getChecksumResult(CalendarUtils.getEpoch(), CalendarUtils.getFromMillis(DEFAULT_DATE.getTime() - 1), DEFAULT_FILE_ID, collectionID);
Expand Down

0 comments on commit 0186d79

Please sign in to comment.