Package org.apache.tapestry.services

Examples of org.apache.tapestry.services.Session


public class SessionPersistentFieldStrategyTest extends InternalBaseTestCase
{
    @Test
    public void post_change_to_root_component()
    {
        Session session = mockSession();
        Request request = mockRequest();
        Object value = new Object();

        train_getSession(request, true, session);

        session.setAttribute("state:foo.Bar::field", value);

        replay();

        SessionPersistentFieldStrategy strategy = new SessionPersistentFieldStrategy(request);
View Full Code Here


    }

    @Test
    public void post_change_to_nested_component()
    {
        Session session = mockSession();
        Request request = mockRequest();
        Object value = new Object();

        train_getSession(request, true, session);

        session.setAttribute("state:foo.Bar:fee.fum:field", value);

        replay();

        SessionPersistentFieldStrategy strategy = new SessionPersistentFieldStrategy(request);
View Full Code Here

    }

    @Test
    public void gather_changes_with_active_session()
    {
        Session session = mockSession();
        Request request = mockRequest();

        train_getSession(request, false, session);
        train_getAttributeNames(
                session,
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    public <T> T get(Class<T> asoClass, ApplicationStateCreator<T> creator)
    {
        Session session = getSession();

        String key = buildKey(asoClass);

        T aso = (T) session.getAttribute(key);

        if (aso == null)
        {
            aso = creator.create();
            session.setAttribute(key, aso);
        }

        return aso;
    }
View Full Code Here

    public <T> boolean exists(Class<T> asoClass)
    {
        String key = buildKey(asoClass);

        Session session = _request.getSession(false);

        return session != null && session.getAttribute(key) != null;
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    @Test
    public void get_aso_already_exists()
    {
        Request request = mockRequest();
        Session session = mockSession();
        Class asoClass = ReadOnlyBean.class;
        Object aso = new ReadOnlyBean();
        String key = "aso:" + asoClass.getName();
        ApplicationStateCreator creator = mockApplicationStateCreator();
View Full Code Here

    @SuppressWarnings("unchecked")
    @Test
    public void get_aso_needs_to_be_created()
    {
        Request request = mockRequest();
        Session session = mockSession();
        Class asoClass = ReadOnlyBean.class;
        Object aso = new ReadOnlyBean();
        String key = "aso:" + asoClass.getName();
        ApplicationStateCreator creator = mockApplicationStateCreator();

        // First for exists()
        train_getSession(request, false, session);
        train_getAttribute(session, key, null);

        // Second for get()
        train_getSession(request, true, session);
        train_getAttribute(session, key, null);

        train_create(creator, aso);

        session.setAttribute(key, aso);

        // Then for exists() after
        train_getSession(request, false, session);
        train_getAttribute(session, key, aso);
View Full Code Here

    @SuppressWarnings("unchecked")
    @Test
    public void set_aso()
    {
        Request request = mockRequest();
        Session session = mockSession();
        Class asoClass = ReadOnlyBean.class;
        Object aso = new ReadOnlyBean();
        String key = "aso:" + asoClass.getName();

        train_getSession(request, true, session);
        session.setAttribute(key, aso);

        replay();

        ApplicationStatePersistenceStrategy strategy = new SessionApplicationStatePersistenceStrategy(request);
View Full Code Here

        expect(hs.getAttributeNames()).andReturn(e);

        replay();

        Session session = new SessionImpl(hs);

        assertEquals(session.getAttributeNames(), Arrays.asList("barney", "fred"));

        verify();
    }
View Full Code Here

        expect(hs.getAttributeNames()).andReturn(e);

        replay();

        Session session = new SessionImpl(hs);

        assertEquals(session.getAttributeNames("f"), Arrays.asList("fanny", "fred"));

        verify();
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry.services.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.