Package org.rendersnake

Examples of org.rendersnake.HtmlCanvas


public class InspectorTest extends TestCase {

    public void testInpsectPersonUI() throws IOException {
        PersonUI ui = new PersonUI(new Person());
        Inspector inspector = new Inspector(ui);
        HtmlCanvas html = new HtmlCanvas();
        html.render(inspector);
        assertNotNull("inspected html", html.toHtml());
        System.out.println(html.toHtml());
        assertTrue(html.toHtml().indexOf("<div class=\"rendersnake-inspector\">") == 0);
    }
View Full Code Here


            assertTrue(true);
        }
    }

    public void testRender() throws Exception {
        HtmlCanvas html = new HtmlCanvas();
        resolver.setNextResolver(new MockCompponentResolver());
        html.render(resolver);
        assertFalse(html.toHtml().length() == 0);
    }
View Full Code Here

import org.rendersnake.HtmlAttributes;
import org.rendersnake.HtmlCanvas;

public class CrossSiteScriptingTest extends TestCase {
    public void testContent() throws Exception {
        HtmlCanvas html = new HtmlCanvas();
        html.write("<&>");
        assertEquals("&lt;&amp;&gt;",html.toHtml());
    }
View Full Code Here

public class HtmlCanvasTest extends TestCase {

    private HtmlCanvas html;

    public void setUp() {
        html = new HtmlCanvas();
    }
View Full Code Here

   


    public void testCreateWithWriter() throws Exception {
        StringWriter out = new StringWriter(1024);
        HtmlCanvas html = new HtmlCanvas(out);
        html.write("hello");
        assertEquals(out.toString(), "hello");
    }
View Full Code Here

        } catch (IllegalArgumentException ex) {
            // got it
        }
    } 
    public void testRender() throws Exception {
        HtmlCanvas html = new HtmlCanvas();
        ctx.renderForErrorOn(html);
        ctx.renderForInpectorOn(new Inspector(new PersonalPage()), html);
        assertFalse(html.toHtml().length() == 0);
    }
View Full Code Here

        }       
    }    
   
    public void testEmpty() throws IOException {
               
        HtmlCanvas html = new HtmlCanvas();
        try {
            html.render(new CloseOnEmpty());
            fail("should raise render exception");
        } catch (RenderException rex) {
            assertTrue(rex.isEmptyStack);
            html.render(rex);
            assertTrue(html.toHtml().length() > 0);
            System.out.println(rex.toString());
        }
    }
View Full Code Here

            System.out.println(rex.toString());
        }
    }
    public void testNull() throws IOException {
       
        HtmlCanvas html = new HtmlCanvas();
        try {
            html.render(new WriteNullTag());
            fail("should raise render exception");
        } catch (RenderException rex) {
            assertTrue(rex.isNullTag);
            html.render(rex);
            assertTrue(html.toHtml().length() > 0);
            System.out.println(rex.toString());
        }
    }
View Full Code Here

            System.out.println(rex.toString());
        }
    }
    public void testCaught() throws IOException {
       
        HtmlCanvas html = new HtmlCanvas();
        try {
            html.render(new ErrorInRender());
            fail("should raise render exception");
        } catch (RenderException rex) {
            assertFalse(rex.isEmptyStack);
            html.render(rex);
            assertTrue(html.toHtml().length() > 0);
            System.out.println(rex.toString());
        }
    }   
View Full Code Here

    /**
     * Return the HTML snippet to replace the reference in a template
     */
    public String toString(Object o) {
        RenderableAttribute cc = (RenderableAttribute)o;
        HtmlCanvas attributeCanvas = cc.getCanvas();
        HtmlCanvas localCanvas = attributeCanvas.createLocalCanvas();
        localCanvas.getPageContext().attributes = attributeCanvas.getPageContext().attributes;
        try {
            cc.getComponent().renderOn(localCanvas);
        } catch (IOException e) {
            return "RenderableAttributeRenderer-ERROR:" + e.getMessage();
        }
        return localCanvas.toHtml();
    }
View Full Code Here

TOP

Related Classes of org.rendersnake.HtmlCanvas

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.