當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。