use of org.apache.myfaces.renderkit.html.HtmlResponseWriterImpl in project myfaces by apache.
the class HtmlResponseWriterImplTest method testEmptyTagNotRenderEndOnXhtmlUppercase.
/**
* In xhtml, it is valid to have an html empty tag with content.
*
* @throws IOException
*/
public void testEmptyTagNotRenderEndOnXhtmlUppercase() throws IOException {
_writer = new HtmlResponseWriterImpl(_stringWriter, "application/xml", "UTF-8", false);
_writer.startDocument();
_writer.startElement("body", null);
_writer.startElement("BR", null);
_writer.writeText("hello", null);
_writer.endElement("BR");
_writer.endElement("body");
_writer.endDocument();
// the following should render <br>hello</br>
String output = _stringWriter.toString();
Assert.assertNotNull(output);
Assert.assertTrue(output.contains("<BR>"));
Assert.assertTrue(output.contains("</BR>"));
}
use of org.apache.myfaces.renderkit.html.HtmlResponseWriterImpl in project myfaces by apache.
the class HtmlResponseWriterImplTest method testEmptyTagNotRenderEndOnXml.
/**
* In xhtml, it is valid to have an html empty tag with content.
*
* @throws IOException
*/
public void testEmptyTagNotRenderEndOnXml() throws IOException {
_writer = new HtmlResponseWriterImpl(_stringWriter, "application/xml", "UTF-8", false);
_writer.startDocument();
_writer.startElement("body", null);
_writer.startElement("br", null);
_writer.writeText("hello", null);
_writer.endElement("br");
_writer.endElement("body");
_writer.endDocument();
// the following should render <br>hello</br>
String output = _stringWriter.toString();
Assert.assertNotNull(output);
Assert.assertTrue(output.contains("<br>"));
Assert.assertTrue(output.contains("</br>"));
}
use of org.apache.myfaces.renderkit.html.HtmlResponseWriterImpl in project myfaces by apache.
the class HtmlResponseWriterImplTest method testScriptOnHtmlIsoEncodingAndScriptXhmlComments.
public void testScriptOnHtmlIsoEncodingAndScriptXhmlComments() throws IOException {
_writer = new HtmlResponseWriterImpl(_stringWriter, "text/html", "ISO-8859-1", true);
String innerScript = "document.write('HELLO');";
_writer.startDocument();
_writer.startElement(HTML.SCRIPT_ELEM, null);
_writer.write(innerScript);
_writer.endElement(HTML.SCRIPT_ELEM);
_writer.endDocument();
String output = _stringWriter.toString();
Assert.assertNotNull(output);
Assert.assertTrue("script does not contain body:" + innerScript, output.contains(innerScript));
Assert.assertTrue("script does not have start comment <!-- ", output.contains(CommentUtils.COMMENT_SIMPLE_START));
Assert.assertTrue("script does not have end comment --> ", output.contains("//" + CommentUtils.COMMENT_SIMPLE_END));
}
use of org.apache.myfaces.renderkit.html.HtmlResponseWriterImpl in project myfaces by apache.
the class HtmlResponseWriterImplTest method testScriptOnXhtmlUTF8Encoding.
public void testScriptOnXhtmlUTF8Encoding() throws IOException {
_writer = new HtmlResponseWriterImpl(_stringWriter, "application/xhtml+xml", "UTF-8", false);
String innerScript = "document.write('HELLO');";
_writer.startDocument();
_writer.startElement(HTML.SCRIPT_ELEM, null);
_writer.write(innerScript);
_writer.endElement(HTML.SCRIPT_ELEM);
_writer.endDocument();
String output = _stringWriter.toString();
Assert.assertNotNull(output);
Assert.assertTrue("script does not contain body:" + innerScript, output.contains(innerScript));
Assert.assertTrue("script does not have start <![CDATA[ ", output.contains(CommentUtils.INLINE_SCRIPT_COMMENT + CommentUtils.CDATA_SIMPLE_START));
Assert.assertTrue("script does not have end ]]> ", output.contains(CommentUtils.INLINE_SCRIPT_COMMENT + CommentUtils.CDATA_SIMPLE_END));
}
use of org.apache.myfaces.renderkit.html.HtmlResponseWriterImpl in project myfaces by apache.
the class HtmlResponseWriterImplTest method testScriptOnHtmlUTF8AndScriptXhmlComments.
public void testScriptOnHtmlUTF8AndScriptXhmlComments() throws IOException {
_writer = new HtmlResponseWriterImpl(_stringWriter, "text/html", "UTF-8", true);
String innerScript = "document.write('HELLO');";
_writer.startDocument();
_writer.startElement(HTML.SCRIPT_ELEM, null);
_writer.write(innerScript);
_writer.endElement(HTML.SCRIPT_ELEM);
_writer.endDocument();
String output = _stringWriter.toString();
Assert.assertNotNull(output);
Assert.assertTrue("script does not contain body:" + innerScript, output.contains(innerScript));
Assert.assertTrue("script does not have start comment <!-- ", output.contains(CommentUtils.COMMENT_SIMPLE_START));
Assert.assertTrue("script does not have end comment --> ", output.contains("//" + CommentUtils.COMMENT_SIMPLE_END));
}
Aggregations