ALF-10525 ACP mimetype detection fix, unit tests for it, and a NPE fix

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31553 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Nick Burch
2011-10-29 18:15:44 +00:00
parent 72b3be8ce0
commit 52c03bc951
2 changed files with 17 additions and 1 deletions

View File

@@ -78,6 +78,12 @@ public class MimetypeMapContentTest extends TestCase
mimetypeService.guessMimetype("image.bmp", openQuickTestFile("quick.bmp")) mimetypeService.guessMimetype("image.bmp", openQuickTestFile("quick.bmp"))
); );
// Alfresco Specific ones, that Tika doesn't know about
assertEquals(
"application/acp",
mimetypeService.guessMimetype("something.acp", openQuickTestFile("quick.acp"))
);
// Where the file is corrupted // Where the file is corrupted
File tmp = File.createTempFile("alfresco", ".tmp"); File tmp = File.createTempFile("alfresco", ".tmp");
@@ -96,13 +102,23 @@ public class MimetypeMapContentTest extends TestCase
// So, it'll fall back to just OLE2, but it won't fail // So, it'll fall back to just OLE2, but it won't fail
assertEquals( assertEquals(
"application/x-tika-msoffice", "application/x-tika-msoffice",
mimetypeService.guessMimetype("something.doc", truncReader) mimetypeService.guessMimetype(null, truncReader)
); );
// But with the filename it'll be able to use the .doc extension
// to guess at it being a .Doc file
assertEquals(
"application/msword",
mimetypeService.guessMimetype("something.doc", truncReader)
);
} }
private ContentReader openQuickTestFile(String filename) private ContentReader openQuickTestFile(String filename)
{ {
URL url = getClass().getClassLoader().getResource("quick/" + filename); URL url = getClass().getClassLoader().getResource("quick/" + filename);
if(url == null)
{
fail("Quick test file \"" + filename + "\" wasn't found");
}
File file = new File(url.getFile()); File file = new File(url.getFile());
return new FileContentReader(file); return new FileContentReader(file);
} }

Binary file not shown.