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

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

Introduction

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

Prototype

@Deprecated
public @NonNull GemfireOperations getTemplate() 

Source Link

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);/* w w  w  .  jav  a 2  s.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));
}