    1   package test.net.sourceforge.pmd.ast;
    2
    3   import junit.framework.TestCase;
    4   import net.sourceforge.pmd.PMD;
    5
    6   import java.io.ByteArrayInputStream;
    7   import java.io.InputStreamReader;
    8
    9   public class EncodingTest extends TestCase {
    10
    11      public void testDecodingOfUTF8() throws Throwable {
    12          //String platformEncoding = System.getProperty("file.encoding");
    13          //String encoding = "ISO-8859-1";
    14          String encoding = "UTF-8";
    15
    16          String code = new String(TEST_UTF8.getBytes(), encoding);
    17          InputStreamReader isr = new InputStreamReader(new ByteArrayInputStream(code.getBytes()));
    18          //FIXME
    19  /*
    20          ASTCompilationUnit acu = new TargetJDK1_4().createParser(isr).CompilationUnit();
    21          String methodName = ((ASTMethodDeclarator)acu.findChildrenOfType(ASTMethodDeclarator.class).get(0)).getImage();
    22          assertEquals(new String("é".getBytes(), encoding), methodName);
    23  */
    24      }
    25
    26      private static final String TEST_UTF8 =
    27              "class Foo {" + PMD.EOL +
    28              " void é() {}" + PMD.EOL +
    29              " void fiddle() {}" + PMD.EOL +
    30              "}";
    31  }