• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java RsPrint类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.takes.rs.RsPrint的典型用法代码示例。如果您正苦于以下问题:Java RsPrint类的具体用法?Java RsPrint怎么用?Java RsPrint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RsPrint类属于org.takes.rs包,在下文中一共展示了RsPrint类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: passesRequestThrough

import org.takes.rs.RsPrint; //导入依赖的package包/类
/**
 * App can pass a request through.
 * @throws Exception If some problem inside
 */
@Test
public void passesRequestThrough() throws Exception {
    MatcherAssert.assertThat(
        new RsPrint(
            new TkApp(new FakeBase()).act(
                new RqFake(
                    new ListOf<>(
                        String.format(
                            "GET /%s",
                            URLEncoder.encode(
                                "http://www.yegor256.com", "UTF-8"
                            )
                        ),
                        "Host: p.rehttp.net"
                    ),
                    ""
                )
            )
        ).print(),
        Matchers.startsWith("HTTP/1.1 200")
    );
}
 
开发者ID:yegor256,项目名称:rehttp,代码行数:27,代码来源:TkAppTest.java


示例2: rendersHomePage

import org.takes.rs.RsPrint; //导入依赖的package包/类
/**
 * App can render front page.
 * @throws Exception If some problem inside
 */
@Test
public void rendersHomePage() throws Exception {
    final Take take = new TkApp(new FakeBase());
    MatcherAssert.assertThat(
        XhtmlMatchers.xhtml(
            new RsPrint(
                take.act(
                    new RqWithHeader(
                        new RqFake("GET", "/"),
                        // @checkstyle MultipleStringLiteralsCheck (1 line)
                        "Accept",
                        "text/xml"
                    )
                )
            ).printBody()
        ),
        XhtmlMatchers.hasXPaths(
            "/page/@date",
            "/page/@sla",
            "/page/millis",
            "/page/links/link[@rel='self']"
        )
    );
}
 
开发者ID:yegor256,项目名称:rehttp,代码行数:29,代码来源:TkAppTest.java


示例3: rendersHomePage

import org.takes.rs.RsPrint; //导入依赖的package包/类
@Test
public void rendersHomePage() throws Exception {
    final Take take = new TkApp(new FkBase());
    MatcherAssert.assertThat(
        XhtmlMatchers.xhtml(
            new RsPrint(
                take.act(
                    new RqWithHeaders(
                        new RqFake("GET", "/"),
                        "Accept: text/xml"
                    )
                )
            ).printBody()
        ),
        XhtmlMatchers.hasXPaths(
            "/page/@date",
            "/page/@sla",
            "/page/millis",
            "/page/links/link[@rel='self']"
        )
    );
}
 
开发者ID:yegor256,项目名称:threecopies,代码行数:23,代码来源:TkAppTest.java


示例4: pingsSimplePages

import org.takes.rs.RsPrint; //导入依赖的package包/类
@Test
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
public void pingsSimplePages() throws IOException {
    final String[] pages = {
        "/org/jpeek/web/layout.xsl",
        "/org/jpeek/web/index.xsl",
        "/jpeek.css",
        "/",
        "/mistakes",
        "/robots.txt",
    };
    final Take app = new TkApp(Files.createTempDirectory("x"));
    for (final String page : pages) {
        final Response response = app.act(new RqFake("GET", page));
        MatcherAssert.assertThat(
            new RsPrint(response).print(),
            response,
            new HmRsStatus(HttpURLConnection.HTTP_OK)
        );
    }
}
 
开发者ID:yegor256,项目名称:jpeek,代码行数:22,代码来源:TkAppTest.java


示例5: rendersMistakesPageInXml

import org.takes.rs.RsPrint; //导入依赖的package包/类
@Test
public void rendersMistakesPageInXml() throws IOException {
    MatcherAssert.assertThat(
        XhtmlMatchers.xhtml(
            new RsPrint(
                new TkMistakes().act(
                    new RqWithHeaders(
                        new RqFake(),
                        "Accept: application/vnd.jpeek+xml"
                    )
                )
            ).printBody()
        ),
        XhtmlMatchers.hasXPath("/page/worst")
    );
}
 
开发者ID:yegor256,项目名称:jpeek,代码行数:17,代码来源:TkMistakesTest.java


示例6: rendersOneReport

import org.takes.rs.RsPrint; //导入依赖的package包/类
@Test
public void rendersOneReport() throws Exception {
    final ExecutorService service = Executors.newSingleThreadExecutor();
    final BiFunc<String, String, Func<String, Response>> bifunc =
        new AsyncReports(
            new SolidBiFunc<>(
                (first, second) -> service.submit(
                    () -> input -> {
                        TimeUnit.DAYS.sleep(1L);
                        return new RsText("done!");
                    }
                )
            )
        );
    final Response response =
        bifunc.apply("org.jpeek", "jpeek").apply("index.html");
    MatcherAssert.assertThat(
        response,
        new HmRsStatus(HttpURLConnection.HTTP_OK)
    );
    MatcherAssert.assertThat(
        XhtmlMatchers.xhtml(new RsPrint(response).printBody()),
        XhtmlMatchers.hasXPath("//xhtml:body")
    );
    service.shutdownNow();
}
 
开发者ID:yegor256,项目名称:jpeek,代码行数:27,代码来源:AsyncReportsTest.java


示例7: rendersHomePageInHtml

import org.takes.rs.RsPrint; //导入依赖的package包/类
/**
 * TkIndex can render home page in HTML.
 * @throws Exception If some problem inside
 */
@Test
public void rendersHomePageInHtml() throws Exception {
    final Take take = new TkAppAuth(new TkIndex(new FkBase()));
    MatcherAssert.assertThat(
        XhtmlMatchers.xhtml(
            new RsPrint(
                take.act(new RqFake("GET", "/"))
            ).printBody()
        ),
        XhtmlMatchers.hasXPaths(
            "/xhtml:html",
            "/xhtml:html/xhtml:body"
        )
    );
}
 
开发者ID:yegor256,项目名称:jare,代码行数:20,代码来源:TkIndexTest.java


示例8: rendersHomePage

import org.takes.rs.RsPrint; //导入依赖的package包/类
/**
 * App can render front page.
 * @throws Exception If some problem inside
 */
@Test
public void rendersHomePage() throws Exception {
    final Take take = new TkApp(new FkBase());
    MatcherAssert.assertThat(
        XhtmlMatchers.xhtml(
            new RsPrint(
                take.act(
                    new RqWithHeader(
                        new RqFake("GET", "/"),
                        // @checkstyle MultipleStringLiteralsCheck (1 line)
                        "Accept",
                        "text/xml"
                    )
                )
            ).printBody()
        ),
        XhtmlMatchers.hasXPaths(
            "/page/@date",
            "/page/@sla",
            "/page/millis",
            "/page/links/link[@rel='takes:logout']"
        )
    );
}
 
开发者ID:yegor256,项目名称:jare,代码行数:29,代码来源:TkAppTest.java


示例9: rendersHomePage

import org.takes.rs.RsPrint; //导入依赖的package包/类
/**
 * TkHome can render home page.
 * @throws Exception If some problem inside
 */
@Test
public void rendersHomePage() throws Exception {
    final Take take = new TkIndex(new FkBase());
    MatcherAssert.assertThat(
        XhtmlMatchers.xhtml(
            new RsPrint(
                take.act(
                    new RqWithHeader(
                        new RqFake("GET", "/"),
                        "Accept",
                        "text/xml"
                    )
                )
            ).printBody()
        ),
        XhtmlMatchers.hasXPaths(
            "/page/millis",
            "/page/links/link[@rel='takes:github']",
            "/page/total"
        )
    );
}
 
开发者ID:yegor256,项目名称:wring,代码行数:27,代码来源:TkIndexTest.java


示例10: rendersHomePage

import org.takes.rs.RsPrint; //导入依赖的package包/类
/**
 * App can render front page.
 * @throws Exception If some problem inside
 */
@Test
public void rendersHomePage() throws Exception {
    final Take take = new TkApp(new FkBase());
    MatcherAssert.assertThat(
        XhtmlMatchers.xhtml(
            new RsPrint(
                take.act(
                    new RqWithHeaders(
                        new RqFake("GET", "/"),
                        "Accept: text/xml"
                    )
                )
            ).printBody()
        ),
        XhtmlMatchers.hasXPaths(
            "/page/millis",
            "/page/links/link[@rel='takes:github']"
        )
    );
}
 
开发者ID:yegor256,项目名称:wring,代码行数:25,代码来源:TkAppTest.java


示例11: rendersListOfEvents

import org.takes.rs.RsPrint; //导入依赖的package包/类
/**
 * TkEvents can render list of events.
 * @throws Exception If some problem inside
 */
@Test
public void rendersListOfEvents() throws Exception {
    final Take take = new TkAppAuth(new TkEvents(new FkBase()));
    MatcherAssert.assertThat(
        XhtmlMatchers.xhtml(
            new RsPrint(
                take.act(
                    new RqWithHeader(
                        new RqFake("GET", "/"),
                        "Accept",
                        "text/xml"
                    )
                )
            ).printBody()
        ),
        XhtmlMatchers.hasXPaths(
            "/page/millis",
            "/page/events/event",
            "/page/events/@total"
        )
    );
}
 
开发者ID:yegor256,项目名称:wring,代码行数:27,代码来源:TkEventsTest.java


示例12: testGETAllRegisteredServicesAsXML

import org.takes.rs.RsPrint; //导入依赖的package包/类
@Test
public void testGETAllRegisteredServicesAsXML() throws Exception {
	Response response = getAllServices("text/xml");
	assertThat(response.head()).contains(HTTP_OK);
	assertThat(new RsPrint(response).printBody()).contains("<services/>");

	registerService();

	response = getAllServices("text/xml");
	assertThat(response.head()).contains(HTTP_OK);
	assertThat(new RsPrint(response).printBody()).contains(
		"<service>",
		"<service><name>example-service</name><env>dev</env><endpoint>http://www.example-service.com/dev</endpoint></service>",
	    "</services>"
	);
}
 
开发者ID:aliceice,项目名称:roster,代码行数:17,代码来源:TkServiceRequestTest.java


示例13: dispatchesByRegularExpression

import org.takes.rs.RsPrint; //导入依赖的package包/类
/**
 * TkFork can dispatch by regular expression.
 * @throws IOException If some problem inside
 */
@Test
public void dispatchesByRegularExpression() throws IOException {
    final String body = "hello, world!";
    MatcherAssert.assertThat(
        new RsPrint(
            new TkFork(new FkRegex("/h[a-z]{2}", body)).act(
                new RqFake("GET", "/hey?yu", "")
            )
        ).print(),
        Matchers.equalTo(
            Joiner.on("\r\n").join(
                "HTTP/1.1 200 OK",
                String.format("Content-Length: %s", body.length()),
                "Content-Type: text/plain",
                "",
                body
            )
        )
    );
}
 
开发者ID:yegor256,项目名称:takes,代码行数:25,代码来源:TkForkTest.java


示例14: dispatchesByRegularExpression

import org.takes.rs.RsPrint; //导入依赖的package包/类
/**
 * FkChain can dispatch by regular expression.
 * @throws Exception If some problem inside
 */
@Test
public void dispatchesByRegularExpression() throws Exception {
    final String body = "hello test!";
    MatcherAssert.assertThat(
        new RsPrint(
            new FkChain(
                new FkRegex("/g[a-z]{2}", ""),
                new FkRegex("/h[a-z]{2}", body),
                new FkRegex("/i[a-z]{2}", "")
            ).route(new RqFake("GET", "/hey?yu")).get()
        ).print(),
        Matchers.equalTo(
            Joiner.on("\r\n").join(
                "HTTP/1.1 200 OK",
                String.format("Content-Length: %s", body.length()),
                "Content-Type: text/plain",
                "",
                body
            )
        )
    );
}
 
开发者ID:yegor256,项目名称:takes,代码行数:27,代码来源:FkChainTest.java


示例15: negotiatesContent

import org.takes.rs.RsPrint; //导入依赖的package包/类
/**
 * RsFork can route by the Accept header.
 * @throws IOException If some problem inside
 */
@Test
public void negotiatesContent() throws IOException {
    final Request req = new RqFake(
        Arrays.asList(
            "GET /hello.html",
            "Accept: text/xml; q=0.3, text/plain; q=0.1",
            "Accept: */*; q=0.05"
        ),
        ""
    );
    MatcherAssert.assertThat(
        new RsPrint(
            new RsFork(
                req,
                new FkTypes("text/plain", new RsText("it's a text")),
                new FkTypes("image/*", new RsText("it's an image"))
            )
        ).printBody(),
        Matchers.endsWith("a text")
    );
}
 
开发者ID:yegor256,项目名称:takes,代码行数:26,代码来源:RsForkTest.java


示例16: negotiatesContentWithComplexHeader

import org.takes.rs.RsPrint; //导入依赖的package包/类
/**
 * RsFork can route by the Accept header.
 * @throws IOException If some problem inside
 */
@Test
public void negotiatesContentWithComplexHeader() throws IOException {
    final Request req = new RqFake(
        Arrays.asList(
            "GET /hell-1o.html",
            "Accept: text/xml"
        ),
        ""
    );
    MatcherAssert.assertThat(
        new RsPrint(
            new RsFork(
                req,
                new FkTypes(
                    "application/xml,text/xml",
                    new RsText("how are you?")
                )
            )
        ).printBody(),
        Matchers.endsWith("you?")
    );
}
 
开发者ID:yegor256,项目名称:takes,代码行数:27,代码来源:RsForkTest.java


示例17: authenticatesUser

import org.takes.rs.RsPrint; //导入依赖的package包/类
/**
 * PsBasic can authenticate a user.
 * @throws Exception If some problem inside
 */
@Test
public void authenticatesUser() throws Exception {
    final Take take = new TkAuth(
        new TkSecure(
            new TkText("secured")
        ),
        new PsBasic(
            "myrealm",
            new PsBasic.Default("mike secret11 urn:users:michael")
        )
    );
    MatcherAssert.assertThat(
        new RsPrint(
            take.act(
                new RqWithHeader(
                    new RqFake(),
                    PsBasicTest.header("mike", "secret11")
                )
            )
        ).print(),
        Matchers.containsString("HTTP/1.1 200 OK")
    );
}
 
开发者ID:yegor256,项目名称:takes,代码行数:28,代码来源:PsBasicTest.java


示例18: requestAuthentication

import org.takes.rs.RsPrint; //导入依赖的package包/类
/**
 * PsBasic can request authentication.
 * @throws Exception If some problem inside
 */
@Test
public void requestAuthentication() throws Exception {
    final Take take = new TkForward(
        new TkAuth(
            new TkSecure(
                new TkText("secured area...")
            ),
            new PsBasic(
                "the realm 5",
                new PsBasic.Default("bob pwd88 urn:users:bob")
            )
        )
    );
    MatcherAssert.assertThat(
        new RsPrint(
            take.act(new RqFake())
        ).print(),
        Matchers.containsString("HTTP/1.1 401 Unauthorized\r\n")
    );
}
 
开发者ID:yegor256,项目名称:takes,代码行数:25,代码来源:PsBasicTest.java


示例19: logsInUserViaCookie

import org.takes.rs.RsPrint; //导入依赖的package包/类
/**
 * TkAuth can login a user via cookie.
 * @throws IOException If some problem inside
 */
@Test
public void logsInUserViaCookie() throws IOException {
    final Pass pass = new PsChain(
        new PsCookie(new CcPlain()),
        new PsLogout()
    );
    MatcherAssert.assertThat(
        new RsPrint(
            new TkAuth(new TkText(), pass).act(
                new RqWithHeader(
                    new RqFake(),
                    String.format(
                        "Cookie:  %s=%s",
                        PsCookie.class.getSimpleName(),
                        "urn%3Atest%3A0"
                    )
                )
            )
        ).print(),
        Matchers.allOf(
            Matchers.startsWith("HTTP/1.1 200 "),
            Matchers.containsString("Set-Cookie: PsCookie=urn%3Atest%3A0")
        )
    );
}
 
开发者ID:yegor256,项目名称:takes,代码行数:30,代码来源:TkAuthTest.java


示例20: logsUserOutWithCookiePresent

import org.takes.rs.RsPrint; //导入依赖的package包/类
/**
 * TkAuth can logout a user when a login cookie is present.
 * @throws IOException If some problem inside
 */
@Test
public void logsUserOutWithCookiePresent() throws IOException {
    final Pass pass = new PsChain(
        new PsLogout(),
        new PsCookie(new CcPlain())
    );
    MatcherAssert.assertThat(
        new RsPrint(
            new TkAuth(new TkText(), pass).act(
                new RqWithHeader(
                    new RqFake(),
                    String.format(
                        "Cookie: %s=%s",
                        PsCookie.class.getSimpleName(),
                        "urn%3Atest%3A5"
                    )
                )
            )
        ).print(),
        Matchers.containsString("Set-Cookie: PsCookie=")
    );
}
 
开发者ID:yegor256,项目名称:takes,代码行数:27,代码来源:TkAuthTest.java



注:本文中的org.takes.rs.RsPrint类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IFindReplaceTarget类代码示例发布时间:2022-05-22
下一篇:
Java Key类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap