import java.util.*; /** * The test class XNodeTest. * * @author (your name) * @version (a version number or a date) */ public class XNodeTest extends junit.framework.TestCase { /** * Default constructor for test class XNodeTest */ public XNodeTest() { } /** * Sets up the test fixture. * * Called before every test case method. */ protected void setUp() { x1 = new XString("hello"); x2 = new XString("lalala"); xx0 = new ArrayList(); xx1 = Arrays.asList(x1); xx2 = Arrays.asList(x1,x2); x3 = new XTag( "em", xx0 ); x4 = new XTag( "em", xx2 ); x5 = new XTag( "p", Arrays.asList( x3, new XString("ahem"), x4 )); } /** * Tears down the test fixture. * * Called after every test case method. */ protected void tearDown() { } public void testToStringTest() { assertEquals( x1.toString(), "hello" ); assertEquals( x2.toString(), "lalala" ); assertEquals( x3.toString(), "\n" ); assertEquals( x4.toString(), "\n hello\n lalala\n" ); assertEquals( x5.toString(), "

\n \n \n ahem\n \n hello\n lalala\n \n

" ); } XNode x1; XNode x2; List xx0; List xx1; List xx2; XNode x3; XNode x4; XNode x5; public static void testParse( String str ) { System.out.println( "Testing parse: " + str ); System.out.println( XNodeList.toString( XNodeList.parse(str) ) ); } public void testParse() { testParse("Hi "); testParse("hi every body "); testParse("hi there all "); testParse(""); testParse("there"); testParse("there all"); } }