コード例 #1
0
  @Test
  public void fileUriTest() throws Exception {
    String origSrc = "";
    if (sampleFilePath.contains(":/")) {
      origSrc = "file://" + sampleFilePath;
    } else {
      origSrc = "file:///" + sampleFilePath;
    }

    Dcp sip = new Dcp();
    DcsFile file = new DcsFile();
    file.setId("example:/file");
    file.setSource(origSrc);
    file.setExtant(true);
    sip.addFile(file);
    String id = ingest.getSipStager().addSIP(sip);

    ExternalContentStager ecs = new ExternalContentStager();
    ecs.setIngestFramework(ingest);

    ecs.execute(id);

    sip = ingest.getSipStager().getSIP(id);
    DcsFile retrieved = sip.getFiles().iterator().next();
    Assert.assertTrue(origSrc != retrieved.getSource());
    Assert.assertTrue(ingest.getFileContentStager().contains(retrieved.getSource()));
  }
コード例 #2
0
  @Test
  public void untouchedStagedFileTest() throws Exception {
    StagedFile staged =
        ingest.getFileContentStager().add(IOUtils.toInputStream("stagedContent"), null);
    Dcp sip = new Dcp();
    DcsFile file = new DcsFile();
    file.setId("example:/file");
    file.setSource(staged.getReferenceURI());
    file.setExtant(true);
    sip.addFile(file);
    String id = ingest.getSipStager().addSIP(sip);

    ExternalContentStager ecs = new ExternalContentStager();
    ecs.setIngestFramework(ingest);

    ecs.execute(id);

    sip = ingest.getSipStager().getSIP(id);
    DcsFile retrieved = sip.getFiles().iterator().next();
    Assert.assertEquals(staged.getReferenceURI(), retrieved.getSource());
  }
コード例 #3
0
  @Test
  public void calculateFixityTest() throws Exception {
    String origSrc = "";
    if (sampleFilePath.contains(":/")) {
      origSrc = "file://" + sampleFilePath;
    } else {
      origSrc = "file:///" + sampleFilePath;
    }

    Dcp sip = new Dcp();
    DcsFile file = new DcsFile();
    file.setId("example:/file");
    file.setSource(origSrc);
    file.setExtant(true);
    sip.addFile(file);
    String id = ingest.getSipStager().addSIP(sip);

    ExternalContentStager ecs = new ExternalContentStager();
    ecs.setAlwaysCalculateFixityFor("SHA-1");
    ecs.setIngestFramework(ingest);

    ecs.execute(id);

    sip = ingest.getSipStager().getSIP(id);
    DcsFile retrieved = sip.getFiles().iterator().next();

    String stagedSipRef = ingest.getFileContentStager().get(retrieved.getSource()).getSipRef();

    DcsFile stagedFile = ingest.getSipStager().getSIP(stagedSipRef).getFiles().iterator().next();

    Assert.assertEquals(1, stagedFile.getFixity().size());

    DcsEvent digestEvent =
        ingest.getEventManager().getEventByType(stagedSipRef, Events.FIXITY_DIGEST);
    Assert.assertNotNull(digestEvent);

    for (DcsEntityReference er : digestEvent.getTargets()) {
      Assert.assertEquals(stagedFile.getId(), er.getRef());
    }
  }
コード例 #4
0
  @Test
  public void untouchedNonExtantFileUriTest() throws Exception {
    String origSrc = "file://" + sampleFilePath;

    Dcp sip = new Dcp();
    DcsFile file = new DcsFile();
    file.setId("example:/file");
    file.setSource(origSrc);
    file.setExtant(false);
    sip.addFile(file);
    String id = ingest.getSipStager().addSIP(sip);

    ExternalContentStager ecs = new ExternalContentStager();
    ecs.setIngestFramework(ingest);

    ecs.execute(id);

    sip = ingest.getSipStager().getSIP(id);
    DcsFile retrieved = sip.getFiles().iterator().next();
    Assert.assertEquals(origSrc, retrieved.getSource());
    Assert.assertFalse(ingest.getFileContentStager().contains(retrieved.getSource()));
  }
コード例 #5
0
  @Test
  public void downloadEventTest() throws Exception {
    String origSrc = "";
    if (sampleFilePath.contains(":/")) {
      origSrc = "file://" + sampleFilePath;
    } else {
      origSrc = "file:///" + sampleFilePath;
    }

    Dcp sip = new Dcp();
    DcsFile file = new DcsFile();
    file.setId("example:/file");
    file.setSource(origSrc);
    file.setExtant(true);
    sip.addFile(file);
    String id = ingest.getSipStager().addSIP(sip);

    ExternalContentStager ecs = new ExternalContentStager();
    ecs.setIngestFramework(ingest);

    ecs.execute(id);

    sip = ingest.getSipStager().getSIP(id);
    DcsFile retrieved = sip.getFiles().iterator().next();

    String stagedSipRef = ingest.getFileContentStager().get(retrieved.getSource()).getSipRef();

    DcsFile stagedFile = ingest.getSipStager().getSIP(stagedSipRef).getFiles().iterator().next();

    DcsEvent upload = ingest.getEventManager().getEventByType(stagedSipRef, Events.FILE_DOWNLOAD);
    Assert.assertNotNull(upload);

    for (DcsEntityReference er : upload.getTargets()) {
      Assert.assertEquals(stagedFile.getId(), er.getRef());
    }
  }