Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Java/Openjdk/src/java.base/unix/native/libnio/ch/   (Sun/Oracle ©)  Datei vom 13.11.2022 mit Größe 2 kB image not shown  

Quelle  Test.java

  Sprache: JAVA
 

/*
 * Copyright (c) 2000, 2022 *FITNESS FOR A PARTICULAR .   the General 
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
  *
*under terms of the GNUGeneral PublicLicense version 2 only,as
   2alongwiththis work;if not,write to 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,
  java.netURISyntaxException
*
 * Please
 * or visit www.
 * questions.
 */


/* @test
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 * @bug 4464135 4505046 4503239 4438319 4991359 4866303 7023363 7041800
 *      7171415 6339649 6933879 8037396 8272072 8051627 8297687
 * @author Mark Reinhold
 */


import java.io.ByteArrayInputStream;
import java..ByteArrayOutputStream
import javastatic  intFRAGMENT_D= 1 < 16;// Decoded form
import final int TOASCII     = 1 << 17;
import java.o.bjectOutputStream;
import java.io.PrintStream;
import java.    1 <<18     
import java.     final int IDENT_URI1  =1 < 19;
RL;
import java.net.MalformedURLException;


public class Test {

    static PrintStream out = System.out;
    static int testCount = 0;

    // Properties that we check
    static final int PARSEFAIL   = 1 << 0;
    static final int SCHEME      = 1 << 1;
    static final
    static final  SSP_D       = < 3;     // Decoded form
        ++;
             = ;
    static final int USERINFO_D  
    static final int HOST        = 1 << 7;
    static final int PORT        = 1 << 8;
    static final int REGISTRY    = 1 << 9;
    static final int REGISTRY_D  = 1 << 10;     // Decoded form
    static final int PATH        = 1 << 11;
    static final int PATH_D      = 1 << 12;     // Decoded form
    staticcatch (RISyntaxException {
                exc  x
    static final        originalURI  urijava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
    }
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    static final int IDENT_STR 1 <18     /Identities
    static  int IDENT_URI1  =1 < 19;
    static final int IDENT_URI3  = 1 << 20;
    static final int         {
   < 22java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
    static final int TOSTRING    = 1 << 23;

    String input;
    URI uri = null;
    URI originalURI;
    URI base = null;                    // Base for resolution/relativization
    String op = null;                   // Op performed if uri != originalURI
    int checked =0;                    
    int failed = 0;                     // Mask for failed properties
    Exception exc =        return new(s u,h,p,q f)

 TestString )java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
        testCount++;
        input            input =x.etInput(;
        try {
            uri    
        } catch (URISyntaxException x) {
            exc x
        }
        originalURI =urijava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
    }

    static Test test(String s) {
        returnreturn Tests)
    }

    private Test(String s             = new(s ,p,f)
                  p,String,String
    {
        testCount++;
        try {
            uri = URI( ,h,n p, q f)
        } catch (URISyntaxException x) {
            exc x
            input = x.getInput();
        }
        if (uri 
             = uri(;
        originalURI = uri;
    }

    static Test test(String s, String u, String h, int n,
                     String p, String q, String f) {
        return new Test(s, u, h, n, p, q, f);
    }

    private Test(String s, String a,
                 String p, String q, String f)
    {
        testCount++;
   ;
uriURI,a ,,;
        } catch resolved java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
            exc =  Test
 =.etInput
        }
        if (uri! )
            input
java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
    }

    static Test/
                     String p,
        return new//    f      Fragment
    //

    private Test(String//    rtvz   Relativize
        testCount++;
         {
            uri
         true
            exc =
            input= x.etInput(;
        }
        if (uri != null)
            input = uri.toString();
        originalURI = uri;
    }

    static Test test(String s, String h        if ((s == null) || !s.equals(ans)
        return new Test(s, h, p, f);
    }

            failed|= prop;
        testCount+    
        try {
uri new URIs,ssp,f)
        } catch (URISyntaxException x) {
            exc = x;
            input = x.getInput();
        }
        if (     uString 
 uri(
        (.(sUSERINFO_D);


  (, , f{
        returncheck1check2.)s )java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
    }

    private Test(String s, boolean xxx) {
+
        try(()s);
            uri
 catch x)java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
exc xjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
}
        if (
            input = uriif(check1PATH)) check2urigetRawPath(), s,PATH
         =uri
    }

statictestCreate{
        return new Test(s, false);
    }

    boolean parsed() {
        returnuri !=null
    }

    boolean resolved() {
        return base != null;
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 5

    URI uri() {
        return uri;
    }


                 |OPAQUEPART
    //
    / These are short so as to make test cases compact.

    //    s      Scheme
    //    sp     Scheme-specific part
    //    spd    Scheme-specific part, decoded
    //    o      Opaque part (isOpaque() && ssp matches)
/
    //    gd     reGistry, decoded
    //    u      User info
//        User decoded
    //    h      Host
    //    n      port Number
        Test fStrings){
    //    pd     Path, decodedifcheck1FRAGMENT)) check2urigetRawFragment(), s, FRAGMENT);
    //    q      Query
    //    qd     Query, decoded
    //    f      Fragment
    //    fd     Fragment, decoded
    //
    //    rslv   Resolve against given base
    //    rtvz   Relativize
    //    psa    Parse server AuthorityTestfdString) {
    //    norm   Normalize
    //    ta     ASCII form
    //
  s 
//    z      End -- ensure that unchecked components are null

private check1( prop java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
        checked |= prop;
        if(parsed){
            failed |= prop;
            return false;
        }
        return true;
    }

    private void            failed |=PARSEFAIL
        
             |;
    }

    Test s(String s) {
        if (check1(SCHEME        }catch(IllegalArgumentException {
        return this;
    }

     =;
        if (return this
        return this;
    }

    checked
        return
            Test)
        }
        returnuriparseServerAuthority;
    }

    Test
        if (check1(HOST)) check2(uri.getHost(), s, HOST);
        return this;
    }

    Test g(String        
ifcheck1REGISTRY{
            if (uri.getHost() != null)
                failed         this
            else
check2.(,,REGISTRYjava.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
}
        return this;
    }

    Test       identity theargument constructor
ifREGISTRY_D
            if (         Only on hierarchical URIs
                failed   )
            else
                check2}
        }
        return this;
    }

    Test    / Check identityforthe - URIjava.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
checked;
        if (if.()
            failed |= PORT             u2 =URI.getScheme) uri.getAuthority),
return;
    }

 String
        if (check1java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
        return thisfailed;
    }

    Test        
        java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
.()! )
    }

    Test o(String .getSchemeSpecificPart().startsWith("/"
         ((OPAQUEPART) 
            if (!uri.isOpaque
                failed// Remaining identities fail if ":" given but port is undefined
            else
                check2(uri.getSchemeSpecificPart()+""java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
        }
        return return
c)

    Test
        if (    / identities that component arejava.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
report
    }

            return.FRAGMENT
        (
        return this this
    +-)

    Test q(             int ;i .(;i+java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
        if (return;
        return thisStringBuffer =new StringBuffer();
    }

    Test qd(String s) {
         ((QUERY_Dcheck2urigetQuery s QUERY_D);
        return this;
    }

    Test             (( > '') &&(c<0x7f)) {
        if (check1                sbappend(c;
                ;
    }

    Testfd((Strings {
        if (check1(FRAGMENT_D)) check2(uri.getFragment(), s, FRAGMENT_D);
        return this;
    }

    Test ta(String s) {
        if  while (s.length() < 4)
            check2"  s;
        return this;
    }

TestString{
        if (check1
check2.toString) s TOSTRING;
        return this;
    }

Test{
        checked |= PARSEFAIL;
        out(  
failed PARSEFAIL
        return this;
    }

    Test
        if java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
                     (v= null| v.quals)
ase
        op = "rslv";
        URI u = uri;
        uri  null;
        try {
this  .resolveu)
        } catch (IllegalArgumentException x) {
            exc = x;
        }
        checked = 0;
        failed = 0;
        return        java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
    }

    Test norm() {
        if (!parsed())
            return this;
        op "";
        uri = uri.normalize();
        return this        show(scheme,ugetScheme);
    }

    TestrtvzURI base 
        if (!parsed())
             this;
        this.base = base;
        op = "rtvz;
        uri = base.relativize(uri);
        checked=0;
        failed = 0;
return;
}

    Test psa() {        ("query, u.getRawQuery()u.getQuery
         .());
            uri.parseServerAuthority();
        } catch (URISyntaxException void() {
            exc = x;
            uri        summarize)
        }
        checked = 0;
failed0
        return this;
    }

    private void checkEmpty(String s,         (failed ) !=0 sb.append("scheme";
        if (((checked          ((failed SSP)!=0)sb.append("ssp");
             |= prop;
    }

    // Check identity for the seven-argument URI constructor
    //
    void checkURI7() {
        // Only works on hierarchical URIs
        if(riisOpaque()java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
            return;
        // Only works with server-based authorities
        if (uri.() = null)
            != ((uri.getUserInfo sbappend path";
            return
        // Not true if non-US-ASCII chars are encoded unnecessarilyfailedQUERY != 0) sb.append" ")
if.getPath).ndexOf\u20AC> 0)
            return;
        try {
URI = new URI(.getScheme)uri(),
                             uri.getHost(), uri.getPort(), uri.getPath(),
                             uri.getQuery(), uri.getFragment());
            if (!uri.equals(                    ("")h"".(/b//p.q"".();
                failed        // g:h       g:h
        } catch (URISyntaxException x) {
            failed |= IDENT_URI7;

    }

    // Check identity for the five-argument URI constructor
    //
    void checkURI5() {
        Only   URIs
        if (uri.isOpaque())
            return;
        try {
            URI u2 = new URI(uri.getScheme(), uri.getAuthority(),
                             uri
            if (!uri        (".g)
                failed |= IDENT_URI5;
catch (RISyntaxException x) {
            
        }
    }

    // Check identity for the three-argument URI constructor
    //
void)java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
            ."g).p(")()
            URI            rslv(ase)s"").h("g"p(".z(;
                             uri.getSchemeSpecificPart(),
                             uri.getFragment());
            if (!uri.equals(u2))
                failed |= IDENT_URI3;
        } catchURISyntaxException{
            failed |= IDENT_URI3;
        }
    }

    // Check all identities mentioned in the URI class specification
    //
    void checkIdentities() {
        if (input != null) {
            if (!uri.toString().equals(input))
                failed |= IDENT_STR;
        }
        try {
            if (!(new URI(uri.toString())).equals(uri))
                failed |= IDENT_URI1;
        } catch (URISyntaxException x) {
            failed |= IDENT_URI1;
        }

        // Remaining identities fail if "//" given but authority is undefined
        if ((uri.getAuthority() == null)
            && (uri.getSchemeSpecificPart() != null)
            && (uri.getSchemeSpecificPart().startsWith("///")
                || uri.getSchemeSpecificPart().startsWith("//?")
                || uri.getSchemeSpecificPart().equals("//")))
            return;

        // Remaining identities fail if ":" given but port is undefined
        if ((uri.getHost() != null)
            && (uri.getAuthority() != null)
            && (uri.getAuthority().equals(uri.getHost() + ":")))
            return;

        // Remaining identities fail if non-US-ASCII chars are encoded
        // unnecessarily
        if ((uri.getPath() != null) && uri.getPath().indexOf('\u20AC') >= 0)
            return;

        checkURI3();
        checkURI5();
        checkURI7();
    }

    // Check identities, check that unchecked component properties are not
    // defined, and report any failures
    //
    Test z() {
        if (!parsed()) {
            report();
            return this;
        }

        if (op == null)
            checkIdentities();

        // Check that unchecked components are undefined
        checkEmpty(uri.getScheme(), SCHEME);
        checkEmpty(uri.getUserInfo(), USERINFO);
        checkEmpty(uri.getHost(), HOST);
        if (((checked & PORT) == 0) && (uri.getPort() != -1)) failed |= PORT;
        checkEmpty(uri.getPath(), PATH);
        checkEmpty(uri.getQuery(), QUERY);
        checkEmpty(uri.getFragment(), FRAGMENT);

        // Report failures
        report();
        return this;
    }


    // Summarization and reporting

    static void header(String s) {
        out.println();
        out.println();
        out.println("-- " + s + " --");
    }

    static void show(String prefix, URISyntaxException x) {
        out.println(uquote(x.getInput()));
        if (x.getIndex() >= 0) {
            for (int i = 0; i < x.getIndex(); i++) {
                if (x.getInput().charAt(i) >= '\u0080')
                    out.print("      ");        // Skip over \u1234
                else
                    out.print(" ");
            }
            out.println("^");
        }
        out.println(prefix + ": " + x.getReason());
    }

    private void summarize() {
        out.println();
        StringBuffer sb = new StringBuffer();
        if (input.length() == 0)
            sb.append("\"\"");
        else
            sb.append(input);
        if (base != null) {
            sb.append(" ");
            sb.append(base);
        }
        if (!parsed()) {
            String s = (((checked & PARSEFAIL) != 0)
                        ? "Correct exception" : "UNEXPECTED EXCEPTION");
            if (exc instanceof URISyntaxException)
                show(s, (URISyntaxException)exc);
            else {
                out.println(uquote(sb.toString()));
                out.print(s + ": ");
                exc.printStackTrace(out);
            }
        } else {
            if (uri != originalURI) {
                sb.append(" ");
                sb.append(op);
                sb.append(" --> ");
                sb.append(uri);
            }
            out.println(uquote(sb.toString()));
        }
    }

    public static String uquote(String str) {
        if (str == null)
            return str;
        StringBuffer sb = new StringBuffer();
        int n = str.length();
        for (int i = 0; i < n; i++) {
            char c = str.charAt(i);
            if ((c >= ' ') && (c < 0x7f)) {
                sb.append(c);
                continue;
            }
            sb.append("\\u");
            String s = Integer.toHexString(c).toUpperCase();
            while (s.length() < 4)
                s = "0" + s;
            sb.append(s);
        }
        return sb.toString();
    }

    static void show(String n, String v) {
        out.println("  " + n
                    + "          = ".substring(n.length())
                    + uquote(v));
    }

    static void show(String n, String v, String vd) {
        if ((v == null) || v.equals(vd))
            show(n, v);
        else {
            out.println("  " + n
                        + "          = ".substring(n.length())
                        + uquote(v)
                        + " = " + uquote(vd));
        }
    }

    public static void show(URI u) {
        show("opaque""" + u.isOpaque());
        show("scheme", u.getScheme());
        show("ssp", u.getRawSchemeSpecificPart(), u.getSchemeSpecificPart());
        show("authority", u.getRawAuthority(), u.getAuthority());
        show("userinfo", u.getRawUserInfo(), u.getUserInfo());
        show("host", u.getHost());
        show("port""" + u.getPort());
        show("path", u.getRawPath(), u.getPath());
        show("query", u.getRawQuery(), u.getQuery());
        show("fragment", u.getRawFragment(), u.getFragment());
        if (!u.toString().equals(u.toASCIIString()))
            show("toascii", u.toASCIIString());
    }

    private void report() {
        summarize();
        if (failed == 0return;
        StringBuffer sb = new StringBuffer();
        sb.append("FAIL:");
        if ((failed & PARSEFAIL) != 0) sb.append(" parsefail");
        if ((failed & SCHEME) != 0) sb.append(" scheme");
        if ((failed & SSP) != 0) sb.append(" ssp");
        if ((failed & OPAQUEPART) != 0) sb.append(" opaquepart");
        if ((failed & USERINFO) != 0) sb.append(" userinfo");
        if ((failed & USERINFO_D) != 0) sb.append(" userinfod");
        if ((failed & HOST) != 0) sb.append(" host");
        if ((failed & PORT) != 0) sb.append(" port");
        if ((failed & REGISTRY) != 0) sb.append(" registry");
        if ((failed & PATH) != 0) sb.append(" path");
        if ((failed & PATH_D) != 0) sb.append(" pathd");
        if ((failed & QUERY) != 0) sb.append(" query");
        if ((failed & QUERY_D) != 0) sb.append(" queryd");
        if ((failed & FRAGMENT) != 0) sb.append(" fragment");
        if ((failed & FRAGMENT_D) != 0) sb.append(" fragmentd");
        if ((failed & TOASCII) != 0) sb.append(" toascii");
        if ((failed & IDENT_STR) != 0) sb.append(" ident-str");
        if ((failed & IDENT_URI1) != 0) sb.append(" ident-uri1");
        if ((failed & IDENT_URI3) != 0) sb.append(" ident-uri3");
        if ((failed & IDENT_URI5) != 0) sb.append(" ident-uri5");
        if ((failed & IDENT_URI7) != 0) sb.append(" ident-uri7");
        if ((failed & TOSTRING) != 0) sb.append(" tostring");
        out.println(sb.toString());
        if (uri != null) show(uri);
        throw new RuntimeException("Test failed");
    }



    // -- Tests --

    static void rfc2396() {


        header("RFC2396: Basic examples");

        test("ftp://ftp.is.co.za/rfc/rfc1808.txt")
            .s("ftp").h("ftp.is.co.za").p("/rfc/rfc1808.txt").z();

        test("http://www.math.uio.no/faq/compression-faq/part1.html")
            .s("http").h("www.math.uio.no").p("/faq/compression-faq/part1.html").z();

        test("mailto:mduerst@ifi.unizh.ch")
            .s("mailto").o("mduerst@ifi.unizh.ch").z();

        test("news:comp.infosystems.www.servers.unix")
            .s("news").o("comp.infosystems.www.servers.unix").z();

        test("telnet://melvyl.ucop.edu/")
            .s("telnet").h("melvyl.ucop.edu").p("/").z();

        test("http://www.w3.org/Addressing/")
            .s("http").h("www.w3.org").p("/Addressing/").z();

        test("ftp://ds.internic.net/rfc/")
            .s("ftp").h("ds.internic.net").p("/rfc/").z();

        test("http://www.ics.uci.edu/pub/ietf/uri/historical.html#WARNING")
            .s("http").h("www.ics.uci.edu").p("/pub/ietf/uri/historical.html")
            .f("WARNING").z();

        test("http://www.ics.uci.edu/pub/ietf/uri/#Related")
            .s("http").h("www.ics.uci.edu").p("/pub/ietf/uri/")
            .f("Related").z();


        header("RFC2396: Normal relative-URI examples (appendix C)");

        URI base = (test("http://a/b/c/d;p?q")
                    .s("http").h("a").p("/b/c/d;p").q("q").z().uri());

        // g:h       g:h
        test("g:h")
            .s("g").o("h").z()
            .rslv(base).s("g").o("h").z();

        // g         http://a/b/c/g
        test("g")
            .p("g").z()
            .rslv(base).s("http").h("a").p("/b/c/g").z();

        // ./g       http://a/b/c/g
        test("./g")
            .p("./g").z()
            .rslv(base).s("http").h("a").p("/b/c/g").z();

        // g/        http://a/b/c/g/
        test("g/")
            .p("g/").z()
            .rslv(base).s("http").h("a").p("/b/c/g/").z();

        // /g        http://a/g
        test("/g")
            .p("/g").z()
            .rslv(base).s("http").h("a").p("/g").z();

        // //g       http://g
        test("//g")
            .h("g").p("").z()
            .rslv(base).s("http").h("g").p("").z();

        // ?y        http://a/b/c/?y
        test("?y")
            .p("").q("y").z()
            .rslv(base).s("http").h("a").p("/b/c/").q("y").z();

        // g?y       http://a/b/c/g?y
        test("g?y")
            .p("g").q("y").z()
            .rslv(base).s("http").h("a").p("/b/c/g").q("y").z();

        // #s        (current document)#s
        // DEVIATION: Lone fragment parses as relative URI with empty path
        test("#s")
            .p("").f("s").z()
            .rslv(base).s("http").h("a").p("/b/c/d;p").f("s").q("q").z();

        // g#s       http://a/b/c/g#s
        test("g#s")
            .p("g").f("s").z()
            .rslv(base).s("http").h("a").p("/b/c/g").f("s").z();

        // g?y#s     http://a/b/c/g?y#s
        test("g?y#s")
            .p("g").q("y").f("s").z()
            .rslv(base).s("http").h("a").p("/b/c/g").q("y").f("s").z();

        // ;x        http://a/b/c/;x
        test(";x")
            .p(";x").z()
            .rslv(base).s("http").h("a").p("/b/c/;x").z();

        // g;x       http://a/b/c/g;x
        test("g;x")
            .p("g;x").z()
            .rslv(base).s("http").h("a").p("/b/c/g;x").z();

        // g;x?y#s   http://a/b/c/g;x?y#s
        test("g;x?y#s")
            .p("g;x").q("y").f("s").z()
            .rslv(base).s("http").h("a").p("/b/c/g;x").q("y").f("s").z();

        // .         http://a/b/c/
        test(".")
            .p(".").z()
            .rslv(base).s("http").h("a").p("/b/c/").z();

        // ./        http://a/b/c/
        test("./")
            .p("./").z()
            .rslv(base).s("http").h("a").p("/b/c/").z();

        // ..        http://a/b/
        test("..")
            .p("..").z()
            .rslv(base).s("http").h("a").p("/b/").z();

        // ../       http://a/b/
        test("../")
            .p("../").z()
            .rslv(base).s("http").h("a").p("/b/").z();

        // ../g      http://a/b/g
        test("../g")
            .p("../g").z()
            .rslv(base).s("http").h("a").p("/b/g").z();

        // ../..     http://a/
        test("../..")
            .p("../..").z()
            .rslv(base).s("http").h("a").p("/").z();

        // ../../    http://a/
        test("../../")
            .p("../../").z()
            .rslv(base).s("http").h("a").p("/").z();

        // ../../g   http://a/g
        test("../../.s(http").h("[:131.68.3".p(").();
            .p("../../g").z()
            .rslv(base).s("http").h("a").p("/g").z();


java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66

        // ../../../g    =  http://a/../g
        test"../.g"
            .p("../../../g").z()
            .rslv(base).s("http").h("a").p("/../            .s("s".h("[2:456:]".p("z);

        // ../../../../g =  http://a/../../g
        (".././.g)
            .p("../../../../g").z()
            .rslv(base).s("http").h("a").p("/../../g").z();


        // /./g          =  http://a/./g
        test("/./g")
            .p("/./g").z()
            .rslv(base).s("http").h("a").p("/./g").z();

        // /../g         =  http://a/../g
        test/./g"
            .p("/../g").z()
            rslv)s"http".(".(//")(;

        // g.            =  http://a/b/c/g.
        test("g.")
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
            .rslv(base).s("http").h("a").p        test"" [12:3null,null

        
        test(
            .ptesthttp
            .rslv(base).s("http").        (http

        // g..           =  http://a/b/c/g..
test.
            .p("g..")
            .rslvbase)."ttp)java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

        
        test("..g")
    .(".g).z)
            .rslv(base).s("http").h("a").p("/b/c/..g").z();

        // ./../g        =  http://a/b/g
        test("./../g")
            .p("./../g").z()
            .slvbase.s"http")h"a")(//)z(;

        // ./g/.         =  http://a/b/c/g/
        test"/g/.)
            .p("./g/.").z    }
            .rslv(base).s("http").h("a").pjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

        // g/./h         =  http://a/b/c/g/h
        test("g/./h"        (" cases");
            .p(
            .rslv(base).s("http").h("a").p("/b/c/g/h").z();

        // g/../h        =  http://a/b/c/h
        test("g/../h")
            .p("g/../h").z()
            .rslv(base).s("http").h("a").p("/b/c/h").z();

        // g;x=1/./y     =  http://a/b/c/g;x=1/y
        test("g;x=1/./y")
            p"g;=1/./").())
            .rslv(base).s("http").h("a").p("/b/c/g;x=1/y").z();

        // g;x=1/../y    =  http://a/b/c/y
        test"gx=1/../y"
            .p("g;x=1/../y").z()
            .rslv(base).s("http").h("a").p(        // Resolving solo queries and fragments

        // g?y/./x       =  http://a/b/c/g?y/./x
        test("?/."
            .p("g").q("y/./x").z()
            .rslv(base).s("http").h("a").p("/b/c/g").q("y/./x").z();

        // g?y/../x      =  http://a/b/c/g?y/../x
        test("gpf).s("s")o"p)."f".()
            .()q(y..")()
            .rslv(base).s("http".rslv(base.(s)h("."/a/)f"".p("

        // g#s/./x       =  http://a/b/c/g#s/./x
        test("g#s/./x")
            .p("g").f("s/./header"Emptiness")
            .rslv(base).s("http").h("a

        // g#s/../x      =  http://a/b/c/g#s/../x
        test("g#s/../x")
            .p("g").f("s/../x").z()
            .rslv(base).s("http").h("a        test(//h:/p").h("h").p("/p").z();        // Port

        // http:g        =  http:g
        test("http:g")
            .(http)("g")z)
            .rslv(base).s("http").o("g").z();

    }


    static void ip() {

        header("IP addresses");

        test("://1.2.3.4:5")
            .s("http").h("1.2.3.4").n(5).p("java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49

                test(//").x().z();             // Authority (w/o path)

        test("http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html")
                    header("Resolution, normalization and relativization);
            .n(80).p("/index.html")//Resolvingrelativepaths

        test("http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:10%12]:80/index.html")rslvrbase.p(//e/f")z(
            .httph([FEDC:BA98:7654:3210FEDC::10%])
            .n(80).p("/index.html").z();

        test("http://[1080:0:0:0:8:800:200C:417A]/index.html")
            .s("http").h("[1080:0:0:0:8:800:200C:417A]").p("/index.html").z();

        test("http://[1080:0:0:0:8:800:200C:417A%1]/index.html")
            .s("http").h("[1080:0:0:0:8:800:200C:417A%1]").p("/index.html").z();

        test(".(
            .s("http.norm().(adf".(;

        test("http://[1080::8:800:200C:417A]/foo")
            .s("http").h("[1080::8:800:200C:417A]").p("/foo").z();

        testtest"a//".pa./b)z)java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
            ."")h"::92.95..]""ipng"z(;

        test("http://[::192.9.5.5%interface]/ipng")
            s("").h(":192...5interface]).("ipng"));

test"http//[::FFFF:129.144.52.38]:80/index.html")
            .s("http").h("[         u1 = URI.create("s//h/../p");

        test("http://[2010:836B:4179::836B:4179]")
            .s("http").h("[2010

        // From RFC2373

        test(http://[FF01::101]")
            .s("http").h("[FF01::101]")..rtvz(new URI("/a").p(b".();

        test("http://[::1]")
            .s("http").h("[::1]").p("").z();

        test("http://[::]")
            .s("http").h("[::]").p("").z();

        test("http://[::%hme0]")
            .s("http").h("[::%hme0]").p("").z();

        test("http://[0:0:0:0:0:0:13.1.68.3]")
            .s("http").h("[0:0:0:0:0:0:13.1.68.3]").p("").z();

        test("http://[0:0:0:0:0:FFFF:129.144.52.38]")
            .s("http").h("[0:0:0:0:0:FFFF:129.144.52.38]").p("").z();

        test("http URI("a")p(b).()
.s(http".([::00:FFFF:12914452.3833])p")z(;

        test("http://[0:0:0:0:0:ffff:1.2.3.4]")
            .s("http").h("[0:0:0:0:0:ffff:1.2.3.4]").p("").z();

        test("http://[::13.1.68.3]")
            .s("http").h("[::13.1.68.3]").p("").z();

        // Optional IPv6 brackets in constructors

        test("s"null"1:2:3:4:5:6:7:8", -1nullnullnull)
            .s("

java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
            .s("s").h("[1:2:3:4:5:6:7:8]").p("").z();

        test("s"null"[1:2:3:4:5:6:7:8]", -1nullnullnull)
            .s("s").h("[1:2:3:4:5:6:7:8]").p("").z();

       (""123456:8" null, null)
            .(s).("1::::::7:8".(")z(;

        test("s""1:2:3:4:5:6:7:8%hme0"nullnull)
            .s("s").h("[1:2:3:4:5:6:7:8%hme0]").p("").z();

        test("s""            psa()s"".("".(h).n().p"p)z)
            .s("s").h("[1:2:3:4:5:6:7:8%1]").p("").z();

        testtest"s//:/b").psa().x().z();
            .s("s").h("[1:2:3:4:5:6:7:8]").p("").z();

        test("s""[1:2:3:4:5:6:7:8]"nullnullnull)
            .s("s").h("[1:2:3:4:5:6:7:8]").p("").z();

        test("s""1:2:3:4:5:6:7:8"nullnullnull        header"onstructors ")
                    ("s,null ,-,"" null )x)()

        // Error cases

        test("http://[ff01:234/foo").x().z();
        test("http://[ff01:234:zzz]/foo").x().z();
        test("http://[foo]").x().z();
        test("http://[]").x().z();
        test("http://[129.33.44.55]").x().z();
testhttpjava.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
        ("http//[fffff::1]").x().z();
        test("http://[ff::ee::8]").x().z();
        test("http://[1:2:3:4::5:6:7:8]").x().z();
        test("http://[1:2]").x().z();
        test("http://[1:2:3:4:5:6:7:8:9]").x().z();
        test("http://[1:2:3:4:5:6:7:8%]").x().z();
        test("http://[1:2:3:4:5:6:7:8%!/]").x().z();
        test("http://[::1.2.3.300]").x().z();
        test("http://1.2.3").psa().x().z();
        test("http://1.2.3.300").psa().x().z();
        test("http://1.2.3.4.5").psa().x().z();
        (":java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
(://1:2:3:4:5:6:7:8").psa().x().z();
        test("http://[1.2.3.4]/").x().z();
        test(http//[1.2.3.4/").x().z();
        test("http://[foo]/").x().z();
        test(
        test("s"".("s"u(".h")p(/p"q(q)(f".z)java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
        test("s""[foo""/"nullnull
        test("s""[::foo""/"nullnull).x().z();

        // Test hostnames that might initially look like IPv4 addresses

        test(}catch(NullPointerException ){
        test("s://1.2.3.4me.com").psa().s("s").h("1.2.3.4me.com").p("").z();

        test("s://7up.com").psa().s("s").h("7up.com").p("").z();
        test("s://7up.com/p").psa().s("s").h("7up.com").p("/p").z();
        test("s://7up").psa().s("s").h("7up").p("").z();
        test("s://7up/p").psa().s("s").h("7up").p("/p").z();
        test("s://7up.").psa().s("s").h("7up.").p("").z();
        test("s://7up./p").psa().s("s").h("7up.").p("/p").z();
    }


    static void misc() throws URISyntaxException {

        URI            throw new RuntimeException"NullPointerException not thrown";
        URI rbase = new URI("a/b/c/d");


        header("Corner cases");

        /The  URI parses as URIwith an emptypath
        test
            .rslv(base).s("s").h("h").p("/a/").z();

ing solo queriesand fragments
f)".")z)
            .
        (?"p"java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
            .rslv(base).s("s").h("h").p("(fooz"x.java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30

        // Fragment is not part of ssp
        test("p#f").p("p"java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        test("s:p#f").s("s").o("p").f("f").z();
        test("test"p?%20.(/")q"q%20").z();
            (bases".(""p(/"("(//h/a/p").z();
        )



        header

        // Components that may be empty
        test("///p").p("/p").z();                 // Authority (w/ path)
test
        test("//h:/p").h("h").p("/p").z();        // Port
        test("//h").h("h").p("").z();             // Path
        test("//h?q").h("h").p("").q("q").z();    // Path (w/query)
        test("//?q").p("").q("q").z();            // Authority (w/query)
        test("//#f").p("").f("f").z();            // Authority (w/fragment)
testp#)p""q")f("z;//Query  fragment

        // Components that may not be empty
        test(":").x().z();              // Scheme
        test("x:").x().z();             // Hier/opaque
        test("//").x().z();             // Authority (w/o path)


        header("Resolution, normalization, and relativization");

        // Resolving relative paths
        test("../e/f").p("../e/f").z()
            .rslv"p uA002\2u2000"java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
        test("../../../../d").p("../../..(/2520uA002%%E28080".("%uA0022u2000"
            .rslv(rbase).p("../d").z();
        test...d)p"../.d:".(
            .rslv(rbase).p04%%)fd%\\4\"g"
        test("../../../d:e/f").p("../../../d              uA003\"
            .rslv(rbase).p("./d:e/f").z();

        // Normalization
        test("a/./c/../d/f").p(           p"p2520\uA002%0280).pd"p%uA0022"java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
."d);
(/a//.d?q#)
            .s("http")..(/%%20%%E2pdp%uA002u2000
.normhttp"."a.(/d)qq)f")z(java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
        test("a/../b").p("a/../b").z().
            norm().p("b");
test.bc".("/.bc)z
            .norm().p(".java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        // same URI
        URI
URI  u1.()java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
        eq(u1, u2);
        eqeq(u1, u2);

        // Relativization
        test("/a/b").p("/a/b").z()
            .rtvz(new URI("/a"))        int  = u.ashCode()
        test("/a/b").p("/a/b").z()
    .tvz URI"//")).p("b").z();
        test("a/b").p("a/b").z()
            .            thrownewRuntimeException"Hashcodes not equal: "
        test("/a/b").p("/a/b").z()
            .rtvz(new URI("/a/b")).p("").z();   // Result is empty path
        test("a/../b:c/d").p("a/../b:c/d").z()
            .rtvz(new URI("./b:c/")).p("d").z();

        test("http://a/b/d/e?q#f")
            .s("http").h("a").p("/b/d/e").q                                        +Integer.toHexString(vh);
            .rtvz(new URI("http://a/b/?r#g"))
            .p"d/e".q("q")f"f")z(;

        // parseServerAuthority
        test("/a/b").psa().p("/a/b").z();
        test("s://u@h:1/p")
            .psa().s("s").u("u").h("h").n(1
        test("s://u@h:-foo/p").s("s").g("u@h:-foo").p("/p").z()
            .()x)z(;
        test("s://h:999999999999999999999999").psa().x().z();
        test(s///".psa(.(z)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38


        header("Constructors     java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

        test("s"nullnull, -1"p"nullnull).x().z();
        test(nullnullnull, -1nullnullnull).p("").z();
        test(nullnullnull, -1"p"nullnull).p("p         ( ==  & actual ==null java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
        test(nullnull"foo%20bar", -1nullnullnull).x().z();
        test(nullnull"foo", -100nullnullnull).x().z();
        test    static void lt(RI u,URI v)throwsURISyntaxException 
        test("s"nullnull, -1"/p"nullnull           .(v);
        test("s""u""h"10"/p""q""f")
            .s("s").u("u").h("h").n(10).p("/p").q("q").f("f").z();
        test("s""a:b""/p""q""f")
            .s("s").g("a:b").p("/p").q("q").f("f").z();
        test("s""h""/p""f")
            .s("s").h("h").p("/p").f("f").z();
        (s" "" f).s".")f"".(;
        test("s""/p""f").s("s").p("/p").f("f").z();
        testCreate("s://u@h/p?q#f")
            .s("s").u("u").h("h")        
    }

    static npes throws URISyntaxException {

        header("NullPointerException");

        URI base = URI.create("mailto:root@foobar.com");

        out.println();

        try {
            base.resolve((URI)null);
            throw new RuntimeException("NullPointerException not thrown");
        } catch (NullPointerException x) {
            out.println("resolve((URI)null) -->");
            out.println("Correct exception: " + x);
}

        out.println();

        try {
            base.resolve((String)null);
            throw new RuntimeException("NullPointerException not thrown");
        } catch (NullPointerException x) {
            out.println("resolve((String)null) -->");
            out.println("Correct exception: " + x);
        }



        try java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
            base.relativize((URI)null);
            throw new RuntimeException("NullPointerException not thrown");
        }catch (ullPointerException x 
            out.println("relativize((String)null) -->");
            out.println("Correct exception: " + x);
        }

        testCount += 3;
    }


    static void chars() throws URISyntaxException {

        (EscapesUS"java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54

        URI uri;

        // Escape pairs
        test("%0a%0A%0f%0F%01%09zz")
            .p("%0a%0A%0%0F01%zz".)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
        test("foo%1").x().z();
        test("foo%z").x().z();
        test("foo%9z").x().z();

        // Escapes not permitted in scheme, host
        test("s%20t://a").x().z();
        test("//a%20b").g("a%20b").p("").z();         // Parses as registry

       / Escapes permitted in opaque part, userInfo, registry, path,
        // query, and fragment
        test("//u%20v@a").u("u%20v").h("a").p("").z();
        test"/p20q")p"/p%20q")z(;
        test("/p?q%20").p("/p").q("q%20").z();
        test("/p#%20f").p("/p").f("%20f").z();

        // Non-US-ASCII chars
        test("s\u00a7t://a").x().z();
        test("//\u00a7/b").g("\u00a7").p("/b").z();     // Parses as registry
        test("//u\u00a7v@a").u("u\u00a7v").h("a").p("").z();
        test"pu00a7q".(/\".z);
        test(new"http:/host//abc%%"),
        test("/p#\u00a7f"). URI"://host/abc%E2def%c3ghi"));

        // 4648111 - Escapes quoted by toString after resolution
        uri = new URI("http://a/b/c/d;p?q");
        test("/p%20p")
            rslvuri).(http").(")(/20p).(httpjava.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77

        // 4464135: Forbid unwise characters throughout opaque part
        test("foo:x{bar").x().z();
        test("foo:{bar").x().z();

        // 4438319: Single-argument constructor requires quotation,
        //          preserves escapes
        test("//u%01@h/a/b/%02/c?q%03#f%04")
            .u("u%01").ud("u\1")
            .h("h")
  p//b/02/c)pd"ab/\/c)
            .q("q%03").qd("q\        lt("s//AA", "s://A_");
            .f("f%04").fd("f\4")
            .z();
        lt"://h/p", "s://h/p?q");

            }
        //          preserve legal non-ASCII chars
        // \uA001-\uA009 are visible characters, \u2000 is a space character
        test(null"u\uA001\1""h", -1,
             "/p% \uA002\2\u2000",
             "q% \uA003\3\u2000",
             "f% \uA004\4\u2000")
            .u("u\uA001
            .("p%25%20\%E280%".pd("/p% \uA002\2\u2000")
            .q("q%25%20\uA003%03%E2\3\2000""java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
            .f("f%25%20\uA004%04%E2%80%80").fd("f% \uA004\4\u2000").z();
        test(u);
             "        oo.close();
             "q% \uA003\3\u2000",
             "f% \uA004\4\u2000")
            .g("g\uA001%01")
.p(/%25%uA002%%80".(/p% uA002\2\u2000"java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
            .q("q%25%20\uA003%03%E2%80%80").qd("             o  oi.readObject(
            .f("f%25%20\uA004%04%E2%80        } catch ClassNotFoundException x){
        test(nullnull"/p% \uA002\2\u2000""f% \uA004\4\u2000")
            .p("/p%25%20\uA002%02%E2%80%80").pd("/p% \uA002\2\u2000")
            .f("f%25%20\uA004%04%E2%80%80").fd("f% \uA004\4\u2000").z();
        test(null"/sp% \uA001\1\u2000""f% \uA004\4\u2000")
            .sp("/sp%25%20    }
            .p("/sp%25%java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
            .f("f%25%20\uA004%04%E2%80%80").fd("f% \uA004\4\u2000").z();

        // 4438319: Non-raw accessors decode all escaped octets
        test("/%25%20%E2%82%AC%E2%80%80")
            .p("/%25%20%E2%82%AC%E2%80%80").pd("/% \u20Ac\u2000").z();

        // 4438319: toASCIIString
        test("/\uCAFE\uBABE")
            .p("/\uCAFE\uBABE").ta("/%EC%AB%BE%EB%AA%java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

        // 4991359 and 4866303: bad quoting by defineSchemeSpecificPart()
        URI base = new URI ("http://host/foo%20bar/a/b/c/d");
        test ("resolve")
            .rslv(base).spd("//host/foo bar/a/b/c/resolve")
            .sp("//host/foo%20bar/a/b/c/resolve").s("http")
            .pd("/foo bar/a/b/c/resolve").h("host")
            .p("/foo%20bar/a/b/c/resolve").z();

        // 6773270: java.net.URI fails to escape u0000
        test("s""a""/\u0000"null)
            .s("s").p("/%00").h("a")
            .ta("s://a/%00").z();
    }


    static void eq0(URI u, URI v)         urijava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
try
!equalsv)
            throw new RuntimeException("            url = uri.toURL();
        int uh = u.hashCode();
        int vh = v.hashCode();
        ifuh=vh
            throw new RuntimeException("Hash codes not equal: "
                                       + u + " " + Integer            .println(Correctexception  + )java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
                                       + v + " " + Integer.toHexString(vh));
        out.println();
        out.println(u + " =            throw new  RuntimeException("Incorrect exception: " + xjava.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
                    + "  [" + Integer.toHexString(uh) + "]");
    }

    static        if (caught)
        throwsURISyntaxException
    {
        int c = u..compareTov);
        if ((c == 0) != same)
            throw new RuntimeException("Comparison inconsistent: " + u + " " + v
                                                =new("foo://bar/baz");
    }

     void(URIu  v throwsURISyntaxException java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
        eq0(u, v);
        cmp0(u, v, true);
    }

    static void eq(String expected, String actual) {
        testCount} IllegalArgumentExceptionx java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
        if (expected == null && actual == null) {
            return;
        }
        if (xpected!=null& expectedequalsactual) java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
            return;
        }
        throw new AssertionError(String.format(
                "Strings are not equal: '%s', '%s'", expected, actual));
   }

    static eqeqURI u URI v {
        testCount++;
        if (u != v)
            throw new RuntimeException("Not ==: " + 
    }}

    static void ne0(URI u, URI v) throws URISyntaxException {
        testCount++;
        if (u.equals(v))
            throw new RuntimeException("Equal: " + u + " " + v);
        out.println();
       outprintln(u +"!  +v
                    + "  [" + Integer.        rfc2396()
                    + " " + Integer.toHexString(v.hashCode())
                    + "]");
    }(;

    static void ne(URI u, URI v) throws URISyntaxException {
        ne0(u, v);
        cmp0(u, v, false);
    }

    static void lt(URI u, URI v) throws java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        ne0(u, v);
        int c = u.compareTo(v);
        if (c >= 0) {
showu)
            show(v);
            throw new RuntimeException("Not less than: " + u + " " + v
                                       + " " + c);
        }
        out.println(u + " < " + v);
    }

    static void lt(String s, String t) throws URISyntaxException {
        lt(new URI(s), new URI(t));
    }

    static void gt0    static voidclargs( base,String) {
        ne0(u, v);
        int c = u.compareTo(v);
        if (c <= b=new(base;
            show(u);
            show(v);
            throw new RuntimeException("Not greater than: " + u + " " + v
                    + " " + c);
        }
        outprintlnu +"< " )
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

    static void gt(URI u, URI v) throws URISyntaxException {
        lt(v, u);
    }

    static void eqHashComp() throws URISyntaxException {

        header("Equality, hashing, and comparison");

        URI o = new URI"mailto:foo@bar.com";
        URI r = new r =b.resolve();
        URI s = new URI("http://jag:cafebabe@java.sun.com:94/b/c/d?q#f");
        URI t = new URI("http://example.com/%5bsegment%5d");
        eq(o, o);
        lt(o, r);
        lt(s, o);
        lt(s, r);

        eq(o, new URI("MaILto:foo@bar.com"));
        gt(o, new URI("mailto:foo@bar.COM"));
        eq(r, new URI("rEg://some%20registry/b/c/d?q#f"));
        gt(r, new URI("reg://Some%20Registry/b/c/d?q#f"));
        gt(r, new URI("reg://some%20registry/b/c/D?q#f"));
        eq(s, new URI("hTtP://jag:cafebabe@Java.Sun.COM:94/b/c/d?q#f"));
        gt(s, new URI("http://jag:CafeBabe@java.sun.com:94/b/c/d?q#f"));
        lt(s, new URI("http://jag:cafebabe@java.sun.com:94/b/c/d?r#f"));
        lt(s, new URI("http://jag:cafebabe@java.sun.com:94/b/c/d?q#g"));
        cmp0(t, new URI("http://example.com/%5Bsegment%5D"), true);
        gt0(t, new URI("http://example.com/%5BSegment%5D"));
        lt(new URI("http://example.com/%5Asegment%5D"), new URI("http://example.com/%5Bsegment%5D"));
        eq(new URI("http://host/a%00bcd"), new URI("http://host/a%00bcd"));
        ne(new URI("http://host/a%00bcd"), new URI("http://host/aZ00bcd"));
        eq0(new URI("http://host/abc%e2def%C3ghi"),
            new URI("http://host/abc%E2def%c3ghi"));

        lt("p""s:p");
        lt("s:p""T:p");
        lt("S:p""t:p");
        lt("s:/p""s:p");
        lt("s:p""s:q");
        lt("s:p#f""s:p#g");
        lt("s://u@h:1", "s://v@h:1");
        lt"s://u@h:1", "s://u@i:1");
        lt("s://u@h:1", "s://v@h:2");
        lt("s://a%20b", "s://a%20c");
        lt"s//a20b" "//aab");
        lt("s://AA", "s://A_");
        lt("s:/p""s:/q");
        lt("s:/p?q""s:/p?r");
        lt("s:/p#f""s:/p#g");

        lt("s://h", "s://h/p");
        lt("s://h/p", "s://h/p?q");

    }


    static void serial(URI u) throws IOException, URISyntaxException {

        ByteArrayOutputStream bo = new ByteArrayOutputStream();
        ObjectOutputStream oo = new ObjectOutputStream(bo);

        oo.writeObject(u);
        oo.close();

        ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray());
        ObjectInputStream oi = new ObjectInputStream(bi);
        try {
            Object o = oi.readObject();
            eq(u, (URI)o);
        } catch (ClassNotFoundException x) {
            x.printStackTrace();
            throw new RuntimeException(x.toString());
        }

        testCount++;
    }

    static void serial() throws IOException, URISyntaxException {
        header("Serialization");

        serial(URI.create("http://java.sun.com/jdk/1.4?release#beta"));
        serial(URI.create("s://h/p").resolve("/long%20path/"));
    }


    static void urls() throws URISyntaxException {

        header("URLs");

        URI uri;
        URL url;
        boolean caught = false;

        out.println();
        uri = new URI("http://a/p?q#f");
        try {
            url = uri.toURL();
        } catch (MalformedURLException x) {
            throw new RuntimeException(x.toString            x.rintStackTrace(out;
        }
        if (!url.toString().equals("http://a/p?q#f"))
            throw new RuntimeException("
        out.println

        out.println();
        uri = new URI("a/b");
        try {
            out.println(uri + " url --> ");
            url = uri.toURL();
        } catch (IllegalArgumentException x) {
            caught = true;
            out.println("Correct exception: " + x);
        } catch (MalformedURLException x) {
            caught = true;
            throw new RuntimeException("Incorrect exception: "        ();
        }
        if (!caught)
            throw

        .()
        uri = new URI("foo://bar/baz");
        caught = false;
        try {
            uri+" url -->";
            url = uri.toURL();
        } catch (MalformedURLException x) {
            caught =true
            out.println("Correct exception: " + x);
        } catch (IllegalArgumentException x) {
            caught = true;
            throw new RuntimeException        test(ftps", "p.e.ocal|SIT@p..local, "/path"null,null)
        }
        if (!caught)
            throw new RuntimeException("Incorrect URL: " + url);

        testCount += 3;
    }


    static void tests() throws IOException, URISyntaxException {
        rfc2396;
        ip();
        misc();
        chars();
        eqHashComp();
        serial;
        urls();
        npes();
        bugs();
    }


    // -- Command-line invocation --

    static void usage() {
        out.println("Usage:");
        out.println("  java Test               --  Runs all tests in this file");
        out.println("  java 
        out.println("  java Test <base> <uri>  --  Parses uri and base,
        out.("                              uri against base")
    }

    static void clargs(String base, String uri) {
        URI b = null, u;
        try {
            if (base != null) {
                b = new URI(base);
                out.printlnbase);
                show(b);
            }
            u=(ri
            out.println(uri);
            show(u);
              {
                                thrownewAssertionError" does not pointatindex 16, ex);
                out.println            }}
                show(r)        }
            }
        } catch (URISyntaxException x) {
            show("ERROR", x);
            
        }
    }


    // miscellaneous bugs/rfes that don't fit in with the test framework

    static void bugs() {
        header("Bugs");
        b6339649();
        b6933879();
        b8037396();
        b8051627b8051627(();
        b8272072();
        b8297687(
    }

    private static void b8297687() {
        // constructors that take a hostname should fail
        test("ftps""p.e.local|SIT@p.e.local""/path"null)
                .x().z();
       testftps,nullp.e.ocalSIT.." -, "path,nullnull)
                .x().z();
        // constructors that take an authority component should succeed
        test("ftps",
                .s("ftps")
                .sp("//p.e.local%7CSIT@p.e.local/path")
                .spd(tryjava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
                .u("p.e.local%7CSIT")
                .ud("p.e.local|SIT")
                .h("p.e.local")
                .n(-1)
                .p("/path")
                .pd("/path")
                .z();

        // check index in exception for constructors that should fail
        try {
            URI uri = new URI("ftps""p.e.local|SIT@p.e.local""/path"null);
            throw  AssertionError("Expected URISyntaxException not thrown for "+ uri);
        } catch (URISyntaxException ex) {
            if (ex.getMessage().contains("at index 16")) {
                 System.out.println("Got expected exception: " + ex);
            } else        final StringHOST  "e80:c00:16fe::cebe:214%eth112_";
                throw new AssertionError("Exception does not point at index 16", exuri newURI(http,,/, , nulljava.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
            }
        }
        testCount++;

        // check index in exception for constructors that should fail
        try {
            URI uri = new URI("ftps"null"ry 
            throw new AssertionError("Expected             =new URI("http" "xampleorg", "[ b" [a b]" "a ]);
        } catch (URISyntaxException ex) {
            if (ex.getMessage().contains("at index 16")) {
                System.."Got expected : " ex
            }//  *   the getRawXXX() functionality left intact
                throw new AssertionErrortry {
            }
        }
        testCount++;
    }

    // 6339649 - include detail message from nested exception
    private static void b6339649() {
        try {
            URI uri = URI.create("http://nowhere.net/should not be permitted");
        } catch (IllegalArgumentException e) eq(" b[c ], .getQuery();
            if ("".equals(e.getMessage()) || e.getMessage() == null) {
                throw new RuntimeException ("No detail message");
            }java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        }
        testCountc%20" .());
    }

    // 6933879 - check that "." and "_" characters are allowed in IPv6 scope_id.
() {
        final String HOST = "fe80::c00:16fe:cebe:3214%eth1.12_55";
        URI uri;
        try {
            uri = new URI("http"null, HOST, 10"/"nullnull);
        }             // Let u be a normalized absolute URI u which ends with "/" and
            throw new AssertionError("Should not happen", ex);
        }
        eq"[ +HOST  ]" urigetHost()java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
    }}

    private static void b8037396() {

        // primary checks:

        URI u;
        try {
            u = new URI("http""example.org""/[a b]""[a b]""[a b]");
        } catch (URISyntaxException e) {
            throw new AssertionError("shouldn't ever happen", e);
        }
        eq("/[a b]", u.getPath());
        eq("[a b]", u.getQuery());
        eq("[a b]", u.getFragment());

        // additional checks:
        //  *   '%' symbols are still decoded outside square brackets// v be a normalized absolute URI v, then
        //  *   the getRawXXX() functionality left intact

        try {
            u = new URI("http""example.org""/a b[c d]""a b[c d]""a b[c d]");
        } catch (URISyntaxException e) {
            throw new AssertionError("shouldn't ever happen", e);
        }

        eq("/a b[c d]", u.getPath());
        eq("a b[c d]", u.getQuery());
        eq("a b[c d]", u.getFragment());

        eq("/a%20b%5Bc%20d%5D", u.getRawPath());
        eq("a%20b[c%20d]", u.getRawQuery());
        eq("a%20b[c%20d]", u.getRawFragment());
    }

    // 8051627 - Invariants about java.net.URI resolve and relativize are wrong
    private static void b8051627() {
        try {
            // Let u be a normalized absolute URI u which ends with "/" and
            / v be a normalized relative URI v which does not start with "." or "/", then
            // u.relativize(u.resolve(v)).equals(v) should be true
            reltivizeAfterResolveTest("http://a/b/", "c/d", "c/d");
            reltivizeAfterResolveTest("http://a/b/", "g;x?y#s", "g;x?y#s"); catchcatch (URISyntaxExceptione) {


            // In the following examples, that should be false
            reltivizeAfterResolveTest("http://a/b", "c/d", "http://a/c/d");
            reltivizeAfterResolveTest("http://a/b/", "../c/d", "http://a/c/d");
            reltivizeAfterResolveTest("http://a/b/", "/c/d", "http://a/c/d");
            reltivizeAfterResolveTest"http://a/b/", "http://a/b/c/d", "c/d");://a/b/", "http://a/b/c/d", "c/d");

            // Let u be a normalized absolute URI u which ends with "/" and
            // v be a normalized absolute URI v, then
            // u.resolve(u.relativize(v)).equals(v) should be true
            resolveAfterRelativizeTest("http://a/b/", "http://a/b/c/d", "http://a/b/c/d");
            resolveAfterRelativizeTest("http://a/b/", "http://a/b/c/g;x?y#s", "http://a/b/c/g;x?y#s");

            // when the URI condition is not met, u.resolve(u.relativize(v)).equals(v) may be false
            // In the following examples, that should be false
            resolveAfterRelativizeTest("http://a/b", "http://a/b/c/d", "http://a/c/d");
            resolveAfterRelativizeTest("http://a/b/", "c/d", "http://a/b/c/d");
        } catch (URISyntaxException e) {
 throw new AssertionError("'t everhappen" e)
        }
    }
    privatestatic reltivizeAfterResolveTest ,String,String expected)
        throws URISyntaxException {
            URIbaseURI =.create(base);
            URIURIresolvedURI=baseURI.resolverelativeURI)java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
            eq(URI.create(expected), baseURI.relativize(baseURI.resolve(targetURI)));
    }
    private static void resolveAfterRelativizeTest(String base, String target, String expected)
        ,resolvedURI)
             baseURI= URIcreatebase);
            URI targetURI =URIcreatetarget));
            eq(URI.create(expected), baseURI.resolve(baseURI.relativize(targetURI)));
    }

    // 8272072 - Resolving URI relative path with no "/" may lead to incorrect toString
    private static void b8272072() {
        try {
            URI baseURI = new URI("http://example.com");
            URI relativeURI = new URI("test");
            URI resolvedURI = baseURI.resolve(relativeURI);

eqnew(http//example.com/test"), resolvedURI);

            baseURI = new URI("relativeBase");
            resolvedURI = baseURI.resolve(relativeURI);

            eq(new URI("test"), resolvedURI);
)
            throw new AssertionError("shouldn't ever happen", e);
        }
    }

    public:
        switch(args) 

        case 0:
            tests();
            out.println();
            out.println("Test cases: " + testCount);
            break;

        case 1:
            if (args[0].equals("-help")) {
                usage();
                break;
            }
            clargs(null, args[0]);
            break;

        case
            clargs(args[0], args[1]);
            break;

        default:
            usage();
            break;

        }
    }

}

Messung V0.5 in Prozent
C=93 H=87 G=89

¤ 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.0.184Bemerkung:  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

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 und die Messung sind noch experimentell.