Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/test/com/sun/javadoc/testCRLineSeparator/TestCRLineSeparator.java
48505 views
1
/*
2
* Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
* @test
26
* @bug 4979486
27
* @summary Make sure tool parses CR line separators properly.
28
* @author jamieh
29
* @library ../lib/
30
* @build JavadocTester
31
* @build TestCRLineSeparator
32
* @run main TestCRLineSeparator
33
*/
34
35
import java.io.*;
36
import java.util.*;
37
38
public class TestCRLineSeparator extends JavadocTester {
39
40
//Test information.
41
private static final String BUG_ID = "4979486-8014636";
42
43
//Javadoc arguments.
44
private static final String[] ARGS = new String[] {
45
"-d", BUG_ID, "-sourcepath", ".", "pkg"
46
};
47
48
//Input for string search tests.
49
private static final String[][] TEST = {
50
{BUG_ID + FS + "pkg" + FS + "MyClass.html", "Line 1" + NL + " Line 2"}
51
};
52
53
private static final String[][] NEGATED_TEST = NO_TEST;
54
55
/**
56
* The entry point of the test.
57
* @param args the array of command line arguments.
58
*/
59
public static void main(String[] args) throws Exception {
60
initFiles(new File(SRC_DIR), new File("."), "pkg");
61
TestCRLineSeparator tester = new TestCRLineSeparator();
62
run(tester, ARGS, TEST, NEGATED_TEST);
63
tester.printSummary();
64
}
65
66
/**
67
* {@inheritDoc}
68
*/
69
public String getBugId() {
70
return BUG_ID;
71
}
72
73
/**
74
* {@inheritDoc}
75
*/
76
public String getBugName() {
77
return getClass().getName();
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
}
111
}
112
113