1 4 package com.openedit.generators; 5 6 import org.apache.commons.logging.Log; 7 import org.apache.commons.logging.LogFactory; 8 import org.openedit.repository.filesystem.StringItem; 9 10 import com.openedit.BaseTestCase; 11 import com.openedit.WebPageRequest; 12 import com.openedit.page.Page; 13 import com.openedit.page.PageSettings; 14 15 18 public class VelocityGeneratorTest extends BaseTestCase 19 { 20 private static final Log log = LogFactory.getLog(VelocityGeneratorTest.class); 21 public VelocityGeneratorTest( String name ) 22 { 23 super( name ); 24 } 25 26 public void testGenerate() throws Exception 27 { 28 WebPageRequest context = getFixture().createPageRequest("/generators/velocity.html"); 29 context.putPageValue("variable", ", it worked."); 30 context.getPageStreamer().render(); 31 String result = context.getWriter().toString(); 32 log.info( result ); 33 assertEquals( "<p>\nTest stuff , it worked.\n</p>", result ); 34 } 35 36 public void testEncoding() throws Exception 38 { 39 Page page = getPage("/apos.html"); 40 getFixture().getPageManager().removePage(page); 41 42 PageSettings settings = page.getPageSettings(); 44 settings.setPageCharacterEncoding("ISO-8859-1"); 47 String desc = "<DIV>Hobby Horse\u0092</DIV>"; 49 StringItem newItem = new StringItem(page.getPath(),desc, settings.getPageCharacterEncoding()); 50 newItem.setMessage("Testing"); 51 page.setContentItem(newItem); 52 53 getFixture().getPageManager().putPage(page); 54 getFixture().getPageManager().clearCache(); 55 Thread.sleep(100); 56 Page reloadpage = getPage("/apos.html"); 58 assertEquals( "ISO-8859-1",reloadpage.getCharacterEncoding()); 59 60 61 String reloadcontent = reloadpage.getContent(); 62 assertEquals(desc,reloadcontent); 63 64 String wrongencoding = "<DIV>Hobby Horse\u2019</DIV>"; 67 68 71 } 72 } 73 | Popular Tags |