Exemplo n.º 1
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);
    }
  }
Exemplo n.º 2
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);
    }
  }
Exemplo n.º 3
0
  @Test
  public void canFollowLogfile() throws IOException {
    File tempFile =
        File.createTempFile("commons-io", "", new File(System.getProperty("java.io.tmpdir")));
    tempFile.deleteOnExit();
    System.out.println("Temp file = " + tempFile.getAbsolutePath());
    PrintStream log = new PrintStream(tempFile);
    LogfileFollower follower = new LogfileFollower(tempFile);
    List<String> lines;

    // Empty file:
    lines = follower.newLines();
    assertEquals(0, lines.size());

    // Write two lines:
    log.println("Line 1");
    log.println("Line 2");
    lines = follower.newLines();
    assertEquals(2, lines.size());
    assertEquals("Line 2", lines.get(1));

    // Write one more line:
    log.println("Line 3");
    lines = follower.newLines();
    assertEquals(1, lines.size());
    assertEquals("Line 3", lines.get(0));

    // Write one and a half line and finish later:
    log.println("Line 4");
    log.print("Line 5 begin");
    lines = follower.newLines();
    assertEquals(1, lines.size());

    // End last line and start a new one:
    log.println(" end");
    log.print("Line 6 begin");
    lines = follower.newLines();
    assertEquals(1, lines.size());
    assertEquals("Line 5 begin end", lines.get(0));

    // End last line:
    log.println(" end");
    lines = follower.newLines();
    assertEquals(1, lines.size());
    assertEquals("Line 6 begin end", lines.get(0));

    // A line only missing a newline:
    log.print("Line 7");
    lines = follower.newLines();
    assertEquals(0, lines.size());
    log.println();
    lines = follower.newLines();
    assertEquals(1, lines.size());
    assertEquals("Line 7", lines.get(0));

    // Delete:
    log.close();
    lines = follower.newLines();
    assertEquals(0, lines.size());
  }
Exemplo n.º 4
0
  @Before
  public void setUp() throws Exception {
    _rgchPwTest = new char[] {'p', 'a', 's', 's', 'w', 'o', 'r', 'd'};

    _fileExisting = File.createTempFile("obzvaultexisting", ".vault");
    _strDecryptedExisting = "existing";
    OBZVaultDocument doc = new OBZVaultDocument();
    doc.setAppVersion("X.Y.DEV");
    doc.setText(_strDecryptedExisting);
    doc.saveAsVaultDoc(_fileExisting, _rgchPwTest);

    _fileText = File.createTempFile("obzvaulttext", ".txt");
    _strText = "Hello world!";
    OutputStream os = new FileOutputStream(_fileText);
    os.write(_strText.getBytes());
    os.close();
  }
Exemplo n.º 5
0
 /**
  * Set up.
  *
  * @throws Exception
  */
 @BeforeClass
 public static void setUpClass() throws Exception {
   URL sigFileV67Url = new URL(SIGNATURE_FILE_V67_URL);
   InputStream sigFileStream = sigFileV67Url.openStream();
   File tmpSigFile = File.createTempFile("tmpsigfile", ".xml");
   FileOutputStream fos = new FileOutputStream(tmpSigFile);
   IOUtils.copy(sigFileStream, fos);
   fos.close();
   dihj = DroidIdentification.getInstance(tmpSigFile.getAbsolutePath());
 }
Exemplo n.º 6
0
 /**
  * Test ODT file format identification
  *
  * @throws IOException
  */
 @Test
 public void testIdentifyOdt() throws IOException {
   InputStream odtTestFileStream =
       DroidIdentificationTest.class.getResourceAsStream("testfile.odt");
   File tmpOdtTestFile = File.createTempFile("odttestfile", ".odt");
   FileOutputStream fos = new FileOutputStream(tmpOdtTestFile);
   IOUtils.copy(odtTestFileStream, fos);
   fos.close();
   String result = dihj.identify(tmpOdtTestFile.getAbsolutePath());
   if (result.isEmpty()) {
     fail("No identification result");
   }
   assertEquals("fmt/291", result);
 }