本文整理汇总了Java中org.takes.http.FtRemote类的典型用法代码示例。如果您正苦于以下问题:Java FtRemote类的具体用法?Java FtRemote怎么用?Java FtRemote使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FtRemote类属于org.takes.http包,在下文中一共展示了FtRemote类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: readsRealUrl
import org.takes.http.FtRemote; //导入依赖的package包/类
@Test
public void readsRealUrl() throws IOException {
new FtRemote(new TkHtml("<html>How are you?</html>")).exec(
home -> MatcherAssert.assertThat(
"Can't fetch bytes from the URL",
new TextOf(
new InputOf(home)
),
new TextHasString(
Matchers.allOf(
Matchers.startsWith("<html"),
Matchers.endsWith("html>")
)
)
)
);
}
开发者ID:yegor256,项目名称:cactoos,代码行数:18,代码来源:InputOfTest.java
示例2: rendersHomePageViaHttp
import org.takes.http.FtRemote; //导入依赖的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
示例3: rendersHomePageViaHttp
import org.takes.http.FtRemote; //导入依赖的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
示例4: rendersOneReport
import org.takes.http.FtRemote; //导入依赖的package包/类
@Test
public void rendersOneReport() throws IOException {
final Take app = new TkApp(Files.createTempDirectory("x"));
new FtRemote(app).exec(
home -> {
new JdkRequest(home)
.uri().path("org.jpeek")
.path("jpeek")
.path("index.html").back()
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK);
new JdkRequest(String.format("%s/org.jpeek/jpeek/", home))
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_SEE_OTHER);
new JdkRequest(String.format("%s/org.jpeek/jpeek", home))
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_SEE_OTHER);
}
);
}
开发者ID:yegor256,项目名称:jpeek,代码行数:24,代码来源:TkAppTest.java
示例5: rendersHomePageViaHttp
import org.takes.http.FtRemote; //导入依赖的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
示例6: justWorks
import org.takes.http.FtRemote; //导入依赖的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
示例7: justWorks
import org.takes.http.FtRemote; //导入依赖的package包/类
/**
* TkProxy can just work.
* @throws Exception If some problem inside
*/
@Test
public void justWorks() throws Exception {
new FtRemote(
new TkFork(
new FkMethods(this.method, new TkFixed(this.expected))
)
).exec(
new FtRemote.Script() {
@Override
public void exec(final URI home) throws IOException {
MatcherAssert.assertThat(
new RsPrint(
new TkProxy(home).act(
new RqFake(TkProxyTest.this.method)
)
).print(),
Matchers.containsString(
TkProxyTest.this.expected
)
);
}
}
);
}
开发者ID:yegor256,项目名称:takes,代码行数:29,代码来源:TkProxyTest.java
示例8: returnsAnEmptyResponseBody
import org.takes.http.FtRemote; //导入依赖的package包/类
/**
* TkSlf4j can return an empty response body for {@link TkEmpty}.
* @throws IOException if some I/O problem occurred.
*/
@Ignore
@Test
public void returnsAnEmptyResponseBody() throws IOException {
new FtRemote(
new TkSlf4j(new TkEmpty())
).exec(
new FtRemote.Script() {
@Override
public void exec(final URI home) throws IOException {
new JdkRequest(home)
.method("POST")
.body().set("returnsAnEmptyResponseBody").back()
.fetch()
.as(RestResponse.class)
.assertBody(new IsEqual<>(""))
.assertStatus(HttpURLConnection.HTTP_OK);
}
}
);
}
开发者ID:yegor256,项目名称:takes,代码行数:25,代码来源:TkSlf4jRemoteTest.java
示例9: launchesOnRandomPort
import org.takes.http.FtRemote; //导入依赖的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
示例10: launchesWebServerInNonLatinLocale
import org.takes.http.FtRemote; //导入依赖的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
示例11: returnsFileContent
import org.takes.http.FtRemote; //导入依赖的package包/类
/**
* Application can return file content.
* @throws Exception If fails
*/
@Test
public void returnsFileContent() throws Exception {
final Base base = new MkBase();
final String name = "test.txt";
final byte[] bytes = "hello, world!".getBytes();
base.user(TkAppTest.FAKE_URN).docs().doc(name).write(
new ByteArrayInputStream(bytes), bytes.length
);
final TkApp app = new TkApp(base);
new FtRemote(app).exec(
new FtRemote.Script() {
@Override
public void exec(final URI home) throws IOException {
new JdkRequest(home)
.uri().path("/doc/read")
.queryParam(TkAppTest.FILE, name).back()
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.assertBody(Matchers.startsWith("hello, world"));
}
}
);
}
开发者ID:libreio,项目名称:libre,代码行数:29,代码来源:TkAppTest.java
示例12: readsFileWithSpecialCharactersInName
import org.takes.http.FtRemote; //导入依赖的package包/类
/**
* TsApp can read file with special characters in its name.
* @throws Exception If fails
*/
@Test
public void readsFileWithSpecialCharactersInName() throws Exception {
final Base base = new MkBase();
final String name = "[][].txt";
final String data = "fake data";
base.user(TkAppTest.FAKE_URN).docs().doc(name).write(
new ByteArrayInputStream(data.getBytes()), data.getBytes().length
);
new FtRemote(new TkApp(base)).exec(
new FtRemote.Script() {
@Override
public void exec(final URI home) throws IOException {
new JdkRequest(home)
.uri().path("/doc/read")
.queryParam(TkAppTest.FILE, name).back()
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.assertBody(Matchers.startsWith(data));
}
}
);
}
开发者ID:libreio,项目名称:libre,代码行数:28,代码来源:TkAppTest.java
示例13: showsPageNotFound
import org.takes.http.FtRemote; //导入依赖的package包/类
/**
* Application can show 'page not found' page.
* @throws Exception If fails
*/
@Test
public void showsPageNotFound() throws Exception {
final Base base = new MkBase();
new FtRemote(new TkApp(base)).exec(
new FtRemote.Script() {
@Override
public void exec(final URI home) throws IOException {
new JdkRequest(home)
.uri().path("/page-is-absent").back()
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.assertBody(Matchers.startsWith("Page not found!"));
}
}
);
}
开发者ID:libreio,项目名称:libre,代码行数:22,代码来源:TkAppTest.java
示例14: returnsTextPageOnHttpRequest
import org.takes.http.FtRemote; //导入依赖的package包/类
@Test
public void returnsTextPageOnHttpRequest() throws Exception {
new FtRemote(new TkApp(new FkBase())).exec(
new FtRemote.Script() {
@Override
public void exec(final URI home) throws IOException {
new JdkRequest(home)
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.assertBody(Matchers.equalTo("try /categories"));
}
}
);
}
开发者ID:yaroska,项目名称:true_oop,代码行数:16,代码来源:TkAppIntegrationCase.java
示例15: sendsRequestThroughToHome
import org.takes.http.FtRemote; //导入依赖的package包/类
/**
* TkRelay can send the request through.
* @throws Exception If some problem inside
*/
@Test
public void sendsRequestThroughToHome() throws Exception {
final Take target = new TkFork(
new FkRegex(
"/alpha/.*",
(Take) req -> new RsText(
new RqHref.Base(req).href().toString()
)
)
);
new FtRemote(target).exec(
home -> MatcherAssert.assertThat(
new RsPrint(
new TkRelay(new FkBase()).act(
TkRelayTest.fake(
home, "/alpha/%D0%B4%D0%B0?abc=cde"
)
)
).printBody(),
Matchers.equalTo(
String.format(
"%s/alpha/%%D0%%B4%%D0%%B0?abc=cde",
home
)
)
)
);
}
开发者ID:yegor256,项目名称:jare,代码行数:33,代码来源:TkRelayTest.java
示例16: setsCachingHeaders
import org.takes.http.FtRemote; //导入依赖的package包/类
/**
* TkRelay can set cache headers to "forever".
* @throws Exception If some problem inside
*/
@Test
public void setsCachingHeaders() throws Exception {
final Take target = new TkWithHeaders(
new TkText("cacheable forever"),
"age: 600",
"cache-control: max-age=600",
"expires: Thu, 08 Dec 2016 22:51:37 GMT"
);
new FtRemote(target).exec(
home -> MatcherAssert.assertThat(
new RsPrint(
new TkRelay(new FkBase()).act(
TkRelayTest.fake(home, "/&whatever")
)
),
Matchers.allOf(
new HmRsHeader("Age", "31536000"),
new HmRsHeader("Cache-control", "max-age=31536000"),
new HmRsHeader("Expires", "Sun, 19 Jul 2020 18:06:32 GMT"),
Matchers.not(
new HmRsHeader("Cache-Control", "max-age=600")
)
)
)
);
}
开发者ID:yegor256,项目名称:jare,代码行数:31,代码来源:TkRelayTest.java
示例17: logins
import org.takes.http.FtRemote; //导入依赖的package包/类
/**
* PsLinkedin can login.
* @throws IOException If some problem inside
*/
@Test
public void logins() throws IOException {
final String tokenpath = "/uas/oauth2/accessToken";
final String firstname = "firstName";
final String lastname = "lastName";
final String frodo = "Frodo";
final String baggins = "Baggins";
// @checkstyle MagicNumber (4 lines)
final String code = RandomStringUtils.randomAlphanumeric(10);
final String lapp = RandomStringUtils.randomAlphanumeric(10);
final String lkey = RandomStringUtils.randomAlphanumeric(10);
final String identifier = RandomStringUtils.randomAlphanumeric(10);
final Take take = new TkFork(
new FkRegex(
tokenpath,
new TokenTake(code, lapp, lkey, tokenpath)
),
new FkRegex(
"/v1/people",
new PeopleTake(identifier, firstname, lastname, frodo, baggins)
)
);
new FtRemote(take).exec(
new LinkedinScript(
code, lapp, lkey, identifier,
firstname, lastname, frodo, baggins
)
);
}
开发者ID:yegor256,项目名称:takes,代码行数:34,代码来源:PsLinkedinTest.java
示例18: correctlyMapsPathString
import org.takes.http.FtRemote; //导入依赖的package包/类
/**
* TkProxy can correctly maps path string.
* @throws Exception If some problem inside
* @checkstyle AnonInnerLengthCheck (100 lines)
*/
@Test
public void correctlyMapsPathString() throws Exception {
final Take take = new Take() {
@Override
public Response act(final Request req) throws IOException {
return new RsText(new RqHref.Base(req).href().toString());
}
};
new FtRemote(
new TkFork(
new FkMethods(this.method, take)
)
).exec(
new FtRemote.Script() {
@Override
public void exec(final URI home) throws IOException {
MatcherAssert.assertThat(
new RsPrint(
new TkProxy(home).act(
new RqFake(
TkProxyTest.this.method,
"/a/%D0%B0/c?%D0%B0=1#%D0%B0"
)
)
).printBody(),
Matchers.equalTo(
String.format(
"http://%s:%d/a/%%D0%%B0/c?%%D0%%B0=1",
home.getHost(), home.getPort()
)
)
);
}
}
);
}
开发者ID:yegor256,项目名称:takes,代码行数:42,代码来源:TkProxyTest.java
示例19: requestBodyIsIgnored
import org.takes.http.FtRemote; //导入依赖的package包/类
/**
* Send a request with body which is ignored.
* @throws Exception If there are problems
*/
@Test
public void requestBodyIsIgnored() throws Exception {
final String expected = "response ok";
final Take take = new Take() {
@Override
public Response act(final Request req) throws IOException {
return new RsText(expected);
}
};
new FtRemote(new TkReadAlways(take)).exec(
new FtRemote.Script() {
@Override
public void exec(final URI home) throws IOException {
new JdkRequest(home)
.method("POST").header(
"Content-Type", "application/x-www-form-urlencoded"
).body()
.formParam("name", "Jeff Warraby")
.formParam("age", "4")
.back()
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.assertBody(Matchers.equalTo(expected));
}
}
);
}
开发者ID:yegor256,项目名称:takes,代码行数:33,代码来源:TkReadAlwaysTest.java
示例20: deletesFileWithSpecialCharactersInName
import org.takes.http.FtRemote; //导入依赖的package包/类
/**
* TsApp can delete file with special characters in its name.
* @throws Exception If fails
*/
@Test
public void deletesFileWithSpecialCharactersInName() throws Exception {
final Base base = new MkBase();
final String name = "[][].txt";
final String data = "fake data";
base.user(TkAppTest.FAKE_URN).docs().doc(name).write(
new ByteArrayInputStream(data.getBytes()), data.getBytes().length
);
MatcherAssert.assertThat(
base.user(TkAppTest.FAKE_URN).docs().names(),
Matchers.not(Matchers.emptyIterable())
);
new FtRemote(new TkApp(base)).exec(
new FtRemote.Script() {
@Override
public void exec(final URI home) throws IOException {
new JdkRequest(home)
.uri().path("/doc/delete")
.queryParam(TkAppTest.FILE, name).back()
.fetch().as(RestResponse.class).follow()
.fetch().as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK);
}
}
);
MatcherAssert.assertThat(
base.user(TkAppTest.FAKE_URN).docs().names(),
Matchers.emptyIterable()
);
}
开发者ID:libreio,项目名称:libre,代码行数:35,代码来源:TkAppTest.java
注:本文中的org.takes.http.FtRemote类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论