package org.bodington.servlet;

import java.io.StringWriter;

import junit.framework.TestCase;

public class AlreadyEscapedHtmlWriterTest extends TestCase
{

    private AlreadyEscapedHtmlWriter writer;
    
    public void setUp()
    {
        writer = new AlreadyEscapedHtmlWriter(new StringWriter());
    }
    /*
     * Test method for 'org.bodington.servlet.AlreadyEscapedHtmlWriter.shouldEscape(String)'
     */
    public void testShouldEscape()
    {
        assertTrue(writer.shouldEscape("&"));
        assertTrue(writer.shouldEscape("B&B&"));
        assertTrue(writer.shouldEscape(" & &amp; hello"));
        assertTrue(writer.shouldEscape("&quot; is a quote &"));
        assertTrue(writer.shouldEscape(" <xml> "));
    }
    
    public void testShouldntEscape()
    {
        assertFalse(writer.shouldEscape("hello &#123; sadsad"));
        assertFalse(writer.shouldEscape(" hello &amp; welcome &quot;"));
        assertFalse(writer.shouldEscape(" asdasd &amp; asd"));   
    }

}
