/** 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())); }
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); } }