@Test public void testAttributeByKey_session() { final SimpleSession session = new SimpleSession(SessionKey.generate()); session.setAttribute("key1", "value1"); final LocalScopeImpl context = new LocalScopeImpl(); context.setSession(session); assertSame(session, context.getSession()); assertEquals("value1", context.getAttribute("key1")); assertEquals(0, context.getAttributes().size()); }
@Test public void testAttributeByType_session() { final SampleValue value = new SampleValue(); final SimpleSession session = new SimpleSession(SessionKey.generate()); session.setAttribute(value); final LocalScopeImpl context = new LocalScopeImpl(); context.setSession(session); assertSame(session, context.getSession()); assertSame(value, context.getAttribute(SampleValue.class)); assertEquals(0, context.getAttributes().size()); }