作者热门文章
- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.jcabi.http.response.XmlResponse.assertXPath()
方法的一些代码示例,展示了XmlResponse.assertXPath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlResponse.assertXPath()
方法的具体详情如下:
包路径:com.jcabi.http.response.XmlResponse
类名称:XmlResponse
方法名:assertXPath
[英]Verifies HTTP response body XHTML/XML content against XPath query, and throws AssertionError in case of mismatch.
[中]根据XPath查询验证HTTP响应正文XHTML/XML内容,并在不匹配的情况下抛出AssertionError。
代码示例来源:origin: jcabi/jcabi-http
/**
* Follow XML link.
* @param query XPath query to fetch new URI
* @return New request
*/
public Request rel(final String query) {
this.assertXPath(query);
return new RestResponse(this).jump(
URI.create(this.xml().xpath(query).get(0))
);
}
代码示例来源:origin: com.jcabi/jcabi-w3c
@Override
public ValidationResponse validate(final String html)
throws IOException {
final Request req = this.request(html);
final Response response = req.fetch();
if (response.status() != HttpURLConnection.HTTP_OK) {
throw new IOException(
response.reason()
);
}
return this.build(
response.as(XmlResponse.class)
.registerNs("nu", "http://n.validator.nu/messages/")
.assertXPath("//nu:messages")
.assertXPath("//nu:source")
.xml()
);
}
代码示例来源:origin: com.jcabi/jcabi-w3c
/**
* Return a response after real processing of the CSS.
* @param css The CSS stylesheet to check
* @return The response
* @throws IOException if fails
*/
private ValidationResponse processed(final String css) throws IOException {
final Request req = this.request(
AbstractBaseValidator.entity(
"file", DefaultCssValidator.filter(css), "text/css"
)
);
final Response response = DefaultCssValidator.correct(req.fetch());
return DefaultCssValidator.build(
response.as(XmlResponse.class)
.registerNs("env", "http://www.w3.org/2003/05/soap-envelope")
.registerNs("m", "http://www.w3.org/2005/07/css-validator")
.assertXPath("//m:validity")
.assertXPath("//m:checkedby")
.xml()
);
}
代码示例来源:origin: yegor256/takes
/**
* Retrieve Github access token.
* @param home Home of this page
* @param code Github "authorization code"
* @return The token
* @throws IOException If failed
*/
private String token(final String home, final String code)
throws IOException {
final String uri = new Href(this.github)
.path(PsGithub.LOGIN).path("oauth").path(PsGithub.ACCESS_TOKEN)
.toString();
return new JdkRequest(uri)
.method("POST")
.header("Accept", "application/xml")
.body()
.formParam("client_id", this.app)
.formParam("redirect_uri", home)
.formParam("client_secret", this.key)
.formParam(PsGithub.CODE, code)
.back()
.fetch().as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.as(XmlResponse.class)
.assertXPath("/OAuth/access_token")
.xml()
.xpath("/OAuth/access_token/text()")
.get(0);
}
代码示例来源:origin: org.takes/takes
/**
* Retrieve Github access token.
* @param home Home of this page
* @param code Github "authorization code"
* @return The token
* @throws IOException If failed
*/
private String token(final String home, final String code)
throws IOException {
final String uri = new Href(this.github)
.path(PsGithub.LOGIN).path("oauth").path(PsGithub.ACCESS_TOKEN)
.toString();
return new JdkRequest(uri)
.method("POST")
.header("Accept", "application/xml")
.body()
.formParam("client_id", this.app)
.formParam("redirect_uri", home)
.formParam("client_secret", this.key)
.formParam(PsGithub.CODE, code)
.back()
.fetch().as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.as(XmlResponse.class)
.assertXPath("/OAuth/access_token")
.xml()
.xpath("/OAuth/access_token/text()")
.get(0);
}
本文整理了Java中com.jcabi.http.response.XmlResponse.assertXPath()方法的一些代码示例,展示了XmlResponse.assertXPath()的具体
我是一名优秀的程序员,十分优秀!