/* * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
/* * @test * @bug 4393671 * @summary URL constructor URL(URL context, String spec) FAILED with specific input
*/
/* * This program tests the URL parser in the URL constructor. It * tries to construct a variety of valid URLs with a given context * (which may be null) and a variety of specs. It then compares the * result with an expected value.
*/
privatestaticboolean hasFtp() { try { returnnew java.net.URL("ftp://") != null;
} catch (java.net.MalformedURLException x) {
System.out.println("FTP not supported by this runtime."); returnfalse;
}
}
staticclass Entry { final String context; final String spec; final String expected;
Entry(String context, String spec, String expected) { this.context = context; this.spec =spec; this.expected = expected;
}
}
static Entry[] fileURLs = new Entry[] { new Entry(null, "file://JavaSoft/Test", "file://JavaSoft/Test"), new Entry(null, "file:///JavaSoft/Test", "file:/JavaSoft/Test"), new Entry(null, "file:/JavaSoft/Test", "file:/JavaSoft/Test"), new Entry(null, "file:/c:/JavaSoft/Test", "file:/c:/JavaSoft/Test"), new Entry(null, "file:/c:/JavaSoft/Test:something", "file:/c:/JavaSoft/Test:something"), new Entry(null, "file:/c:/JavaSoft/Test#anchor", "file:/c:/JavaSoft/Test#anchor"), new Entry("file://JavaSoft/Test", "Test#bar", "file://JavaSoft/Test#bar"), new Entry("file://codrus/c:/jdk/eng/index.html", "pulsar.html", "file://codrus/c:/jdk/eng/pulsar.html"), new Entry("file:///c:/jdk/eng/index.html", "pulsar.html", "file:/c:/jdk/eng/pulsar.html"), new Entry("file:///jdk/eng/index.html", "pulsar.html", "file:/jdk/eng/pulsar.html"), new Entry("file://JavaSoft/Test", "file://radartoad.com/Test#bar", "file://radartoad.com/Test#bar"), new Entry("file://JavaSoft/Test", "/c:/Test#bar", "file://JavaSoft/c:/Test#bar"),
};
static Entry[] ftpURLs = new Entry[] { new Entry(null, "ftp://ftp.foo.com/dir1/entry.txt", "ftp://ftp.foo.com/dir1/entry.txt"), new Entry(null, "ftp://br:pwd@ftp.foo.com/dir1/jar.jar", "ftp://br:pwd@ftp.foo.com/dir1/jar.jar"), new Entry("ftp://ftp.foo.com/dir1/foo.txt", "bar.txt", "ftp://ftp.foo.com/dir1/bar.txt"), new Entry("ftp://ftp.foo.com/dir1/jar.jar", "/entry.txt", "ftp://ftp.foo.com/entry.txt"), new Entry("ftp://ftp.foo.com/dir1/jar.jar", "dir1/entry.txt", "ftp://ftp.foo.com/dir1/dir1/entry.txt"), new Entry("ftp://ftp.foo.com/dir1/jar.jar", "/dir1/entry.txt", "ftp://ftp.foo.com/dir1/entry.txt"), new Entry("ftp://br:pwd@ftp.foo.com/dir1/jar.jar", "/dir1/entry.txt", "ftp://br:pwd@ftp.foo.com/dir1/entry.txt")
};
}
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.