Search in sources :

Example 36 with Bag

use of gov.loc.repository.bagit.domain.Bag in project bagit-java by LibraryOfCongress.

the class BagVerifierTest method testVersion2_0IsValid.

@Test
public void testVersion2_0IsValid() throws Exception {
    rootDir = Paths.get(new File("src/test/resources/bags/v2_0/bag").toURI());
    Bag bag = reader.read(rootDir);
    sut.isValid(bag, true);
}
Also used : Bag(gov.loc.repository.bagit.domain.Bag) File(java.io.File) Test(org.junit.Test)

Example 37 with Bag

use of gov.loc.repository.bagit.domain.Bag in project bagit-java by LibraryOfCongress.

the class BagVerifierTest method testCanQuickVerify.

@Test
public void testCanQuickVerify() throws Exception {
    Bag bag = reader.read(rootDir);
    boolean canQuickVerify = BagVerifier.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 = BagVerifier.canQuickVerify(bag);
    assertTrue("Since " + bag.getRootDir() + " DOES contain the metadata Payload-Oxum then it should return true!", canQuickVerify);
}
Also used : Path(java.nio.file.Path) Bag(gov.loc.repository.bagit.domain.Bag) File(java.io.File) Test(org.junit.Test)

Example 38 with Bag

use of gov.loc.repository.bagit.domain.Bag in project bagit-java by LibraryOfCongress.

the class BagVerifierTest method testAddSHA3SupportViaExtension.

@Test
public void testAddSHA3SupportViaExtension() throws Exception {
    Path sha3BagDir = Paths.get(new File("src/test/resources/sha3Bag").toURI());
    MySupportedNameToAlgorithmMapping mapping = new MySupportedNameToAlgorithmMapping();
    BagReader extendedReader = new BagReader(mapping);
    Bag bag = extendedReader.read(sha3BagDir);
    try (BagVerifier extendedSut = new BagVerifier(mapping)) {
        extendedSut.isValid(bag, true);
    }
}
Also used : Path(java.nio.file.Path) BagReader(gov.loc.repository.bagit.reader.BagReader) Bag(gov.loc.repository.bagit.domain.Bag) File(java.io.File) Test(org.junit.Test)

Example 39 with Bag

use of gov.loc.repository.bagit.domain.Bag in project bagit-java by LibraryOfCongress.

the class BagVerifierTest method testQuickVerify.

@Test
public void testQuickVerify() throws Exception {
    Path passingRootDir = Paths.get(new File("src/test/resources/bags/v0_94/bag").toURI());
    Bag bag = reader.read(passingRootDir);
    BagVerifier.quicklyVerify(bag);
}
Also used : Path(java.nio.file.Path) Bag(gov.loc.repository.bagit.domain.Bag) File(java.io.File) Test(org.junit.Test)

Example 40 with Bag

use of gov.loc.repository.bagit.domain.Bag in project bagit-java by LibraryOfCongress.

the class BagVerifierTest method testIsComplete.

@Test
public void testIsComplete() throws Exception {
    Bag bag = reader.read(rootDir);
    sut.isComplete(bag, true);
}
Also used : Bag(gov.loc.repository.bagit.domain.Bag) Test(org.junit.Test)

Aggregations

Bag (gov.loc.repository.bagit.domain.Bag)71 Test (org.junit.Test)67 Path (java.nio.file.Path)55 File (java.io.File)38 PrivateConstructorTest (gov.loc.repository.bagit.PrivateConstructorTest)28 Version (gov.loc.repository.bagit.domain.Version)11 InputStream (java.io.InputStream)10 Manifest (gov.loc.repository.bagit.domain.Manifest)9 BagReader (gov.loc.repository.bagit.reader.BagReader)9 BagVerifier (gov.loc.repository.bagit.verify.BagVerifier)6 Metadata (gov.loc.repository.bagit.domain.Metadata)2 CorruptChecksumException (gov.loc.repository.bagit.exceptions.CorruptChecksumException)2 FileNotInPayloadDirectoryException (gov.loc.repository.bagit.exceptions.FileNotInPayloadDirectoryException)2 InvalidBagitFileFormatException (gov.loc.repository.bagit.exceptions.InvalidBagitFileFormatException)2 MaliciousPathException (gov.loc.repository.bagit.exceptions.MaliciousPathException)2 MissingBagitFileException (gov.loc.repository.bagit.exceptions.MissingBagitFileException)2 MissingPayloadDirectoryException (gov.loc.repository.bagit.exceptions.MissingPayloadDirectoryException)2 MissingPayloadManifestException (gov.loc.repository.bagit.exceptions.MissingPayloadManifestException)2 UnparsableVersionException (gov.loc.repository.bagit.exceptions.UnparsableVersionException)2 UnsupportedAlgorithmException (gov.loc.repository.bagit.exceptions.UnsupportedAlgorithmException)2