1/* 2 * Copyright (c) 2013, 2015, 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 8006615 27 * @summary move remaining messages into resource bundle 28 * @modules jdk.compiler/com.sun.tools.doclint 29 */ 30 31import java.io.IOException; 32import java.io.PrintWriter; 33import java.io.StringWriter; 34import java.util.Arrays; 35import java.util.List; 36import java.util.Locale; 37 38import com.sun.tools.doclint.DocLint; 39 40public class ResourceTest { 41 public static void main(String... args) throws Exception { 42 Locale prev = Locale.getDefault(); 43 Locale.setDefault(Locale.ENGLISH); 44 try { 45 new ResourceTest().run(); 46 } finally { 47 Locale.setDefault(prev); 48 } 49 } 50 51 public void run() throws Exception { 52 test(Arrays.asList("-help"), 53 Arrays.asList("Usage:", "Options")); 54 test(Arrays.asList("-foo"), 55 Arrays.asList("bad option: -foo")); 56 } 57 58 void test(List<String> opts, List<String> expects) throws Exception { 59 StringWriter sw = new StringWriter(); 60 PrintWriter pw = new PrintWriter(sw); 61 try { 62 new DocLint().run(pw, opts.toArray(new String[opts.size()])); 63 } catch (DocLint.BadArgs e) { 64 pw.println("BadArgs: " + e.getMessage()); 65 } catch (IOException e) { 66 pw.println("IOException: " + e.getMessage()); 67 } finally { 68 pw.close(); 69 } 70 71 String out = sw.toString(); 72 if (!out.isEmpty()) { 73 System.err.println(out); 74 } 75 76 for (String e: expects) { 77 if (!out.contains(e)) 78 throw new Exception("expected string not found: " + e); 79 } 80 } 81} 82 83