Search in sources :

Example 6 with BagReader

use of gov.loc.repository.bagit.reader.BagReader in project bagit-java by LibraryOfCongress.

the class ReaderWriterVerifierIntegrationTest method testReaderWriterVersion2_0.

@Test
public void testReaderWriterVersion2_0() throws Exception {
    BagReader reader = new BagReader();
    Path rootDir = Paths.get(this.getClass().getClassLoader().getResource("bags/v2_0/bag").toURI());
    Bag bag = reader.read(rootDir);
    Path outputDir = Paths.get(folder.newFolder().toURI());
    BagWriter.write(bag, outputDir);
    testBagsEqual(rootDir, outputDir);
    try (BagVerifier verifier = new BagVerifier()) {
        verifier.isValid(reader.read(outputDir), true);
    }
}
Also used : Path(java.nio.file.Path) BagVerifier(gov.loc.repository.bagit.verify.BagVerifier) BagReader(gov.loc.repository.bagit.reader.BagReader) Bag(gov.loc.repository.bagit.domain.Bag) Test(org.junit.Test)

Example 7 with BagReader

use of gov.loc.repository.bagit.reader.BagReader in project bagit-java by LibraryOfCongress.

the class ReaderWriterVerifierIntegrationTest method testReaderWriterVersion97.

@Test
public void testReaderWriterVersion97() throws Exception {
    BagReader reader = new BagReader();
    Path rootDir = Paths.get(this.getClass().getClassLoader().getResource("bags/v0_97/bag").toURI());
    Bag bag = reader.read(rootDir);
    Path outputDir = Paths.get(folder.newFolder().toURI());
    BagWriter.write(bag, outputDir);
    testBagsEqual(rootDir, outputDir);
    try (BagVerifier verifier = new BagVerifier()) {
        verifier.isValid(reader.read(outputDir), true);
    }
}
Also used : Path(java.nio.file.Path) BagVerifier(gov.loc.repository.bagit.verify.BagVerifier) BagReader(gov.loc.repository.bagit.reader.BagReader) Bag(gov.loc.repository.bagit.domain.Bag) Test(org.junit.Test)

Example 8 with BagReader

use of gov.loc.repository.bagit.reader.BagReader in project bagit-java by LibraryOfCongress.

the class ReaderWriterVerifierIntegrationTest method testReaderWriterVersion93.

@Test
public void testReaderWriterVersion93() throws Exception {
    try (BagVerifier verifier = new BagVerifier()) {
        BagReader reader = new BagReader();
        Path rootDir = Paths.get(this.getClass().getClassLoader().getResource("bags/v0_93/bag").toURI());
        Path outputDir = Paths.get(folder.newFolder().toURI());
        Bag bag = reader.read(rootDir);
        verifier.isValid(bag, true);
        BagWriter.write(bag, outputDir);
        testBagsEqual(rootDir, outputDir);
        verifier.isValid(reader.read(outputDir), true);
    }
}
Also used : Path(java.nio.file.Path) BagVerifier(gov.loc.repository.bagit.verify.BagVerifier) BagReader(gov.loc.repository.bagit.reader.BagReader) Bag(gov.loc.repository.bagit.domain.Bag) Test(org.junit.Test)

Example 9 with BagReader

use of gov.loc.repository.bagit.reader.BagReader in project bagit-java by LibraryOfCongress.

the class ReaderWriterVerifierIntegrationTest method testReaderWriterVersion96.

@Test
public void testReaderWriterVersion96() throws Exception {
    BagReader reader = new BagReader();
    Path rootDir = Paths.get(this.getClass().getClassLoader().getResource("bags/v0_96/bag").toURI());
    Bag bag = reader.read(rootDir);
    Path outputDir = Paths.get(folder.newFolder().toURI());
    BagWriter.write(bag, outputDir);
    testBagsEqual(rootDir, outputDir);
    try (BagVerifier verifier = new BagVerifier()) {
        verifier.isValid(reader.read(outputDir), true);
    }
}
Also used : Path(java.nio.file.Path) BagVerifier(gov.loc.repository.bagit.verify.BagVerifier) BagReader(gov.loc.repository.bagit.reader.BagReader) Bag(gov.loc.repository.bagit.domain.Bag) Test(org.junit.Test)

Example 10 with BagReader

use of gov.loc.repository.bagit.reader.BagReader in project bagit-java by LibraryOfCongress.

the class ReaderWriterVerifierIntegrationTest method testReaderWriterVersion94.

@Test
public void testReaderWriterVersion94() throws Exception {
    BagReader reader = new BagReader();
    Path rootDir = Paths.get(this.getClass().getClassLoader().getResource("bags/v0_94/bag").toURI());
    Bag bag = reader.read(rootDir);
    Path outputDir = Paths.get(folder.newFolder().toURI());
    BagWriter.write(bag, outputDir);
    testBagsEqual(rootDir, outputDir);
    try (BagVerifier verifier = new BagVerifier()) {
        verifier.isValid(reader.read(outputDir), true);
    }
}
Also used : Path(java.nio.file.Path) BagVerifier(gov.loc.repository.bagit.verify.BagVerifier) BagReader(gov.loc.repository.bagit.reader.BagReader) Bag(gov.loc.repository.bagit.domain.Bag) Test(org.junit.Test)

Aggregations

BagReader (gov.loc.repository.bagit.reader.BagReader)10 Bag (gov.loc.repository.bagit.domain.Bag)9 Path (java.nio.file.Path)9 Test (org.junit.Test)9 BagVerifier (gov.loc.repository.bagit.verify.BagVerifier)6 File (java.io.File)2 PrivateConstructorTest (gov.loc.repository.bagit.PrivateConstructorTest)1 InputStream (java.io.InputStream)1