1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.myfaces.shared.renderkit.html.util;
17
18 import java.io.StringWriter;
19 import junit.framework.Assert;
20 import org.apache.myfaces.test.base.junit4.AbstractJsfTestCase;
21 import org.junit.Test;
22
23 public class UnicodeEncoderTest extends AbstractJsfTestCase
24 {
25
26 @Test
27 public void testUnicodeEncoder1() throws Exception
28 {
29 StringWriter sw = new StringWriter(40);
30 UnicodeEncoder.encode(sw, ""+(char)0xE1);
31 Assert.assertEquals(UnicodeEncoder.encode(""+(char)0xE1), sw.toString());
32 }
33
34 @Test
35 public void testUnicodeEncoder2() throws Exception
36 {
37 StringWriter sw = new StringWriter(40);
38 UnicodeEncoder.encode(sw, "h"+(char)0xE1);
39 Assert.assertEquals(UnicodeEncoder.encode("h"+(char)0xE1), sw.toString());
40 }
41
42 @Test
43 public void testUnicodeEncoder3() throws Exception
44 {
45 StringWriter sw = new StringWriter(40);
46 UnicodeEncoder.encode(sw, ""+(char)0xE1+"a");
47 Assert.assertEquals(UnicodeEncoder.encode(""+(char)0xE1)+"a", sw.toString());
48 }
49
50 @Test
51 public void testUnicodeEncoder4() throws Exception
52 {
53 StringWriter sw = new StringWriter(40);
54 UnicodeEncoder.encode(sw, "hello h"+(char)0xE1+"aaa <p></p>");
55 Assert.assertEquals("hello háaaa <p></p>", sw.toString());
56 }
57
58 }