示例#1
0
  /** Test of execute method, of class ToolProcessor. */
  public void testExecuteFileIdentify() throws Exception {
    Tool tool = repo.getTool("file");

    String tmpInputFile = this.getClass().getClassLoader().getResource("ps2pdf-input.ps").getFile();

    LOG.debug("tmpInputFile = " + tmpInputFile);

    LOG.info("TEST file-identify");

    ToolProcessor processor = new ToolProcessor(tool);

    Operation operation = processor.findOperation("identify");
    processor.setOperation(operation);

    Map<String, String> mapInput = new HashMap<String, String>();
    mapInput.put("input", tmpInputFile);

    processor.setInputFileParameters(mapInput);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    processor.next(new StreamProcessor(baos));
    try {
      processor.execute();
    } catch (IOException ex) {
      LOG.error("Exception during execution (maybe unresolved system dependency?): " + ex);
    }
    LOG.info("output: " + new String(baos.toByteArray()));
  }
示例#2
0
  public void testExecuteFileIdentifyStdin() throws Exception {

    LOG.info("TEST file-identify-stdin");

    // This test may throw an "Broken pipe" IOException
    // because file needs not to read the whole file data from
    // stdin and will terminate while the other thread is reading streams.

    Tool tool = repo.getTool("file");

    String tmpInputFile = this.getClass().getClassLoader().getResource("ps2pdf-input.ps").getFile();

    ToolProcessor processor = new ToolProcessor(tool);
    Operation operation = processor.findOperation("identify-stdin");
    processor.setOperation(operation);

    FileInputStream fin = new FileInputStream(new File(tmpInputFile));
    StreamProcessor in = new StreamProcessor(fin);
    in.next(processor);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    baos = new ByteArrayOutputStream();

    processor.next(new StreamProcessor(baos));
    try {
      in.execute();
    } catch (IOException ex) {
      LOG.error("Exception during execution (maybe unresolved system dependency?): " + ex);
    }
    LOG.info("output: " + new String(baos.toByteArray()));
  }
示例#3
0
  public void testExecutePs2pdfConvertStreamed() throws Exception {

    LOG.info("TEST ps2pdf-convert-streamed");
    Tool tool = repo.getTool("ps2pdf");

    String tmpInputFile = this.getClass().getClassLoader().getResource("ps2pdf-input.ps").getFile();
    String tmpOutputFile = File.createTempFile("ps2pdf", ".pdf").getAbsolutePath();

    ToolProcessor processor = new ToolProcessor(tool);
    Operation operation = processor.findOperation("convert-streamed");
    processor.setOperation(operation);

    LOG.debug("tmpInputFile = " + tmpInputFile);

    LOG.debug("tmpOutputFile = " + tmpOutputFile);

    FileInputStream fin = new FileInputStream(new File(tmpInputFile));
    StreamProcessor in = new StreamProcessor(fin);
    in = new StreamProcessor(fin);
    in.next(processor);

    FileOutputStream fout = new FileOutputStream(new File(tmpOutputFile));
    processor.next(new StreamProcessor(fout));

    try {
      in.execute();
    } catch (IOException ex) {
      LOG.error("Exception during execution (maybe unresolved system dependency?): " + ex);
    }
  }