diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f82cf9..ce8e475 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,4 +17,8 @@ jobs: distribution: liberica cache: maven - name: Build with Maven - run: mvn -V -B package \ No newline at end of file + run: mvn -V -B package -DskipTests + - name: Run Tests + run: mvn -V -B test + - name: Check JavaDoc + run: mvn -V -B javadoc:javadoc \ No newline at end of file diff --git a/pom.xml b/pom.xml index 182b146..33180f7 100644 --- a/pom.xml +++ b/pom.xml @@ -13,14 +13,17 @@ - 21 - 21 + 21 + 21 UTF-8 - 4.10.9 + + 4.10.14 + 4.10.2 4.12.0 2.8.2 netty - 6.0.1 + 2.19.1 + 6.0.2 com.evolvedbinary.bblValidator.Application @@ -29,8 +32,8 @@ io.micronaut micronaut-http-server-netty - - 4.10.12 + ${micronaut.version} + runtime @@ -45,13 +48,7 @@ io.micronaut micronaut-runtime ${micronaut.version} - - - - - io.micronaut.validation - micronaut-validation - ${micronaut.validation.version} + runtime @@ -74,6 +71,7 @@ io.micronaut.reactor micronaut-reactor 3.9.1 + runtime @@ -88,13 +86,65 @@ io.micronaut.views micronaut-views-velocity 5.9.0 + runtime + + + + io.micronaut + micronaut-context + ${micronaut.version} + + + io.micronaut + micronaut-http + ${micronaut.version} + + + io.micronaut + micronaut-aop + ${micronaut.version} + compile + + + io.micronaut + micronaut-core + ${micronaut.version} + compile + + + jakarta.inject + jakarta.inject-api + 2.0.1 + + + jakarta.annotation + jakarta.annotation-api + 3.0.0 + compile + + + org.slf4j + slf4j-api + 2.0.17 + + + org.reactivestreams + reactive-streams + 1.0.4 + compile + + + io.projectreactor + reactor-core + 3.8.2 + compile ch.qos.logback logback-classic - 1.5.21 + 1.5.26 runtime @@ -102,28 +152,41 @@ org.yaml snakeyaml - 2.0 + 2.5 runtime + + com.fasterxml.jackson.core + jackson-core + ${jackson.version} + com.fasterxml.jackson.core jackson-databind - 2.15.3 + ${jackson.version} uk.gov.nationalarchives csv-validator-java-api - 1.4.1 + 1.4.3 + + + + org.apache.httpcomponents.client5 + httpclient5 + 5.6 + compile - org.apache.httpcomponents - httpclient - 4.5.14 + org.apache.httpcomponents.core5 + httpcore5 + 5.4 + compile @@ -142,7 +205,7 @@ io.micronaut.test micronaut-test-junit5 - 4.6.0 + ${micronaut.test.version} test @@ -154,9 +217,9 @@ - org.junit.jupiter - junit-jupiter-engine - ${junit.version} + io.micronaut.test + micronaut-test-core + ${micronaut.test.version} test @@ -166,6 +229,34 @@ ${micronaut.version} test + + + io.micronaut + micronaut-http-client-core + ${micronaut.version} + test + + + + org.junit.jupiter + junit-jupiter-engine + ${junit.version} + test + + + + org.junit.platform + junit-platform-commons + ${junit.version} + test + + + + org.apiguardian + apiguardian-api + 1.1.2 + test + @@ -198,7 +289,7 @@ org.apache.maven.plugins maven-source-plugin - 3.3.1 + 3.4.0 org.apache.maven.plugins @@ -213,20 +304,47 @@ org.sonatype.central central-publishing-maven-plugin - 0.9.0 + 0.10.0 true + + org.apache.maven.plugins + maven-enforcer-plugin + 3.6.2 + + + enforce-maven-version + + enforce + + + + + [21,) + + + [3.6.3,) + + + true + + + + + org.apache.maven.plugins maven-compiler-plugin - 3.11.0 + 3.14.1 - 21 + ${project.build.source} + ${project.build.target} + ${project.build.sourceEncoding} io.micronaut @@ -246,7 +364,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.5.1 + 3.6.1 package @@ -269,7 +387,7 @@ io.micronaut.maven micronaut-maven-plugin - 4.11.4 + 4.11.6 ${micronaut.test.resources.version} true @@ -278,7 +396,7 @@ io.fabric8 docker-maven-plugin - 0.46.0 + 0.48.0 true @@ -339,17 +457,17 @@ true + true + - org.apache.maven:maven-compat:jar + io.micronaut:micronaut-http-client + org.junit.jupiter:junit-jupiter-engine - - - org.eclipse.sisu:org.eclipse.sisu.plexus:jar - + - org.eclipse.sisu:org.eclipse.sisu.plexus:jar + com.fasterxml.jackson.core:jackson-core + @@ -384,7 +502,7 @@ org.apache.maven.plugins maven-release-plugin - 3.2.0 + 3.3.1 bbl-validator-@{project.version} bbl-validator-release @@ -487,4 +605,4 @@ - \ No newline at end of file + diff --git a/src/main/java/com/evolvedbinary/bblValidator/service/FileDownloadService.java b/src/main/java/com/evolvedbinary/bblValidator/service/FileDownloadService.java index c81bb62..dee8ada 100644 --- a/src/main/java/com/evolvedbinary/bblValidator/service/FileDownloadService.java +++ b/src/main/java/com/evolvedbinary/bblValidator/service/FileDownloadService.java @@ -3,15 +3,17 @@ import com.fasterxml.uuid.Generators; import com.fasterxml.uuid.impl.RandomBasedGenerator; import jakarta.inject.Singleton; +import org.apache.hc.client5.http.classic.methods.HttpGet; +import org.apache.hc.client5.http.config.RequestConfig; +import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.client5.http.impl.classic.HttpClients; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager; +import org.apache.hc.core5.http.HttpStatus; +import org.apache.hc.core5.util.TimeValue; +import org.apache.hc.core5.util.Timeout; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.apache.http.HttpStatus; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import java.io.IOException; import java.io.InputStream; @@ -19,7 +21,6 @@ import java.nio.file.Path; import java.nio.file.StandardCopyOption; import java.util.UUID; -import java.util.concurrent.TimeUnit; @Singleton public class FileDownloadService { @@ -37,13 +38,13 @@ public FileDownloadService() { this.poolingHttpClientConnectionManager = new PoolingHttpClientConnectionManager(); this.poolingHttpClientConnectionManager.setMaxTotal(20); this.poolingHttpClientConnectionManager.setDefaultMaxPerRoute(15); - this.poolingHttpClientConnectionManager.setValidateAfterInactivity(15_000); + this.poolingHttpClientConnectionManager.setValidateAfterInactivity(TimeValue.ofMilliseconds(15_000)); this.httpRequestConfig = RequestConfig.custom() - .setConnectTimeout(10_000) - .setSocketTimeout(10_000) - .setConnectionRequestTimeout(3_000) - .build(); + .setConnectTimeout(Timeout.ofMilliseconds(10_000)) + .setResponseTimeout(Timeout.ofMilliseconds(10_000)) + .setConnectionRequestTimeout(Timeout.ofMilliseconds(3_000)) + .build(); try { this.sharedTempDir = Files.createTempDirectory(TEMP_DIR_NAME); @@ -57,7 +58,7 @@ private CloseableHttpClient buildHttpClient() { .custom() .setConnectionManager(poolingHttpClientConnectionManager) .setDefaultRequestConfig(httpRequestConfig) - .evictIdleConnections(30, TimeUnit.SECONDS) + .evictIdleConnections(TimeValue.ofSeconds(30)) .evictExpiredConnections() .build(); } @@ -77,8 +78,9 @@ public Path downloadToTemp(final String url) throws IOException { final HttpGet httpGet = new HttpGet(url); try (final CloseableHttpResponse response = buildHttpClient().execute(httpGet)) { - - final int statusCode = response.getStatusLine().getStatusCode(); + + final int statusCode = response.getCode(); + if (statusCode != HttpStatus.SC_OK) { throw new IOException("Non Resolvable url: " + url); } @@ -122,4 +124,4 @@ private String generateUuidFilename() { final UUID uuid = generator.generate(); return uuid.toString() + ".csv"; } -} +} \ No newline at end of file