You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2026/04/17 08:26:39 UTC
(sling-org-apache-sling-jcr-contentloader) branch issue/SLING-13173 created (now 1b9fd39)
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a change to branch issue/SLING-13173
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentloader.git
at 1b9fd39 SLING-13173 - Overly broad mocking of Files.class can lead to test failures
This branch includes the following new commits:
new 1b9fd39 SLING-13173 - Overly broad mocking of Files.class can lead to test failures
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(sling-org-apache-sling-jcr-contentloader) 01/01: SLING-13173 - Overly broad mocking of Files.class can lead to test failures
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch issue/SLING-13173
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentloader.git
commit 1b9fd39a1f9dcdf700ccce49da147bce4f8a73d1
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Fri Apr 17 10:25:38 2026 +0200
SLING-13173 - Overly broad mocking of Files.class can lead to test failures
Add the CALLS_REAL_METHOD modifier when mocking Files.class . This makes mocking more
precise and prevents unexpected method calls from failing.
---
.../sling/jcr/contentloader/internal/readers/ZipReaderTest.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/test/java/org/apache/sling/jcr/contentloader/internal/readers/ZipReaderTest.java b/src/test/java/org/apache/sling/jcr/contentloader/internal/readers/ZipReaderTest.java
index dc08e32..729242f 100644
--- a/src/test/java/org/apache/sling/jcr/contentloader/internal/readers/ZipReaderTest.java
+++ b/src/test/java/org/apache/sling/jcr/contentloader/internal/readers/ZipReaderTest.java
@@ -252,7 +252,7 @@ class ZipReaderTest {
try {
final File finalTempFile = ZipReader.createTempFile();
tempFile = finalTempFile;
- try (MockedStatic<Files> filesMock = Mockito.mockStatic(Files.class); ) {
+ try (MockedStatic<Files> filesMock = Mockito.mockStatic(Files.class, CALLS_REAL_METHODS); ) {
filesMock
.when(() -> Files.delete(finalTempFile.toPath()))
.thenThrow(new IOException("simulating ioexception during delete"));
@@ -303,7 +303,7 @@ class ZipReaderTest {
}
});
- try (MockedStatic<Files> filesMock = Mockito.mockStatic(Files.class); ) {
+ try (MockedStatic<Files> filesMock = Mockito.mockStatic(Files.class, CALLS_REAL_METHODS); ) {
filesMock.when(() -> Files.createTempFile("zipentry", ".tmp")).thenReturn(pathMock);
IOException ioe = assertThrows(IOException.class, ZipReader::createTempFile);
assertEquals(expectedMsg, ioe.getMessage());