Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/langtools/jdk/javadoc/doclet/testCRLineSeparator/TestCRLineSeparator.java
40971 views
1
/*
2
* Copyright (c) 2004, 2019, 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
* @library ../../lib
29
* @modules jdk.javadoc/jdk.javadoc.internal.tool
30
* @build javadoc.tester.*
31
* @run main TestCRLineSeparator
32
*/
33
34
import java.io.*;
35
import java.util.*;
36
37
import javadoc.tester.JavadocTester;
38
39
public class TestCRLineSeparator extends JavadocTester {
40
41
public static void main(String... args) throws Exception {
42
TestCRLineSeparator tester = new TestCRLineSeparator();
43
tester.runTests();
44
}
45
46
@Test
47
public void test() throws IOException {
48
initFiles(new File(testSrc), new File("src"), "pkg");
49
javadoc("-d", "out",
50
"-sourcepath", "src",
51
"pkg");
52
checkExit(Exit.OK);
53
54
checkOutput("pkg/MyClass.html", true,
55
"Line 1\n"
56
+ " Line 2");
57
}
58
59
// recursively copy files from fromDir to toDir, replacing newlines
60
// with \r
61
void initFiles(File fromDir, File toDir, String f) throws IOException {
62
File from_f = new File(fromDir, f);
63
File to_f = new File(toDir, f);
64
if (from_f.isDirectory()) {
65
to_f.mkdirs();
66
for (String child: from_f.list()) {
67
initFiles(from_f, to_f, child);
68
}
69
} else {
70
List<String> lines = new ArrayList<>();
71
try (BufferedReader in = new BufferedReader(new FileReader(from_f))) {
72
String line;
73
while ((line = in.readLine()) != null)
74
lines.add(line);
75
}
76
try (BufferedWriter out = new BufferedWriter(new FileWriter(to_f))) {
77
for (String line: lines) {
78
out.write(line);
79
out.write("\r");
80
}
81
}
82
}
83
}
84
}
85
86