本文整理匯總了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
)
)
);
}
示例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"
);
}
示例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)
);
}
示例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)
);
}
示例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));
}
}