2362N/A * Copyright (c) 2001, 2003, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * @summary Unit test for java.net.URL (Based on the URI tests that is authored by Mark Reinhold) 0N/A // Properties that we check 0N/A static final int REF =
1 <<
7;
0N/A int failed =
0;
// Mask for failed properties 0N/A // Operations on Test instances 0N/A // These are short so as to make test cases compact. 0N/A // rslv Resolve against given base 0N/A // psa Parse server Authority 0N/A // x Check that parse failed as expected 0N/A // z End -- ensure that unchecked components are null 0N/A // Check that unchecked component properties are not defined, 0N/A // and report any failures 0N/A // Summarization and reporting 0N/A ?
"Correct exception" :
"UNEXPECTED EXCEPTION");
0N/A .s(
"http").h(
"www.w3.org").p(
"/Addressing/").z();
0N/A .s(
"ftp").h(
"ds.internic.net").p(
"/rfc/").z();
0N/A header(
"RFC2396: Normal relative-URL examples (appendix C)");
0N/A .s(
"http").h(
"a").p(
"/b/c/d;p").q(
"q").z().
url());
0N/A // test(base, "http:h").s("g").p("h").z(); 0N/A test(
base,
"?y").s(
"http").h(
"a").p(
"/b/c/").q(
"y").z();
0N/A test(
base,
"g?y").s(
"http").h(
"a").p(
"/b/c/g").q(
"y").z();
0N/A // #s (current document)#s 0N/A // DEVIATION: Lone fragment parses as relative URL with empty path, 0N/A // and resolves without removing the last segment of the base path. 0N/A // test(base,"#s").s("http").h("a").p("/b/c/d;p").f("s").z(); 0N/A test(
base,
"#s").s(
"http").h(
"a").p(
"/b/c/d;p").q(
"q").f(
"s").z();
0N/A test(
base,
"g#s").s(
"http").h(
"a").p(
"/b/c/g").f(
"s").z();
0N/A test(
base,
"g?y#s").s(
"http").h(
"a").p(
"/b/c/g").q(
"y").f(
"s").z();
0N/A test(
base,
"g;x?y#s").s(
"http").h(
"a").p(
"/b/c/g;x").q(
"y").f(
"s").z();
0N/A .s(
"http").h(
"s2").u(
null).p(
"/p2").z();
0N/A header(
"RFC2396: Abnormal relative-URL examples (appendix C)");
0N/A test(
base,
"../../../g").s(
"http").h(
"a").p(
"/../g").z();
0N/A test(
base,
"../../../../g").s(
"http").h(
"a").p(
"/../../g").z();
0N/A test(
base,
"g;x=1/./y").s(
"http").h(
"a").p(
"/b/c/g;x=1/y").z();
0N/A test(
base,
"g;x=1/../y").s(
"http").h(
"a").p(
"/b/c/y").z();
0N/A test(
base,
"g?y/./x").s(
"http").h(
"a").p(
"/b/c/g").q(
"y/./x").z();
0N/A test(
base,
"g?y/../x").s(
"http").h(
"a").p(
"/b/c/g").q(
"y/../x").z();
0N/A test(
base,
"g#s/./x").s(
"http").h(
"a").p(
"/b/c/g").f(
"s/./x").z();
0N/A test(
base,
"g#s/../x").s(
"http").h(
"a").p(
"/b/c/g").f(
"s/../x").z();
0N/A // test(base,"http:g").s("http").p("g").z(); 0N/A .s(
"http").h(
"1.2.3.4").n(
5).p(
"").z();
0N/A .s(
"http").h(
"[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]")
0N/A .s(
"http").h(
"[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210%12]")
0N/A .s(
"http").h(
"[1080:0:0:0:8:800:200C:417A]").p(
"/index.html").z();
0N/A .s(
"http").h(
"[1080:0:0:0:8:800:200C:417A%1]").p(
"/index.html").z();
0N/A test(
"http://[3ffe:2a00:100:7031::1]")
0N/A .s(
"http").h(
"[3ffe:2a00:100:7031::1]").p(
"").z();
0N/A test(
"http://[1080::8:800:200C:417A]/foo")
0N/A .s(
"http").h(
"[1080::8:800:200C:417A]").p(
"/foo").z();
0N/A .s(
"http").h(
"[::192.9.5.5]").p(
"/ipng").z();
0N/A test(
"http://[::192.9.5.5%interface]/ipng")
0N/A .s(
"http").h(
"[::192.9.5.5%interface]").p(
"/ipng").z();
0N/A .s(
"http").h(
"[::FFFF:129.144.52.38]").n(
80).p(
"/index.html").z();
0N/A test(
"http://[2010:836B:4179::836B:4179]")
0N/A .s(
"http").h(
"[2010:836B:4179::836B:4179]").p(
"").z();
0N/A .s(
"http").h(
"[FF01::101]").p(
"").z();
0N/A .s(
"http").h(
"[::1]").p(
"").z();
0N/A .s(
"http").h(
"[::]").p(
"").z();
0N/A .s(
"http").h(
"[::%hme0]").p(
"").z();
0N/A test(
"http://[0:0:0:0:0:0:13.1.68.3]")
0N/A .s(
"http").h(
"[0:0:0:0:0:0:13.1.68.3]").p(
"").z();
0N/A test(
"http://[0:0:0:0:0:FFFF:129.144.52.38]")
0N/A .s(
"http").h(
"[0:0:0:0:0:FFFF:129.144.52.38]").p(
"").z();
0N/A test(
"http://[0:0:0:0:0:FFFF:129.144.52.38%33]")
0N/A .s(
"http").h(
"[0:0:0:0:0:FFFF:129.144.52.38%33]").p(
"").z();
0N/A .s(
"http").h(
"[::13.1.68.3]").p(
"").z();
0N/A .s(
"http").h(
"[::13.1.68.3]").p(
"").z();
0N/A test(
"http://[ff01:234/foo").x().z();
0N/A test(
"http://[ff01:234:zzz]/foo").x().z();
0N/A test(
"http://[129.33.44.55]").x().z();
0N/A test(
"http://[ff:ee:dd::cc:bb::aa:9:8]").x().z();
0N/A test(
"http://[1:2:3:4:5:6:7:8%]").x().z();
0N/A test(
"http://[1:2:3:4:5:6:7:8%!/]").x().z();
0N/A test(
"http://[1:2:3:4:5:6:7:8:9]").x().z();
0N/A test(
"http://[::1.2.3.300]").x().z();
0N/A test(
"http://[1.2.3.4:5]").x().z();
0N/A // Optional IPv6 brackets in constructors 0N/A test(
"http",
"1:2:3:4:5:6:7:8", -
1,
"")
0N/A .s(
"http").h(
"[1:2:3:4:5:6:7:8]").p(
"").z();
0N/A test(
"http",
"1:2:3:4:5:6:7:8%hme0", -
1,
"")
0N/A .s(
"http").h(
"[1:2:3:4:5:6:7:8%hme0]").p(
"").z();
0N/A test(
"http",
"[1:2:3:4:5:6:7:8]", -
1,
"")
0N/A .s(
"http").h(
"[1:2:3:4:5:6:7:8]").p(
"").z();
0N/A // -- Command-line invocation -- 0N/A out.
println(
" java Test <base> <url> -- Parses url and base, then resolves");
0N/A // clargs(null, args[0]); 0N/A // clargs(args[0], args[1]);