本文整理匯總了Java中play.mvc.Http.RequestBuilder方法的典型用法代碼示例。如果您正苦於以下問題:Java Http.RequestBuilder方法的具體用法?Java Http.RequestBuilder怎麽用?Java Http.RequestBuilder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類play.mvc.Http
的用法示例。
在下文中一共展示了Http.RequestBuilder方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testIndex
import play.mvc.Http; //導入方法依賴的package包/類
@Test
public void testIndex() {
Http.RequestBuilder request = new Http.RequestBuilder()
.method(GET)
.uri("/");
Result result = route(app, request);
assertEquals(OK, result.status());
}
示例2: testUnauthenticatedUserRequestingProtectedPage
import play.mvc.Http; //導入方法依賴的package包/類
@Test
public void testUnauthenticatedUserRequestingProtectedPage() {
Http.RequestBuilder request = Helpers.fakeRequest()
.method(GET)
.uri(controllers.routes.PostController.getNewPostForm().url());
Result result = route(app, request);
assertThat(result.status()).isEqualTo(UNAUTHORIZED);
}
示例3: testAuthenticatedUserRequestingProtectedPage
import play.mvc.Http; //導入方法依賴的package包/類
@Test
public void testAuthenticatedUserRequestingProtectedPage() {
Http.RequestBuilder request = Helpers.fakeRequest()
.method(GET)
.session("username", USERNAME)
.uri(controllers.routes.PostController.getNewPostForm().url());
Result result = route(app, request);
assertThat(result.status()).isEqualTo(OK);
}
示例4: testAuthenticatedUserRequestingRegisterPage
import play.mvc.Http; //導入方法依賴的package包/類
@Test
public void testAuthenticatedUserRequestingRegisterPage() {
Http.RequestBuilder request = Helpers.fakeRequest()
.method(GET)
.session("username", USERNAME)
.uri(controllers.routes.UserController.getRegistrationForm().url());
Result result = route(app, request);
assertThat(result.status()).isEqualTo(SEE_OTHER);
}
示例5: testAuthenticatedUserRequestingToEditHisPost
import play.mvc.Http; //導入方法依賴的package包/類
@Test
public void testAuthenticatedUserRequestingToEditHisPost() {
PostDTO postDTO = postService.savePost(new PostDTO(null, "TEST", "TEST", null, USERNAME));
Http.RequestBuilder request = Helpers.fakeRequest()
.method(GET)
.session("username", USERNAME)
.uri(controllers.routes.PostController.getEditPostForm(postDTO.id).url());
Result result = route(app, request);
assertThat(result.status()).isEqualTo(OK);
}
示例6: testAuthenticatedUserRequestingToEditPostByOtherUser
import play.mvc.Http; //導入方法依賴的package包/類
@Test
public void testAuthenticatedUserRequestingToEditPostByOtherUser() {
UserDTO userDTO = new UserDTO("TEST", "TEST", "[email protected]", "firstName", "lastName");
userService.saveUser(userDTO);
PostDTO postDTO = postService.savePost(new PostDTO(null, "TEST", "TEST", null, userDTO.username));
Http.RequestBuilder request = Helpers.fakeRequest()
.method(GET)
.session("username", USERNAME)
.uri(controllers.routes.PostController.getEditPostForm(postDTO.id).url());
Result result = route(app, request);
assertThat(result.status()).isEqualTo(UNAUTHORIZED);
}
示例7: enviaPOSTAddOpiniao
import play.mvc.Http; //導入方法依賴的package包/類
public static Result enviaPOSTAddOpiniao(JsonNode json, long iniciativaExemplo, String token) {
Logger.debug("Requisição para add opinião: " + json.toString());
Http.RequestBuilder request = new Http.RequestBuilder().method("POST")
.bodyJson(json)
.header("authorization", "token " + token)
.uri(controllers.routes.OpiniaoController.addOpiniao(iniciativaExemplo).url());
return route(request);
}
示例8: testIndex
import play.mvc.Http; //導入方法依賴的package包/類
@Test
public void testIndex() {
Http.RequestBuilder request = new Http.RequestBuilder()
.method(GET)
.uri("/login");
Result result = route(app, request);
assertEquals(OK, result.status());
}