Search in sources :

Example 1 with DefaultMarkupModel

use of org.apache.tapestry5.dom.DefaultMarkupModel in project tapestry-5 by apache.

the class AnyTest method render_simple.

@Test
public void render_simple() {
    ComponentResources resources = mockComponentResources();
    JavaScriptSupport support = mockJavaScriptSupport();
    MarkupWriter writer = new MarkupWriterImpl(new DefaultMarkupModel());
    resources.renderInformalParameters(writer);
    replay();
    Any component = new Any();
    component.inject(support, resources, "span", "foo");
    component.beginRender(writer);
    writer.write("content");
    component.afterRender(writer);
    assertEquals(writer.toString(), "<span>content</span>");
    verify();
}
Also used : MarkupWriterImpl(org.apache.tapestry5.internal.services.MarkupWriterImpl) JavaScriptSupport(org.apache.tapestry5.services.javascript.JavaScriptSupport) DefaultMarkupModel(org.apache.tapestry5.dom.DefaultMarkupModel) MarkupWriter(org.apache.tapestry5.MarkupWriter) ComponentResources(org.apache.tapestry5.ComponentResources) Test(org.testng.annotations.Test)

Example 2 with DefaultMarkupModel

use of org.apache.tapestry5.dom.DefaultMarkupModel in project tapestry-5 by apache.

the class AnyTest method render_with_id.

@Test
public void render_with_id() {
    ComponentResources resources = mockComponentResources();
    JavaScriptSupport support = mockJavaScriptSupport();
    MarkupWriter writer = new MarkupWriterImpl(new DefaultMarkupModel());
    resources.renderInformalParameters(writer);
    String clientId = "bar";
    String uniqueId = "bar_0";
    expect(support.allocateClientId(clientId)).andReturn(uniqueId);
    replay();
    Any component = new Any();
    component.inject(support, resources, "div", clientId);
    component.beginRender(writer);
    writer.write("content");
    component.afterRender(writer);
    assertEquals(writer.toString(), "<div>content</div>");
    assertEquals(component.getClientId(), uniqueId);
    assertEquals(writer.toString(), "<div id=\"bar_0\">content</div>");
    assertEquals(component.getClientId(), uniqueId);
    verify();
}
Also used : MarkupWriterImpl(org.apache.tapestry5.internal.services.MarkupWriterImpl) JavaScriptSupport(org.apache.tapestry5.services.javascript.JavaScriptSupport) DefaultMarkupModel(org.apache.tapestry5.dom.DefaultMarkupModel) MarkupWriter(org.apache.tapestry5.MarkupWriter) ComponentResources(org.apache.tapestry5.ComponentResources) Test(org.testng.annotations.Test)

Aggregations

ComponentResources (org.apache.tapestry5.ComponentResources)2 MarkupWriter (org.apache.tapestry5.MarkupWriter)2 DefaultMarkupModel (org.apache.tapestry5.dom.DefaultMarkupModel)2 MarkupWriterImpl (org.apache.tapestry5.internal.services.MarkupWriterImpl)2 JavaScriptSupport (org.apache.tapestry5.services.javascript.JavaScriptSupport)2 Test (org.testng.annotations.Test)2