PeerToPeerSessionCache extends AbstractSessionCache { @Override public void initialize() { registerFunctions(); createOrRetrieveRegion(); this.operatingRegion = getSessionManager().getEnableLocalCache() ? createOrRetrieveLocalRegion() : this.sessionRegion; createStatistics(); } PeerToPeerSessionCache(SessionManager sessionManager, Cache cache); @Override void initialize(); @Override String getDefaultRegionAttributesId(); @Override boolean getDefaultEnableLocalCache(); @Override void touchSessions(Set<String> sessionIds); @Override boolean isPeerToPeer(); @Override boolean isClientServer(); @Override Set<String> keySet(); @Override int size(); @Override GemFireCache getCache(); @Override boolean isBackingCacheAvailable();  }
@Test public void nonDefaultMaxTimeoutIntervalSetsExpirationDetails() { when(sessionManager.getMaxInactiveInterval()) .thenReturn(RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL + 1); sessionCache.initialize(); verify(regionFactory).setStatisticsEnabled(true); verify(regionFactory).setCustomEntryIdleTimeout(any(SessionCustomExpiry.class)); verify(regionFactory).addCacheListener(any(SessionExpirationCacheListener.class)); }
@Test public void initializeSessionCacheSucceedsWhenLocalRegionAlreadyExists() { doReturn(localRegion).when(cache).getRegion(localRegionName); sessionCache.initialize(); verify(regionFactory, times(0)).create(any(String.class)); }
@Test public void operationRegionIsCorrectlySetWhenEnableLocalCachingIsFalse() { when(sessionManager.getEnableLocalCache()).thenReturn(false); sessionCache.initialize(); verify(cache, times(0)).getRegion(localRegionName); assertThat(sessionCache.sessionRegion).isEqualTo(sessionCache.operatingRegion); }