Example usage for org.springframework.session.data.gemfire AbstractGemFireOperationsSessionRepository setMaxInactiveIntervalInSeconds

List of usage examples for org.springframework.session.data.gemfire AbstractGemFireOperationsSessionRepository setMaxInactiveIntervalInSeconds

Introduction

In this page you can find the example usage for org.springframework.session.data.gemfire AbstractGemFireOperationsSessionRepository setMaxInactiveIntervalInSeconds.

Prototype

public void setMaxInactiveIntervalInSeconds(int maxInactiveIntervalInSeconds) 

Source Link

Document

Sets the maximum interval in seconds in which a Session can remain inactive before the Session is considered expired.

Usage

From source file:org.springframework.session.data.gemfire.AbstractGemFireOperationsSessionRepositoryTest.java

@Test
@SuppressWarnings("unchecked")
public void gemfireOperationsSessionRepositoryIsProperlyConstructedAndInitialized() throws Exception {
    ApplicationEventPublisher mockApplicationEventPublisher = mock(ApplicationEventPublisher.class);
    AttributesMutator<Object, ExpiringSession> mockAttributesMutator = mock(AttributesMutator.class);
    Region<Object, ExpiringSession> mockRegion = mock(Region.class);

    given(mockRegion.getFullPath()).willReturn("/Example");
    given(mockRegion.getAttributesMutator()).willReturn(mockAttributesMutator);

    GemfireTemplate template = new GemfireTemplate(mockRegion);

    AbstractGemFireOperationsSessionRepository sessionRepository = new TestGemFireOperationsSessionRepository(
            template);/*from ww  w .j av  a2s . c  om*/

    ApplicationEventPublisher applicationEventPublisher = sessionRepository.getApplicationEventPublisher();

    assertThat(applicationEventPublisher).isNotNull();
    assertThat(sessionRepository.getFullyQualifiedRegionName()).isNull();
    assertThat(sessionRepository.getMaxInactiveIntervalInSeconds())
            .isEqualTo(GemFireHttpSessionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL_IN_SECONDS);
    assertThat(sessionRepository.getTemplate()).isSameAs(template);

    sessionRepository.setApplicationEventPublisher(mockApplicationEventPublisher);
    sessionRepository.setMaxInactiveIntervalInSeconds(300);
    sessionRepository.afterPropertiesSet();

    assertThat(sessionRepository.getApplicationEventPublisher()).isSameAs(mockApplicationEventPublisher);
    assertThat(sessionRepository.getFullyQualifiedRegionName()).isEqualTo("/Example");
    assertThat(sessionRepository.getMaxInactiveIntervalInSeconds()).isEqualTo(300);
    assertThat(sessionRepository.getTemplate()).isSameAs(template);

    verify(mockRegion, times(1)).getAttributesMutator();
    verify(mockRegion, times(1)).getFullPath();
    verify(mockAttributesMutator, times(1)).addCacheListener(same(sessionRepository));
}