本文整理汇总了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));
}
}