use of gov.loc.repository.bagit.domain.Bag in project bagit-java by LibraryOfCongress.
the class BagReaderTest method testReadVersion0_97Bag.
@Test
public void testReadVersion0_97Bag() throws Exception {
Path rootBag = Paths.get(new File("src/test/resources/bags/v0_97/bag").toURI());
Path[] payloadFiles = new Path[] { rootBag.resolve("data/dir1/test3.txt"), rootBag.resolve("data/dir2/dir3/test5.txt"), rootBag.resolve("data/dir2/test4.txt"), rootBag.resolve("data/test1.txt"), rootBag.resolve("data/test2.txt") };
Bag returnedBag = sut.read(rootBag);
assertNotNull(returnedBag);
assertEquals(new Version(0, 97), returnedBag.getVersion());
Manifest payloadManifest = (Manifest) returnedBag.getPayLoadManifests().toArray()[0];
for (Path payloadFile : payloadFiles) {
assertTrue(payloadManifest.getFileToChecksumMap().containsKey(payloadFile));
}
}
use of gov.loc.repository.bagit.domain.Bag in project bagit-java by LibraryOfCongress.
the class BagReaderTest method testReadBagWithEscapableCharacter.
@Test
public void testReadBagWithEscapableCharacter() throws Exception {
Path rootDir = Paths.get(getClass().getClassLoader().getResource("bags/v0_96/bag-with-escapable-characters").toURI());
Bag bag = sut.read(rootDir);
assertNotNull(bag);
for (Manifest payloadManifest : bag.getPayLoadManifests()) {
for (Path file : payloadManifest.getFileToChecksumMap().keySet()) {
assertTrue(file + " should exist but it doesn't!", Files.exists(file));
}
}
}
use of gov.loc.repository.bagit.domain.Bag in project bagit-java by LibraryOfCongress.
the class BagReaderTest method testReadVersion0_94.
@Test
public void testReadVersion0_94() throws Exception {
Path rootDir = Paths.get(getClass().getClassLoader().getResource("bags/v0_94/bag").toURI());
Bag bag = sut.read(rootDir);
assertEquals(new Version(0, 94), bag.getVersion());
for (SimpleImmutableEntry<String, String> keyValue : bag.getMetadata().getAll()) {
if ("Payload-Oxum".equals(keyValue.getKey())) {
assertEquals("25.5", keyValue.getValue());
}
}
}
use of gov.loc.repository.bagit.domain.Bag in project bagit-java by LibraryOfCongress.
the class BagReaderTest method testReadUTF_16_Encoding.
@Test
public void testReadUTF_16_Encoding() throws Exception {
Metadata expectedMetaData = new Metadata();
expectedMetaData.add("Bag-Software-Agent", "bagit.py <http://github.com/libraryofcongress/bagit-python>");
expectedMetaData.add("Bagging-Date", "2016-02-26");
expectedMetaData.add("Contact-Email", "cadams@loc.gov");
expectedMetaData.add("Contact-Name", "Chris Adams");
expectedMetaData.add("Payload-Oxum", "58.2");
Path bagPath = Paths.get(new File("src/test/resources/UTF-16-encoded-tag-files").toURI());
List<FetchItem> expectedFetchItems = new ArrayList<>();
expectedFetchItems.add(new FetchItem(new URL("http://localhost/foo/data/dir1/test3.txt"), -1l, bagPath.resolve("data/dir1/test3.txt")));
Bag bag = sut.read(bagPath);
assertNotNull(bag);
assertEquals(StandardCharsets.UTF_16, bag.getFileEncoding());
assertEquals(expectedMetaData, bag.getMetadata());
assertEquals(expectedFetchItems, bag.getItemsToFetch());
}
use of gov.loc.repository.bagit.domain.Bag in project bagit-java by LibraryOfCongress.
the class ManifestReaderTest method testReadAllManifests.
@Test
public void testReadAllManifests() throws Exception {
Path rootBag = Paths.get(getClass().getClassLoader().getResource("bags/v0_97/bag").toURI());
Bag bag = new Bag();
bag.setRootDir(rootBag);
ManifestReader.readAllManifests(new StandardBagitAlgorithmNameToSupportedAlgorithmMapping(), rootBag, bag);
assertEquals(1, bag.getPayLoadManifests().size());
assertEquals(1, bag.getTagManifests().size());
}
Aggregations