1 16 package org.apache.cocoon.bean; 17 18 import java.io.ByteArrayOutputStream ; 19 20 import org.apache.cocoon.bean.helpers.OutputStreamListener; 21 22 import junit.framework.TestCase; 23 24 34 public class CocoonBeanTestCase extends TestCase { 35 36 40 public CocoonBeanTestCase(String arg0) { 41 super(arg0); 42 43 } 44 45 public void testProcessToStream() throws Exception { 46 CocoonBean cocoon = getCocoonBean(); 47 ByteArrayOutputStream baos = new ByteArrayOutputStream (); 48 cocoon.processURI("test-suite/static-site/index.html", baos); 49 String result = baos.toString(); 50 assertEquals(1603, result.length()); 51 assertTrue(result.indexOf("Cocoon TestSuite")>-1); 52 assertTrue(result.indexOf("<h1>General information</h1>")>-1); 53 cocoon.dispose(); 54 } 55 56 private CocoonBean getCocoonBean() throws Exception { 57 CocoonBean cocoon = new CocoonBean(); 58 cocoon.setContextDir("build/webapp"); 59 cocoon.setConfigFile("WEB-INF/cocoon.xconf"); 60 cocoon.setPrecompileOnly(false); 61 cocoon.setWorkDir("build/work"); 62 cocoon.setLogKit("build/webapp/WEB-INF/logkit.xconf"); 63 cocoon.setLogger("cli-test"); 64 cocoon.setLogLevel("DEBUG"); 65 cocoon.setFollowLinks(true); 70 cocoon.setConfirmExtensions(false); 71 cocoon.addListener(new OutputStreamListener(System.out)); 74 cocoon.initialize(); 75 return cocoon; 76 } 77 } 78 | Popular Tags |