Package org.apache.tapestry

Examples of org.apache.tapestry.MarkupWriter


    @Test
    public void writer_notifies_map_about_links()
    {
        ComponentInvocationMap map = mockComponentInvocationMap();

        MarkupWriter writer = new MarkupWriterImpl(new XMLMarkupModel(), map);
        Link link = mockLink();

        Element e = writer.element("form");

        map.store(e, link);

        replay();

        writer.attributes("action", link);

        verify();
    }
View Full Code Here


    }

    @Test
    public void write_raw()
    {
        MarkupWriter w = new MarkupWriterImpl();

        w.element("root");
        w.write("<");
        w.writeRaw("&nbsp;");
        w.write(">");
        w.end();

        assertEquals(w.toString(), "<root>&lt;&nbsp;&gt;</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 = mockComponentPageElement();
        MarkupWriter writer = newMock(MarkupWriter.class);

        component.enqueueBeforeRenderBody(queue);

        replay();
View Full Code Here

    public void render_informal_parameters_no_bindings()
    {
        ComponentPageElement element = mockComponentPageElement();
        Component component = mockComponent();
        Instantiator ins = mockInstantiator(component);
        MarkupWriter writer = mockMarkupWriter();
        TypeCoercer coercer = mockTypeCoercer();
        ComponentModel model = mockComponentModel();

        train_getModel(ins, model);
View Full Code Here

    public void render_informal_parameters_skips_formal_parameters()
    {
        ComponentPageElement element = mockComponentPageElement();
        Component component = mockComponent();
        Instantiator ins = mockInstantiator(component);
        MarkupWriter writer = mockMarkupWriter();
        TypeCoercer coercer = mockTypeCoercer();
        ComponentModel model = mockComponentModel();
        ParameterModel pmodel = mockParameterModel();
        Binding binding = mockBinding();
View Full Code Here

    public void render_an_informal_parameter()
    {
        ComponentPageElement element = mockComponentPageElement();
        Component component = mockComponent();
        Instantiator ins = mockInstantiator(component);
        MarkupWriter writer = mockMarkupWriter();
        TypeCoercer coercer = mockTypeCoercer();
        ComponentModel model = mockComponentModel();
        Binding binding = mockBinding();
        Object rawValue = new Object();
        String convertedValue = "*converted*";

        train_getModel(ins, model);

        train_getParameterModel(model, "fred", null);

        train_get(binding, rawValue);

        train_coerce(coercer, rawValue, String.class, convertedValue);

        writer.attributes("fred", convertedValue);

        replay();

        InternalComponentResources resources = new InternalComponentResourcesImpl(element, null,
                ins, coercer, null);
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(null, token);

        writer.element("root");

        element.render(writer, queue);

        verify();

        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

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.