SessionScopeExtractor implements AttributeExtractor { @Override public Object getValue(String key) { PortletSession session = request.getPortletSession(false); if (session != null) { return session.getAttribute(key, scope); } return null; } SessionScopeExtractor(PortletRequest request, int scope); @Override void setValue(String name, Object value); @Override void removeValue(String name); @Override Enumeration<String> getKeys(); @Override Object getValue(String key);  }
@Test public void testGetValue() { expect(request.getPortletSession(false)).andReturn(session); expect(session.getAttribute("name", PortletSession.PORTLET_SCOPE)).andReturn("value"); replay(request, session); assertEquals("value", extractor.getValue("name")); verify(request, session); }
@Test public void testGetValueNoSession() { expect(request.getPortletSession(false)).andReturn(null); replay(request, session); assertNull(extractor.getValue("name")); verify(request, session); }