jjg@451: /* ohair@554: * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. jjg@451: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jjg@451: * jjg@451: * This code is free software; you can redistribute it and/or modify it jjg@451: * under the terms of the GNU General Public License version 2 only, as ohair@554: * published by the Free Software Foundation. Oracle designates this jjg@451: * particular file as subject to the "Classpath" exception as provided ohair@554: * by Oracle in the LICENSE file that accompanied this code. jjg@451: * jjg@451: * This code is distributed in the hope that it will be useful, but WITHOUT jjg@451: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jjg@451: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jjg@451: * version 2 for more details (a copy is included in the LICENSE file that jjg@451: * accompanied this code). jjg@451: * jjg@451: * You should have received a copy of the GNU General Public License version jjg@451: * 2 along with this work; if not, write to the Free Software Foundation, jjg@451: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jjg@451: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. jjg@451: */ jjg@451: jjg@451: /* jjg@451: * @test jjg@451: * @bug 6907575 jjg@451: * @build GetDeps p.C1 jjg@451: * @run main T6907575 jjg@451: */ jjg@451: jjg@451: import java.io.*; jjg@451: jjg@451: public class T6907575 { jjg@451: public static void main(String... args) throws Exception { jjg@451: new T6907575().run(); jjg@451: } jjg@451: jjg@451: void run() throws Exception { jjg@451: String testSrc = System.getProperty("test.src"); jjg@451: String testClasses = System.getProperty("test.classes"); jjg@451: jjg@451: StringWriter sw = new StringWriter(); jjg@451: PrintWriter pw = new PrintWriter(sw); jjg@451: GetDeps gd = new GetDeps(); jjg@451: gd.run(pw, "-classpath", testClasses, "-t", "-p", "p", "p/C1"); jjg@451: pw.close(); jjg@451: System.out.println(sw); jjg@451: jjg@451: String ref = readFile(new File(testSrc, "T6907575.out")); jjg@451: diff(sw.toString().replaceAll("[\r\n]+", "\n"), ref); jjg@451: } jjg@451: jjg@451: void diff(String actual, String ref) throws Exception { jjg@451: System.out.println("EXPECT:>>>" + ref + "<<<"); jjg@451: System.out.println("ACTUAL:>>>" + actual + "<<<"); jjg@451: if (!actual.equals(ref)) jjg@451: throw new Exception("output not as expected"); jjg@451: } jjg@451: jjg@451: String readFile(File f) throws IOException { jjg@451: Reader r = new FileReader(f); jjg@451: char[] buf = new char[(int) f.length()]; jjg@451: int offset = 0; jjg@451: int n; jjg@451: while (offset < buf.length && (n = r.read(buf, offset, buf.length - offset)) != -1) jjg@451: offset += n; jjg@451: return new String(buf, 0, offset); jjg@451: } jjg@451: }