SAMimeType extends Move2AlfReceivingAction<FileInfo> { String determineMimeType (File file) { String mimeType; try { mimeType = tika.detect(file); if(mimeType.contains(";")){ mimeType = mimeType.split(";")[0]; } } catch (IOException e) { logger.error(e.getMessage(), e); throw new Move2AlfException(e.getMessage(), e); } return mimeType; }  @Override void executeImpl(FileInfo fileInfo);  }
@Test (expected=Move2AlfException.class) public final void testDetermineMimeTypeOfNonExistingFile () { File file = new File(DIR, "xyz"); SAMimeType saMimeType = new SAMimeType(); saMimeType.determineMimeType(file); }
@Test public final void testDetermineMimeType () { testDetermineMimeType("testfile_gif.gif", "image/gif"); testDetermineMimeType("testfile_gif", "image/gif"); testDetermineMimeType("testfile_gif.jpg", "image/gif"); testDetermineMimeType("testfile_corrupt_gif.gif", "image/gif"); testDetermineMimeType("testfile_corrupt_gif", "application/octet-stream"); testDetermineMimeType("testfile_ppt.ppt", "application/vnd.ms-powerpoint"); testDetermineMimeType("testfile_ppt", "application/x-tika-msoffice"); }