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


Java Helpers.fakeRequest方法代码示例

本文整理汇总了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);
}
 
开发者ID:play2-maven-plugin,项目名称:play2-maven-test-projects,代码行数:20,代码来源:UnitTest.java

示例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);
}
 
开发者ID:edulify,项目名称:play-sitemap-module.edulify.com,代码行数:8,代码来源:SitemapControllerTest.java

示例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);
}
 
开发者ID:edulify,项目名称:play-sitemap-module.edulify.com,代码行数:8,代码来源:SitemapControllerTest.java

示例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);
}
 
开发者ID:edulify,项目名称:play-sitemap-module.edulify.com,代码行数:8,代码来源:SitemapControllerTest.java

示例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);
}
 
开发者ID:edulify,项目名称:play-sitemap-module.edulify.com,代码行数:8,代码来源:SitemapControllerTest.java

示例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);
}
 
开发者ID:edulify,项目名称:play-sitemap-module.edulify.com,代码行数:8,代码来源:SitemapControllerTest.java

示例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);
}
 
开发者ID:edulify,项目名称:play-sitemap-module.edulify.com,代码行数:8,代码来源:SitemapControllerTest.java


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