jjg@400: /* ohair@554: * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. jjg@400: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jjg@400: * jjg@400: * This code is free software; you can redistribute it and/or modify it jjg@400: * under the terms of the GNU General Public License version 2 only, as jjg@400: * published by the Free Software Foundation. jjg@400: * jjg@400: * This code is distributed in the hope that it will be useful, but WITHOUT jjg@400: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jjg@400: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jjg@400: * version 2 for more details (a copy is included in the LICENSE file that jjg@400: * accompanied this code). jjg@400: * jjg@400: * You should have received a copy of the GNU General Public License version jjg@400: * 2 along with this work; if not, write to the Free Software Foundation, jjg@400: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jjg@400: * 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@400: */ jjg@400: jjg@400: /* jjg@400: * @test jjg@400: * @bug 6501502 6877206 6483788 jjg@400: * @summary JSR 199: FileObject.toUri should return file:///c:/ or file:/c:/ not file://c:/ jjg@400: */ jjg@400: jjg@400: import java.io.*; jjg@400: import java.net.URI; jjg@400: import javax.tools.*; jjg@400: jjg@400: public class T6501502 { jjg@400: public static void main(String... args) throws Exception { jjg@400: new T6501502().run(); jjg@400: } jjg@400: jjg@400: // The spec for java.io.File includes the following: jjg@400: // For a given abstract pathname f it is guaranteed that jjg@400: // new File( f.toURI()).equals( f.getAbsoluteFile()) jjg@400: // For JavaFileObject we test as follows: jjg@400: // new File( CONVERT_TO_FILEOBJECT(f).toURI()).equals( f.getAbsoluteFile()) jjg@400: // to verify that we get reasonable URIs returned from toURI. jjg@400: // To make this a general test, and not just a Windows test, jjg@400: // we test a number of platform-independent paths. jjg@400: void run() throws Exception { jjg@400: JavaCompiler c = ToolProvider.getSystemJavaCompiler(); jjg@400: fm = c.getStandardFileManager(null, null, null); jjg@400: System.err.println(System.getProperties()); jjg@400: File tmpDir = new File(System.getProperty("java.io.tmpdir")); jjg@400: File testSrcDir = new File(System.getProperty("test.src")); jjg@400: File testClassesDir = new File(System.getProperty("test.classes")); jjg@400: test(new File("abc.tmp")); jjg@400: test(new File(tmpDir, "bad.file")); jjg@400: test(new File(testSrcDir, "T6501501.java")); jjg@400: test(new File(testClassesDir, "T6501501.class")); jjg@400: test(new File("a b")); jjg@400: } jjg@400: jjg@400: void test(File f) throws Exception { jjg@400: System.err.println("test " + f); jjg@400: FileObject fo = fm.getJavaFileObjects(f).iterator().next(); jjg@400: URI uri = fo.toUri(); jjg@400: System.err.println("FileObject uri: " + uri); jjg@400: if (!new File(uri).equals(f.getAbsoluteFile())) jjg@400: throw new Exception("unexpected URI returned"); jjg@400: } jjg@400: jjg@400: StandardJavaFileManager fm; jjg@400: } jjg@400: