1 package org.appfuse.buildtools; 2 3 import java.io.StringReader ; 4 5 import junit.framework.TestCase; 6 7 import org.apache.tools.ant.util.FileUtils; 8 9 13 public class EscapeHtmlEntitiesTest extends TestCase { 14 15 19 public void testEscape() throws Exception { 20 StringReader str = new StringReader ("\u00E4\u00FC\u00F6\u00DF-\u00D6\u00F3"); 21 EscapeHtmlEntities boot = new EscapeHtmlEntities(); 22 EscapeHtmlEntities filter = (EscapeHtmlEntities) boot.chain(str); 23 filter.setMode(EscapeHtmlEntities.ESCAPE); 24 String result = FileUtils.readFully(filter, 200); 25 assertEquals("äüöß-Öó",result); 26 } 27 28 32 public void testUnescape() throws Exception { 33 StringReader str = new StringReader ("äüöß-Öó&noentity;"); 34 EscapeHtmlEntities boot = new EscapeHtmlEntities(); 35 EscapeHtmlEntities filter = (EscapeHtmlEntities) boot.chain(str); 36 filter.setMode(EscapeHtmlEntities.UNESCAPE); 37 String result = FileUtils.readFully(filter, 200); 38 assertEquals("\u00E4\u00FC\u00F6\u00DF-\u00D6\u00F3&noentity;",result); 39 } 40 } 41 | Popular Tags |