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/12/12 02:18:51 UTC
[james-project] 07/15: [Refactoring] Create a Tika extension for
JUnit 5 in mailbox-tika package
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 8ba41230807e58c54c1b2c5df5895e1ac127c9de
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Fri Dec 6 14:59:55 2019 +0700
[Refactoring] Create a Tika extension for JUnit 5 in mailbox-tika package
---
.../apache/james/mailbox/tika/TikaExtension.java | 67 ++++++++++++++++++++++
1 file changed, 67 insertions(+)
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
new file mode 100644
index 0000000..82f924d
--- /dev/null
+++ b/mailbox/tika/src/test/java/org/apache/james/mailbox/tika/TikaExtension.java
@@ -0,0 +1,67 @@
+/****************************************************************
+ * 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;
+
+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();
+ }
+
+ @Override
+ public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
+ return (parameterContext.getParameter().getType() == TikaContainer.class);
+ }
+
+ @Override
+ public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
+ return tika;
+ }
+
+ public String getIp() {
+ return tika.getIp();
+ }
+
+ public int getPort() {
+ return tika.getPort();
+ }
+
+ public int getTimeoutInMillis() {
+ return tika.getTimeoutInMillis();
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org