1   package test.net.sourceforge.pmd.ast;
2   
3   import junit.framework.TestCase;
4   import net.sourceforge.pmd.PMD;
5   import net.sourceforge.pmd.TargetJDK1_4;
6   import net.sourceforge.pmd.ast.ASTCompilationUnit;
7   import net.sourceforge.pmd.ast.ASTMethodDeclarator;
8   import net.sourceforge.pmd.ast.JavaParser;
9   
10  import java.io.StringReader;
11  import java.util.List;
12  
13  public class EncodingTest extends TestCase {
14  
15      public void testDecodingOfUTF8() throws Throwable {
16          JavaParser parser = (new TargetJDK1_4()).createParser(new StringReader(TEST_UTF8));
17          ASTCompilationUnit acu = parser.CompilationUnit();
18          List kids = acu.findChildrenOfType(ASTMethodDeclarator.class);
19          assertEquals("é", ((ASTMethodDeclarator)kids.get(0)).getImage());
20      }
21  
22      private static final String TEST_UTF8 =
23      "class Foo {" + PMD.EOL +
24      " void é() {}" + PMD.EOL +
25      " void fiddle() {}" + PMD.EOL +
26      "}";
27  }