MimeTypeDaoImpl implements MimeTypeDao { @Override public MimeType getMimeType(final String fileName) { return MimeType.valueOf(properties.getProperty(getFileExtension(fileName).toLowerCase())); } @Inject  MimeTypeDaoImpl(@Named("mimeTypePath") final String mimeTypePath); @Override MimeType getMimeType(final String fileName); @Override MimeType getAliasMimeType(final MimeType mimeType);  }
@Test public void testMimeType() { MimeTypeDao mimeTypeDao = new MimeTypeDaoImpl("/mimetypes.properties"); String fileName = "movie.avi"; MimeType mimeType = mimeTypeDao.getMimeType(fileName); assertNotNull(mimeType); assertEquals(MediaType.TYPE_VIDEO, mimeType.getType()); assertEquals("avi", mimeType.getSubType()); assertEquals("video/avi", mimeType.getMimeType()); }
@Test public void testBadMimeType() { MimeTypeDao mimeTypeDao = new MimeTypeDaoImpl("/mimetypes.properties"); String fileName = "movie.blabla"; MimeType mimeType = mimeTypeDao.getMimeType(fileName); assertNull(mimeType); }