Address review comments

This commit is contained in:
rajatgarg 2023-09-25 01:34:58 +05:30
parent 6c4848958f
commit d2ede7f67c
6 changed files with 80 additions and 18 deletions

View File

@ -0,0 +1,2 @@
test-link*
0.*

View File

@ -0,0 +1,8 @@
## Core Java IO
This module contains articles about core Java input and output (IO)
### Relevant Articles:
- [[<-- Prev]](/core-java-modules/core-java-io-4)

View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-io-5</artifactId>
<name>core-java-io-5</name>
<packaging>jar</packaging>
<parent>
<groupId>com.baeldung.core-java-modules</groupId>
<artifactId>core-java-modules</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<dependencies>
<!-- Mime Type Resolution Libraries -->
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId>
<version>${tika.version}</version>
</dependency>
<dependency>
<groupId>net.sf.jmimemagic</groupId>
<artifactId>jmimemagic</artifactId>
<version>${jmime-magic.version}</version>
</dependency>
<dependency>
<groupId>org.jodd</groupId>
<artifactId>jodd-util</artifactId>
<version>${jodd-util.version}</version>
</dependency>
<dependency>
<groupId>com.j256.simplemagic</groupId>
<artifactId>simplemagic</artifactId>
<version>${simplemagic.version}</version>
</dependency>
</dependencies>
<build>
<finalName>core-java-io-5</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<!-- Mime Type Libraries -->
<tika.version>2.8.0</tika.version>
<jmime-magic.version>0.1.5</jmime-magic.version>
<jodd-util.version>6.2.1</jodd-util.version>
<simplemagic.version>1.17</simplemagic.version>
</properties>
</project>

View File

@ -11,10 +11,8 @@ import java.util.Map;
import java.util.Set;
import org.apache.tika.mime.MimeTypeException;
import org.junit.Test;
import com.j256.simplemagic.ContentType;
import org.junit.Test;
public class ExtensionFromMimeTypeUnitTest {
private static final String IMAGE_JPEG_MIME_TYPE = "image/jpeg";
@ -37,14 +35,14 @@ public class ExtensionFromMimeTypeUnitTest {
}
@Test
public void whenUsingMimetypesFileTypeMap_thenGetFileExtension() {
public void whenUsingSimpleMagic_thenGetFileExtension() {
List<String> expectedExtensions = Arrays.asList("jpeg", "jpg", "jpe");
String[] detectedExtensions = ContentType.fromMimeType(IMAGE_JPEG_MIME_TYPE).getFileExtensions();
assertThat(detectedExtensions).containsExactlyElementsOf(expectedExtensions);
}
@Test
public void whenUsingCustomLogic_thenGetFileExtension() {
public void whenUsingCustomMap_thenGetFileExtension() {
Map<String, Set<String>> mimeExtensionsMap = new HashMap<>();
List<String> expectedExtensions = Arrays.asList(".jpg", ".jpe", ".jpeg");
addMimeExtensions(mimeExtensionsMap, "image/jpeg", ".jpg");

View File

@ -43,17 +43,6 @@
<version>${angus-activation.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jodd</groupId>
<artifactId>jodd-util</artifactId>
<version>${jodd-util.version}</version>
</dependency>
<dependency>
<groupId>com.j256.simplemagic</groupId>
<artifactId>simplemagic</artifactId>
<version>${simplemagic.version}</version>
</dependency>
</dependencies>
<build>
@ -153,8 +142,6 @@
<fscontext.version>4.4.2</fscontext.version>
<jakarta-activation-api.version>2.1.2</jakarta-activation-api.version>
<angus-activation.version>2.0.1</angus-activation.version>
<jodd-util.version>6.2.1</jodd-util.version>
<simplemagic.version>1.17</simplemagic.version>
</properties>
</project>

View File

@ -108,6 +108,7 @@
<module>core-java-io-2</module>
<module>core-java-io-3</module>
<module>core-java-io-4</module>
<module>core-java-io-5</module>
<module>core-java-io-apis</module>
<module>core-java-io-apis-2</module>
<module>core-java-io-conversions</module>