Beispiel #1
0
  /**
   * Sets the up before class.
   *
   * @throws IOException
   */
  @Before
  public void setUp() throws IOException {

    j.setRep_name(REPNAME);

    DAFile premis = new DAFile(REPNAME + "a", "premis.xml");
    DAFile file = new DAFile(REPNAME + "a", TIFF_TESTFILE);
    file.setFormatPUID(TIF_PUID);
    List<DAFile> files = new ArrayList<DAFile>();
    files.add(file);
    files.add(premis);
    o.getLatestPackage().getFiles().addAll(files);

    Set<Node> nodes = new HashSet<Node>();
    nodes.add(n);
    ConversionRoutine toPng =
        new ConversionRoutine(
            "TOPNG", "de.uzk.hki.da.cb.CLIConversionStrategy", "cp input output", "bmp");
    ConversionPolicy policy = new ConversionPolicy(TIF_PUID, toPng);
    List<ConversionPolicy> policies = new ArrayList<ConversionPolicy>();
    List<ConversionPolicy> noPolicies = new ArrayList<ConversionPolicy>();
    policies.add(policy);

    PreservationSystem pSystem = mock(PreservationSystem.class);

    when(pSystem.getApplicablePolicies((DAFile) anyObject(), (Boolean) anyObject()))
        .thenReturn(policies)
        .thenReturn(noPolicies);
    when(pSystem.getAdmin()).thenReturn(o.getContractor()); // quick fix
    action.setDistributedConversionAdapter(mock(DistributedConversionAdapter.class));
    action.setPSystem(pSystem);
    n.setWorkAreaRootPath(workAreaRootPath);

    FileUtils.copyFile(Path.makeFile(workAreaRootPath, "premis.xml_MIGRATION_NOTIFY"), premisFile);
  }
Beispiel #2
0
  @Test
  public void testMigrationJustNotify() throws IOException {

    action.implementation();
    assertEquals("", j.getQuestion());
    assertEquals(null, action.getEndStatus());
  }
Beispiel #3
0
  @Test
  public void testMigrationToConfirm() throws IOException {
    premisFile.delete();
    FileUtils.copyFile(Path.makeFile(workAreaRootPath, "premis.xml_MIGRATION_CONFIRM"), premisFile);

    action.implementation();
    assertEquals(C.QUESTION_MIGRATION_ALLOWED, j.getQuestion());
    assertEquals(C.WORKFLOW_STATUS_WAIT___PROCESS_FOR_USER_DECISION_ACTION, action.getEndStatus());
  }
Beispiel #4
0
  /**
   * Conversion instructions get created properly.
   *
   * @throws IOException
   */
  @Test
  public void conversionInstructionsGetCreatedProperly() throws IOException {
    action.implementation();

    ConversionInstruction[] instrs =
        j.getConversion_instructions().toArray(new ConversionInstruction[0]);

    System.out.println(instrs[0]);

    assertEquals(
        REPNAME + "a/" + TIFF_TESTFILE,
        instrs[0].getSource_file().getRep_name()
            + "/"
            + instrs[0].getSource_file().getRelative_path());
    assertEquals("", instrs[0].getTarget_folder());
    assertEquals("TOPNG", instrs[0].getConversion_routine().getName());
  }
Beispiel #5
0
  private void scanTree(byte[] hash, ScanAction scanAction) {

    Value node = this.getCache().get(hash);
    if (node == null) return;

    if (node.isList()) {
      List<Object> siblings = node.asList();
      if (siblings.size() == PAIR_SIZE) {
        Value val = new Value(siblings.get(1));
        if (val.isHashCode()) scanTree(val.asBytes(), scanAction);
      } else {
        for (int j = 0; j < LIST_SIZE; ++j) {
          Value val = new Value(siblings.get(j));
          if (val.isHashCode()) scanTree(val.asBytes(), scanAction);
        }
      }
      scanAction.doOnNode(hash, node);
    }
  }