Search in sources :

Example 46 with Bag

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

the class MandatoryVerifierTest method testErrorWhenMissingPayloadDirectory.

@Test(expected = MissingPayloadDirectoryException.class)
public void testErrorWhenMissingPayloadDirectory() throws Exception {
    copyBagToTestFolder();
    Bag bag = reader.read(Paths.get(folder.getRoot().toURI()));
    File dataDir = new File(folder.getRoot(), "data");
    deleteDirectory(Paths.get(dataDir.toURI()));
    MandatoryVerifier.checkPayloadDirectoryExists(bag);
}
Also used : Bag(gov.loc.repository.bagit.domain.Bag) File(java.io.File) PrivateConstructorTest(gov.loc.repository.bagit.PrivateConstructorTest) Test(org.junit.Test)

Example 47 with Bag

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

the class MandatoryVerifierTest method testErrorWhenMissingPayloadManifest.

@Test(expected = MissingPayloadManifestException.class)
public void testErrorWhenMissingPayloadManifest() throws Exception {
    copyBagToTestFolder();
    Bag bag = reader.read(Paths.get(folder.getRoot().toURI()));
    File manifestFile = new File(folder.getRoot(), "manifest-md5.txt");
    manifestFile.delete();
    MandatoryVerifier.checkIfAtLeastOnePayloadManifestsExist(bag.getRootDir(), bag.getVersion());
}
Also used : Bag(gov.loc.repository.bagit.domain.Bag) File(java.io.File) PrivateConstructorTest(gov.loc.repository.bagit.PrivateConstructorTest) Test(org.junit.Test)

Example 48 with Bag

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

the class MandatoryVerifierTest method testErrorWhenFetchItemsDontExist.

@Test(expected = FileNotInPayloadDirectoryException.class)
public void testErrorWhenFetchItemsDontExist() throws Exception {
    rootDir = Paths.get(new File("src/test/resources/bad-fetch-bag").toURI());
    Bag bag = reader.read(rootDir);
    MandatoryVerifier.checkFetchItemsExist(bag.getItemsToFetch(), bag.getRootDir());
}
Also used : Bag(gov.loc.repository.bagit.domain.Bag) File(java.io.File) PrivateConstructorTest(gov.loc.repository.bagit.PrivateConstructorTest) Test(org.junit.Test)

Example 49 with Bag

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

the class QuickVerifierTest method testExceptionIsThrownWhenPayloadOxumDoesntExist.

@Test(expected = PayloadOxumDoesNotExistException.class)
public void testExceptionIsThrownWhenPayloadOxumDoesntExist() throws Exception {
    Bag bag = reader.read(rootDir);
    QuickVerifier.quicklyVerify(bag);
}
Also used : Bag(gov.loc.repository.bagit.domain.Bag) PrivateConstructorTest(gov.loc.repository.bagit.PrivateConstructorTest) Test(org.junit.Test)

Example 50 with Bag

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

the class QuickVerifierTest method testInvalidFileCountForQuickVerify.

@Test(expected = InvalidPayloadOxumException.class)
public void testInvalidFileCountForQuickVerify() throws Exception {
    Path badRootDir = Paths.get(new File("src/test/resources/badPayloadOxumFileCount/bag").toURI());
    Bag bag = reader.read(badRootDir);
    QuickVerifier.quicklyVerify(bag);
}
Also used : Path(java.nio.file.Path) Bag(gov.loc.repository.bagit.domain.Bag) File(java.io.File) PrivateConstructorTest(gov.loc.repository.bagit.PrivateConstructorTest) 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