Unit test for detecting JS files As we don't currently have any JS file magic, we can't detect as such without the file name. However, with the filename, ensure we do get it right, even if there's HTML snippet in the JS. TIKA-1141
Project: http://git-wip-us.apache.org/repos/asf/tika/repo Commit: http://git-wip-us.apache.org/repos/asf/tika/commit/557b3704 Tree: http://git-wip-us.apache.org/repos/asf/tika/tree/557b3704 Diff: http://git-wip-us.apache.org/repos/asf/tika/diff/557b3704 Branch: refs/heads/master Commit: 557b3704501a9692809a3e1b7838866786ed3366 Parents: d740f5d Author: Nick Burch <n...@gagravarr.org> Authored: Wed Feb 3 17:20:55 2016 +0000 Committer: Nick Burch <n...@gagravarr.org> Committed: Wed Feb 3 17:25:52 2016 +0000 ---------------------------------------------------------------------- .../test/java/org/apache/tika/mime/TestMimeTypes.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tika/blob/557b3704/tika-parsers/src/test/java/org/apache/tika/mime/TestMimeTypes.java ---------------------------------------------------------------------- diff --git a/tika-parsers/src/test/java/org/apache/tika/mime/TestMimeTypes.java b/tika-parsers/src/test/java/org/apache/tika/mime/TestMimeTypes.java index 77d25df..92f7b88 100644 --- a/tika-parsers/src/test/java/org/apache/tika/mime/TestMimeTypes.java +++ b/tika-parsers/src/test/java/org/apache/tika/mime/TestMimeTypes.java @@ -971,6 +971,18 @@ public class TestMimeTypes { assertTypeByData("text/x-matlab", "testMATLAB.m"); assertTypeByData("text/x-matlab", "testMATLAB_wtsgaus.m"); assertTypeByData("text/x-matlab", "testMATLAB_barcast.m"); + + // By name, or by name+data, gets it as JS + assertTypeByName("application/javascript", "testJS.js"); + assertTypeByName("application/javascript", "testJS_HTML.js"); + assertType("application/javascript", "testJS.js"); + assertType("application/javascript", "testJS_HTML.js"); + + // With data only, because we have no JS file magic, can't be + // detected. One will come through as plain text, the other + // as HTML due to <html> in it. TODO Add JS magic. See TIKA-1141 + //assertTypeByData("application/javascript", "testJS.js"); + //assertTypeByData("application/javascript", "testJS_HTML.js"); } @Test