author | katleman |
Tue, 21 Jan 2014 18:17:23 -0800 | |
changeset 22365 | 895bfde469d4 |
parent 18004 | dcf9d59b1635 |
child 30730 | d3ce7619db2c |
permissions | -rw-r--r-- |
18004
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
1 |
/* |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
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 |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
28 |
*/ |
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 |
import java.io.IOException; |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
31 |
import java.io.PrintWriter; |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
32 |
import java.io.StringWriter; |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
33 |
import java.util.Arrays; |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
34 |
import java.util.List; |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
35 |
import java.util.Locale; |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
36 |
|
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
37 |
import com.sun.tools.doclint.DocLint; |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
38 |
|
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
39 |
public class ResourceTest { |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
40 |
public static void main(String... args) throws Exception { |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
41 |
Locale prev = Locale.getDefault(); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
42 |
Locale.setDefault(Locale.ENGLISH); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
43 |
try { |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
44 |
new ResourceTest().run(); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
45 |
} finally { |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
46 |
Locale.setDefault(prev); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
47 |
} |
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 |
public void run() throws Exception { |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
51 |
test(Arrays.asList("-help"), |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
52 |
Arrays.asList("Usage:", "Options")); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
53 |
test(Arrays.asList("-foo"), |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
54 |
Arrays.asList("bad option: -foo")); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
55 |
} |
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 |
void test(List<String> opts, List<String> expects) throws Exception { |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
58 |
StringWriter sw = new StringWriter(); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
59 |
PrintWriter pw = new PrintWriter(sw); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
60 |
try { |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
61 |
new DocLint().run(pw, opts.toArray(new String[opts.size()])); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
62 |
} catch (DocLint.BadArgs e) { |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
63 |
pw.println("BadArgs: " + e.getMessage()); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
64 |
} catch (IOException e) { |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
65 |
pw.println("IOException: " + e.getMessage()); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
66 |
} finally { |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
67 |
pw.close(); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
68 |
} |
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 |
String out = sw.toString(); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
71 |
if (!out.isEmpty()) { |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
72 |
System.err.println(out); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
73 |
} |
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 |
for (String e: expects) { |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
76 |
if (!out.contains(e)) |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
77 |
throw new Exception("expected string not found: " + e); |
dcf9d59b1635
8006615: [doclint] move remaining messages into resource bundle
jjg
parents:
diff
changeset
|
78 |
} |
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 |