From f71ab69aeb5f04965779872507968fc1f363d5c5 Mon Sep 17 00:00:00 2001 From: bono007 Date: Sun, 7 Feb 2021 18:39:15 -0600 Subject: [PATCH 1/2] Validate Cassandra defaults See gh-25130 --- .../cassandra/CassandraPropertiesTest.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraPropertiesTest.java diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraPropertiesTest.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraPropertiesTest.java new file mode 100644 index 0000000000..bd73ede747 --- /dev/null +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraPropertiesTest.java @@ -0,0 +1,39 @@ +package org.springframework.boot.autoconfigure.cassandra; + +import com.datastax.oss.driver.api.core.config.OptionsMap; +import com.datastax.oss.driver.api.core.config.TypedDriverOption; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link CassandraProperties}. + * + * @author Chris Bono + */ +class CassandraPropertiesTest { + + @Test + void defaultValuesAreConsistent() { + CassandraProperties properties = new CassandraProperties(); + OptionsMap optionsMap = OptionsMap.driverDefaults(); + + assertThat(properties.getConnection().getConnectTimeout()) + .isEqualTo(optionsMap.get(TypedDriverOption.CONNECTION_CONNECT_TIMEOUT)); + + assertThat(properties.getConnection().getInitQueryTimeout()) + .isEqualTo(optionsMap.get(TypedDriverOption.CONNECTION_INIT_QUERY_TIMEOUT)); + + assertThat(properties.getRequest().getTimeout()).isEqualTo(optionsMap.get(TypedDriverOption.REQUEST_TIMEOUT)); + + assertThat(properties.getRequest().getPageSize()) + .isEqualTo(optionsMap.get(TypedDriverOption.REQUEST_PAGE_SIZE)); + + assertThat(properties.getRequest().getThrottler().getType().type()) + .isEqualTo(optionsMap.get(TypedDriverOption.REQUEST_THROTTLER_CLASS)); + + assertThat(properties.getPool().getHeartbeatInterval()) + .isEqualTo(optionsMap.get(TypedDriverOption.HEARTBEAT_INTERVAL)); + } + +} From e5098697cb4886ebaeba51c35540f0ba2b3047b7 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 10 Feb 2021 10:15:15 +0100 Subject: [PATCH 2/2] Polish "Validate Cassandra defaults" See gh-25130 --- .../cassandra/CassandraPropertiesTest.java | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraPropertiesTest.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraPropertiesTest.java index bd73ede747..162915164b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraPropertiesTest.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraPropertiesTest.java @@ -1,3 +1,19 @@ +/* + * Copyright 2012-2021 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.boot.autoconfigure.cassandra; import com.datastax.oss.driver.api.core.config.OptionsMap; @@ -16,24 +32,19 @@ class CassandraPropertiesTest { @Test void defaultValuesAreConsistent() { CassandraProperties properties = new CassandraProperties(); - OptionsMap optionsMap = OptionsMap.driverDefaults(); - + OptionsMap driverDefaults = OptionsMap.driverDefaults(); assertThat(properties.getConnection().getConnectTimeout()) - .isEqualTo(optionsMap.get(TypedDriverOption.CONNECTION_CONNECT_TIMEOUT)); - + .isEqualTo(driverDefaults.get(TypedDriverOption.CONNECTION_CONNECT_TIMEOUT)); assertThat(properties.getConnection().getInitQueryTimeout()) - .isEqualTo(optionsMap.get(TypedDriverOption.CONNECTION_INIT_QUERY_TIMEOUT)); - - assertThat(properties.getRequest().getTimeout()).isEqualTo(optionsMap.get(TypedDriverOption.REQUEST_TIMEOUT)); - + .isEqualTo(driverDefaults.get(TypedDriverOption.CONNECTION_INIT_QUERY_TIMEOUT)); + assertThat(properties.getRequest().getTimeout()) + .isEqualTo(driverDefaults.get(TypedDriverOption.REQUEST_TIMEOUT)); assertThat(properties.getRequest().getPageSize()) - .isEqualTo(optionsMap.get(TypedDriverOption.REQUEST_PAGE_SIZE)); - + .isEqualTo(driverDefaults.get(TypedDriverOption.REQUEST_PAGE_SIZE)); assertThat(properties.getRequest().getThrottler().getType().type()) - .isEqualTo(optionsMap.get(TypedDriverOption.REQUEST_THROTTLER_CLASS)); - + .isEqualTo(driverDefaults.get(TypedDriverOption.REQUEST_THROTTLER_CLASS)); assertThat(properties.getPool().getHeartbeatInterval()) - .isEqualTo(optionsMap.get(TypedDriverOption.HEARTBEAT_INTERVAL)); + .isEqualTo(driverDefaults.get(TypedDriverOption.HEARTBEAT_INTERVAL)); } }