1 4 package org.oddjob.designer.arooa; 5 6 import java.io.ByteArrayOutputStream ; 7 8 import junit.framework.TestCase; 9 10 import org.oddjob.arooa.ArooaContext; 11 import org.oddjob.arooa.handlers.MainHandler; 12 import org.oddjob.arooa.handlers.XmlHandler; 13 import org.xml.sax.SAXParseException ; 14 15 18 public class DesignParserTest extends TestCase { 19 20 public void testParse() throws SAXParseException { 21 class Test { 22 public String getTest() { 23 return "test"; 24 } 25 26 public ElementWrapper[] elements() { 27 return new ElementWrapper[] { 28 new ElementWrapper("test", 29 new Object () { 30 public String getTest2() { 31 return "test2"; 32 } 33 } 34 ) }; 35 } 36 } 37 Test test = new Test(); 38 39 ByteArrayOutputStream out = new ByteArrayOutputStream (); 40 XmlHandler handler = new XmlHandler(out); 41 42 DesignParser dp = new DesignParser(new ArooaContext()); 43 dp.parse("mytest", test, new MainHandler(handler)); 44 45 String eol = System.getProperty("line.separator"); 46 String expected = "<mytest test=\"test\">" + eol + 47 " <test test2=\"test2\"/>" + eol + 48 "</mytest>" + eol; 49 50 assertEquals("xml", expected, out.toString()); 51 } 52 } 53 | Popular Tags |