本文整理汇总了Java中play.test.Helpers.fakeRequest方法的典型用法代码示例。如果您正苦于以下问题:Java Helpers.fakeRequest方法的具体用法?Java Helpers.fakeRequest怎么用?Java Helpers.fakeRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类play.test.Helpers
的用法示例。
在下文中一共展示了Helpers.fakeRequest方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkIndex
import play.test.Helpers; //导入方法依赖的package包/类
@Test
public void checkIndex() {
// XXX This is a gap in the test API -- it should be play.test.Helpers.httpContext() by 2.6.0-M4
// and JavaHelpers should be removed.
Http.RequestBuilder request = Helpers.fakeRequest("GET", "/");
// XXX This should be play.test.CSRFTokenHelper
Http.RequestBuilder tokenRequest = play.api.test.CSRFTokenHelper.addCSRFToken(request);
JavaContextComponents contextComponents = createContextComponents();
Http.Context.current.set(createJavaContext(tokenRequest.build()._underlyingRequest(), contextComponents));
PersonRepository repository = mock(PersonRepository.class);
FormFactory formFactory = mock(FormFactory.class);
HttpExecutionContext ec = new HttpExecutionContext(ForkJoinPool.commonPool());
final PersonController controller = new PersonController(formFactory, repository, ec);
final Result result = controller.index();
assertThat(result.status()).isEqualTo(OK);
}
示例2: should_return_not_found_if_sitemap_file_does_not_exists
import play.test.Helpers; //导入方法依赖的package包/类
@Test @SuppressWarnings("rawtypes")
public void should_return_not_found_if_sitemap_file_does_not_exists() {
Call action = routes.Sitemaps.sitemap("-fake");
Http.RequestBuilder request = Helpers.fakeRequest(action);
Result result = Helpers.route(request);
Assertions.assertThat(result.status()).isEqualTo(Helpers.NOT_FOUND);
}
示例3: should_return_sitemap_file_when_it_does_exists
import play.test.Helpers; //导入方法依赖的package包/类
@Test @SuppressWarnings("rawtypes")
public void should_return_sitemap_file_when_it_does_exists() {
Call action = routes.Sitemaps.sitemap("-blog");
Http.RequestBuilder request = Helpers.fakeRequest(action);
Result result = Helpers.route(request);
Assertions.assertThat(result.status()).isEqualTo(Helpers.OK);
}
示例4: should_return_sitemap_file_root
import play.test.Helpers; //导入方法依赖的package包/类
@Test @SuppressWarnings("rawtypes")
public void should_return_sitemap_file_root() {
Call action = routes.Sitemaps.sitemap("");
Http.RequestBuilder request = Helpers.fakeRequest(action);
Result result = Helpers.route(request);
Assertions.assertThat(result.status()).isEqualTo(Helpers.OK);
}
示例5: should_return_sitemap_file_index
import play.test.Helpers; //导入方法依赖的package包/类
@Test @SuppressWarnings("rawtypes")
public void should_return_sitemap_file_index() {
Call action = routes.Sitemaps.sitemap("_index");
Http.RequestBuilder request = Helpers.fakeRequest(action);
Result result = Helpers.route(request);
Assertions.assertThat(result.status()).isEqualTo(Helpers.OK);
}
示例6: should_handle_malicious_directory_transversing_attack
import play.test.Helpers; //导入方法依赖的package包/类
@Test @SuppressWarnings("rawtypes")
public void should_handle_malicious_directory_transversing_attack() {
Call action = routes.Sitemaps.sitemap("../conf/application.conf");
Http.RequestBuilder request = Helpers.fakeRequest(action);
Result result = Helpers.route(request);
Assertions.assertThat(result.status()).isEqualTo(Helpers.NOT_FOUND);
}
示例7: should_return_not_found_when_given_path_is_a_directory
import play.test.Helpers; //导入方法依赖的package包/类
@Test @SuppressWarnings("rawtypes")
public void should_return_not_found_when_given_path_is_a_directory() {
Call action = routes.Sitemaps.sitemap("javascripts");
Http.RequestBuilder request = Helpers.fakeRequest(action);
Result result = Helpers.route(request);
Assertions.assertThat(result.status()).isEqualTo(Helpers.NOT_FOUND);
}