use of gov.loc.repository.bagit.domain.Version in project bagit-java by LibraryOfCongress.
the class BagReaderTest method testReadVersion0_93.
@Test
public void testReadVersion0_93() throws Exception {
Path rootDir = Paths.get(getClass().getClassLoader().getResource("bags/v0_93/bag").toURI());
Bag bag = sut.read(rootDir);
assertEquals(new Version(0, 93), 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.Version 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.Version 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.Version in project bagit-java by LibraryOfCongress.
the class BagitFileWriterTest method testWriteBagitFile.
@Test
public void testWriteBagitFile() throws Exception {
File rootDir = folder.newFolder();
Path rootDirPath = Paths.get(rootDir.toURI());
Path bagit = rootDirPath.resolve("bagit.txt");
assertFalse(Files.exists(bagit));
BagitFileWriter.writeBagitFile(new Version(0, 97), StandardCharsets.UTF_8, rootDirPath);
assertTrue(Files.exists(bagit));
// test truncating existing
long originalModified = Files.getLastModifiedTime(bagit).toMillis();
long size = Files.size(bagit);
BagitFileWriter.writeBagitFile(new Version(0, 97), StandardCharsets.UTF_8, rootDirPath);
assertTrue(Files.exists(bagit));
assertTrue(Files.getLastModifiedTime(bagit) + " should be >= " + originalModified, Files.getLastModifiedTime(bagit).toMillis() >= originalModified);
assertEquals(size, Files.size(bagit));
}
use of gov.loc.repository.bagit.domain.Version in project bagit-java by LibraryOfCongress.
the class BagitTextFileReaderTest method testReadBagitFile.
@Test
public void testReadBagitFile() throws Exception {
Path bagitFile = Paths.get(new File("src/test/resources/bagitFiles/bagit-0.97.txt").toURI());
SimpleImmutableEntry<Version, Charset> actualBagitInfo = BagitTextFileReader.readBagitTextFile(bagitFile);
assertEquals(new Version(0, 97), actualBagitInfo.getKey());
assertEquals(StandardCharsets.UTF_8, actualBagitInfo.getValue());
}
Aggregations