Continue renaming SessionIdGenerationStrategy to SessionIdGenerator

This commit is contained in:
Yanming Zhou
2023-08-07 13:13:44 +08:00
committed by Marcus Hert Da Coregio
parent b4e9af9ca4
commit f7662b03b3
15 changed files with 71 additions and 71 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 the original author or authors.
* Copyright 2014-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,7 +44,7 @@ class MapSessionTests {
}
@Test
void constructorWhenSessionIdGenerationStrategyThenUsesStrategy() {
void constructorWhenSessionIdGeneratorThenUsesStrategy() {
MapSession session = new MapSession(new FixedSessionIdGenerator("my-id"));
assertThat(session.getId()).isEqualTo("my-id");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -153,7 +153,7 @@ class ReactiveMapSessionRepositoryTests {
}
@Test
void createSessionWhenSessionIdGenerationStrategyThenUses() {
void createSessionWhenSessionIdGeneratorThenUses() {
this.repository.setSessionIdGenerator(() -> "test");
MapSession session = this.repository.createSession().block();
assertThat(session.getId()).isEqualTo("test");
@@ -161,13 +161,13 @@ class ReactiveMapSessionRepositoryTests {
}
@Test
void setSessionIdGenerationStrategyWhenNullThenThrowsException() {
void setSessionIdGeneratorWhenNullThenThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.repository.setSessionIdGenerator(null))
.withMessage("sessionIdGenerator cannot be null");
}
@Test
void findByIdWhenChangeSessionIdThenUsesSessionIdGenerationStrategy() {
void findByIdWhenChangeSessionIdThenUsesSessionIdGenerator() {
this.repository.setSessionIdGenerator(() -> "test");
MapSession session = this.repository.createSession().block();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -212,7 +212,7 @@ public class MongoIndexedSessionRepositoryTest {
}
@Test
void createSessionWhenSessionIdGenerationStrategyThenUses() {
void createSessionWhenSessionIdGeneratorThenUses() {
this.repository.setSessionIdGenerator(new FixedSessionIdGenerator("123"));
MongoSession session = this.repository.createSession();
assertThat(session.getId()).isEqualTo("123");
@@ -220,12 +220,12 @@ public class MongoIndexedSessionRepositoryTest {
}
@Test
void setSessionIdGenerationStrategyWhenNullThenThrowsException() {
void setSessionIdGeneratorWhenNullThenThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.repository.setSessionIdGenerator(null));
}
@Test
void findByIdWhenChangeSessionIdThenUsesSessionIdGenerationStrategy() {
void findByIdWhenChangeSessionIdThenUsesSessionIdGenerator() {
this.repository.setSessionIdGenerator(new FixedSessionIdGenerator("456"));
Document sessionDocument = new Document();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -212,7 +212,7 @@ public class ReactiveMongoSessionRepositoryTest {
}
@Test
void createSessionWhenSessionIdGenerationStrategyThenUses() {
void createSessionWhenSessionIdGeneratorThenUses() {
this.repository.setSessionIdGenerator(() -> "test");
this.repository.createSession().as(StepVerifier::create).assertNext((mongoSession) -> {
@@ -222,13 +222,13 @@ public class ReactiveMongoSessionRepositoryTest {
}
@Test
void setSessionIdGenerationStrategyWhenNullThenThrowsException() {
void setSessionIdGeneratorWhenNullThenThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.repository.setSessionIdGenerator(null))
.withMessage("sessionIdGenerator cannot be null");
}
@Test
void findByIdWhenChangeSessionIdThenUsesSessionIdGenerationStrategy() {
void findByIdWhenChangeSessionIdThenUsesSessionIdGenerator() {
this.repository.setSessionIdGenerator(() -> "test");
String sessionId = UUID.randomUUID().toString();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -203,14 +203,14 @@ public class MongoHttpSessionConfigurationTest {
}
@Test
void registerWhenSessionIdGenerationStrategyBeanThenUses() {
registerAndRefresh(SessionIdGenerationStrategyConfiguration.class);
void registerWhenSessionIdGeneratorBeanThenUses() {
registerAndRefresh(SessionIdGeneratorConfiguration.class);
MongoIndexedSessionRepository sessionRepository = this.context.getBean(MongoIndexedSessionRepository.class);
assertThat(sessionRepository).extracting("sessionIdGenerator").isInstanceOf(TestSessionIdGenerator.class);
}
@Test
void registerWhenNoSessionIdGenerationStrategyBeanThenDefault() {
void registerWhenNoSessionIdGeneratorBeanThenDefault() {
registerAndRefresh(DefaultConfiguration.class);
MongoIndexedSessionRepository sessionRepository = this.context.getBean(MongoIndexedSessionRepository.class);
assertThat(sessionRepository).extracting("sessionIdGenerator").isInstanceOf(UuidSessionIdGenerator.class);
@@ -369,10 +369,10 @@ public class MongoHttpSessionConfigurationTest {
@Configuration(proxyBeanMethods = false)
@EnableMongoHttpSession
@Import(MongoConfiguration.class)
static class SessionIdGenerationStrategyConfiguration {
static class SessionIdGeneratorConfiguration {
@Bean
SessionIdGenerator sessionIdGenerationStrategy() {
SessionIdGenerator sessionIdGenerator() {
return new TestSessionIdGenerator();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -225,14 +225,14 @@ public class ReactiveMongoWebSessionConfigurationTest {
}
@Test
void registerWhenSessionIdGenerationStrategyBeanThenUses() {
registerAndRefresh(GoodConfig.class, SessionIdGenerationStrategyConfiguration.class);
void registerWhenSessionIdGeneratorBeanThenUses() {
registerAndRefresh(GoodConfig.class, SessionIdGeneratorConfiguration.class);
ReactiveMongoSessionRepository sessionRepository = this.context.getBean(ReactiveMongoSessionRepository.class);
assertThat(sessionRepository).extracting("sessionIdGenerator").isInstanceOf(TestSessionIdGenerator.class);
}
@Test
void registerWhenNoSessionIdGenerationStrategyBeanThenDefault() {
void registerWhenNoSessionIdGeneratorBeanThenDefault() {
registerAndRefresh(GoodConfig.class);
ReactiveMongoSessionRepository sessionRepository = this.context.getBean(ReactiveMongoSessionRepository.class);
assertThat(sessionRepository).extracting("sessionIdGenerator").isInstanceOf(UuidSessionIdGenerator.class);
@@ -434,10 +434,10 @@ public class ReactiveMongoWebSessionConfigurationTest {
}
@Configuration(proxyBeanMethods = false)
static class SessionIdGenerationStrategyConfiguration {
static class SessionIdGeneratorConfiguration {
@Bean
SessionIdGenerator sessionIdGenerationStrategy() {
SessionIdGenerator sessionIdGenerator() {
return new TestSessionIdGenerator();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -439,7 +439,7 @@ class ReactiveRedisSessionRepositoryTests {
}
@Test
void createSessionWhenSessionIdGenerationStrategyThenUses() {
void createSessionWhenSessionIdGeneratorThenUses() {
this.repository.setSessionIdGenerator(() -> "test");
this.repository.createSession().as(StepVerifier::create).assertNext((redisSession) -> {
@@ -449,14 +449,14 @@ class ReactiveRedisSessionRepositoryTests {
}
@Test
void setSessionIdGenerationStrategyWhenNullThenThrowsException() {
void setSessionIdGeneratorWhenNullThenThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.repository.setSessionIdGenerator(null))
.withMessage("sessionIdGenerator cannot be null");
}
@Test
@SuppressWarnings("unchecked")
void findByIdWhenChangeSessionIdThenUsesSessionIdGenerationStrategy() {
void findByIdWhenChangeSessionIdThenUsesSessionIdGenerator() {
this.repository.setSessionIdGenerator(() -> "changed-session-id");
given(this.redisOperations.opsForHash()).willReturn(this.hashOperations);
String attribute1 = "attribute1";

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -911,7 +911,7 @@ class RedisIndexedSessionRepositoryTests {
}
@Test
void createSessionWhenSessionIdGenerationStrategyThenUses() {
void createSessionWhenSessionIdGeneratorThenUses() {
this.redisRepository.setSessionIdGenerator(() -> "test");
RedisSession session = this.redisRepository.createSession();
assertThat(session.getId()).isEqualTo("test");
@@ -919,13 +919,13 @@ class RedisIndexedSessionRepositoryTests {
}
@Test
void setSessionIdGenerationStrategyWhenNullThenThrowsException() {
void setSessionIdGeneratorWhenNullThenThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.redisRepository.setSessionIdGenerator(null))
.withMessage("sessionIdGenerator cannot be null");
}
@Test
void findByIdWhenChangeSessionIdThenUsesSessionIdGenerationStrategy() {
void findByIdWhenChangeSessionIdThenUsesSessionIdGenerator() {
this.redisRepository.setSessionIdGenerator(() -> "test");
String attribute1 = "attribute1";
String attribute2 = "attribute2";

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -374,7 +374,7 @@ class RedisSessionRepositoryTests {
}
@Test
void createSessionWhenSessionIdGenerationStrategyThenUses() {
void createSessionWhenSessionIdGeneratorThenUses() {
this.sessionRepository.setSessionIdGenerator(() -> "test");
RedisSessionRepository.RedisSession session = this.sessionRepository.createSession();
assertThat(session.getId()).isEqualTo("test");
@@ -382,13 +382,13 @@ class RedisSessionRepositoryTests {
}
@Test
void setSessionIdGenerationStrategyWhenNullThenThrowsException() {
void setSessionIdGeneratorWhenNullThenThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.sessionRepository.setSessionIdGenerator(null))
.withMessage("sessionIdGenerator cannot be null");
}
@Test
void findByIdWhenChangeSessionIdThenUsesSessionIdGenerationStrategy() {
void findByIdWhenChangeSessionIdThenUsesSessionIdGenerator() {
this.sessionRepository.setSessionIdGenerator(() -> "test");
Instant now = Instant.now().truncatedTo(ChronoUnit.MILLIS);
given(this.sessionHashOperations.entries(eq(TEST_SESSION_KEY)))

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -209,14 +209,14 @@ class RedisHttpsSessionConfigurationTests {
}
@Test
void registerWhenSessionIdGenerationStrategyBeanThenUses() {
registerAndRefresh(RedisConfig.class, SessionIdGenerationStrategyConfiguration.class);
void registerWhenSessionIdGeneratorBeanThenUses() {
registerAndRefresh(RedisConfig.class, SessionIdGeneratorConfiguration.class);
RedisSessionRepository sessionRepository = this.context.getBean(RedisSessionRepository.class);
assertThat(sessionRepository).extracting("sessionIdGenerator").isInstanceOf(TestSessionIdGenerator.class);
}
@Test
void registerWhenNoSessionIdGenerationStrategyBeanThenDefault() {
void registerWhenNoSessionIdGeneratorBeanThenDefault() {
registerAndRefresh(RedisConfig.class, DefaultConfiguration.class);
RedisSessionRepository sessionRepository = this.context.getBean(RedisSessionRepository.class);
assertThat(sessionRepository).extracting("sessionIdGenerator").isInstanceOf(UuidSessionIdGenerator.class);
@@ -399,10 +399,10 @@ class RedisHttpsSessionConfigurationTests {
@Configuration(proxyBeanMethods = false)
@EnableRedisHttpSession
static class SessionIdGenerationStrategyConfiguration {
static class SessionIdGeneratorConfiguration {
@Bean
SessionIdGenerator sessionIdGenerationStrategy() {
SessionIdGenerator sessionIdGenerator() {
return new TestSessionIdGenerator();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -243,14 +243,14 @@ class RedisIndexedHttpSessionConfigurationTests {
}
@Test
void registerWhenSessionIdGenerationStrategyBeanThenUses() {
registerAndRefresh(RedisConfig.class, SessionIdGenerationStrategyConfiguration.class);
void registerWhenSessionIdGeneratorBeanThenUses() {
registerAndRefresh(RedisConfig.class, SessionIdGeneratorConfiguration.class);
RedisIndexedSessionRepository sessionRepository = this.context.getBean(RedisIndexedSessionRepository.class);
assertThat(sessionRepository).extracting("sessionIdGenerator").isInstanceOf(TestSessionIdGenerator.class);
}
@Test
void registerWhenNoSessionIdGenerationStrategyBeanThenDefault() {
void registerWhenNoSessionIdGeneratorBeanThenDefault() {
registerAndRefresh(RedisConfig.class, DefaultConfiguration.class);
RedisIndexedSessionRepository sessionRepository = this.context.getBean(RedisIndexedSessionRepository.class);
assertThat(sessionRepository).extracting("sessionIdGenerator").isInstanceOf(UuidSessionIdGenerator.class);
@@ -462,10 +462,10 @@ class RedisIndexedHttpSessionConfigurationTests {
@Configuration(proxyBeanMethods = false)
@EnableRedisIndexedHttpSession
static class SessionIdGenerationStrategyConfiguration {
static class SessionIdGeneratorConfiguration {
@Bean
SessionIdGenerator sessionIdGenerationStrategy() {
SessionIdGenerator sessionIdGenerator() {
return new TestSessionIdGenerator();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -466,7 +466,7 @@ class HazelcastIndexedSessionRepositoryTests {
}
@Test
void createSessionWhenSessionIdGenerationStrategyThenUses() {
void createSessionWhenSessionIdGeneratorThenUses() {
this.repository.setSessionIdGenerator(() -> "test");
HazelcastSession session = this.repository.createSession();
assertThat(session.getId()).isEqualTo("test");
@@ -474,13 +474,13 @@ class HazelcastIndexedSessionRepositoryTests {
}
@Test
void setSessionIdGenerationStrategyWhenNullThenThrowsException() {
void setSessionIdGeneratorWhenNullThenThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.repository.setSessionIdGenerator(null))
.withMessage("sessionIdGenerator cannot be null");
}
@Test
void findByIdWhenChangeSessionIdThenUsesSessionIdGenerationStrategy() {
void findByIdWhenChangeSessionIdThenUsesSessionIdGenerator() {
this.repository.setSessionIdGenerator(() -> "test");
MapSession saved = new MapSession("original");
saved.setAttribute("savedName", "savedValue");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -241,15 +241,15 @@ class HazelcastHttpSessionConfigurationTests {
}
@Test
void registerWhenSessionIdGenerationStrategyBeanThenUses() {
registerAndRefresh(DefaultConfiguration.class, SessionIdGenerationStrategyConfiguration.class);
void registerWhenSessionIdGeneratorBeanThenUses() {
registerAndRefresh(DefaultConfiguration.class, SessionIdGeneratorConfiguration.class);
HazelcastIndexedSessionRepository sessionRepository = this.context
.getBean(HazelcastIndexedSessionRepository.class);
assertThat(sessionRepository).extracting("sessionIdGenerator").isInstanceOf(TestSessionIdGenerator.class);
}
@Test
void registerWhenNoSessionIdGenerationStrategyBeanThenDefault() {
void registerWhenNoSessionIdGeneratorBeanThenDefault() {
registerAndRefresh(DefaultConfiguration.class);
HazelcastIndexedSessionRepository sessionRepository = this.context
.getBean(HazelcastIndexedSessionRepository.class);
@@ -484,10 +484,10 @@ class HazelcastHttpSessionConfigurationTests {
}
@Configuration(proxyBeanMethods = false)
static class SessionIdGenerationStrategyConfiguration {
static class SessionIdGeneratorConfiguration {
@Bean
SessionIdGenerator sessionIdGenerationStrategy() {
SessionIdGenerator sessionIdGenerator() {
return new TestSessionIdGenerator();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -264,7 +264,7 @@ class JdbcIndexedSessionRepositoryTests {
}
@Test
void setSessionIdGenerationStrategyWhenNullThenException() {
void setSessionIdGeneratorWhenNullThenException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.repository.setSessionIdGenerator(null))
.withMessage("sessionIdGenerator cannot be null");
}
@@ -776,7 +776,7 @@ class JdbcIndexedSessionRepositoryTests {
}
@Test
void createSessionWhenSessionIdGenerationStrategyThenUses() {
void createSessionWhenSessionIdGeneratorThenUses() {
this.repository.setSessionIdGenerator(() -> "test");
JdbcSession session = this.repository.createSession();
assertThat(session.getId()).isEqualTo("test");
@@ -784,13 +784,13 @@ class JdbcIndexedSessionRepositoryTests {
}
@Test
void setSessionIdGenerationStrategyWhenNullThenThrowsException() {
void setSessionIdGeneratorWhenNullThenThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.repository.setSessionIdGenerator(null))
.withMessage("sessionIdGenerator cannot be null");
}
@Test
void findByIdWhenChangeSessionIdThenUsesSessionIdGenerationStrategy() {
void findByIdWhenChangeSessionIdThenUsesSessionIdGenerator() {
this.repository.setSessionIdGenerator(() -> "test");
Session saved = this.repository.new JdbcSession(new MapSession(), "primaryKey", false);
saved.setAttribute("savedName", "savedValue");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -322,8 +322,8 @@ class JdbcHttpSessionConfigurationTests {
}
@Test
void sessionIdGenerationStrategyWhenCustomBeanThenUses() {
registerAndRefresh(DataSourceConfiguration.class, CustomSessionIdGenerationStrategyConfiguration.class);
void sessionIdGeneratorWhenCustomBeanThenUses() {
registerAndRefresh(DataSourceConfiguration.class, CustomSessionIdGeneratorConfiguration.class);
JdbcIndexedSessionRepository sessionRepository = this.context.getBean(JdbcIndexedSessionRepository.class);
SessionIdGenerator sessionIdGenerator = (SessionIdGenerator) ReflectionTestUtils.getField(sessionRepository,
"sessionIdGenerator");
@@ -331,7 +331,7 @@ class JdbcHttpSessionConfigurationTests {
}
@Test
void sessionIdGenerationStrategyWhenNoBeanThenDefault() {
void sessionIdGeneratorWhenNoBeanThenDefault() {
registerAndRefresh(DataSourceConfiguration.class, DefaultConfiguration.class);
JdbcIndexedSessionRepository sessionRepository = this.context.getBean(JdbcIndexedSessionRepository.class);
SessionIdGenerator sessionIdGenerator = (SessionIdGenerator) ReflectionTestUtils.getField(sessionRepository,
@@ -346,10 +346,10 @@ class JdbcHttpSessionConfigurationTests {
@Configuration(proxyBeanMethods = false)
@EnableJdbcHttpSession
static class CustomSessionIdGenerationStrategyConfiguration {
static class CustomSessionIdGeneratorConfiguration {
@Bean
SessionIdGenerator sessionIdGenerationStrategy() {
SessionIdGenerator sessionIdGenerator() {
return new FixedSessionIdGenerator("my-id");
}