use of org.apache.myfaces.test.mock.MockResponseWriter in project myfaces-build-tools by apache.
the class OddNumberValidatorTest method setUp.
public void setUp() throws Exception {
super.setUp();
oddNumValidator = new OddNumberValidator();
writer = new MockResponseWriter(new StringWriter(), null, null);
facesContext.setResponseWriter(writer);
}
use of org.apache.myfaces.test.mock.MockResponseWriter in project myfaces by apache.
the class UITestCase method testRelativePaths.
@Test
public void testRelativePaths() throws Exception {
UIViewRoot root = facesContext.getViewRoot();
vdl.buildView(facesContext, root, "parent.xml");
StringWriter sw = new StringWriter();
MockResponseWriter mrw = new MockResponseWriter(sw);
facesContext.setResponseWriter(mrw);
root.encodeAll(facesContext);
sw.flush();
Assert.assertTrue(sw.toString().equals("Hello World!"));
// System.out.println("************************");
// System.out.println(sw.toString());
// System.out.println("************************");
}
use of org.apache.myfaces.test.mock.MockResponseWriter in project myfaces by apache.
the class UITestCase method testCompositionTemplate.
@Test
public void testCompositionTemplate() throws Exception {
UIViewRoot root = facesContext.getViewRoot();
vdl.buildView(facesContext, root, "composition-template.xml");
StringWriter sw = new StringWriter();
MockResponseWriter mrw = new MockResponseWriter(sw);
facesContext.setResponseWriter(mrw);
root.encodeAll(facesContext);
sw.flush();
String response = sw.toString();
Assert.assertTrue(response.contains("New Title"));
Assert.assertTrue(response.contains("New Body"));
}
use of org.apache.myfaces.test.mock.MockResponseWriter in project myfaces by apache.
the class CompositionTestCase method testComposition3EmptyComposition.
/**
* An empty ui:composition does not means the content of a ui:insert without
* name to be rendered
*
* @throws Exception
*/
@Test
public void testComposition3EmptyComposition() throws Exception {
UIViewRoot root = facesContext.getViewRoot();
vdl.buildView(facesContext, root, "composition3.xhtml");
StringWriter sw = new StringWriter();
MockResponseWriter mrw = new MockResponseWriter(sw);
facesContext.setResponseWriter(mrw);
root.encodeAll(facesContext);
sw.flush();
String response = sw.toString();
Assert.assertFalse(response.contains("This fragment will not be inserted"));
Assert.assertFalse(response.contains("THIS SHOULD NOT BE RENDERED"));
}
use of org.apache.myfaces.test.mock.MockResponseWriter in project myfaces by apache.
the class CompositionTestCase method testComposition2EmptyComposition.
/**
* An empty ui:composition does not means the content of a ui:insert without
* name to be rendered
*
* @throws Exception
*/
@Test
public void testComposition2EmptyComposition() throws Exception {
UIViewRoot root = facesContext.getViewRoot();
vdl.buildView(facesContext, root, "composition2.xhtml");
StringWriter sw = new StringWriter();
MockResponseWriter mrw = new MockResponseWriter(sw);
facesContext.setResponseWriter(mrw);
root.encodeAll(facesContext);
sw.flush();
String response = sw.toString();
Assert.assertFalse(response.contains("This fragment will not be inserted"));
Assert.assertFalse(response.contains("THIS SHOULD NOT BE RENDERED"));
}
Aggregations