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/04/11 10:15:45 UTC
[james-project] 06/06: JAMES-2708 Singleton Linshare Docker Compose
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 db3b9a42bc2d55d207004999bddb8c5fc0cbdee8
Author: Tran Tien Duc <dt...@linagora.com>
AuthorDate: Tue Apr 9 10:26:13 2019 +0700
JAMES-2708 Singleton Linshare Docker Compose
---
.../apache/james/linshare/LinshareExtension.java | 21 +++-------------
.../apache/james/linshare/LinshareSingleton.java | 29 ++++++++++++++++++++++
2 files changed, 33 insertions(+), 17 deletions(-)
diff --git a/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareExtension.java b/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareExtension.java
index 2a3fbad..29895cc 100644
--- a/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareExtension.java
+++ b/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareExtension.java
@@ -27,9 +27,7 @@ import java.util.Optional;
import org.apache.james.linshare.client.LinshareAPI;
import org.apache.james.linshare.client.User;
-import org.junit.jupiter.api.extension.AfterAllCallback;
-import org.junit.jupiter.api.extension.AfterEachCallback;
-import org.junit.jupiter.api.extension.BeforeAllCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import com.github.fge.lambdas.Throwing;
@@ -44,7 +42,7 @@ import feign.jackson.JacksonDecoder;
import feign.jackson.JacksonEncoder;
import feign.slf4j.Slf4jLogger;
-public class LinshareExtension implements BeforeAllCallback, AfterEachCallback, AfterAllCallback {
+public class LinshareExtension implements BeforeEachCallback {
private interface LinshareAPIForTesting {
@@ -68,24 +66,13 @@ public class LinshareExtension implements BeforeAllCallback, AfterEachCallback,
List<User> allUsers();
}
- private Linshare linshare;
+ private final Linshare linshare = LinshareSingleton.singleton;
@Override
- public void beforeAll(ExtensionContext context) {
- linshare = new Linshare();
- linshare.start();
- }
-
- @Override
- public void afterEach(ExtensionContext context) throws Exception {
+ public void beforeEach(ExtensionContext context) throws Exception {
deleteAllUsersDocuments();
}
- @Override
- public void afterAll(ExtensionContext extensionContext) {
- linshare.stop();
- }
-
public Linshare getLinshare() {
return linshare;
}
diff --git a/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareSingleton.java b/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareSingleton.java
new file mode 100644
index 0000000..c32a2ee
--- /dev/null
+++ b/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareSingleton.java
@@ -0,0 +1,29 @@
+/****************************************************************
+ * 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.linshare;
+
+public class LinshareSingleton {
+
+ public static final Linshare singleton = new Linshare();
+
+ static {
+ singleton.start();
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org