/*
* Created on Oct 4, 2006 by mschilli
*/
package alma.acs.jhelpgen;
import java.io.File;
import java.util.List;
import java.util.Vector;
import junit.framework.TestCase;
import alma.acs.jhelpgen.Gen.AnchorNode;
public class GenTest extends TestCase {
final boolean dbg = false;
@Override
public void setUp() {
System.out.println("================="+getName()+"===================");
}
// uppercase/lowercase tags
String H1_a = "
";
String H1_b = "";
String H1_c = "";
// single quotes, double quotes, no quotes
String H2_a = "";
String H2_b = "";
String H2_c = "";
// with/without embedded anchor
String H3_a = "";
String H3_b = " The h3_b
";
String H3_c = "";
// and some other variations
String H4_a = "";
String Hxy = "The hxy";
String htmlContent = "Some content " +
H1_a + ", containing " +
H2_a + ", containing " +
H3_a +
H3_b +
H1_b + " holding " +
H2_b + ", having " +
H3_c +
H2_c + " having " +
H4_a +
H1_c + " and stuff ";
String[] expectedDom = new String[]{
"The h1_a",
"The h2_a",
"The h1_b",
"The h2_b",
"The h3_c",
"The h2_c",
"The h4_a",
"The h1_c"};
String expectedToc =
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"";
String expectedMap =
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"";
public void testHtmlToDom() throws Exception {
Gen gen = new Gen();
String contents = htmlContent;
Gen.AnchorNode domRoot = gen.htmlToDom(contents);
if (dbg)
Gui.showTree(domRoot);
List result = domRoot.depthFirst(new Vector());
// skip first node as it is the root node itself
result.remove(0);
assertEquals(expectedDom.length, result.size());
for (int i=0; i