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 44b46e9992fd3ee35ba0e726fae304f7e2440038 Author: Rene Cordier <[email protected]> AuthorDate: Tue Dec 10 10:27:56 2019 +0700 [Refactoring] TikaExtension should hold a singleton Docker TikaContainer --- .../james/mailbox/tika/TikaContainerSingleton.java | 30 ++++++++++++++++++++++ .../apache/james/mailbox/tika/TikaExtension.java | 20 ++------------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/mailbox/tika/src/test/java/org/apache/james/mailbox/tika/TikaContainerSingleton.java b/mailbox/tika/src/test/java/org/apache/james/mailbox/tika/TikaContainerSingleton.java new file mode 100644 index 0000000..6df0e5b --- /dev/null +++ b/mailbox/tika/src/test/java/org/apache/james/mailbox/tika/TikaContainerSingleton.java @@ -0,0 +1,30 @@ +/**************************************************************** + * 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.mailbox.tika; + +public class TikaContainerSingleton { + public static final TikaContainer INSTANCE = new TikaContainer(); + + static { + INSTANCE.start(); + } + + // Cleanup will be performed by test container resource reaper +} diff --git a/mailbox/tika/src/test/java/org/apache/james/mailbox/tika/TikaExtension.java b/mailbox/tika/src/test/java/org/apache/james/mailbox/tika/TikaExtension.java index 82f924d..be5809a 100644 --- a/mailbox/tika/src/test/java/org/apache/james/mailbox/tika/TikaExtension.java +++ b/mailbox/tika/src/test/java/org/apache/james/mailbox/tika/TikaExtension.java @@ -19,29 +19,13 @@ package org.apache.james.mailbox.tika; -import org.junit.jupiter.api.extension.AfterAllCallback; -import org.junit.jupiter.api.extension.BeforeAllCallback; import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.jupiter.api.extension.ParameterContext; import org.junit.jupiter.api.extension.ParameterResolutionException; import org.junit.jupiter.api.extension.ParameterResolver; -public class TikaExtension implements AfterAllCallback, BeforeAllCallback, ParameterResolver { - private final TikaContainer tika; - - public TikaExtension() { - this.tika = new TikaContainer(); - } - - @Override - public void beforeAll(ExtensionContext extensionContext) { - tika.start(); - } - - @Override - public void afterAll(ExtensionContext extensionContext) { - tika.stop(); - } +public class TikaExtension implements ParameterResolver { + private final TikaContainer tika = TikaContainerSingleton.INSTANCE; @Override public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException { --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
