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

Thu, 25 Aug 2011 17:18:25 -0700

author
schien
date
Thu, 25 Aug 2011 17:18:25 -0700
changeset 1067
f497fac86cf9
parent 554
9d9f26857129
child 2525
2eb010b6cb22
permissions
-rw-r--r--

Added tag jdk8-b02 for changeset b3c059de2a61

     1 /*
     2  * Copyright (c) 2009, 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.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    26 /*
    27  * @test
    28  * @bug 6907575
    29  * @build GetDeps p.C1
    30  * @run main T6907575
    31  */
    33 import java.io.*;
    35 public class T6907575 {
    36     public static void main(String... args) throws Exception {
    37         new T6907575().run();
    38     }
    40     void run() throws Exception {
    41         String testSrc = System.getProperty("test.src");
    42         String testClasses = System.getProperty("test.classes");
    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);
    51         String ref = readFile(new File(testSrc, "T6907575.out"));
    52         diff(sw.toString().replaceAll("[\r\n]+", "\n"), ref);
    53     }
    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     }
    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