当前位置: 首页>>代码示例>>Java>>正文


Java RqFormBase类代码示例

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


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

示例1: act

import org.takes.rq.form.RqFormBase; //导入依赖的package包/类
@Override
public Response act(final Request req) throws IOException {
    final String name = new RqFormBase(req).param("name")
        .iterator().next().trim();
    try {
        new SafeUser(this.base.user(new RqUser(req).name())).add(name);
    } catch (final SafeUser.InvalidNameException ex) {
        throw TkAdd.forward(new RsFlash(ex));
    }
    return TkAdd.forward(
        new RsFlash(
            String.format(
                "domain \"%s\" added", name
            )
        )
    );
}
 
开发者ID:yegor256,项目名称:jare,代码行数:18,代码来源:TkAdd.java

示例2: act

import org.takes.rq.form.RqFormBase; //导入依赖的package包/类
@Override
public Response act(final Request req) throws IOException {
    this.base.user(new RqUser(req).urn()).pipes().add(
        new RqFormBase(req).param("json").iterator().next().trim()
    );
    return new RsForward(
        new RsFlash("pipe created"),
        "/pipes"
    );
}
 
开发者ID:yegor256,项目名称:wring,代码行数:11,代码来源:TkPipeAdd.java

示例3: assertParam

import org.takes.rq.form.RqFormBase; //导入依赖的package包/类
/**
 * Checks the parameter value for the expected value.
 * @param req Request
 * @param param Parameter name
 * @param value Parameter value
 * @throws IOException If some problem inside
 */
private static void assertParam(final Request req,
    final CharSequence param, final String value) throws IOException {
    MatcherAssert.assertThat(
        new RqFormSmart(new RqFormBase(req)).single(param),
        Matchers.equalTo(value)
    );
}
 
开发者ID:yegor256,项目名称:takes,代码行数:15,代码来源:PsGoogleTest.java

示例4: assertParam

import org.takes.rq.form.RqFormBase; //导入依赖的package包/类
/**
 * Checks the parameter value for the expected value.
 * @param req Request
 * @param param Parameter name
 * @param value Parameter value
 * @throws IOException  If some problem inside
 */
private static void assertParam(final Request req,
    final CharSequence param, final String value)  throws IOException {
    MatcherAssert.assertThat(
        new RqFormSmart(new RqFormBase(req)).single(param),
        Matchers.equalTo(value)
    );
}
 
开发者ID:yegor256,项目名称:takes,代码行数:15,代码来源:PsGithubTest.java

示例5: worksInParallelThreads

import org.takes.rq.form.RqFormBase; //导入依赖的package包/类
/**
 * FtRemote can work in parallel threads.
 * @throws Exception If some problem inside
 */
@Test
public void worksInParallelThreads() throws Exception {
    final Take take = new Take() {
        @Override
        public Response act(final org.takes.Request req)
            throws IOException {
            MatcherAssert.assertThat(
                new RqFormBase(req).param("alpha"),
                Matchers.hasItem("123")
            );
            return new RsText("works fine");
        }
    };
    final Callable<Long> task = new Callable<Long>() {
        @Override
        public Long call() throws Exception {
            new FtRemote(take).exec(
                new FtRemote.Script() {
                    @Override
                    public void exec(final URI home) throws IOException {
                        new JdkRequest(home)
                            .method(Request.POST)
                            .body().set("alpha=123").back()
                            .fetch()
                            .as(RestResponse.class)
                            .assertStatus(HttpURLConnection.HTTP_OK)
                            .assertBody(Matchers.startsWith("works"));
                    }
                }
            );
            return 0L;
        }
    };
    final int total = Runtime.getRuntime().availableProcessors() << 2;
    final Collection<Callable<Long>> tasks = new ArrayList<>(total);
    for (int idx = 0; idx < total; ++idx) {
        tasks.add(task);
    }
    final Collection<Future<Long>> futures =
        Executors.newFixedThreadPool(total).invokeAll(tasks);
    for (final Future<Long> future : futures) {
        MatcherAssert.assertThat(future.get(), Matchers.equalTo(0L));
    }
}
 
开发者ID:yegor256,项目名称:takes,代码行数:49,代码来源:FtRemoteTest.java


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