Repository: james-project Updated Branches: refs/heads/master 4ac0a34af -> 9e66ddb13
JAMES-2549 Fix testing method getRefreshSchemaIntervalMillis (not used yet) Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/da4a8d26 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/da4a8d26 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/da4a8d26 Branch: refs/heads/master Commit: da4a8d264407538940fc042bcae635106a520ec8 Parents: 4ac0a34 Author: Antoine Duprat <adup...@linagora.com> Authored: Mon Sep 17 17:25:23 2018 +0200 Committer: Antoine Duprat <adup...@linagora.com> Committed: Mon Sep 17 17:25:23 2018 +0200 ---------------------------------------------------------------------- .../backends/cassandra/init/ClusterBuilder.java | 2 +- .../cassandra/init/ClusterBuilderTest.java | 59 ++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/da4a8d26/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/ClusterBuilder.java ---------------------------------------------------------------------- diff --git a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/ClusterBuilder.java b/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/ClusterBuilder.java index 7af4519..3b3c721 100644 --- a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/ClusterBuilder.java +++ b/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/ClusterBuilder.java @@ -187,7 +187,7 @@ public class ClusterBuilder { } private Optional<Integer> getRefreshSchemaIntervalMillis() { - return forTest ? Optional.of(0) : refreshSchemaIntervalMillis; + return refreshSchemaIntervalMillis; } private Collection<Host> getServers() { http://git-wip-us.apache.org/repos/asf/james-project/blob/da4a8d26/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/ClusterBuilderTest.java ---------------------------------------------------------------------- diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/ClusterBuilderTest.java b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/ClusterBuilderTest.java new file mode 100644 index 0000000..c74276e --- /dev/null +++ b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/ClusterBuilderTest.java @@ -0,0 +1,59 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you 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 * + * * + * http://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.apache.james.backends.cassandra.init; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; + +import com.datastax.driver.core.Cluster; + +class ClusterBuilderTest { + + @Test + void refreshSchemaIntervalMillisShouldReturnDefaultValueWhenNotGiven() { + Cluster cluster = ClusterBuilder.builder() + .host("localhost") + .port(ClusterBuilder.DEFAULT_CASSANDRA_PORT) + .build(); + + int refreshSchemaIntervalMillis = cluster.getConfiguration() + .getQueryOptions() + .getRefreshSchemaIntervalMillis(); + + assertThat(refreshSchemaIntervalMillis).isEqualTo(1000); + } + + @Test + void refreshSchemaIntervalMillisShouldReturnCustomValueWhenGiven() { + int expected = 123; + Cluster cluster = ClusterBuilder.builder() + .host("localhost") + .port(ClusterBuilder.DEFAULT_CASSANDRA_PORT) + .forTest() + .refreshSchemaIntervalMillis(expected) + .build(); + + int refreshSchemaIntervalMillis = cluster.getConfiguration() + .getQueryOptions() + .getRefreshSchemaIntervalMillis(); + + assertThat(refreshSchemaIntervalMillis).isEqualTo(expected); + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org