use of gov.loc.repository.bagit.domain.Manifest in project bagit-java by LibraryOfCongress.
the class PayloadWriterTest method testWritePayloadFiles.
@Test
public void testWritePayloadFiles() throws IOException, URISyntaxException {
Path rootDir = Paths.get(getClass().getClassLoader().getResource("bags/v0_97/bag").toURI());
Path testFile = Paths.get(getClass().getClassLoader().getResource("bags/v0_97/bag/data/dir1/test3.txt").toURI());
Manifest manifest = new Manifest(StandardSupportedAlgorithms.MD5);
manifest.getFileToChecksumMap().put(testFile, "someHashValue");
Set<Manifest> payloadManifests = new HashSet<>();
payloadManifests.add(manifest);
File outputDir = folder.newFolder();
File copiedFile = new File(outputDir, "data/dir1/test3.txt");
assertFalse(copiedFile.exists() || copiedFile.getParentFile().exists());
PayloadWriter.writePayloadFiles(payloadManifests, new ArrayList<>(), Paths.get(outputDir.toURI()), rootDir);
assertTrue(copiedFile.exists() && copiedFile.getParentFile().exists());
}
use of gov.loc.repository.bagit.domain.Manifest in project bagit-java by LibraryOfCongress.
the class PayloadWriterTest method testWritePayloadFilesMinusFetchFiles.
@Test
public void testWritePayloadFilesMinusFetchFiles() throws IOException, URISyntaxException {
Path rootDir = Paths.get(getClass().getClassLoader().getResource("bags/v0_97/bag").toURI());
Path testFile = Paths.get(getClass().getClassLoader().getResource("bags/v0_97/bag/data/dir1/test3.txt").toURI());
Manifest manifest = new Manifest(StandardSupportedAlgorithms.MD5);
manifest.getFileToChecksumMap().put(testFile, "someHashValue");
Set<Manifest> payloadManifests = new HashSet<>();
payloadManifests.add(manifest);
File outputDir = folder.newFolder();
File copiedFile = new File(outputDir, "data/dir1/test3.txt");
assertFalse(copiedFile.exists() || copiedFile.getParentFile().exists());
PayloadWriter.writePayloadFiles(payloadManifests, Arrays.asList(new FetchItem(null, null, Paths.get("data/dir1/test3.txt"))), Paths.get(outputDir.toURI()), rootDir.resolve("data"));
assertFalse(copiedFile.exists() && copiedFile.getParentFile().exists());
}
Aggregations