You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2019/11/11 08:05:07 UTC
[james-project] 07/09: [Refactoring] Remove
ContainerLifecycleConfiguration as it seems not used
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 4e360bc70ecd8e11dedb836a80b3826d9f69baa2
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Fri Nov 8 15:53:29 2019 +0700
[Refactoring] Remove ContainerLifecycleConfiguration as it seems not used
---
.../cassandra/ContainerLifecycleConfiguration.java | 100 ---------------------
1 file changed, 100 deletions(-)
diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/ContainerLifecycleConfiguration.java b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/ContainerLifecycleConfiguration.java
deleted file mode 100644
index 208448c..0000000
--- a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/ContainerLifecycleConfiguration.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************
- * 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;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.junit.rules.TestRule;
-import org.junit.runners.model.Statement;
-import org.testcontainers.containers.GenericContainer;
-
-import com.google.common.base.Preconditions;
-
-public class ContainerLifecycleConfiguration {
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static Builder withDefaultIterationsBetweenRestart() {
- return new Builder();
- }
-
- public static class Builder {
- private static int DEFAULT_ITERATIONS_BETWEEN_RESTART = 20;
-
- private GenericContainer<?> container;
- private int iterationsBetweenRestart = DEFAULT_ITERATIONS_BETWEEN_RESTART;
-
- private Builder() {}
-
- public Builder container(GenericContainer<?> container) {
- this.container = container;
- return this;
- }
-
- public Builder iterationsBetweenRestart(int iterationsBetweenRestart) {
- this.iterationsBetweenRestart = iterationsBetweenRestart;
- return this;
- }
-
- public ContainerLifecycleConfiguration build() {
- Preconditions.checkState(container != null);
- return new ContainerLifecycleConfiguration(container, iterationsBetweenRestart);
- }
- }
-
- private final GenericContainer<?> container;
- private final int iterationsBetweenRestart;
- private AtomicInteger iterationsBeforeRestart;
-
- public ContainerLifecycleConfiguration(GenericContainer<?> container, int iterationsBetweenRestart) {
- this.container = container;
- this.iterationsBetweenRestart = iterationsBetweenRestart;
- this.iterationsBeforeRestart = new AtomicInteger(iterationsBetweenRestart);
- }
-
- private void restartContainer() {
- iterationsBeforeRestart.set(iterationsBetweenRestart);
- container.stop();
- container.start();
- }
-
- private boolean needsRestart() {
- return iterationsBeforeRestart.decrementAndGet() <= 0;
- }
-
- private void restartContainerIfNeeded() {
- if (needsRestart()) {
- restartContainer();
- }
- }
-
- public TestRule asTestRule() {
- return (base, description) -> new Statement() {
- @Override
- public void evaluate() throws Throwable {
- restartContainerIfNeeded();
- base.evaluate();
- }
- };
- }
-
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org