コード例 #1
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());
    }
  }
コード例 #2
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());
    }
  }