From 780141ca48ac6dd831c156b178fbfa8a898719e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20G=C4=99bal?= Date: Thu, 23 Apr 2026 11:22:37 +0300 Subject: [PATCH 1/3] Add back HTML coverage resources. The HTML coverage resources were missing since version 3.1.9 of the utplsql-java-api. They are now again included in the JAR so that the utplsql-maven-plugin and utPLSQL-cli can use it. --- pom.xml | 46 +++++++++++++++++++ .../java/org/utplsql/api/ResourceUtil.java | 10 +++- .../java/org/utplsql/api/TestRunnerIT.java | 4 -- .../CoverageHTMLReporterAssetTest.java | 2 - 4 files changed, 54 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 1606ee3..7451ff2 100644 --- a/pom.xml +++ b/pom.xml @@ -19,6 +19,9 @@ utplsql https://sonarcloud.io + + 1.0.1 + ${project.build.directory}/coverage-html-download @@ -117,6 +120,49 @@ + + com.googlecode.maven-download-plugin + download-maven-plugin + 1.8.1 + + + download-coverage-html-assets + generate-resources + + wget + + + https://github.com/utPLSQL/utPLSQL-coverage-html/archive/refs/tags/${coverage.html.version}.zip + ${coverage.html.download.dir} + coverage-html.zip + true + + + + + + org.apache.maven.plugins + maven-resources-plugin + 3.3.1 + + + copy-coverage-html-assets + process-resources + + copy-resources + + + ${project.build.outputDirectory}/CoverageHTMLReporter + + + ${coverage.html.download.dir}/utPLSQL-coverage-html-${coverage.html.version}/assets + false + + + + + + org.apache.maven.plugins maven-compiler-plugin diff --git a/src/main/java/org/utplsql/api/ResourceUtil.java b/src/main/java/org/utplsql/api/ResourceUtil.java index d4ac0b3..b580cce 100644 --- a/src/main/java/org/utplsql/api/ResourceUtil.java +++ b/src/main/java/org/utplsql/api/ResourceUtil.java @@ -3,6 +3,7 @@ import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; +import java.net.URL; import java.nio.file.*; import java.nio.file.attribute.BasicFileAttributes; import java.util.Collections; @@ -27,7 +28,12 @@ public static void copyResources(Path resourceAsPath, Path targetDirectory) { try { String resourceName = "/" + resourceAsPath; Files.createDirectories(targetDirectory); - URI uri = ResourceUtil.class.getResource(resourceName).toURI(); + URL resourceUrl = ResourceUtil.class.getResource(resourceName); + if (resourceUrl == null) { + throw new IOException("Coverage HTML assets not found in classpath: " + resourceName + + ". The JAR was built without bundled coverage HTML reporter assets."); + } + URI uri = resourceUrl.toURI(); Path myPath; if (uri.getScheme().equalsIgnoreCase("jar")) { try (FileSystem fileSystem = FileSystems.newFileSystem(uri, Collections.emptyMap())) { @@ -44,7 +50,7 @@ public static void copyResources(Path resourceAsPath, Path targetDirectory) { } private static void copyRecursive(Path from, Path targetDirectory) throws IOException { - Files.walkFileTree(from, new SimpleFileVisitor() { + Files.walkFileTree(from, new SimpleFileVisitor<>() { @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { diff --git a/src/test/java/org/utplsql/api/TestRunnerIT.java b/src/test/java/org/utplsql/api/TestRunnerIT.java index 4ceb184..0246c26 100644 --- a/src/test/java/org/utplsql/api/TestRunnerIT.java +++ b/src/test/java/org/utplsql/api/TestRunnerIT.java @@ -1,6 +1,5 @@ package org.utplsql.api; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import org.utplsql.api.compatibility.CompatibilityProxy; @@ -65,7 +64,6 @@ void runWithManyReporters() throws SQLException { /** * This can only be tested on frameworks >= 3.0.3 */ - @Disabled @Test void failOnErrors() throws SQLException, InvalidVersionException { Connection conn = getConnection(); @@ -82,8 +80,6 @@ void failOnErrors() throws SQLException, InvalidVersionException { @Test void runWithRandomExecutionOrder() throws SQLException { - CompatibilityProxy proxy = new CompatibilityProxy(getConnection()); - new TestRunner() .randomTestOrder(true) .randomTestOrderSeed(123) diff --git a/src/test/java/org/utplsql/api/reporter/CoverageHTMLReporterAssetTest.java b/src/test/java/org/utplsql/api/reporter/CoverageHTMLReporterAssetTest.java index b94cc32..b6e5297 100644 --- a/src/test/java/org/utplsql/api/reporter/CoverageHTMLReporterAssetTest.java +++ b/src/test/java/org/utplsql/api/reporter/CoverageHTMLReporterAssetTest.java @@ -1,6 +1,5 @@ package org.utplsql.api.reporter; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; @@ -25,7 +24,6 @@ private void testFileExists(Path filePath) { assertTrue(f.exists(), () -> "File " + f + " does not exist"); } - @Disabled("No idea why this ever worked") @Test void writeReporterAssetsTo() throws RuntimeException { From 87a3ac1073c4e40851beed889b4d98a3c30b93a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20G=C4=99bal?= Date: Thu, 23 Apr 2026 11:53:15 +0300 Subject: [PATCH 2/3] Extending examples to include a taest taht is failing and a test that is raising exception. This allows for comprehensive API testing. --- .../sql/simple/scripts/tests/APP.TEST_PKG_TEST_ME.pkb | 11 +++++++++++ .../sql/simple/scripts/tests/APP.TEST_PKG_TEST_ME.pks | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/scripts/sql/simple/scripts/tests/APP.TEST_PKG_TEST_ME.pkb b/scripts/sql/simple/scripts/tests/APP.TEST_PKG_TEST_ME.pkb index 115bc15..e3623d5 100644 --- a/scripts/sql/simple/scripts/tests/APP.TEST_PKG_TEST_ME.pkb +++ b/scripts/sql/simple/scripts/tests/APP.TEST_PKG_TEST_ME.pkb @@ -122,5 +122,16 @@ CREATE OR REPLACE PACKAGE BODY TEST_PKG_TEST_ME AS UT.EXPECT(VEXPECTED).TO_(EQUAL(VACTUAL)); END; + + PROCEDURE TEST_THAT_FAILS IS + BEGIN + UT.FAIL('Tis test is meant to fail to demonstrate failure'); + END; + + PROCEDURE TEST_THAT_RAISES_EXCEPTION IS + l_num number; + BEGIN + l_num := 1/0; + END; END; / diff --git a/scripts/sql/simple/scripts/tests/APP.TEST_PKG_TEST_ME.pks b/scripts/sql/simple/scripts/tests/APP.TEST_PKG_TEST_ME.pks index 8a2b852..757cd5c 100644 --- a/scripts/sql/simple/scripts/tests/APP.TEST_PKG_TEST_ME.pks +++ b/scripts/sql/simple/scripts/tests/APP.TEST_PKG_TEST_ME.pks @@ -84,5 +84,10 @@ CREATE OR REPLACE PACKAGE TEST_PKG_TEST_ME AS -- %tags(cursor) PROCEDURE TEST_PR_TEST_ME_CURSOR; + -- %test( This is a failing test) + PROCEDURE TEST_THAT_FAILS; + + -- %test( This is a test that raises an exception) + PROCEDURE TEST_THAT_RAISES_EXCEPTION; END; / From ad1735e9902363cd72f1e713fc2c8bd1e0557f67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20G=C4=99bal?= Date: Thu, 23 Apr 2026 12:37:07 +0300 Subject: [PATCH 3/3] Reverting a check in code to see if assets are inclusion in JAR. They are to be included. --- src/main/java/org/utplsql/api/ResourceUtil.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/utplsql/api/ResourceUtil.java b/src/main/java/org/utplsql/api/ResourceUtil.java index b580cce..d4ac0b3 100644 --- a/src/main/java/org/utplsql/api/ResourceUtil.java +++ b/src/main/java/org/utplsql/api/ResourceUtil.java @@ -3,7 +3,6 @@ import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; -import java.net.URL; import java.nio.file.*; import java.nio.file.attribute.BasicFileAttributes; import java.util.Collections; @@ -28,12 +27,7 @@ public static void copyResources(Path resourceAsPath, Path targetDirectory) { try { String resourceName = "/" + resourceAsPath; Files.createDirectories(targetDirectory); - URL resourceUrl = ResourceUtil.class.getResource(resourceName); - if (resourceUrl == null) { - throw new IOException("Coverage HTML assets not found in classpath: " + resourceName - + ". The JAR was built without bundled coverage HTML reporter assets."); - } - URI uri = resourceUrl.toURI(); + URI uri = ResourceUtil.class.getResource(resourceName).toURI(); Path myPath; if (uri.getScheme().equalsIgnoreCase("jar")) { try (FileSystem fileSystem = FileSystems.newFileSystem(uri, Collections.emptyMap())) { @@ -50,7 +44,7 @@ public static void copyResources(Path resourceAsPath, Path targetDirectory) { } private static void copyRecursive(Path from, Path targetDirectory) throws IOException { - Files.walkFileTree(from, new SimpleFileVisitor<>() { + Files.walkFileTree(from, new SimpleFileVisitor() { @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {