diff -r 35e29f51a7c3 -r dd98acd9f717 test/com/sun/javadoc/testCRLineSeparator/TestCRLineSeparator.java --- a/test/com/sun/javadoc/testCRLineSeparator/TestCRLineSeparator.java Tue Sep 08 11:12:13 2009 -0700 +++ b/test/com/sun/javadoc/testCRLineSeparator/TestCRLineSeparator.java Tue Sep 08 11:29:58 2009 -0700 @@ -32,6 +32,9 @@ * @run main TestCRLineSeparator */ +import java.io.*; +import java.util.*; + public class TestCRLineSeparator extends JavadocTester { //Test information. @@ -39,7 +42,7 @@ //Javadoc arguments. private static final String[] ARGS = new String[] { - "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg" + "-d", BUG_ID, "-sourcepath", ".", "pkg" }; //Input for string search tests. @@ -53,7 +56,8 @@ * The entry point of the test. * @param args the array of command line arguments. */ - public static void main(String[] args) { + public static void main(String[] args) throws Exception { + initFiles(new File(SRC_DIR), new File("."), "pkg"); TestCRLineSeparator tester = new TestCRLineSeparator(); run(tester, ARGS, TEST, NEGATED_TEST); tester.printSummary(); @@ -72,4 +76,36 @@ public String getBugName() { return getClass().getName(); } + + // recursively copy files from fromDir to toDir, replacing newlines + // with \r + static void initFiles(File fromDir, File toDir, String f) throws IOException { + File from_f = new File(fromDir, f); + File to_f = new File(toDir, f); + if (from_f.isDirectory()) { + to_f.mkdirs(); + for (String child: from_f.list()) { + initFiles(from_f, to_f, child); + } + } else { + List lines = new ArrayList(); + BufferedReader in = new BufferedReader(new FileReader(from_f)); + try { + String line; + while ((line = in.readLine()) != null) + lines.add(line); + } finally { + in.close(); + } + BufferedWriter out = new BufferedWriter(new FileWriter(to_f)); + try { + for (String line: lines) { + out.write(line); + out.write("\r"); + } + } finally { + out.close(); + } + } + } }