本文整理了Java中org.apache.shindig.common.uri.UriBuilder.toUri()
方法的一些代码示例,展示了UriBuilder.toUri()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。UriBuilder.toUri()
方法的具体详情如下:
包路径:org.apache.shindig.common.uri.UriBuilder
类名称:UriBuilder
方法名:toUri
[英]Convert the builder to a Uri.
[中]将生成器转换为Uri。
代码示例来源:origin: org.apache.shindig/shindig-gadgets
static Uri getComponentUri(String str) {
return (str.startsWith("res://")) ?
new UriBuilder().setScheme(RESOURCE_SCHEME).setPath(str.substring(6)).toUri() :
Uri.parse(str);
}
代码示例来源:origin: org.gatein.shindig/shindig-gadgets
private Uri getSocialUri(GadgetContext context, String token) {
String jsonUri = config.getString(context.getContainer(), "gadgets.osDataUri");
Preconditions.checkNotNull(jsonUri, "No JSON URI available for social preloads");
Preconditions.checkNotNull(token, "No token available for social preloads");
UriBuilder builder = UriBuilder.parse(
jsonUri.replace("%host%", context.getHost()))
.addQueryParameter("st", token);
return builder.toUri();
}
}
代码示例来源:origin: com.lmco.shindig/shindig-gadgets
private String getGadgetDomainCallback(SecurityToken securityToken, Uri activeUrl) {
Uri gadgetCallback = oauthUriManager.makeOAuthCallbackUri(
securityToken.getContainer(), activeUrl.getAuthority());
if (gadgetCallback == null) {
return null;
}
if (StringUtils.isEmpty(gadgetCallback.getScheme())) {
gadgetCallback = new UriBuilder(gadgetCallback).setScheme(activeUrl.getScheme()).toUri();
}
return gadgetCallback.toString();
}
代码示例来源:origin: org.apache.shindig/shindig-gadgets
private String getGadgetDomainCallback(SecurityToken securityToken, Uri activeUrl) {
Uri gadgetCallback = oauthUriManager.makeOAuthCallbackUri(
securityToken.getContainer(), activeUrl.getAuthority());
if (gadgetCallback == null) {
return null;
}
if (Strings.isNullOrEmpty(gadgetCallback.getScheme())) {
gadgetCallback = new UriBuilder(gadgetCallback).setScheme(activeUrl.getScheme()).toUri();
}
return gadgetCallback.toString();
}
代码示例来源:origin: org.apache.shindig/shindig-common
@Test
public void constructFromUriAndBack() {
Uri uri = Uri.parse("http://apache.org/foo/bar?foo=bar&a=b&c=d&y=z&foo=zoo#foo");
UriBuilder builder = new UriBuilder(uri);
assertEquals(uri, builder.toUri());
}
代码示例来源:origin: org.wso2.org.apache.shindig/shindig-gadgets
@Test
public void newJsUriCopyOfOtherJsUri() throws Exception {
Uri uri = newTestUriBuilder(RenderingContext.CONTAINER,
JsCompileMode.CONCAT_COMPILE_EXPORT_ALL).toUri();
JsUriManager.JsUri jsUri = new JsUriManager.JsUri(STATUS, uri, LIBS, HAVE);
JsUriManager.JsUri jsUriCopy = new JsUriManager.JsUri(jsUri);
assertEquals(jsUri, jsUriCopy);
}
代码示例来源:origin: com.lmco.shindig/shindig-gadgets
@Test(expected = GadgetException.class)
public void missingUrlChained() throws Exception {
String host = "host.com";
String path = "/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN + "/path";
DefaultProxyUriManager manager = makeManager(host, path, null);
Uri testUri = new UriBuilder().setAuthority(host).setPath(
"/proxy/container=" +
CONTAINER + "/path/").toUri();
manager.process(testUri);
}
代码示例来源: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.wso2.org.apache.shindig/shindig-gadgets
@Test(expected=IllegalArgumentException.class)
public void loadFileNothingAvailable() throws Exception {
Uri nilUri = new UriBuilder().setScheme("file").setPath("/does/not/exist.js").toUri();
loader.load(nilUri, null);
fail("Should have failed indicating could not find: " + nilUri.toString());
}
代码示例来源:origin: org.wso2.org.apache.shindig/shindig-common
@Test
public void resolvePathRelativeToNullPath() throws Exception {
Uri base = new UriBuilder().setScheme("http").setAuthority("example.org").toUri();
Uri other = Uri.parse("dir");
assertEquals("http://example.org/dir", base.resolve(other).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.wso2.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.apache.shindig/shindig-gadgets
@Test public void testHttpFetch() throws Exception {
String content = "Hello, world!";
Uri uri = new UriBuilder(BASE_URL).addQueryParameter("body", content).toUri();
HttpRequest request = new HttpRequest(uri);
HttpResponse response = fetcher.fetch(request);
assertEquals(200, response.getHttpStatusCode());
assertEquals(content, response.getResponseAsString());
}
代码示例来源: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-gadgets
@Test
public void mismatchedHostNonStrict() throws Exception {
String host = "host.com";
String path = "/proxy/path";
DefaultProxyUriManager manager = makeManager("foo" + host, path, null);
Uri testUri = new UriBuilder().setAuthority(host).setPath(path)
.addQueryParameter(Param.URL.getKey(), "http://foo.com")
.addQueryParameter(Param.CONTAINER.getKey(), CONTAINER).toUri();
manager.process(testUri);
}
代码示例来源:origin: com.lmco.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 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());
}
代码示例来源:origin: com.lmco.shindig/shindig-gadgets
@Test
public void testWithProxy() throws Exception {
String content = "Hello, Gagan!";
Uri uri = new UriBuilder(Uri.parse("http://www.google.com/search"))
.addQueryParameter("body", content)
.addQueryParameter("status", "201")
.toUri();
HttpRequest request = new HttpRequest(uri);
HttpResponse response = fetcher.fetch(request);
assertEquals(201, response.getHttpStatusCode());
assertEquals(content, response.getResponseAsString());
}
代码示例来源:origin: com.lmco.shindig/shindig-gadgets
@Test public void testFollowRedirects() throws Exception {
String content = "";
Uri uri = new UriBuilder(BASE_URL)
.addQueryParameter("body", content)
.addQueryParameter("status", "302")
.addQueryParameter("header", "Location=" + BASE_URL.toString() + "?body=redirected")
.toUri();
HttpRequest request = new HttpRequest(uri);
HttpResponse response = fetcher.fetch(request);
assertEquals(200, response.getHttpStatusCode());
assertEquals("redirected", response.getResponseAsString());
}
内容来源于网络,如有侵权,请联系作者删除!