[
https://issues.apache.org/jira/browse/OPENNLP-1659?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17901734#comment-17901734
]
ASF GitHub Bot commented on OPENNLP-1659:
-----------------------------------------
mawiesne commented on code in PR #697:
URL: https://github.com/apache/opennlp/pull/697#discussion_r1862257211
##########
opennlp-tools/src/test/java/opennlp/tools/util/AbstractDownloadUtilTest.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * 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 opennlp.tools.util;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.nio.file.DirectoryStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import org.junit.jupiter.api.BeforeAll;
+
+import opennlp.tools.EnabledWhenCDNAvailable;
+
+import static org.junit.jupiter.api.Assertions.fail;
+
+@EnabledWhenCDNAvailable(hostname = "dlcdn.apache.org")
+public abstract class AbstractDownloadUtilTest {
+
+ private static final String APACHE_CDN = "dlcdn.apache.org";
+
+ @BeforeAll
+ public static void cleanupWhenOnline() {
+ boolean isOnline;
+ try (Socket socket = new Socket()) {
+ socket.connect(new InetSocketAddress(APACHE_CDN, 80),
EnabledWhenCDNAvailable.TIMEOUT_MS);
+ isOnline = true;
+ } catch (IOException e) {
+ // Unreachable, unresolvable or timeout
+ isOnline = false;
+ }
+ // If CDN is available -> go cleanup in preparation of the actual tests
+ if (isOnline) {
+ wipeExistingModelFiles("-tokens-");
Review Comment:
For consistency: Missing "-pos-" and "-lemmas-" here?
##########
pom.xml:
##########
@@ -177,7 +177,8 @@
<log4j2.version>2.24.2</log4j2.version>
<jmh.version>1.37</jmh.version>
<classgraph.version>4.8.179</classgraph.version>
-
+ <logcaptor.version>2.10.0</logcaptor.version>
Review Comment:
please move this to line 178, just below `log4j2.version`, so that it better
fits the "group" of dependencies.
##########
opennlp-tools/pom.xml:
##########
@@ -121,7 +122,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <argLine>-Xmx2048m -Dorg.slf4j.simpleLogger.defaultLogLevel=off
-javaagent:${settings.localRepository}/com/ginsberg/junit5-system-exit/${junit5-system-exit.version}/junit5-system-exit-${junit5-system-exit.version}.jar</argLine>
+ <argLine>-Xmx2048m -DOPENNLP_DOWNLOAD_HOME=${opennlp.download.home}
-javaagent:${settings.localRepository}/com/ginsberg/junit5-system-exit/${junit5-system-exit.version}/junit5-system-exit-${junit5-system-exit.version}.jar</argLine>
Review Comment:
Do we have to adapt the _failsafe-plugin_ config as well? Afair, there are
ITs which will also download (all) models? That should also go the adapted
download home, correct?
> Improve DownloadUtil with several enhancements
> ----------------------------------------------
>
> Key: OPENNLP-1659
> URL: https://issues.apache.org/jira/browse/OPENNLP-1659
> Project: OpenNLP
> Issue Type: Improvement
> Reporter: Richard Zowalla
> Assignee: Richard Zowalla
> Priority: Major
> Fix For: 2.5.1
>
>
> DownloadUtil has the need for some improvements:
> * (1) Path handling is done without taking OS specific file separators into
> account
> * (2) Location of download cannot be configured
> * (3) As soon as the classloader loads this class, a HTTP call is made to
> parse download information, which might be bad, if we are in an offline
> environment, etc.
> * (4) There is no indication, if a model is downloaded multiple times. We
> should at least log that situation and have a proper test case for it.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)