SessionManager implements Closeable { public ScheduledFuture<?> schedule(String timer, Runnable task, long period) { if (timer != null) { return executors.scheduleAtFixedRate(new RunnableWithTimer(timer, task), period, period, TimeUnit.SECONDS); } return executors.scheduleAtFixedRate(task, period, period, TimeUnit.SECONDS); } SessionManager(ExecutorFacade executors, SessionFactory factory, SessionRepository repository,
      SessionTracking tracking, SessionNotifier notifier, SessionConfiguration configuration, ClassLoader classLoader); RepositoryBackedSession fetchSession(String sessionId, boolean updateTimestamp); RepositoryBackedSession getSession(RequestWithSession request, boolean create,
      SessionTracking.IdAndSource forceId); void propagateSession(RequestWithSession request, ResponseWithSessionId response); void delete(String sessionId, boolean expired); void requestFinished(); Future<?> submit(String timer, Runnable task); ScheduledFuture<?> schedule(String timer, Runnable task, long period); void deleteAsync(final String sessionId, final boolean expired); SessionRepository getRepository(); SessionNotifier getNotifier(); void invokeCommit(RepositoryBackedSession session); SessionConfiguration getConfiguration(); ClassLoader getSessionClassLoader(); SerializerDeserializer getSerializerDeserializer(); void invalidationConflict(RepositoryBackedSession session, boolean onExpiry); MetricRegistry getMetrics(); String encodeUrl(RequestWithSession request, String url); void reset(); @Override void close(); void switchSessionId(RepositoryBackedSession session); void switchSessionId(RepositoryBackedSession session, String forceId); @Override String toString(); void remove(SessionData sessionData); boolean isConnected();  }
@Test public void testSchedule() { Runnable runnable = mock(Runnable.class); sessionManager.schedule(null, runnable, 10); verify(executors).scheduleAtFixedRate(runnable, 10L, 10L, TimeUnit.SECONDS); }
@Test public void testScheduleMinutes() { Runnable runnable = mock(Runnable.class); sessionManager.schedule(null, runnable, TimeUnit.MINUTES.toSeconds(1)); verify(executors).scheduleAtFixedRate(runnable, 60L, 60L, TimeUnit.SECONDS); }
@Test public void testScheduleWithTimer() { Runnable runnable = mock(Runnable.class); sessionManager.schedule("test", runnable, 10); ArgumentCaptor<SessionManager.RunnableWithTimer> arg = ArgumentCaptor .forClass(SessionManager.RunnableWithTimer.class); verify(executors).scheduleAtFixedRate(arg.capture(), eq(10L), eq(10L), eq(TimeUnit.SECONDS)); assertNotNull(arg.getValue().timer); assertSame(runnable, arg.getValue().task); }