use of gov.loc.repository.bagit.domain.Bag in project bagit-java by LibraryOfCongress.
the class QuickVerifierTest method testCanQuickVerify.
@Test
public void testCanQuickVerify() throws Exception {
Bag bag = reader.read(rootDir);
boolean canQuickVerify = QuickVerifier.canQuickVerify(bag);
assertFalse("Since " + bag.getRootDir() + " DOES NOT contain the metadata Payload-Oxum then it should return false!", canQuickVerify);
Path passingRootDir = Paths.get(new File("src/test/resources/bags/v0_94/bag").toURI());
bag = reader.read(passingRootDir);
canQuickVerify = QuickVerifier.canQuickVerify(bag);
assertTrue("Since " + bag.getRootDir() + " DOES contain the metadata Payload-Oxum then it should return true!", canQuickVerify);
}
use of gov.loc.repository.bagit.domain.Bag in project bagit-java by LibraryOfCongress.
the class BagWriterTest method testWriteVersion95.
@Test
public void testWriteVersion95() throws Exception {
Path rootDir = Paths.get(getClass().getClassLoader().getResource("bags/v0_95/bag").toURI());
Bag bag = reader.read(rootDir);
File bagitDir = folder.newFolder();
Path bagitDirPath = Paths.get(bagitDir.toURI());
List<Path> expectedPaths = Arrays.asList(bagitDirPath.resolve("tagmanifest-md5.txt"), bagitDirPath.resolve("manifest-md5.txt"), bagitDirPath.resolve("bagit.txt"), bagitDirPath.resolve("package-info.txt"), bagitDirPath.resolve("data"), bagitDirPath.resolve("data").resolve("test1.txt"), bagitDirPath.resolve("data").resolve("test2.txt"), bagitDirPath.resolve("data").resolve("dir1"), bagitDirPath.resolve("data").resolve("dir2"), bagitDirPath.resolve("data").resolve("dir1").resolve("test3.txt"), bagitDirPath.resolve("data").resolve("dir2").resolve("test4.txt"), bagitDirPath.resolve("data").resolve("dir2").resolve("dir3"), bagitDirPath.resolve("data").resolve("dir2").resolve("dir3").resolve("test5.txt"));
BagWriter.write(bag, bagitDirPath);
for (Path expectedPath : expectedPaths) {
assertTrue("Expected " + expectedPath + " to exist!", Files.exists(expectedPath));
}
}
use of gov.loc.repository.bagit.domain.Bag in project bagit-java by LibraryOfCongress.
the class BagWriterTest method testWriteVersion2_0.
@Test
public void testWriteVersion2_0() throws Exception {
Path rootDir = Paths.get(getClass().getClassLoader().getResource("bags/v2_0/bag").toURI());
Bag bag = reader.read(rootDir);
File bagitDir = folder.newFolder();
Path bagitDirPath = Paths.get(bagitDir.toURI());
List<Path> expectedPaths = Arrays.asList(bagitDirPath.resolve(".bagit"), bagitDirPath.resolve(".bagit").resolve("manifest-md5.txt"), bagitDirPath.resolve(".bagit").resolve("bagit.txt"), bagitDirPath.resolve(".bagit").resolve("bag-info.txt"), bagitDirPath.resolve(".bagit").resolve("tagmanifest-md5.txt"), bagitDirPath.resolve("test1.txt"), bagitDirPath.resolve("test2.txt"), bagitDirPath.resolve("dir1"), bagitDirPath.resolve("dir2"), bagitDirPath.resolve("dir1").resolve("test3.txt"), bagitDirPath.resolve("dir2").resolve("test4.txt"), bagitDirPath.resolve("dir2").resolve("dir3"), bagitDirPath.resolve("dir2").resolve("dir3").resolve("test5.txt"));
BagWriter.write(bag, bagitDirPath);
for (Path expectedPath : expectedPaths) {
assertTrue("Expected " + expectedPath + " to exist!", Files.exists(expectedPath));
}
}
use of gov.loc.repository.bagit.domain.Bag in project bagit-java by LibraryOfCongress.
the class BagWriterTest method testWriteHoley.
@Test
public void testWriteHoley() throws Exception {
Path rootDir = Paths.get(getClass().getClassLoader().getResource("bags/v0_96/holey-bag").toURI());
Bag bag = reader.read(rootDir);
File bagitDir = folder.newFolder();
BagWriter.write(bag, Paths.get(bagitDir.toURI()));
assertTrue(bagitDir.exists());
File fetchFile = new File(bagitDir, "fetch.txt");
assertTrue(fetchFile.exists());
}
use of gov.loc.repository.bagit.domain.Bag in project bagit-java by LibraryOfCongress.
the class PathUtilsTest method testGetDataDirUsingBag.
@Test
public void testGetDataDirUsingBag() throws IOException {
Bag bag = new Bag(new Version(2, 0));
bag.setRootDir(Paths.get("foo"));
Path expectedPath = bag.getRootDir();
Path actualPath = PathUtils.getDataDir(bag);
assertEquals(expectedPath, actualPath);
bag = new Bag(new Version(0, 97));
bag.setRootDir(Paths.get("foo"));
expectedPath = bag.getRootDir().resolve("data");
actualPath = PathUtils.getDataDir(bag);
assertEquals(expectedPath, actualPath);
}
Aggregations