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? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@opennlp.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org