Author: nick Date: Mon Oct 22 08:24:18 2012 New Revision: 1400795 URL: http://svn.apache.org/viewvc?rev=1400795&view=rev Log: Add test CSS and JS files taken from the Tika website, and use these to add additional detection unit tests for these two formats
Added: tika/trunk/tika-parsers/src/test/resources/test-documents/testCSS.css tika/trunk/tika-parsers/src/test/resources/test-documents/testJS.js Modified: tika/trunk/tika-parsers/src/test/java/org/apache/tika/mime/TestMimeTypes.java Modified: tika/trunk/tika-parsers/src/test/java/org/apache/tika/mime/TestMimeTypes.java URL: http://svn.apache.org/viewvc/tika/trunk/tika-parsers/src/test/java/org/apache/tika/mime/TestMimeTypes.java?rev=1400795&r1=1400794&r2=1400795&view=diff ============================================================================== --- tika/trunk/tika-parsers/src/test/java/org/apache/tika/mime/TestMimeTypes.java (original) +++ tika/trunk/tika-parsers/src/test/java/org/apache/tika/mime/TestMimeTypes.java Mon Oct 22 08:24:18 2012 @@ -404,6 +404,23 @@ public class TestMimeTypes extends TestC assertTypeByName("application/x-prt", "x.prt"); assertTypeByData("application/x-prt", "testCADKEY.prt"); } + + /** + * Formats which are based on plain text + */ + public void testTextBasedFormatsDetection() throws Exception { + assertTypeByName("text/plain", "testTXT.txt"); + assertType( "text/plain", "testTXT.txt"); + + assertTypeByName("text/css", "testCSS.css"); + assertType( "text/css", "testCSS.css"); + + assertTypeByName("text/html", "testHTML.html"); + assertType( "text/html", "testHTML.html"); + + assertTypeByName("application/javascript", "testJS.js"); + assertType( "application/javascript", "testJS.js"); + } public void testWmfDetection() throws Exception { assertTypeByName("application/x-msmetafile", "x.wmf"); Added: tika/trunk/tika-parsers/src/test/resources/test-documents/testCSS.css URL: http://svn.apache.org/viewvc/tika/trunk/tika-parsers/src/test/resources/test-documents/testCSS.css?rev=1400795&view=auto ============================================================================== --- tika/trunk/tika-parsers/src/test/resources/test-documents/testCSS.css (added) +++ tika/trunk/tika-parsers/src/test/resources/test-documents/testCSS.css Mon Oct 22 08:24:18 2012 @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +body { + font-family: serif; + font-size: 13pt; + background-color: #eee; + margin: 0; + padding: 0; +} + +#body { + width: 800px; + height: 100%; + margin: 20px auto; + left: auto; + right: auto; + background-color: white; + padding: 20px; + border: 1px solid #CCC; + -moz-border-radius: 15px; + border-radius: 15px; + -moz-box-shadow: 1ex 1ex 1ex #666; + -webkit-box-shadow: 1ex 1ex 1ex #666; + box-shadow: 5px 5px 5px #666; +} + +#banner { + height: 100px; + padding-bottom: 1em; + border-bottom: 1px solid #eee; +} Added: tika/trunk/tika-parsers/src/test/resources/test-documents/testJS.js URL: http://svn.apache.org/viewvc/tika/trunk/tika-parsers/src/test/resources/test-documents/testJS.js?rev=1400795&view=auto ============================================================================== --- tika/trunk/tika-parsers/src/test/resources/test-documents/testJS.js (added) +++ tika/trunk/tika-parsers/src/test/resources/test-documents/testJS.js Mon Oct 22 08:24:18 2012 @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +function selectProvider(form) { + provider = form.elements['searchProvider'].value; + if (provider == "any") { + if (Math.random() > 0.5) { + provider = "lucid"; + } else { + provider = "sl"; + } + } + if (provider == "lucid") { + form.action = "http://search.lucidimagination.com/p:tika"; + } else if (provider == "sl") { + form.action = "http://search-lucene.com/tika"; + } + days = 90; + date = new Date(); + date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); + expires = "; expires=" + date.toGMTString(); + document.cookie = "searchProvider=" + provider + expires + "; path=/"; +} +function initProvider() { + if (document.cookie.length>0) { + cStart=document.cookie.indexOf("searchProvider="); + if (cStart!=-1) { + cStart=cStart + "searchProvider=".length; + cEnd=document.cookie.indexOf(";", cStart); + if (cEnd==-1) { + cEnd=document.cookie.length; + } + provider = unescape(document.cookie.substring(cStart,cEnd)); + document.forms['searchform'].elements['searchProvider'].value = provider; + } + } + document.forms['searchform'].elements['q'].focus(); +}