1 package org.jahia.urls; 2 3 import junit.framework.*; 4 import org.jahia.services.database.*; 5 import java.io.*; 6 7 public class TestURICodec extends TestCase { 8 private URICodec uRICodec = null; 9 10 public TestURICodec(String name) { 11 super(name); 12 } 13 14 protected void setUp() throws Exception { 15 super.setUp(); 16 17 uRICodec = new URICodec(); 18 } 19 20 protected void tearDown() throws Exception { 21 uRICodec = null; 22 super.tearDown(); 23 } 24 25 public void testEncode() throws UnsupportedEncodingException { 26 String input = null; 27 String encoding = null; 28 String authorizedChars = null; 29 String expectedReturn = null; 30 String actualReturn = uRICodec.encode(input, encoding, authorizedChars); 31 assertEquals("return value", expectedReturn, actualReturn); 32 33 input = "abcdef éàèäöü+_&%~ó;//_$*"; 34 encoding = "ISO-8859-1"; 35 actualReturn = uRICodec.decode(uRICodec.encode(input, encoding, URICodec.DEFAULT_AUTHORIZEDCHARS), encoding); 36 assertEquals("return value", input, actualReturn); 37 input = "abcdef éàèäöü+_&%~ó;//_$*"; 38 encoding = "UTF-8"; 39 actualReturn = uRICodec.decode(uRICodec.encode(input, encoding, URICodec.DEFAULT_AUTHORIZEDCHARS), encoding); 40 assertEquals("return value", input, actualReturn); 41 } 42 43 } 44 | Popular Tags |