Package play.mvc

Examples of play.mvc.Result


    {
      // Signup with a username/password
      Map<String, String> data = new HashMap<String, String>();
      data.put("email", email);
      data.put("password", password);
      Result result = callAction(
          controllers.routes.ref.Application.doSignup(),
          fakeRequest().withFormUrlEncodedBody(data));
      assertThat(status(result)).isEqualTo(SEE_OTHER);
    }
    {
      // Validate the token
      String token = upAuthProvider().getVerificationToken(email);
      assertThat(token).isNotNull();
      Logger.info("Verifying token: " + token);
      Result result = callAction(controllers.routes.ref.Application
          .verify(token));
      assertThat(status(result)).isEqualTo(SEE_OTHER);
      assertThat(upAuthProvider().getVerificationToken(email)).isNull();
      // We should actually be logged in here, but let's ignore that
      // as we want to test login too.
      assertThat(redirectLocation(result)).isEqualTo("/");
    }
    {
      // Log the user in
      Map<String, String> data = new HashMap<String, String>();
      data.put("email", email);
      data.put("password", password);
      Result result = callAction(
          controllers.routes.ref.Application.doLogin(), fakeRequest()
              .withFormUrlEncodedBody(data));
      assertThat(status(result)).isEqualTo(SEE_OTHER);
      assertThat(redirectLocation(result)).isEqualTo("/");
      // Create a Java session from the Scala session
View Full Code Here


public class AuthenticityTokenControllerTest {
    @Test
    public void formContainsAuthenticityToken() {
        running(fakeApplication(), new Runnable() {
            public void run() {
                Result res = route(fakeRequest("GET", "/form").withSession("", ""));
                Logger logger = Logger.getLogger(AuthenticityTokenControllerTest.class.getName());
                String sContent = contentAsString(res);
                logger.log(Level.FINE, sContent);
                assertThat(sContent.contains(AuthTokenConstants.AUTH_TOKEN_FORM_FIELD));
            }
View Full Code Here

    @Test
    public void badFormDoesntContainsAuthenticityToken() {
        running(fakeApplication(), new Runnable() {
            public void run() {
                Result res = route(fakeRequest("GET", "/badform").withSession("", ""));
                String sContent = contentAsString(res);
                assertThat(!sContent.contains(AuthTokenConstants.AUTH_TOKEN_FORM_FIELD));
            }
        });
    }
View Full Code Here

                String token = UUID.randomUUID().toString();

                final Map<String, String> data = new HashMap<String, String>();
                data.put(AuthTokenConstants.AUTH_TOKEN_FORM_FIELD, token);

                Result result = route(fakeRequest("POST", "/form/process")
                        .withFormUrlEncodedBody(data)
                        .withSession(AuthTokenConstants.AUTH_TOKEN, Crypto.sign(token))
                );

                assertThat(status(result)).isEqualTo(OK);
View Full Code Here

                String token = UUID.randomUUID().toString();

                final Map<String, String> data = new HashMap<String, String>();
                data.put(AuthTokenConstants.AUTH_TOKEN_FORM_FIELD, "SOME INVALID TOKEN");

                Result result = route(fakeRequest("POST", "/form/process")
                        .withFormUrlEncodedBody(data)
                        .withSession(AuthTokenConstants.AUTH_TOKEN, Crypto.sign(token))
                );

                assertThat(status(result)).isEqualTo(BAD_REQUEST);
View Full Code Here

    @RoleHolderPresent
    public static Result submitModuleRegistrationForm()
    {
        Form<Module> form = form(Module.class).bindFromRequest();
        Result result;
        User user = currentUser();
        if (form.hasErrors())
        {
            result = badRequest(moduleRegistrationForm.render(user,
                                                              form));
View Full Code Here

    }

    @RoleHolderPresent
    public static Result uploadNewVersion(String moduleKey)
    {
        Result result;
        Form<ModuleVersion> form = form(ModuleVersion.class).bindFromRequest();
        User user = currentUser();
        if (form.hasErrors())
        {
            result = badRequest(manageVersionsForm.render(user,
View Full Code Here

    // e.g. /modules/play-1.2.4
    public static Result getModulesByPlayVersion(String version)
    {
        List<PlayVersion> playVersionList = PlayVersion.findByLooseName(version);
        Result result;
        if (playVersionList.isEmpty()){
            result = notFound("Play version not found: " + version);
        }                                                                       
        else
        {
View Full Code Here

        return TODO;
    }

    public static Result details(String moduleKey)
    {
        Result result;
        final Module module = Module.findByModuleKey(moduleKey);
        if (module == null)
        {
            result = notFound("Module not found: " + moduleKey);
        }
View Full Code Here

    }

    @RoleHolderPresent
    public static Result voteUp(String moduleKey)
    {
        Result result;
        final Module module = Module.findByModuleKey(moduleKey);
        if (module == null)
        {
            result = notFound("Module not found: " + moduleKey);
        }
View Full Code Here

TOP

Related Classes of play.mvc.Result

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.