ReusedSessionStoreImpl implements ReusedSessionStore { @Override public ReusedSession pull(InitializationParameter key) { synchronized (rawStore) { LinkedList<ByteArray> queue = null; log.log(Level.FINER, "Pulling key {0} from Session Store", key); for (Entry<ByteArray, LinkedList<ByteArray>> entry : rawStore.entrySet()) { InitializationParameter candidate = entry.getKey().as(InitializationParameter.class); if (candidate != null && candidate.equals(key)) { queue = entry.getValue(); break; } } if (queue == null || queue.isEmpty()) { return null; } LinkedList<RawDisposableReusedSession> sessions = getValidSessions(queue); if (sessions == null || sessions.isEmpty()) { return null; } RawDisposableReusedSession disposableSession = sessions.getLast(); disposableSession.dispose(); log.log(Level.FINE, "Reusing session {0} ", disposableSession.getSession().getSessionId()); return disposableSession.getSession(); } } ReusedSessionStoreImpl(); @Override ReusedSession pull(InitializationParameter key); @Override void store(InitializationParameter key, ReusedSession session);  }
@Test public void when_store_does_not_contain_any_session_for_key_then_null_value_is_pulled() { ReusedSessionStoreImpl store = new ReusedSessionStoreImpl(); assertNull(store.pull(key1)); }