Skip to content

Commit cea1309

Browse files
committed
added test for writing version 0.95
1 parent 9642767 commit cea1309

1 file changed

Lines changed: 26 additions & 13 deletions

File tree

src/test/java/gov/loc/repository/bagit/writer/BagWriterTest.java

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,32 @@ public void testGetCorrectRelativeOuputPath() throws Exception{
5050
assertTrue(Files.exists(newRoot.resolve("data").resolve("fooFile.txt")));
5151
}
5252

53+
@Test
54+
public void testWriteVersion95() throws Exception{
55+
Path rootDir = Paths.get(getClass().getClassLoader().getResource("bags/v0_95/bag").toURI());
56+
Bag bag = reader.read(rootDir);
57+
File bagitDir = folder.newFolder();
58+
Path bagitDirPath = Paths.get(bagitDir.toURI());
59+
List<Path> expectedPaths = Arrays.asList(bagitDirPath.resolve("tagmanifest-md5.txt"),
60+
bagitDirPath.resolve("manifest-md5.txt"),
61+
bagitDirPath.resolve("bagit.txt"),
62+
bagitDirPath.resolve("package-info.txt"),
63+
bagitDirPath.resolve("data"),
64+
bagitDirPath.resolve("data").resolve("test1.txt"),
65+
bagitDirPath.resolve("data").resolve("test2.txt"),
66+
bagitDirPath.resolve("data").resolve("dir1"),
67+
bagitDirPath.resolve("data").resolve("dir2"),
68+
bagitDirPath.resolve("data").resolve("dir1").resolve("test3.txt"),
69+
bagitDirPath.resolve("data").resolve("dir2").resolve("test4.txt"),
70+
bagitDirPath.resolve("data").resolve("dir2").resolve("dir3"),
71+
bagitDirPath.resolve("data").resolve("dir2").resolve("dir3").resolve("test5.txt"));
72+
73+
BagWriter.write(bag, bagitDirPath);
74+
for(Path expectedPath : expectedPaths){
75+
assertTrue("Expected " + expectedPath + " to exist!", Files.exists(expectedPath));
76+
}
77+
}
78+
5379
@Test
5480
public void testWriteVersion97() throws Exception{
5581
Path rootDir = Paths.get(getClass().getClassLoader().getResource("bags/v0_97/bag").toURI());
@@ -208,17 +234,4 @@ public void testWriteEmptyBagStillCreatesDataDir() throws Exception{
208234
BagWriter.write(bag, bag.getRootDir());
209235
assertTrue(Files.exists(dataDir));
210236
}
211-
212-
@Test
213-
public void foo(){
214-
Path bagRootDir = Paths.get("/tmp/foo");
215-
Path payloadFile = bagRootDir.resolve("data/bar/ham.txt");
216-
Path tagFile = bagRootDir.resolve("addtionalTagFile.txt");
217-
218-
System.err.println("payload relative to data dir : " + payloadFile.relativize(bagRootDir.resolve("data")));
219-
System.err.println("tag file relative to root dir: " + tagFile.relativize(bagRootDir));
220-
221-
System.err.println("data dir relative to payload file: " + bagRootDir.resolve("data").relativize(payloadFile));
222-
System.err.println("root dir relative to tag file : " + bagRootDir.relativize(tagFile));
223-
}
224237
}

0 commit comments

Comments
 (0)