test/com/sun/javadoc/testCRLineSeparator/TestCRLineSeparator.java

changeset 401
dd98acd9f717
parent 1
9a66ca7c79fa
child 404
14735c7932d7
     1.1 --- a/test/com/sun/javadoc/testCRLineSeparator/TestCRLineSeparator.java	Tue Sep 08 11:12:13 2009 -0700
     1.2 +++ b/test/com/sun/javadoc/testCRLineSeparator/TestCRLineSeparator.java	Tue Sep 08 11:29:58 2009 -0700
     1.3 @@ -32,6 +32,9 @@
     1.4   * @run main TestCRLineSeparator
     1.5   */
     1.6  
     1.7 +import java.io.*;
     1.8 +import java.util.*;
     1.9 +
    1.10  public class TestCRLineSeparator extends JavadocTester {
    1.11  
    1.12      //Test information.
    1.13 @@ -39,7 +42,7 @@
    1.14  
    1.15      //Javadoc arguments.
    1.16      private static final String[] ARGS = new String[] {
    1.17 -        "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg"
    1.18 +        "-d", BUG_ID, "-sourcepath", ".", "pkg"
    1.19      };
    1.20  
    1.21      //Input for string search tests.
    1.22 @@ -53,7 +56,8 @@
    1.23       * The entry point of the test.
    1.24       * @param args the array of command line arguments.
    1.25       */
    1.26 -    public static void main(String[] args) {
    1.27 +    public static void main(String[] args) throws Exception {
    1.28 +        initFiles(new File(SRC_DIR), new File("."), "pkg");
    1.29          TestCRLineSeparator tester = new TestCRLineSeparator();
    1.30          run(tester, ARGS, TEST, NEGATED_TEST);
    1.31          tester.printSummary();
    1.32 @@ -72,4 +76,36 @@
    1.33      public String getBugName() {
    1.34          return getClass().getName();
    1.35      }
    1.36 +
    1.37 +    // recursively copy files from fromDir to toDir, replacing newlines
    1.38 +    // with \r
    1.39 +    static void initFiles(File fromDir, File toDir, String f) throws IOException {
    1.40 +        File from_f = new File(fromDir, f);
    1.41 +        File to_f = new File(toDir, f);
    1.42 +        if (from_f.isDirectory()) {
    1.43 +            to_f.mkdirs();
    1.44 +            for (String child: from_f.list()) {
    1.45 +                initFiles(from_f, to_f, child);
    1.46 +            }
    1.47 +        } else {
    1.48 +            List<String> lines = new ArrayList<String>();
    1.49 +            BufferedReader in = new BufferedReader(new FileReader(from_f));
    1.50 +            try {
    1.51 +                String line;
    1.52 +                while ((line = in.readLine()) != null)
    1.53 +                    lines.add(line);
    1.54 +            } finally {
    1.55 +                in.close();
    1.56 +            }
    1.57 +            BufferedWriter out = new BufferedWriter(new FileWriter(to_f));
    1.58 +            try {
    1.59 +                for (String line: lines) {
    1.60 +                    out.write(line);
    1.61 +                    out.write("\r");
    1.62 +                }
    1.63 +            } finally {
    1.64 +                out.close();
    1.65 +            }
    1.66 +        }
    1.67 +    }
    1.68  }

mercurial