java.net.URI#parseServerAuthority ( )源码实例Demo

下面列出了java.net.URI#parseServerAuthority ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ehcache3   文件: UnitTestConnectionService.java
/**
 * Creates a "key" {@code URI} by dropping the <i>user-info</i>, <i>path</i>, <i>query</i>, and <i>fragment</i>
 * portions of the {@code URI}.
 *
 * @param requestURI the {@code URI} for which the key is to be generated
 *
 * @return a {@code URI} instance with the <i>user-info</i>, <i>path</i>, <i>query</i>, and <i>fragment</i> discarded
 */
private static URI createKey(URI requestURI) {
  try {
    URI keyURI = requestURI.parseServerAuthority();
    return new URI(keyURI.getScheme(), null, keyURI.getHost(), keyURI.getPort(), null, null, null);
  } catch (URISyntaxException e) {
    throw new IllegalArgumentException(e);
  }
}
 
源代码2 项目: j2objc   文件: URITest.java
public void testParseServerAuthorityInvalidPortMinus() throws Exception {
    URI uri = new URI("http://host:-2/");
    assertEquals("host:-2", uri.getAuthority());
    assertNull(uri.getHost());
    assertEquals(-1, uri.getPort());
    try {
        uri.parseServerAuthority();
        fail();
    } catch (URISyntaxException expected) {
    }
}
 
源代码3 项目: j2objc   文件: URITest.java
public void testParseServerAuthorityInvalidPortPlus() throws Exception {
    URI uri = new URI("http://host:+2/");
    assertEquals("host:+2", uri.getAuthority());
    assertNull(uri.getHost());
    assertEquals(-1, uri.getPort());
    try {
        uri.parseServerAuthority();
        fail();
    } catch (URISyntaxException expected) {
    }
}
 
源代码4 项目: j2objc   文件: URITest.java
public void testParseServerAuthorityInvalidPortNonASCII() throws Exception {
    URI uri = new URI("http://host:١٢٣/"); // 123 in arabic
    assertEquals("host:١٢٣", uri.getAuthority());
    assertNull(uri.getHost());
    assertEquals(-1, uri.getPort());
    try {
        uri.parseServerAuthority();
        fail();
    } catch (URISyntaxException expected) {
    }
}
 
源代码5 项目: j2objc   文件: URITest.java
public void testParseServerAuthorityOmittedAuthority() throws Exception {
    URI uri = new URI("http:file");
    uri.parseServerAuthority(); // does nothing!
    assertNull(uri.getAuthority());
    assertNull(uri.getHost());
    assertEquals(-1, uri.getPort());
}