Polish "Fix scope of CqlSessionBuilder bean"
See gh-19899
This commit is contained in:
parent
c8105413b9
commit
0516520b7e
|
@ -45,13 +45,13 @@ class CassandraAutoConfigurationTests {
|
|||
.withConfiguration(AutoConfigurations.of(CassandraAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
void cqlSessionBuilderThreadSafe() {
|
||||
void cqlSessionBuildHasScopePrototype() {
|
||||
this.contextRunner.run((context) -> {
|
||||
CqlIdentifier keyspace = CqlIdentifier.fromCql("test");
|
||||
assertThat(context).hasSingleBean(CqlSessionBuilder.class);
|
||||
assertThat(context.getBean(CqlSessionBuilder.class).withKeyspace(keyspace))
|
||||
.hasFieldOrPropertyWithValue("keyspace", keyspace);
|
||||
assertThat(context.getBean(CqlSessionBuilder.class)).hasFieldOrPropertyWithValue("keyspace", null);
|
||||
CqlSessionBuilder firstBuilder = context.getBean(CqlSessionBuilder.class);
|
||||
assertThat(firstBuilder.withKeyspace(keyspace)).hasFieldOrPropertyWithValue("keyspace", keyspace);
|
||||
CqlSessionBuilder secondBuilder = context.getBean(CqlSessionBuilder.class);
|
||||
assertThat(secondBuilder).hasFieldOrPropertyWithValue("keyspace", null);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -4266,6 +4266,8 @@ Generally, you provide `keyspace-name` and `contact-points` as well the local da
|
|||
You can also register an arbitrary number of beans that implement `DriverConfigLoaderBuilderCustomizer` for more advanced driver customizations.
|
||||
The `CqlSession` can be customized with a bean of type `CqlSessionBuilderCustomizer`.
|
||||
|
||||
NOTE: If you're using `CqlSessionBuilder` to create multiple `CqlSession` beans, keep in mind the builder is mutable so make sure to inject a fresh copy for each session.
|
||||
|
||||
The following code listing shows how to inject a Cassandra bean:
|
||||
|
||||
[source,java,indent=0]
|
||||
|
|
Loading…
Reference in New Issue