Package org.apache.tapestry

Examples of org.apache.tapestry.MarkupWriter


    }

    @Test
    public void begin_render_writes_input_tag() throws Exception
    {
        MarkupWriter writer = createMarkupWriter();
        writer.element("form");
        FormSupport formSupport = mockFormSupport();

        formSupport.setEncodingType(Upload.MULTIPART_ENCTYPE);

        replay();

        Upload component = new Upload();

        setValidationDecorator(component, new StubValidationDecorator());

        setFormSupport(component, formSupport);

        component.beginRender(writer);

        Element element = writer.getElement();
        assertNotNull(element);
        assertEquals(element.getName(), "input");
        assertEquals(element.getAttribute("type"), "file");
        // assertEquals(element.getAttribute("name"),null);
        // assertEquals(element.getAttribute("id"),null);
View Full Code Here


    @Test
    public void validation_decorator_invoked_inside_begin_render() throws Exception
    {
        Upload component = new Upload();
        MarkupWriter writer = createMarkupWriter();
        writer.element("form");

        FormSupport formSupport = mockFormSupport();
        formSupport.setEncodingType(Upload.MULTIPART_ENCTYPE);
        setField(component, "_formSupport", formSupport);
View Full Code Here

    @Test
    public void begin_render_invokes_field_validator() throws Exception
    {
        FieldValidator<Object> validate = mockFieldValidator();
        Upload component = new Upload(null, validate, null, null);
        MarkupWriter writer = createMarkupWriter();
        writer.element("form");

        FormSupport formSupport = mockFormSupport();
        formSupport.setEncodingType(Upload.MULTIPART_ENCTYPE);
        setField(component, "_formSupport", formSupport);
View Full Code Here

    @Test
    public void after_render_closes_element() throws Exception
    {
        Upload component = new Upload();
        MarkupWriter writer = mockMarkupWriter();

        expect(writer.end()).andReturn(null);

        replay();

        component.afterRender(writer);
View Full Code Here

    @Test
    public void start_element()
    {
        ComponentInstantiatorSource source = mockComponentInstantiatorSource();
        ComponentClassResolver resolver = mockComponentClassResolver();
        MarkupWriter writer = new MarkupWriterImpl();
        Location l = mockLocation();
        RenderQueue queue = mockRenderQueue();

        replay();

        PageElementFactory factory = new PageElementFactoryImpl(source, resolver, null, null, null);
        StartElementToken token = new StartElementToken("fred", l);

        PageElement element = factory.newStartElement(token);

        element.render(writer, queue);

        verify();

        assertEquals(element.toString(), "Start[fred]");
        assertEquals(writer.toString(), "<fred></fred>");
    }
View Full Code Here

    @Test
    public void attribute()
    {
        ComponentInstantiatorSource source = mockComponentInstantiatorSource();
        ComponentClassResolver resolver = mockComponentClassResolver();
        MarkupWriter writer = new MarkupWriterImpl(_xmlModel, null);
        Location l = mockLocation();
        RenderQueue queue = mockRenderQueue();

        replay();

        PageElementFactory factory = new PageElementFactoryImpl(source, resolver, null, null, null);
        AttributeToken token = new AttributeToken("name", "value", l);

        PageElement element = factory.newAttributeElement(token);

        writer.element("root");

        element.render(writer, queue);

        verify();

        assertEquals(element.toString(), "Attribute[name=value]");
        assertEquals(writer.toString(), "<root name=\"value\"/>");
    }
View Full Code Here

    @Test
    public void end_element()
    {
        ComponentInstantiatorSource source = mockComponentInstantiatorSource();
        ComponentClassResolver resolver = mockComponentClassResolver();
        MarkupWriter writer = new MarkupWriterImpl(_xmlModel, null);
        RenderQueue queue = mockRenderQueue();

        replay();

        PageElementFactory factory = new PageElementFactoryImpl(source, resolver, null, null, null);

        PageElement element = factory.newEndElement();

        writer.element("root");
        writer.write("before");
        writer.element("nested");

        element.render(writer, queue);

        writer.write("after");

        verify();

        assertEquals(element.toString(), "End");
        assertEquals(writer.toString(), "<root>before<nested/>after</root>");
    }
View Full Code Here

    @Test
    public void text_element()
    {
        ComponentInstantiatorSource source = mockComponentInstantiatorSource();
        ComponentClassResolver resolver = mockComponentClassResolver();
        MarkupWriter writer = new MarkupWriterImpl();
        Location l = mockLocation();
        RenderQueue queue = mockRenderQueue();

        replay();

        PageElementFactory factory = new PageElementFactoryImpl(source, resolver, null, null, null);
        TextToken token = new TextToken("some text", l);

        PageElement element = factory.newTextElement(token);

        writer.element("root");
        element.render(writer, queue);

        verify();

        assertEquals(element.toString(), "Text[some text]");
        assertEquals(writer.toString(), "<root>some text</root>");
    }
View Full Code Here

    {
        ComponentInstantiatorSource source = mockComponentInstantiatorSource();
        ComponentClassResolver resolver = mockComponentClassResolver();
        RenderQueue queue = mockRenderQueue();
        ComponentPageElement component = newMock(ComponentPageElement.class);
        MarkupWriter writer = newMock(MarkupWriter.class);

        component.enqueueBeforeRenderBody(queue);

        replay();
View Full Code Here

    }

    @Test
    public void label_error_no_existing_class_attribute()
    {
        MarkupWriter writer = new MarkupWriterImpl(new XMLMarkupModel(), null);
        Environment env = mockEnvironment();
        Field field = mockField();
        ValidationTracker tracker = mockValidationTracker();

        train_peekRequired(env, ValidationTracker.class, tracker);
        train_inError(tracker, field, true);

        replay();

        Element e = writer.element("label", "accesskey", "f");

        ValidationDecorator decorator = new DefaultValidationDecorator(env, null, null);

        decorator.insideLabel(field, e);

        assertEquals(writer.toString(), "<label accesskey=\"f\" class=\"t-error\"/>");

        verify();
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry.MarkupWriter

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.