@Test
 public void testGetExtensionFor() {
   assertEquals(
       "odt", mimeType.getStandardExtensionForMimeType("application/vnd.oasis.opendocument.text"));
   assertTrue(
       mimeType.doesExtensionMatchMimeType("odt", "application/vnd.oasis.opendocument.text"));
 }
 @Test
 public void testScratch() {
   assertEquals(
       "Standard extension of scratch was wrongly returned",
       "sb",
       mimeType.getStandardExtensionForMimeType("application/x-mit-scratch"));
   assertTrue(
       "doesExtensionMatchMimeType of Scratch didn't return true",
       mimeType.doesExtensionMatchMimeType("sb", "application/x-mit-scratch"));
   assertMime("application/x-mit-scratch", "test2-sb.sbx");
 }
  /**
   * Generate a Thumbnail of the input file. Try all available Thumbnailers and use the first that
   * returns an image.
   *
   * <p>MIME-Detection narrows the selection of Thumbnailers to try:
   * <li>First all Thumbnailers that declare to accept such a MIME Type are used
   * <li>Then all Thumbnailers that declare to accept all possible MIME Types.
   *
   * @param input Input file that should be processed
   * @param output File in which should be written
   * @param mimeType MIME-Type of input file (null if unknown)
   * @throws IOException If file cannot be read/written.
   * @throws ThumbnailerException If the thumbnailing process failed (i.e., no thumbnailer could
   *     generate an Thumbnail. The last ThumbnailerException is re-thrown.)
   */
  public void generateThumbnail(File input, File output, String mimeType)
      throws IOException, ThumbnailerException {
    FileDoesNotExistException.check(input, "The input file");
    FileDoesNotExistException.checkWrite(output, "The output file", true, false);

    boolean generated = false;

    // MIME might be known already (in case of recursive thumbnail managers)
    if (mimeType == null) {
      mimeType = mimeTypeDetector.getMimeType(input);
      mLog.debug("Detected Mime-Typ: " + mimeType);
    }

    if (mimeType != null) generated = executeThumbnailers(mimeType, input, output, mimeType);

    // Try again using wildcard thumbnailers
    if (!generated) generated = executeThumbnailers(ALL_MIME_WILDCARD, input, output, mimeType);

    if (!generated)
      throw new ThumbnailerException(
          "No suitable Thumbnailer has been found. (File: "
              + input.getName()
              + " ; Detected MIME: "
              + mimeType
              + ")");
  }
 public void assertMime(String expectedMime, String filename) {
   String mime = mimeType.getMimeType(new File(parent, filename));
   if (!expectedMime.equalsIgnoreCase(mime))
     fail(
         "File "
             + filename
             + ": Mime is not equal: expected \""
             + expectedMime
             + "\", but was \""
             + mime
             + "\".");
 }