1   /***
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package test.net.sourceforge.pmd.util;
5   
6   import junit.framework.TestCase;
7   import net.sourceforge.pmd.util.StringUtil;
8   
9   public class StringUtilTest extends TestCase {
10  
11      public void testReplaceWithOneChar() {
12          assertEquals("faa", StringUtil.replaceString("foo", 'o', "a"));
13      }
14  
15      public void testReplaceWithMultipleChars() {
16          assertEquals("faaaa", StringUtil.replaceString("foo", 'o', "aa"));
17      }
18  
19      public void testReplaceStringWithString() {
20          assertEquals("foo]]>bar", StringUtil.replaceString("foo]]>bar", "]]>", "]]>"));
21      }
22  
23      public void testReplaceStringWithString2() {
24          assertEquals("replaceString didn't work with a >", "foobar", StringUtil.replaceString("foobar", "]]>", "]]>"));
25      }
26  
27      public void testReplaceWithNull() {
28          assertEquals("replaceString didn't work with a char", "f", StringUtil.replaceString("foo", 'o', null));
29      }
30  
31  /*
32      // FIXME
33      public void testUTF8NotSupported() {
34          System.setProperty("net.sourceforge.pmd.supportUTF8","no");
35          StringBuffer sb = new StringBuffer();
36          String test = "�";
37          StringUtil.appendXmlEscaped(sb, test);
38          assertEquals("é", sb.toString());
39      }
40      public void testUTF8Supported() {
41          System.setProperty("net.sourceforge.pmd.supportUTF8","yes");
42          StringBuffer sb = new StringBuffer();
43          String test = "�";
44          StringUtil.appendXmlEscaped(sb, test);
45          assertEquals("�", sb.toString());
46          System.setProperty("net.sourceforge.pmd.supportUTF8","no");
47      }
48  */
49  }