Package org.apache.tapestry.services

Examples of org.apache.tapestry.services.ResponseBuilder


    {
        IPage page = createPage();
        ListenerFixture l = new ListenerFixture();
       
        IRequestCycle cycle = newCycle();
        ResponseBuilder builder = newMock(ResponseBuilder.class);
       
        expect(cycle.isRewinding()).andReturn(true).anyTimes();
       
        builder.render(NullWriter.getSharedInstance(), page, cycle);
       
        replay();

        // Code path: no listener list

        page.renderPage(builder, cycle);

        verify();

        expect(cycle.isRewinding()).andReturn(true).anyTimes();
       
        builder.render(NullWriter.getSharedInstance(), page, cycle);
       
        replay();

        page.addPageEndRenderListener(l);

        page.renderPage(builder, cycle);

        assertEquals("pageEndRender", l.getMethod());

        l.reset();

        page.removePageEndRenderListener(l);

        verify();

        expect(cycle.isRewinding()).andReturn(true).anyTimes();
       
        builder.render(NullWriter.getSharedInstance(), page, cycle);
       
        replay();

        page.renderPage(builder, cycle);
View Full Code Here


    public void test_Render_Component()
    {
        IRequestCycle cycle = newMock(IRequestCycle.class);
        checkOrder(cycle, false);
       
        ResponseBuilder resp = newMock(ResponseBuilder.class);
        IEngineService engine = newMock(IEngineService.class);
        IEngine cengine = newMock(IEngine.class);
        ILink link = newMock(ILink.class);
        IScript script = newMock(IScript.class);
        PageRenderSupport prs = newMock(PageRenderSupport.class);

        TranslatedFieldSupport translator = newMock(TranslatedFieldSupport.class);
        ValidatableFieldSupport validator = newMock(ValidatableFieldSupport.class);

        IValidationDelegate delegate = new ValidationDelegate();
        IForm form = newMock(IForm.class);
        IMarkupWriter writer = newBufferWriter();

        Suggest comp = newInstance(Suggest.class,
                                   "response", resp,
                                   "templateTagName", "input",
                                   "name", "suggest",
                                   "clientId", "suggest",
                                   "form", form,
                                   "translatedFieldSupport", translator,
                                   "validatableFieldSupport", validator,
                                   "engineService", engine,
                                   "script", script);

        expect(cycle.isRewinding()).andReturn(false).anyTimes();
        expect(resp.isDynamic()).andReturn(false);
        expect(cycle.getAttribute(TapestryUtils.FORM_ATTRIBUTE)).andReturn(form).anyTimes();

        expect(form.wasPrerendered(writer, comp)).andReturn(false).anyTimes();
        expect(form.getDelegate()).andReturn(delegate).anyTimes();
        expect(form.getElementId(comp)).andReturn("suggest");
View Full Code Here

    public void test_Render_TextArea_Component()
    {
        IRequestCycle cycle = newMock(IRequestCycle.class);
        checkOrder(cycle, false);

        ResponseBuilder resp = newMock(ResponseBuilder.class);
        IEngineService engine = newMock(IEngineService.class);
        IEngine cengine = newMock(IEngine.class);
        ILink link = newMock(ILink.class);
        IScript script = newMock(IScript.class);
        PageRenderSupport prs = newMock(PageRenderSupport.class);

        TranslatedFieldSupport translator = newMock(TranslatedFieldSupport.class);
        ValidatableFieldSupport validator = newMock(ValidatableFieldSupport.class);

        IValidationDelegate delegate = new ValidationDelegate();
        IForm form = newMock(IForm.class);
        IMarkupWriter writer = newBufferWriter();

        Suggest comp = newInstance(Suggest.class,
                                   "response", resp,
                                   "templateTagName", "textarea",
                                   "name", "suggest",
                                   "clientId", "suggest",
                                   "form", form,
                                   "translatedFieldSupport", translator,
                                   "validatableFieldSupport", validator,
                                   "engineService", engine,
                                   "script", script,
                                   "options", "{afterUpdateElement:myapp.processUpdate,other:other}");

        expect(cycle.isRewinding()).andReturn(false).anyTimes();
        expect(resp.isDynamic()).andReturn(false);
        expect(cycle.getAttribute(TapestryUtils.FORM_ATTRIBUTE)).andReturn(form).anyTimes();

        expect(form.wasPrerendered(writer, comp)).andReturn(false).anyTimes();
        expect(form.getDelegate()).andReturn(delegate).anyTimes();
        expect(form.getElementId(comp)).andReturn("suggest");
View Full Code Here

    public void test_Render_Invalid_Options_JSON_Syntax()
    {
        IRequestCycle cycle = newMock(IRequestCycle.class);
        checkOrder(cycle, false);
        ResponseBuilder resp = newMock(ResponseBuilder.class);

        TranslatedFieldSupport translator = newMock(TranslatedFieldSupport.class);
        ValidatableFieldSupport validator = newMock(ValidatableFieldSupport.class);

        IValidationDelegate delegate = new ValidationDelegate();
        IForm form = new MockForm(delegate);
        IMarkupWriter writer = newBufferWriter();

        IBinding binding = newMock(IBinding.class);
        Location l = newLocation();
        ComponentSpecification spec = new ComponentSpecification();
       
        Suggest comp = newInstance(Suggest.class,
                                   "response", resp,
                                   "templateTagName", "input",
                                   "name", "suggest",
                                   "clientId", "suggest",
                                   "form", form,
                                   "translatedFieldSupport", translator,
                                   "validatableFieldSupport", validator,
                                   "options", "{thisisinvalid:true",
                                   "specification", spec);

        expect(cycle.isRewinding()).andReturn(false).anyTimes();
        expect(resp.isDynamic()).andReturn(false);
        expect(cycle.getAttribute(TapestryUtils.FORM_ATTRIBUTE)).andReturn(form).anyTimes();

        expect(translator.format(comp, null)).andReturn("r2d2");
        translator.renderContributions(comp, writer, cycle);
        validator.renderContributions(comp, writer, cycle);
View Full Code Here

    public void test_Render_List()
    {
        IRequestCycle cycle = newMock(IRequestCycle.class);
        checkOrder(cycle, false);
        ResponseBuilder resp = newMock(ResponseBuilder.class);

        IValidationDelegate delegate = new ValidationDelegate();
        IForm form = newMock(IForm.class);
        IMarkupWriter writer = newBufferWriter();

        ValueConverter converter = newMock(ValueConverter.class);

        List<String> source = new ArrayList<String>();
        source.add("Foo");
        source.add("Stimpy");
        source.add("Cat");

        Suggest comp = newInstance(Suggest.class,
                                   "response", resp,
                                   "templateTagName", "input",
                                   "name", "suggest",
                                   "clientId", "suggest",
                                   "form", form,
                                   "searchTriggered", true,
                                   "listSource", source,
                                   "valueConverter", converter,
                                   "listItemRenderer", DefaultListItemRenderer.SHARED_INSTANCE);

        expect(form.isRewinding()).andReturn(false);
        expect(cycle.isRewinding()).andReturn(false).anyTimes();
        expect(resp.isDynamic()).andReturn(true);
        trainGetAttribute(cycle, TapestryUtils.FORM_ATTRIBUTE, form);
        expect(form.wasPrerendered(writer, comp)).andReturn(false);

        expect(form.getElementId(comp)).andReturn("suggest");
        expect(cycle.getParameter("suggest")).andReturn("b");
View Full Code Here

    {
        IPage page = createPage();
        ListenerFixture l = new ListenerFixture();
       
        IRequestCycle cycle = newCycle();
        ResponseBuilder builder = newMock(ResponseBuilder.class);
       
        expect(cycle.isRewinding()).andReturn(true).anyTimes();
       
        builder.render(NullWriter.getSharedInstance(), page, cycle);
       
        replay();
       
        // Code path: no listener list

        page.renderPage(builder, cycle);
       
        verify();

        expect(cycle.isRewinding()).andReturn(true).anyTimes();
       
        builder.render(NullWriter.getSharedInstance(), page, cycle);
       
        replay();

        page.addPageBeginRenderListener(l);

        page.renderPage(builder, cycle);

        assertEquals("pageBeginRender", l.getMethod());

        l.reset();

        page.removePageBeginRenderListener(l);

        verify();

        expect(cycle.isRewinding()).andReturn(true).anyTimes();
       
        builder.render(NullWriter.getSharedInstance(), page, cycle);
       
        replay();

        page.renderPage(builder, cycle);
View Full Code Here

    {
        IPage page = createPage();
        ListenerFixture l = new ListenerFixture();
       
        IRequestCycle cycle = newCycle();
        ResponseBuilder builder = newMock(ResponseBuilder.class);
       
        expect(cycle.isRewinding()).andReturn(true).anyTimes();
       
        builder.render(NullWriter.getSharedInstance(), page, cycle);
       
        replay();

        // Code path: no listener list

        page.renderPage(builder, cycle);

        verify();

        expect(cycle.isRewinding()).andReturn(true).anyTimes();
       
        builder.render(NullWriter.getSharedInstance(), page, cycle);
       
        replay();

        page.addPageEndRenderListener(l);

        page.renderPage(builder, cycle);

        assertEquals("pageEndRender", l.getMethod());

        l.reset();

        page.removePageEndRenderListener(l);

        verify();

        expect(cycle.isRewinding()).andReturn(true).anyTimes();
       
        builder.render(NullWriter.getSharedInstance(), page, cycle);
       
        replay();

        page.renderPage(builder, cycle);
View Full Code Here

    public void test_Rewinding()
    {
        IMarkupWriter writer = newWriter();
        NestedMarkupWriter nested = newNestedWriter();
        ResponseBuilder builder = newMock(ResponseBuilder.class);
        IRequestCycle cycle = newCycle(true, writer);
        IRender body = newRender();
       
        Shell shell = (Shell) newInstance(Shell.class, "builder", builder);
       
        expect(cycle.renderStackPush(shell)).andReturn(shell);
        shell.addBody(body);

        trainStoreShellInCycle(cycle, shell);
        expect(builder.isDynamic()).andReturn(false);
        trainGetNestedWriter(writer, nested);
       
        body.render(nested, cycle);
       
        nested.close();
View Full Code Here

    public void test_Complex_Render()
    {
        IMarkupWriter writer = newWriter();
        NestedMarkupWriter nested = newNestedWriter();
        IRequestCycle cycle = newCycle();
        ResponseBuilder builder = newMock(ResponseBuilder.class);
        IValidationDelegate delegate = newDelegate();
        ILink link = newLink();
        IRender render = newRender();
        MockForm form = new MockForm(delegate);
View Full Code Here

    public void test_Complex_Submit_Event_Handler()
    {
        IMarkupWriter writer = newWriter();
        NestedMarkupWriter nested = newNestedWriter();
        IRequestCycle cycle = newCycle();
        ResponseBuilder builder = newMock(ResponseBuilder.class);
        IValidationDelegate delegate = newDelegate();
        PageRenderSupport support = newPageRenderSupport();
        ILink link = newLink();
        IRender render = newRender();
View Full Code Here

TOP

Related Classes of org.apache.tapestry.services.ResponseBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.