SessionScopeExtractor implements AttributeExtractor { @Override public Enumeration<String> getKeys() { PortletSession session = request.getPortletSession(false); if (session != null) { return session.getAttributeNames(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);  }
@SuppressWarnings("unchecked") @Test public void testGetKeys() { Enumeration<String> keys = createMock(Enumeration.class); expect(request.getPortletSession(false)).andReturn(session); expect(session.getAttributeNames(PortletSession.PORTLET_SCOPE)).andReturn(keys); replay(request, session, keys); assertEquals(keys, extractor.getKeys()); verify(request, session, keys); }
@Test public void testGetKeysNoSession() { expect(request.getPortletSession(false)).andReturn(null); replay(request, session); assertNull(extractor.getKeys()); verify(request, session); }