예제 #1
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()));
  }
예제 #2
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);
    }
  }
예제 #3
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()));
  }
예제 #4
0
  public void testExecutePs2pdfConvert() throws Exception {

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

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

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

    Map<String, String> mapInput = new HashMap<String, String>();

    LOG.debug("tool = " + tool.getName());

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

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

    String tmpOutputFile = File.createTempFile("ps2pdf", ".pdf").getAbsolutePath();
    LOG.debug("tmpOutputFile = " + tmpOutputFile);

    Map<String, String> mapOutput = new HashMap<String, String>();
    mapOutput.put("outFile", tmpOutputFile);

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