本文整理汇总了Java中com.jcabi.http.response.XmlResponse类的典型用法代码示例。如果您正苦于以下问题:Java XmlResponse类的具体用法?Java XmlResponse怎么用?Java XmlResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlResponse类属于com.jcabi.http.response包,在下文中一共展示了XmlResponse类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: rendersHomePageViaHttp
import com.jcabi.http.response.XmlResponse; //导入依赖的package包/类
/**
* App can render front page.
* @throws Exception If some problem inside
*/
@Test
public void rendersHomePageViaHttp() throws Exception {
final Take app = new TkApp(new FakeBase());
new FtRemote(app).exec(
home -> {
new JdkRequest(home)
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.as(XmlResponse.class)
.assertXPath("/xhtml:html");
new JdkRequest(home)
.through(VerboseWire.class)
.header("Accept", "application/xml")
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.as(XmlResponse.class)
.assertXPath("/page/version");
}
);
}
开发者ID:yegor256,项目名称:rehttp,代码行数:27,代码来源:TkAppTest.java
示例2: rendersHomePageViaHttp
import com.jcabi.http.response.XmlResponse; //导入依赖的package包/类
@Test
public void rendersHomePageViaHttp() throws Exception {
final Take app = new TkApp(new FkBase());
new FtRemote(app).exec(
home -> {
new JdkRequest(home)
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.as(XmlResponse.class)
.assertXPath("/xhtml:html");
new JdkRequest(home)
.through(VerboseWire.class)
.header("accept", "application/xml")
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.as(XmlResponse.class)
.assertXPath("/page/version");
}
);
}
开发者ID:yegor256,项目名称:threecopies,代码行数:23,代码来源:TkAppTest.java
示例3: rendersHomePageViaHttp
import com.jcabi.http.response.XmlResponse; //导入依赖的package包/类
/**
* App can render front page.
* @throws Exception If some problem inside
*/
@Test
public void rendersHomePageViaHttp() throws Exception {
final Take app = new TkApp(new FkBase());
new FtRemote(app).exec(
home -> {
new JdkRequest(home)
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.as(XmlResponse.class)
.assertXPath("/xhtml:html");
new JdkRequest(home)
.through(VerboseWire.class)
.header("Accept", "application/xml")
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.as(XmlResponse.class)
.assertXPath("/page/version");
}
);
}
开发者ID:yegor256,项目名称:jare,代码行数:27,代码来源:TkAppTest.java
示例4: token
import com.jcabi.http.response.XmlResponse; //导入依赖的package包/类
/**
* 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();
final List<String> tokens = 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)
.xml().xpath("/OAuth/access_token/text()");
if (tokens.isEmpty()) {
throw new HttpException(
HttpURLConnection.HTTP_BAD_REQUEST, "No access token"
);
}
return tokens.get(0);
}
开发者ID:yegor256,项目名称:takes,代码行数:33,代码来源:PsGithub.java
示例5: justWorks
import com.jcabi.http.response.XmlResponse; //导入依赖的package包/类
/**
* App can work.
* @throws Exception If some problem inside
*/
@Test
public void justWorks() throws Exception {
final File dir = this.temp.newFolder();
FileUtils.write(new File(dir, "hello.txt"), "hello, world!");
new FtRemote(new App(dir)).exec(
new FtRemote.Script() {
@Override
public void exec(final URI home) throws IOException {
new JdkRequest(home)
.uri().path("/f").back()
.through(VerboseWire.class)
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.as(XmlResponse.class)
.assertXPath("//xhtml:li[.='hello.txt: 13']");
}
}
);
}
开发者ID:yegor256,项目名称:takes,代码行数:25,代码来源:AppTest.java
示例6: launchesOnRandomPort
import com.jcabi.http.response.XmlResponse; //导入依赖的package包/类
/**
* Launches web server on random port.
* @throws Exception If fails
*/
@Test
public void launchesOnRandomPort() throws Exception {
final TkApp app = new TkApp(new MkBase());
new FtRemote(app).exec(
new FtRemote.Script() {
@Override
public void exec(final URI home) throws IOException {
new JdkRequest(home)
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.as(XmlResponse.class)
.assertXPath("/xhtml:html");
new JdkRequest(home)
.through(VerboseWire.class)
.header("Accept", "application/xml")
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.as(XmlResponse.class)
.assertXPath("/page/version");
}
}
);
}
开发者ID:libreio,项目名称:libre,代码行数:30,代码来源:TkAppTest.java
示例7: launchesWebServerInNonLatinLocale
import com.jcabi.http.response.XmlResponse; //导入依赖的package包/类
/**
* TsApp can launch web server in non-latin locale.
* @throws Exception If fails
*/
@Test
public void launchesWebServerInNonLatinLocale() throws Exception {
final Locale def = Locale.getDefault();
try {
Locale.setDefault(Locale.CHINESE);
final TkApp app = new TkApp(new MkBase());
new FtRemote(app).exec(
new FtRemote.Script() {
@Override
public void exec(final URI home) throws IOException {
new JdkRequest(home)
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.as(XmlResponse.class)
.assertXPath("/xhtml:html");
}
}
);
} finally {
Locale.setDefault(def);
}
}
开发者ID:libreio,项目名称:libre,代码行数:28,代码来源:TkAppTest.java
示例8: processed
import com.jcabi.http.response.XmlResponse; //导入依赖的package包/类
/**
* 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()
);
}
开发者ID:jcabi,项目名称:jcabi-w3c,代码行数:23,代码来源:DefaultCssValidator.java
示例9: validate
import com.jcabi.http.response.XmlResponse; //导入依赖的package包/类
@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()
);
}
开发者ID:jcabi,项目名称:jcabi-w3c,代码行数:19,代码来源:DefaultHtmlValidator.java
示例10: hitsAbsentPages
import com.jcabi.http.response.XmlResponse; //导入依赖的package包/类
/**
* IndexRs can hit not-found pages.
* @throws Exception If some problem inside
*/
@Test
@Ignore
public void hitsAbsentPages() throws Exception {
final String[] pages = {
"/page-doesnt-exist",
"/xsl/xsl-stylesheet-doesnt-exist.xsl",
"/css/stylesheet-is-absent.css",
};
for (final String page : pages) {
new JdkRequest(IndexRsITCase.HOME)
.uri().path(page).back()
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_NOT_FOUND)
.as(XmlResponse.class)
.assertXPath("//xhtml:h1[contains(.,'Page not found')]");
}
}
开发者ID:yegor256,项目名称:requs,代码行数:23,代码来源:IndexRsITCase.java
示例11: renderAbsentPages
import com.jcabi.http.response.XmlResponse; //导入依赖的package包/类
/**
* IndexRs can render absent pages.
* @throws Exception If some problem inside
*/
@Test
@Ignore
public void renderAbsentPages() throws Exception {
final String[] pages = {
"/page-doesnt-exist",
"/xsl/xsl-stylesheet-doesnt-exist.xsl",
"/css/stylesheet-is-absent.css",
};
final Request request = new JdkRequest(HomeRsITCase.HOME);
for (final String page : pages) {
request.uri().path(page).back()
.method(Request.GET)
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_NOT_FOUND)
.as(XmlResponse.class)
.assertXPath("//xhtml:title[contains(.,'page not found')]");
}
}
开发者ID:yegor256,项目名称:bibrarian,代码行数:24,代码来源:HomeRsITCase.java
示例12: token
import com.jcabi.http.response.XmlResponse; //导入依赖的package包/类
/**
* Retrieve Github access token.
* @param code Github "authorization code"
* @return The token
* @throws IOException If failed
*/
private String token(final String code) throws IOException {
final URI uri = UriBuilder
.fromUri("https://github.com/login/oauth/access_token")
.queryParam("client_id", "{id}")
.queryParam("redirect_uri", "{uri}")
.queryParam("client_secret", "{secret}")
.queryParam("code", "{code}")
.build(
this.app,
this.redirectUri(),
this.key,
code
);
return new JdkRequest(uri)
.method(Request.POST)
.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_XML)
.fetch().as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.as(XmlResponse.class)
.xml().xpath("/OAuth/access_token/text()").get(0);
}
开发者ID:yegor256,项目名称:rexsl,代码行数:28,代码来源:Github.java
示例13: justWorks
import com.jcabi.http.response.XmlResponse; //导入依赖的package包/类
/**
* App can work.
* @throws Exception If some problem inside
* @checkstyle NonStaticMethodCheck (2 lines)
*/
@Test
public void justWorks() throws Exception {
Assume.assumeNotNull(AppITCase.HOME);
new JdkRequest(String.format("%s/f", AppITCase.HOME))
.through(VerboseWire.class)
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.as(XmlResponse.class)
.assertXPath("//xhtml:html");
}
开发者ID:yegor256,项目名称:takes,代码行数:17,代码来源:AppITCase.java
示例14: sendsHttpRequestAndProcessesHttpResponse
import com.jcabi.http.response.XmlResponse; //导入依赖的package包/类
/**
* BaseRequest can fetch HTTP request and process HTTP response.
* @throws Exception If something goes wrong inside
*/
@Test
public void sendsHttpRequestAndProcessesHttpResponse() throws Exception {
this.request(new URI("http://http.jcabi.com"))
.fetch().as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.as(XmlResponse.class)
.assertXPath("/xhtml:html");
}
开发者ID:jcabi,项目名称:jcabi-http,代码行数:13,代码来源:RequestITCase.java
示例15: assertsResponseBodyWithXpathQuery
import com.jcabi.http.response.XmlResponse; //导入依赖的package包/类
/**
* BaseRequest can assert response body content with XPath query.
* @throws Exception If something goes wrong inside.
*/
@Test
public void assertsResponseBodyWithXpathQuery() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(
new MkAnswer.Simple("<root><a>\u0443\u0440\u0430!</a></root>")
).start();
this.request(container.home())
.method(Request.GET)
.fetch().as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.as(XmlResponse.class)
.assertXPath("/root/a[contains(.,'!')]");
container.stop();
}
开发者ID:jcabi,项目名称:jcabi-http,代码行数:18,代码来源:RequestTest.java
示例16: acceptsUnicodeInXml
import com.jcabi.http.response.XmlResponse; //导入依赖的package包/类
/**
* BaseRequest can handle unicode in XML response.
* @throws Exception If something goes wrong inside
*/
@Test
public void acceptsUnicodeInXml() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(
new MkAnswer.Simple("<text>\u0443\u0440\u0430!</text>").withHeader(
HttpHeaders.CONTENT_TYPE, "text/xml;charset=utf-8"
)
).start();
this.request(container.home())
.method(Request.GET)
.uri().path("/barbar").back()
.fetch().as(XmlResponse.class)
.assertXPath("/text[contains(.,'\u0443\u0440\u0430')]");
container.stop();
}
开发者ID:jcabi,项目名称:jcabi-http,代码行数:19,代码来源:RequestTest.java
示例17: check
import com.jcabi.http.response.XmlResponse; //导入依赖的package包/类
/**
* Check for validness.
* @param response Response to check
*/
private void check(final Response response) {
final Collection<String> links = new XmlResponse(response).xml().xpath(
new StringBuilder("//head/link/@href")
.append(" | //body//a/@href")
.append(" | //body//img/@src")
.append(" | //xhtml:img/@src")
.append(" | //xhtml:a/@href")
.append(" | //xhtml:link/@href")
.toString()
);
Logger.debug(
this, "#assertThat(): %d links found: %[list]s",
links.size(), links
);
this.broken.clear();
for (final String link : links) {
final URI uri;
if (link.isEmpty() || link.charAt(0) != '/') {
uri = URI.create(link);
} else {
uri = this.home.resolve(link);
}
if (!uri.isAbsolute() || !NoBrokenLinks.isValid(uri)) {
this.broken.add(uri);
}
}
}
开发者ID:jcabi,项目名称:jcabi-matchers,代码行数:32,代码来源:NoBrokenLinks.java
示例18: rendersVersion
import com.jcabi.http.response.XmlResponse; //导入依赖的package包/类
/**
* IndexRs can render version.
* @throws Exception If some problem inside
*/
@Test
public void rendersVersion() throws Exception {
new JdkRequest(IndexRsITCase.HOME)
.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_XML)
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.assertThat(new NoBrokenLinks(URI.create(IndexRsITCase.HOME)))
.as(XmlResponse.class)
.assertXPath("/page/version");
}
开发者ID:yegor256,项目名称:requs,代码行数:16,代码来源:IndexRsITCase.java
示例19: rendersException
import com.jcabi.http.response.XmlResponse; //导入依赖的package包/类
/**
* IndexRs can render exception.
* @throws Exception If some problem inside
*/
@Test
public void rendersException() throws Exception {
new JdkRequest(IndexRsITCase.HOME)
.uri().path("/trap").back()
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.as(XmlResponse.class)
.assertXPath("//xhtml:title[.='Internal application error']");
}
开发者ID:yegor256,项目名称:requs,代码行数:15,代码来源:IndexRsITCase.java
示例20: rendersExceptionTrapPage
import com.jcabi.http.response.XmlResponse; //导入依赖的package包/类
/**
* IndexRs can render exception trap page.
* @throws Exception If some problem inside
*/
@Test
public void rendersExceptionTrapPage() throws Exception {
new JdkRequest(HomeRsITCase.HOME).uri().path("/trap").back()
.method(Request.GET)
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.as(XmlResponse.class)
.assertXPath("//xhtml:title[.='oops...']");
}
开发者ID:yegor256,项目名称:bibrarian,代码行数:15,代码来源:HomeRsITCase.java
注:本文中的com.jcabi.http.response.XmlResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论