author | lana |
Thu, 21 Jan 2016 09:46:01 -0800 | |
changeset 35340 | 38f7386ed942 |
parent 30730 | d3ce7619db2c |
permissions | -rw-r--r-- |
18004
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
1 |
/* |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
18004
diff
changeset
|
2 |
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. |
18004
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
4 |
* |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
8 |
* |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
13 |
* accompanied this code). |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
14 |
* |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
18 |
* |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
21 |
* questions. |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
22 |
*/ |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
23 |
|
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
24 |
/* |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
25 |
* @test |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
26 |
* @bug 8006615 |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
27 |
* @summary move remaining messages into resource bundle |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
18004
diff
changeset
|
28 |
* @modules jdk.compiler/com.sun.tools.doclint |
18004
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
29 |
*/ |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
30 |
|
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
31 |
import java.io.IOException; |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
32 |
import java.io.PrintWriter; |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
33 |
import java.io.StringWriter; |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
34 |
import java.util.Arrays; |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
35 |
import java.util.List; |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
36 |
import java.util.Locale; |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
37 |
|
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
38 |
import com.sun.tools.doclint.DocLint; |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
39 |
|
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
40 |
public class ResourceTest { |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
41 |
public static void main(String... args) throws Exception { |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
42 |
Locale prev = Locale.getDefault(); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
43 |
Locale.setDefault(Locale.ENGLISH); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
44 |
try { |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
45 |
new ResourceTest().run(); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
46 |
} finally { |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
47 |
Locale.setDefault(prev); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
48 |
} |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
49 |
} |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
50 |
|
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
51 |
public void run() throws Exception { |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
52 |
test(Arrays.asList("-help"), |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
53 |
Arrays.asList("Usage:", "Options")); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
54 |
test(Arrays.asList("-foo"), |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
55 |
Arrays.asList("bad option: -foo")); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
56 |
} |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
57 |
|
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
58 |
void test(List<String> opts, List<String> expects) throws Exception { |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
59 |
StringWriter sw = new StringWriter(); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
60 |
PrintWriter pw = new PrintWriter(sw); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
61 |
try { |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
62 |
new DocLint().run(pw, opts.toArray(new String[opts.size()])); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
63 |
} catch (DocLint.BadArgs e) { |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
64 |
pw.println("BadArgs: " + e.getMessage()); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
65 |
} catch (IOException e) { |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
66 |
pw.println("IOException: " + e.getMessage()); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
67 |
} finally { |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
68 |
pw.close(); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
69 |
} |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
70 |
|
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
71 |
String out = sw.toString(); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
72 |
if (!out.isEmpty()) { |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
73 |
System.err.println(out); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
74 |
} |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
75 |
|
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
76 |
for (String e: expects) { |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
77 |
if (!out.contains(e)) |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
78 |
throw new Exception("expected string not found: " + e); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
79 |
} |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
80 |
} |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
81 |
} |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
82 |