test/tools/javap/classfile/deps/T6907575.java

changeset 451
fbeb560f39e7
child 554
9d9f26857129
equal deleted inserted replaced
450:4011f49b4af8 451:fbeb560f39e7
1 /*
2 * Copyright 2009 Sun Microsystems, Inc. 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. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26 /*
27 * @test
28 * @bug 6907575
29 * @build GetDeps p.C1
30 * @run main T6907575
31 */
32
33 import java.io.*;
34
35 public class T6907575 {
36 public static void main(String... args) throws Exception {
37 new T6907575().run();
38 }
39
40 void run() throws Exception {
41 String testSrc = System.getProperty("test.src");
42 String testClasses = System.getProperty("test.classes");
43
44 StringWriter sw = new StringWriter();
45 PrintWriter pw = new PrintWriter(sw);
46 GetDeps gd = new GetDeps();
47 gd.run(pw, "-classpath", testClasses, "-t", "-p", "p", "p/C1");
48 pw.close();
49 System.out.println(sw);
50
51 String ref = readFile(new File(testSrc, "T6907575.out"));
52 diff(sw.toString().replaceAll("[\r\n]+", "\n"), ref);
53 }
54
55 void diff(String actual, String ref) throws Exception {
56 System.out.println("EXPECT:>>>" + ref + "<<<");
57 System.out.println("ACTUAL:>>>" + actual + "<<<");
58 if (!actual.equals(ref))
59 throw new Exception("output not as expected");
60 }
61
62 String readFile(File f) throws IOException {
63 Reader r = new FileReader(f);
64 char[] buf = new char[(int) f.length()];
65 int offset = 0;
66 int n;
67 while (offset < buf.length && (n = r.read(buf, offset, buf.length - offset)) != -1)
68 offset += n;
69 return new String(buf, 0, offset);
70 }
71 }

mercurial