SessionScopeExtractor implements AttributeExtractor { @Override public void setValue(String key, Object value) { if (context.getSession() == null) { return; } context.setAttribute(key, value, PageContext.SESSION_SCOPE); } SessionScopeExtractor(PageContext context); @Override void removeValue(String name); @Override Enumeration<String> getKeys(); @Override Object getValue(String key); @Override void setValue(String key, Object value);  }
@Test public void testSetValue() { expect(context.getSession()).andReturn(session); context.setAttribute("key", "value", PageContext.SESSION_SCOPE); replay(context, session); extractor.setValue("key", "value"); verify(context, session); }
@Test public void testSetValueNoSession() { expect(context.getSession()).andReturn(null); replay(context, session); extractor.setValue("key", "value"); verify(context, session); }