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

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

Introduction

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

Prototype

public int getMaxInactiveIntervalInSeconds() 

Source Link

Document

Returns 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  w  ww .j  a  v a  2 s. c  o m*/

    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));
}