package org.htmlcleaner;

import junit.framework.TestCase;

import java.io.IOException;

/**
 * Testing HtmlCleaner constructors.
 */
public class ConstructorTest extends TestCase {

    public void testPrpertiesConstructor() throws XPatherException, IOException {
        CleanerProperties props = new CleanerProperties();
        props.setOmitComments(true);

        HtmlCleaner cleaner1 = new HtmlCleaner(props);
        TagNode node1 = cleaner1.clean("<a href=index.htm><b><!--COMMENT 1--><b>text text<body>");
        assertTrue( new SimpleXmlSerializer(props).getAsString(node1).indexOf("<!--COMMENT 1-->") < 0 );

        HtmlCleaner cleaner2 = new HtmlCleaner(props);
        TagNode node2 = cleaner2.clean("<span href=index1.htm><b><!--COMMENT 2--><x>DDDD text<body>");
        assertTrue( new SimpleXmlSerializer(props).getAsString(node2).indexOf("<!--COMMENT 2-->") < 0 );

        HtmlCleaner cleaner3 = new HtmlCleaner(props);
        props.setOmitComments(false);
        TagNode node3 = cleaner3.clean("<a href=index3.htm><b><!--COMMENT 3--><x>EEEEEEE text<body>");
        assertTrue( new SimpleXmlSerializer(props).getAsString(node3).indexOf("<!--COMMENT 3-->") > 0 );
    }

}
@@ -53,24 +53,62 @@
 estCase;%0D%0A%0D%0A
+import java.io.ByteArrayInputStream;%0D%0A
 import java.
@@ -1241,22 +1241,268 @@
 %3E%22) %3E 0 );%0D%0A
+%0D%0A        TagNode node4 = cleaner3.clean( new ByteArrayInputStream( (%22FIRST%22 + (char)0x2 + (char)0x3 + %22SECOND%22).getBytes() ), %22ASCII%22 );%0D%0A        assertTrue( new CompactXmlSerializer(props).getAsString(node4).indexOf(%22FIRST  SECOND%22) %3E= 0 );%0D%0A%0D%0A
     %7D%0D%0A%0D%0A%7D

test cases updated