Search in sources :

Example 1 with HazelcastIndexedSessionRepository

use of org.springframework.session.hazelcast.HazelcastIndexedSessionRepository in project spring-boot by spring-projects.

the class SessionAutoConfigurationHazelcastTests method customSaveMode.

@Test
void customSaveMode() {
    this.contextRunner.withPropertyValues("spring.session.store-type=hazelcast", "spring.session.hazelcast.save-mode=on-get-attribute").run((context) -> {
        HazelcastIndexedSessionRepository repository = validateSessionRepository(context, HazelcastIndexedSessionRepository.class);
        assertThat(repository).hasFieldOrPropertyWithValue("saveMode", SaveMode.ON_GET_ATTRIBUTE);
    });
}
Also used : HazelcastIndexedSessionRepository(org.springframework.session.hazelcast.HazelcastIndexedSessionRepository) Test(org.junit.jupiter.api.Test)

Example 2 with HazelcastIndexedSessionRepository

use of org.springframework.session.hazelcast.HazelcastIndexedSessionRepository in project spring-boot by spring-projects.

the class SessionAutoConfigurationHazelcastTests method customFlushMode.

@Test
void customFlushMode() {
    this.contextRunner.withPropertyValues("spring.session.store-type=hazelcast", "spring.session.hazelcast.flush-mode=immediate").run((context) -> {
        HazelcastIndexedSessionRepository repository = validateSessionRepository(context, HazelcastIndexedSessionRepository.class);
        assertThat(repository).hasFieldOrPropertyWithValue("flushMode", FlushMode.IMMEDIATE);
    });
}
Also used : HazelcastIndexedSessionRepository(org.springframework.session.hazelcast.HazelcastIndexedSessionRepository) Test(org.junit.jupiter.api.Test)

Example 3 with HazelcastIndexedSessionRepository

use of org.springframework.session.hazelcast.HazelcastIndexedSessionRepository in project spring-boot by spring-projects.

the class SessionAutoConfigurationHazelcastTests method validateDefaultConfig.

private void validateDefaultConfig(AssertableWebApplicationContext context) {
    HazelcastIndexedSessionRepository repository = validateSessionRepository(context, HazelcastIndexedSessionRepository.class);
    assertThat(repository).hasFieldOrPropertyWithValue("defaultMaxInactiveInterval", (int) new ServerProperties().getServlet().getSession().getTimeout().getSeconds());
    HazelcastInstance hazelcastInstance = context.getBean(HazelcastInstance.class);
    then(hazelcastInstance).should().getMap("spring:session:sessions");
}
Also used : HazelcastIndexedSessionRepository(org.springframework.session.hazelcast.HazelcastIndexedSessionRepository) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ServerProperties(org.springframework.boot.autoconfigure.web.ServerProperties)

Example 4 with HazelcastIndexedSessionRepository

use of org.springframework.session.hazelcast.HazelcastIndexedSessionRepository in project spring-boot by spring-projects.

the class SessionAutoConfigurationHazelcastTests method defaultConfigWithCustomTimeout.

@Test
void defaultConfigWithCustomTimeout() {
    this.contextRunner.withPropertyValues("spring.session.store-type=hazelcast", "spring.session.timeout=1m").run((context) -> {
        HazelcastIndexedSessionRepository repository = validateSessionRepository(context, HazelcastIndexedSessionRepository.class);
        assertThat(repository).hasFieldOrPropertyWithValue("defaultMaxInactiveInterval", 60);
    });
}
Also used : HazelcastIndexedSessionRepository(org.springframework.session.hazelcast.HazelcastIndexedSessionRepository) Test(org.junit.jupiter.api.Test)

Aggregations

HazelcastIndexedSessionRepository (org.springframework.session.hazelcast.HazelcastIndexedSessionRepository)4 Test (org.junit.jupiter.api.Test)3 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 ServerProperties (org.springframework.boot.autoconfigure.web.ServerProperties)1