org.apache.shindig.common.uri.UriBuilder.<init>()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(141)

本文整理了Java中org.apache.shindig.common.uri.UriBuilder.<init>()方法的一些代码示例,展示了UriBuilder.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。UriBuilder.<init>()方法的具体详情如下:
包路径:org.apache.shindig.common.uri.UriBuilder
类名称:UriBuilder
方法名:<init>

UriBuilder.<init>介绍

[英]Create an empty builder.
[中]

代码示例

代码示例来源:origin: org.apache.shindig/shindig-common

/**
 * Construct a builder by parsing a string.
 */
public static UriBuilder parse(String text) {
 return new UriBuilder(Uri.parse(text));
}

代码示例来源:origin: org.apache.shindig/shindig-common

@Test
public void justSchemeAndAuthority() {
 UriBuilder builder = new UriBuilder()
   .setScheme("http")
   .setAuthority("apache.org");
 assertEquals("http://apache.org", builder.toString());
}

代码示例来源:origin: org.gatein.shindig/shindig-common

@Test
public void justSchemeAndAuthority() {
 UriBuilder builder = new UriBuilder()
   .setScheme("http")
   .setAuthority("apache.org");
 assertEquals("http://apache.org", builder.toString());
}

代码示例来源:origin: org.gatein.shindig/shindig-common

@Test
public void justAuthorityAndPath() {
 UriBuilder builder = new UriBuilder()
   .setAuthority("apache.org")
   .setPath("/shindig");
 assertEquals("//apache.org/shindig", builder.toString());
}

代码示例来源:origin: org.wso2.org.apache.shindig/shindig-common

@Test
public void justSchemeAndAuthority() {
 UriBuilder builder = new UriBuilder()
   .setScheme("http")
   .setAuthority("apache.org");
 assertEquals("http://apache.org", builder.toString());
}

代码示例来源:origin: org.gatein.shindig/shindig-common

@Test
public void hostRelativePaths() {
 UriBuilder builder = new UriBuilder()
   .setPath("/shindig")
   .setQuery("hello=world")
   .setFragment("foo");
 assertEquals("/shindig?hello=world#foo", builder.toString());
}

代码示例来源:origin: org.gatein.shindig/shindig-common

@Test
public void constructFromUriAndModify() {
 Uri uri = Uri.parse("http://apache.org/foo/bar?foo=bar#foo");
 UriBuilder builder = new UriBuilder(uri);
 builder.setAuthority("example.org");
 builder.addQueryParameter("bar", "foo");
 assertEquals("http://example.org/foo/bar?foo=bar&bar=foo#foo", builder.toString());
}

代码示例来源:origin: org.apache.shindig/shindig-gadgets

@Test
public void badUriValidatingUri() throws Exception {
 Uri uri = new UriBuilder().addQueryParameter(Param.URL.getKey(), "^':   bad:").toUri();
 TestDefaultIframeUriManager manager = makeManager(false, false);
 UriStatus status = manager.validateRenderingUri(uri);
 assertEquals(UriStatus.BAD_URI, status);
}

代码示例来源:origin: org.gatein.shindig/shindig-common

@Test
public void noAuthorityUsed() {
 UriBuilder builder = new UriBuilder()
   .setScheme("http")
   .setPath("/shindig")
   .setQuery("hello=world")
   .setFragment("foo");
 assertEquals("http:/shindig?hello=world#foo", builder.toString());
}

代码示例来源:origin: org.apache.shindig/shindig-common

@Test
public void addSingleFragmentParameter() {
 UriBuilder builder = new UriBuilder()
   .setScheme("http")
   .setAuthority("apache.org")
   .setPath("/shindig")
   .addFragmentParameter("hello", "world")
   .setQuery("foo");
 assertEquals("http://apache.org/shindig?foo#hello=world", builder.toString());
}

代码示例来源:origin: org.gatein.shindig/shindig-common

@Test
public void addSingleFragmentParameter() {
 UriBuilder builder = new UriBuilder()
   .setScheme("http")
   .setAuthority("apache.org")
   .setPath("/shindig")
   .addFragmentParameter("hello", "world")
   .setQuery("foo");
 assertEquals("http://apache.org/shindig?foo#hello=world", builder.toString());
}

代码示例来源:origin: org.wso2.org.apache.shindig/shindig-common

@Test
public void allPartsUsed() {
 UriBuilder builder = new UriBuilder()
   .setScheme("http")
   .setAuthority("apache.org")
   .setPath("/shindig")
   .setQuery("hello=world")
   .setFragment("foo");
 assertEquals("http://apache.org/shindig?hello=world#foo", builder.toString());
}

代码示例来源:origin: org.apache.shindig/shindig-gadgets

@Test(expected = GadgetException.class)
public void mismatchedHostStrict() throws Exception {
 String host = "host.com";
 String path = "/proxy/path";
 DefaultProxyUriManager manager = makeManager("foo" + host, path, null);
 manager.setUseStrictParsing(true);
 Uri testUri = new UriBuilder().setAuthority(host).setPath(path)
   .addQueryParameter(Param.URL.getKey(), "http://foo.com").toUri();
 manager.process(testUri);
}

代码示例来源:origin: org.gatein.shindig/shindig-common

@Test
public void addIdenticalParameters() {
 UriBuilder builder = new UriBuilder()
   .setScheme("http")
   .setAuthority("apache.org")
   .setPath("/shindig")
   .addQueryParameter("hello", "world")
   .addQueryParameter("hello", "goodbye")
   .setFragment("foo");
 assertEquals("http://apache.org/shindig?hello=world&hello=goodbye#foo", builder.toString());
}

代码示例来源:origin: org.gatein.shindig/shindig-common

@Test
public void addTwoFragmentParameters() {
 UriBuilder builder = new UriBuilder()
   .setScheme("http")
   .setAuthority("apache.org")
   .setPath("/shindig")
   .addFragmentParameter("hello", "world")
   .addFragmentParameter("foo", "bar")
   .setQuery("foo");
 assertEquals("http://apache.org/shindig?foo#hello=world&foo=bar", builder.toString());
}

代码示例来源:origin: org.apache.shindig/shindig-common

@Test
public void queryParamsAreEscaped() {
 UriBuilder builder = new UriBuilder()
   .setScheme("http")
   .setAuthority("apache.org")
   .setPath("/shindig")
   .addQueryParameter("hello world", "foo&bar")
   .setFragment("foo");
 assertEquals("http://apache.org/shindig?hello+world=foo%26bar#foo", builder.toString());
 assertEquals("hello+world=foo%26bar", builder.getQuery());
}

代码示例来源:origin: org.apache.shindig/shindig-gadgets

@Test public void testHttp404() throws Exception {
 String content = "Hello, world!";
 Uri uri = new UriBuilder(BASE_URL)
   .addQueryParameter("body", content)
   .addQueryParameter("status", "404")
   .toUri();
 HttpRequest request = new HttpRequest(uri);
 HttpResponse response = fetcher.fetch(request);
 assertEquals(404, response.getHttpStatusCode());
 assertEquals(content, response.getResponseAsString());
}

代码示例来源:origin: org.apache.shindig/shindig-gadgets

@Test(expected = GadgetException.class)
public void invalidUrlParamQuery() throws Exception {
 // Only test query style, since chained style should be impossible.
 String host = "host.com";
 String path = "/proxy/path";
 DefaultProxyUriManager manager = makeManager(host, path, null);
 Uri testUri = new UriBuilder().setAuthority(host).setPath(path)
   .addQueryParameter(Param.CONTAINER.getKey(), CONTAINER)
   .addQueryParameter(Param.URL.getKey(), "!^!").toUri();
 manager.process(testUri);
}

代码示例来源:origin: org.wso2.org.apache.shindig/shindig-common

@Test
public void queryParamsAreEscaped() {
 UriBuilder builder = new UriBuilder()
   .setScheme("http")
   .setAuthority("apache.org")
   .setPath("/shindig")
   .addQueryParameter("hello world", "foo&bar")
   .setFragment("foo");
 assertEquals("http://apache.org/shindig?hello+world=foo%26bar#foo", builder.toString());
 assertEquals("hello+world=foo%26bar", builder.getQuery());
}

代码示例来源:origin: org.apache.shindig/shindig-gadgets

@Test public void testFollowRelativeRedirects() throws Exception {
 String content = "";
 Uri uri = new UriBuilder(BASE_URL)
   .addQueryParameter("body", content)
   .addQueryParameter("status", "302")
   .addQueryParameter("header", "Location=/?body=redirected")
   .toUri();
 HttpRequest request = new HttpRequest(uri);
 HttpResponse response = fetcher.fetch(request);
 assertEquals(200, response.getHttpStatusCode());
 assertEquals("redirected", response.getResponseAsString());
}

相关文章