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

changeset 401
dd98acd9f717
parent 1
9a66ca7c79fa
child 404
14735c7932d7
equal deleted inserted replaced
400:35e29f51a7c3 401:dd98acd9f717
30 * @build JavadocTester 30 * @build JavadocTester
31 * @build TestCRLineSeparator 31 * @build TestCRLineSeparator
32 * @run main TestCRLineSeparator 32 * @run main TestCRLineSeparator
33 */ 33 */
34 34
35 import java.io.*;
36 import java.util.*;
37
35 public class TestCRLineSeparator extends JavadocTester { 38 public class TestCRLineSeparator extends JavadocTester {
36 39
37 //Test information. 40 //Test information.
38 private static final String BUG_ID = "4979486"; 41 private static final String BUG_ID = "4979486";
39 42
40 //Javadoc arguments. 43 //Javadoc arguments.
41 private static final String[] ARGS = new String[] { 44 private static final String[] ARGS = new String[] {
42 "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg" 45 "-d", BUG_ID, "-sourcepath", ".", "pkg"
43 }; 46 };
44 47
45 //Input for string search tests. 48 //Input for string search tests.
46 private static final String[][] TEST = { 49 private static final String[][] TEST = {
47 {BUG_ID + FS + "pkg" + FS + "MyClass.html", "Line 1\n Line 2"} 50 {BUG_ID + FS + "pkg" + FS + "MyClass.html", "Line 1\n Line 2"}
51 54
52 /** 55 /**
53 * The entry point of the test. 56 * The entry point of the test.
54 * @param args the array of command line arguments. 57 * @param args the array of command line arguments.
55 */ 58 */
56 public static void main(String[] args) { 59 public static void main(String[] args) throws Exception {
60 initFiles(new File(SRC_DIR), new File("."), "pkg");
57 TestCRLineSeparator tester = new TestCRLineSeparator(); 61 TestCRLineSeparator tester = new TestCRLineSeparator();
58 run(tester, ARGS, TEST, NEGATED_TEST); 62 run(tester, ARGS, TEST, NEGATED_TEST);
59 tester.printSummary(); 63 tester.printSummary();
60 } 64 }
61 65
70 * {@inheritDoc} 74 * {@inheritDoc}
71 */ 75 */
72 public String getBugName() { 76 public String getBugName() {
73 return getClass().getName(); 77 return getClass().getName();
74 } 78 }
79
80 // recursively copy files from fromDir to toDir, replacing newlines
81 // with \r
82 static void initFiles(File fromDir, File toDir, String f) throws IOException {
83 File from_f = new File(fromDir, f);
84 File to_f = new File(toDir, f);
85 if (from_f.isDirectory()) {
86 to_f.mkdirs();
87 for (String child: from_f.list()) {
88 initFiles(from_f, to_f, child);
89 }
90 } else {
91 List<String> lines = new ArrayList<String>();
92 BufferedReader in = new BufferedReader(new FileReader(from_f));
93 try {
94 String line;
95 while ((line = in.readLine()) != null)
96 lines.add(line);
97 } finally {
98 in.close();
99 }
100 BufferedWriter out = new BufferedWriter(new FileWriter(to_f));
101 try {
102 for (String line: lines) {
103 out.write(line);
104 out.write("\r");
105 }
106 } finally {
107 out.close();
108 }
109 }
110 }
75 } 111 }

mercurial