1 20 package org.enhydra.barracuda.core.comp; 21 22 import java.io.*; 23 import java.util.*; 24 25 import org.w3c.dom.*; 26 import junit.framework.*; 27 import org.apache.log4j.*; 28 import org.apache.log4j.xml.*; 29 30 import org.enhydra.barracuda.core.util.dom.*; 33 import org.enhydra.barracuda.core.view.*; 34 import org.enhydra.barracuda.examples.xmlc.*; 35 import org.enhydra.barracuda.testbed.*; 36 import org.enhydra.barracuda.testbed.servlet.*; 37 38 39 42 public class TestBasicComponentsRender extends DefaultTestCase { 43 private static String testClass = TestBasicComponentsRender.class.getName(); 45 private static Logger logger = Logger.getLogger("test."+testClass); 46 47 49 53 public TestBasicComponentsRender(String name) { 54 super(name); 55 } 56 57 64 public static void main(String args[]) { 65 TestUtil.parseParams(args); 67 68 if (TestUtil.BATCH_MODE) junit.textui.TestRunner.main(new String [] {testClass}); 70 else junit.swingui.TestRunner.main(new String [] {testClass}); 71 } 72 73 74 80 83 public void testBasicRender() throws IOException, RenderException { 84 if (logger.isInfoEnabled()) logger.info("testing basic render"); 86 CompEx1 cg = new CompEx1(); 87 BComponent root = new BComponent(); 88 root.initCycle(); 89 90 MockHttpServletRequest req = new MockHttpServletRequest(); 92 req.setHeader("User-Agent","Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); 93 ViewCapabilities vcap = new ViewCapabilities(req, null); 94 96 ViewContext vc = new DefaultViewContext(vcap, req, null); 98 Document doc = cg.handleDefault(root, vc, req, null); 99 root.render(vc); 100 root.destroyCycle(); 101 DefaultDOMWriter ddw = new DefaultDOMWriter(false); 102 StringWriter sw = new StringWriter(2000); 103 ddw.write(doc, sw); 104 String html = sw.toString(); 105 107 int fpos = html.indexOf("render failed"); 109 assertTrue("BLink render err: "+(fpos>20 ? html.substring(fpos-20,fpos+20) : "??"), fpos<0); 110 111 } 112 } 113 | Popular Tags |