View Javadoc
1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.lang.java.ast;
5   
6   import static org.junit.Assert.assertEquals;
7   import net.sourceforge.pmd.PMD;
8   import net.sourceforge.pmd.lang.java.ParserTst;
9   
10  import org.junit.Test;
11  
12  public class EncodingTest extends ParserTst {
13  
14      @Test
15      public void testDecodingOfUTF8() throws Exception {
16          ASTCompilationUnit acu = parseJava14(TEST_UTF8);
17          String methodName = acu.findDescendantsOfType(ASTMethodDeclarator.class).get(0).getImage();
18          assertEquals("é", methodName);
19      }
20  
21      private static final String TEST_UTF8 = 
22              "class Foo {" + PMD.EOL +
23              "  void é() {}" + PMD.EOL +
24              "  void fiddle() {}" + PMD.EOL +
25              "}";
26  }