@Test
  public void shouldDoAsyncConversionGivenConverterName() throws IOException {
    File file = FileUtils.getResourceFileFromContext("test-data/hello.doc");
    Blob blob = Blobs.createBlob(file, "application/msword", null, "hello.doc");
    BlobHolder bh = new SimpleBlobHolder(blob);

    String id = conversionService.scheduleConversion("identity", bh, null);
    assertNotNull(id);

    eventService.waitForAsyncCompletion();

    BlobHolder result = conversionService.getConversionResult(id, true);
    assertNotNull(result);
    List<Blob> blobs = result.getBlobs();
    assertEquals(1, blobs.size());
    Blob resultBlob = blobs.get(0);
    assertEquals(blob.getFilename(), resultBlob.getFilename());
    assertEquals(blob.getMimeType(), resultBlob.getMimeType());
  }
  @Test
  public void testHTMLConverter() throws Exception {
    String converterName = cs.getConverterName("application/vnd.apple.pages", "text/html");
    assertEquals("iwork2html", converterName);

    CommandLineExecutorService cles = Framework.getLocalService(CommandLineExecutorService.class);
    assertNotNull(cles);

    ConverterCheckResult check = cs.isConverterAvailable(converterName);
    assertNotNull(check);
    if (!check.isAvailable()) {
      log.warn("Skipping PDF2Html tests since commandLine is not installed");
      log.warn(" converter check output : " + check.getInstallationMessage());
      log.warn(" converter check output : " + check.getErrorMessage());
      return;
    }

    CommandAvailability ca = cles.getCommandAvailability("pdftohtml");

    if (!ca.isAvailable()) {
      log.warn("pdftohtml command is not available, skipping test");
      return;
    }

    BlobHolder pagesBH = getBlobFromPath("test-docs/hello.pages");
    pagesBH.getBlob().setMimeType("application/vnd.apple.pages");
    BlobHolder result = cs.convert(converterName, pagesBH, null);
    assertNotNull(result);

    List<Blob> blobs = result.getBlobs();
    assertNotNull(blobs);
    assertEquals(2, blobs.size());

    Blob mainBlob = result.getBlob();
    assertEquals("index.html", mainBlob.getFilename());

    Blob subBlob = blobs.get(1);
    assertTrue(subBlob.getFilename().startsWith("index001"));

    String htmlContent = mainBlob.getString();
    assertTrue(htmlContent.contains("hello"));
  }
  @Test
  public void testConverter() throws Exception {
    String converterName = cs.getConverterName("text/plain", "application/pdf");
    assertEquals("any2pdf", converterName);

    checkConverterAvailability(converterName);
    checkCommandAvailability("soffice");

    BlobHolder pdfBH = getBlobFromPath("test-docs/hello.txt");
    Map<String, Serializable> parameters = new HashMap<>();

    BlobHolder result = cs.convert(converterName, pdfBH, parameters);
    assertNotNull(result);

    List<Blob> blobs = result.getBlobs();
    assertNotNull(blobs);
    assertEquals(1, blobs.size());

    Blob mainBlob = result.getBlob();
    String text = DocumentUTUtils.readPdfText(mainBlob.getFile());
    assertTrue(text.contains("Hello") || text.contains("hello"));
  }
  public void testiWorkConverter(String blobPath) throws Exception {
    String converterName = cs.getConverterName("application/vnd.apple.iwork", "application/pdf");
    assertEquals("iwork2pdf", converterName);

    BlobHolder pagesBH = getBlobFromPath(blobPath);
    pagesBH.getBlob().setMimeType("application/vnd.apple.iwork");

    BlobHolder result = cs.convert(converterName, pagesBH, null);
    assertNotNull(result);

    List<Blob> blobs = result.getBlobs();
    assertNotNull(blobs);
    assertEquals(1, blobs.size());

    File pdfFile = File.createTempFile("testingPDFConverter", ".pdf");
    try {
      result.getBlob().transferTo(pdfFile);
      String text = BaseConverterTest.readPdfText(pdfFile).toLowerCase();
      assertTrue(text.contains("hello"));
    } finally {
      pdfFile.delete();
    }
  }