View Javadoc

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