Examples of MapSession


Examples of org.springframework.session.MapSession

    }

    @Test
    public void redisSessionGetAttributes() {
        String attrName = "attrName";
        RedisSession session = redisRepository.new RedisSession(new MapSession());
        assertThat(session.getAttributeNames()).isEmpty();
        session.setAttribute(attrName, "attrValue");
        assertThat(session.getAttributeNames()).containsOnly(attrName);
        session.removeAttribute(attrName);
        assertThat(session.getAttributeNames()).isEmpty();
View Full Code Here

Examples of org.springframework.session.MapSession

    }

    @Test
    public void delete() {
        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);
        when(expirationRedisOperations.boundSetOps(anyString())).thenReturn(boundSetOperations);

        String id = expected.getId();
        redisRepository.delete(id);
        verify(redisOperations).delete(getKey(id));
    }
View Full Code Here

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
Copyright © 2018 www.massapi.com. 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.