1 package libcore.java.nio.file.spi; 2 3 import org.junit.Test; 4 5 import java.nio.file.Paths; 6 import java.nio.file.spi.FileTypeDetector; 7 8 import static org.junit.Assert.assertEquals; 9 10 public class FileTypeDetectorTest { 11 12 @Test 13 public void test_probeFileType() throws Exception { 14 FileTypeDetector defaultFileTypeDetector = sun.nio.fs.DefaultFileTypeDetector.create(); 15 // The method uses file extensions to deduce mime type, therefore, it doesn't check for 16 // file existence. 17 assertEquals("text/plain", 18 defaultFileTypeDetector.probeContentType(Paths.get("file.txt"))); 19 assertEquals("text/x-java", 20 defaultFileTypeDetector.probeContentType(Paths.get("file.java"))); 21 } 22 } 23