@Test
public void testCreateHtmlDocument() throws Exception {

    final String htmlFileName = "test.html";
    final String htmlText = "<html><head><meta name=\"generator\" content=\"olat-tinymce-1\"><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></head><body>"
            + "<H1>Test HTML Seite fuer JUnit Test</H1>" + "Dies ist<br />der Test&nbsp;Text" + "</body></html>"; // Text = 'Dies ist der Test Text'
    final String text = "Test HTML Seite fuer JUnit Test Dies ist der Test\u00A0Text"; // must include '\u00A0' !!! 19.5.2010/cg
    // Create a test HTML File
    final File htmlFile = new File(SEARCH_TEST_FOLDER, htmlFileName);
    if (htmlFile.exists()) {
        htmlFile.delete();
    }
    String filePath = "anyFilePath";
    FileUtils.save(htmlFile, htmlText, "utf-8");
    try {
        final SearchResourceContext resourceContext = new SearchResourceContext();
        resourceContext.setBusinessControlFor(OresHelper.createOLATResourceableType("FileDocumentFactoryITCase"));
        resourceContext.setFilePath(filePath + "/" + htmlFileName);
        final Document htmlDocument = FileDocumentFactory.createDocument(resourceContext, new LocalFileImpl(htmlFile));
        // 1. Check content
        final String content = htmlDocument.get(AbstractOlatDocument.CONTENT_FIELD_NAME);
        assertEquals("Wrong HTML content=" + content.trim() + " , must be =" + text.trim(), text.trim(), content.trim());
        // 2. Check resourceUrl
        final String resourceUrl = htmlDocument.get(AbstractOlatDocument.RESOURCEURL_FIELD_NAME);
        assertEquals("Wrong ResourceUrl", "[FileDocumentFactoryITCase:0][path=" + filePath + "/" + htmlFileName + "]", resourceUrl);
        // 3. Check File-Type
        final String fileType = htmlDocument.get(AbstractOlatDocument.FILETYPE_FIELD_NAME);
        assertEquals("Wrong file-type", "type.file.html", fileType);
    } catch (final IOException e) {
        fail("IOException=" + e.getMessage());
    } catch (final DocumentException e) {
        fail("DocumentException=" + e.getMessage());
    }
}