package org.htmlcleaner;

import junit.framework.TestCase;

/**
 * Test cases for for {@link BrowserCompactXmlSerializer}
 * 
 * @author Konstantin Burov (aectann@gmail.com)
 *
 */
public class BrowserCompactXmlSerializerTest extends TestCase {

    /**
     * Tests that serializer removes white spaces properly.
     */
    public void testRemoveInsignificantWhitespaces(){
        CleanerProperties properties = new CleanerProperties();
        properties.setOmitHtmlEnvelope(true);
        properties.setOmitXmlDeclaration(true);
        BrowserCompactXmlSerializer compactXmlSerializer = new BrowserCompactXmlSerializer(properties);
        String cleaned = compactXmlSerializer.getXmlAsString(properties, "        <u>text here, </u><b>some text</b>      ", "UTF-8");
        assertEquals("<u>text here, </u><b>some text</b>", cleaned);
        cleaned = compactXmlSerializer.getXmlAsString(properties, "    <div class=\"foo\">2 roots < here >  </div>", "UTF-8");
        assertEquals("<div class=\"foo\">2 roots &lt; here &gt;</div>", cleaned);
        cleaned = compactXmlSerializer.getXmlAsString(properties, "    <div class=\"foo\">2 roots \n    < here >  </div>", "UTF-8");
        assertEquals("<div class=\"foo\">2 roots\n&lt; here &gt;</div>", cleaned);
    }
}

@@ -1225,18 +1225,240 @@
 %3E2 roots
-%5Cn
+ &lt; here &gt;%3C/div%3E%22, cleaned);%0A        cleaned = compactXmlSerializer.getXmlAsString(properties, %22    %3Cdiv class=%5C%22foo%5C%22%3E2 roots %5Cn%5Cn    %3C here %3E  %3C/div%3E%22, %22UTF-8%22);%0A        assertEquals(%22%3Cdiv class=%5C%22foo%5C%22%3E2 roots %3Cbr /%3E
 &lt; her

Corrected test.