### Question:
RedisStore extends AbstractLifecycle implements RedisStoreManagement, Store { @Override public String[] keys() { return this.lockTemplate.withReadLock(new LockTemplate.LockedOperation<String[]>() { @Override public String[] invoke() { try { Set<String> sessions = RedisStore.this.jedisClient.getSessions(getSessionKeyPrefix()); return sessions.toArray(new String[sessions.size()]); } catch (JedisConnectionException e) { RedisStore.this.logger.error("Unable to get the keys of persisted sessions", e); return new String[0]; } } }); } RedisStore();   RedisStore(JmxSupport jmxSupport, PropertyChangeSupport propertyChangeSupport,
               SessionSerializationUtils sessionSerializationUtils, JedisClient jedisClient); @Override void addPropertyChangeListener(PropertyChangeListener propertyChangeListener); @Override void clear(); @Override int getConnectionPoolSize(); void setConnectionPoolSize(final int connectionPoolSize); @Override int getDatabase(); void setDatabase(final int database); @Override String getSessionKeyPrefix(); void setSessionKeyPrefix(final String sessionKeyPrefix); @Override String getHost(); void setHost(final String host); @Override Manager getManager(); @Override void setManager(final Manager manager); @Override String getPassword(); void setPassword(final String password); @Override int getPort(); void setPort(final int port); @Override int getSize(); @Override int getTimeout(); void setTimeout(final int timeout); @Override String getUri(); @Override boolean getCluster(); void setCluster(final boolean cluster); void setUri(final String uri); @Override String[] keys(); @Override Session load(final String id); @Override void remove(final String id); @Override void removePropertyChangeListener(PropertyChangeListener propertyChangeListener); @Override void save(final Session session); static final int DEFAULT_SO_TIMEOUT; }### Answer:
@Test public void keys() throws IOException { Set<String> response = new HashSet<String>(Arrays.asList("test-id")); when(this.jedisClient.getSessions(SESSIONS_KEY)).thenReturn(response); String[] result = this.store.keys(); assertEquals(1, result.length); assertArrayEquals(new String[]{"test-id"}, result); }
@Test public void keysJedisConnectionException() { doThrow(new JedisConnectionException("test-message")) .when(this.jedisClient) .getSessions(SESSIONS_KEY); String[] result = this.store.keys(); assertArrayEquals(new String[0], result); }