Package org.springframework.session

Examples of org.springframework.session.MapSession


    @Test
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public void getSessionFound() {
        String attrName = "attrName";
        MapSession expected = new MapSession();
        expected.setLastAccessedTime(System.currentTimeMillis() - 60000);
        expected.setAttribute(attrName, "attrValue");
        when(redisOperations.boundHashOps(getKey(expected.getId()))).thenReturn(boundHashOperations);
        Map map = map(
                getSessionAttrNameKey(attrName), expected.getAttribute(attrName),
                CREATION_TIME_ATTR, expected.getCreationTime(),
                MAX_INACTIVE_ATTR, expected.getMaxInactiveInterval(),
                LAST_ACCESSED_ATTR, expected.getLastAccessedTime());
        when(boundHashOperations.entries()).thenReturn(map);

        long now = System.currentTimeMillis();
        RedisSession session = redisRepository.getSession(expected.getId());
        assertThat(session.getId()).isEqualTo(expected.getId());
        assertThat(session.getAttributeNames()).isEqualTo(expected.getAttributeNames());
        assertThat(session.getAttribute(attrName)).isEqualTo(expected.getAttribute(attrName));
        assertThat(session.getCreationTime()).isEqualTo(expected.getCreationTime());
        assertThat(session.getMaxInactiveInterval()).isEqualTo(expected.getMaxInactiveInterval());
        assertThat(session.getLastAccessedTime()).isGreaterThanOrEqualTo(now);

    }
View Full Code Here

TOP

Related Classes of org.springframework.session.MapSession

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.