Package play.mvc.Scope

Examples of play.mvc.Scope.Session


  private void beginRequest() {
    long start = System.currentTimeMillis();
    startTime.set(start);
   
    Session session = Session.current();
    if(session != null) {
      setupMDC(session);
    }
   
    Request current = Request.current();
View Full Code Here


    }

    @Test
    public void testSessionManipulationMethods() {
        mockRequestAndResponse();
        Session session = Session.restore();
        assertFalse(session.changed);

        session.change();
        assertTrue(session.changed);

        // Reset
        session.changed = false;
        session.put("username", "Alice");
        assertTrue(session.changed);

        session.changed = false;
        session.remove("username");
        assertTrue(session.changed);

        session.changed = false;
        session.clear();
        assertTrue(session.changed);
    }
View Full Code Here

    @Test
    public void testSendOnlyIfChanged() {
        // Mock secret
        Play.secretKey = "0112358";

        Session session;
        setSendOnlyIfChangedConstant(true);
        mockRequestAndResponse();

        // Change nothing in the session
        session = Session.restore();
        session.save();
        assertNull(Response.current().cookies.get(Scope.COOKIE_PREFIX + "_SESSION"));

        mockRequestAndResponse();
        // Change the session
        session = Session.restore();
        session.put("username", "Bob");
        session.save();

        Cookie sessionCookie = Response.current().cookies.get(Scope.COOKIE_PREFIX + "_SESSION");
        assertNotNull(sessionCookie);
        assertTrue(sessionCookie.value.contains("username"));
        assertTrue(sessionCookie.value.contains("Bob"));
View Full Code Here

        assertTrue(sessionCookie.value.contains("Bob"));
    }

    @Test
    public void testSendAlways() {
        Session session;
        setSendOnlyIfChangedConstant(false);

        mockRequestAndResponse();

        // Change nothing in the session
        session = Session.restore();
        session.save();
        assertNotNull(Response.current().cookies.get(Scope.COOKIE_PREFIX + "_SESSION"));
    }
View Full Code Here

    }

    @Test
    public void testSessionManipulationMethods() {
        mockRequestAndResponse();
        Session session = Session.restore();
        assertFalse(session.changed);

        session.change();
        assertTrue(session.changed);

        // Reset
        session.changed = false;
        session.put("username", "Alice");
        assertTrue(session.changed);

        session.changed = false;
        session.remove("username");
        assertTrue(session.changed);

        session.changed = false;
        session.clear();
        assertTrue(session.changed);
    }
View Full Code Here

    @Test
    public void testSendOnlyIfChanged() {
        // Mock secret
        Play.secretKey = "0112358";

        Session session;
        setSendOnlyIfChangedConstant(true);
        mockRequestAndResponse();

        // Change nothing in the session
        session = Session.restore();
        session.save();
        assertNull(Response.current().cookies.get(Scope.COOKIE_PREFIX + "_SESSION"));

        mockRequestAndResponse();
        // Change the session
        session = Session.restore();
        session.put("username", "Bob");
        session.save();

        Cookie sessionCookie = Response.current().cookies.get(Scope.COOKIE_PREFIX + "_SESSION");
        assertNotNull(sessionCookie);
        assertTrue(sessionCookie.value.contains("username"));
        assertTrue(sessionCookie.value.contains("Bob"));
View Full Code Here

        assertTrue(sessionCookie.value.contains("Bob"));
    }

    @Test
    public void testSendAlways() {
        Session session;
        setSendOnlyIfChangedConstant(false);

        mockRequestAndResponse();

        // Change nothing in the session
        session = Session.restore();
        session.save();
        assertNotNull(Response.current().cookies.get(Scope.COOKIE_PREFIX + "_SESSION"));
    }
View Full Code Here

      Params params = Params.current();
      if (params != null && params.data != null) {
    Logger.error(params.toString());
      }

      Session session = Session.current();
      if (session != null) {
    Logger.error(session.all().toString());
      }
  }

  return ret;
    }
View Full Code Here

  private void beginRequest() {
    long start = System.currentTimeMillis();
    startTime.set(start);
   
    Session session = Session.current();
    if(session != null) {
      setupMDC(session);
    }
   
    Request current = Request.current();
View Full Code Here

TOP

Related Classes of play.mvc.Scope.Session

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.