Use ContentType to fetch the extensions

This commit is contained in:
rajatgarg 2023-09-20 00:36:33 +05:30
parent 30b5e9d7cb
commit 030f308c5b
1 changed files with 2 additions and 3 deletions

View File

@ -14,7 +14,7 @@ import org.apache.tika.mime.MimeTypeException;
import org.junit.Test;
import com.j256.simplemagic.ContentInfo;
import com.j256.simplemagic.ContentType;
public class ExtensionFromMimeTypeUnitTest {
private static final String IMAGE_JPEG_MIME_TYPE = "image/jpeg";
@ -39,8 +39,7 @@ public class ExtensionFromMimeTypeUnitTest {
@Test
public void whenUsingMimetypesFileTypeMap_thenGetFileExtension() {
List<String> expectedExtensions = Arrays.asList("jpeg", "jpg", "jpe");
ContentInfo contentInfo = new ContentInfo("", IMAGE_JPEG_MIME_TYPE, "", true);
String[] detectedExtensions = contentInfo.getFileExtensions();
String[] detectedExtensions = ContentType.fromMimeType(IMAGE_JPEG_MIME_TYPE).getFileExtensions();
assertThat(detectedExtensions).containsExactlyElementsOf(expectedExtensions);
}