This is an automated email from the ASF dual-hosted git repository.

hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git


The following commit(s) were added to refs/heads/main by this push:
     new 43930bf8f7 fix broken tests (#7153)
43930bf8f7 is described below

commit 43930bf8f73a4d3b9c6fa309c360fb03b79888f1
Author: Hans Van Akelyen <[email protected]>
AuthorDate: Thu May 21 11:15:15 2026 +0200

    fix broken tests (#7153)
---
 .../apache/hop/vfs/azure/AzureFileNameParserTest.java | 14 ++++++++++++--
 .../hop/vfs/azure/AzureFileObjectSdkPathTest.java     | 19 ++++++++++++-------
 2 files changed, 24 insertions(+), 9 deletions(-)

diff --git 
a/plugins/tech/azure/src/test/java/org/apache/hop/vfs/azure/AzureFileNameParserTest.java
 
b/plugins/tech/azure/src/test/java/org/apache/hop/vfs/azure/AzureFileNameParserTest.java
index 3b406d551c..91e0e00a0b 100644
--- 
a/plugins/tech/azure/src/test/java/org/apache/hop/vfs/azure/AzureFileNameParserTest.java
+++ 
b/plugins/tech/azure/src/test/java/org/apache/hop/vfs/azure/AzureFileNameParserTest.java
@@ -23,6 +23,7 @@ import org.apache.commons.vfs2.FileType;
 import org.apache.commons.vfs2.provider.VfsComponentContext;
 import org.apache.hop.vfs.azure.config.AzureConfig;
 import org.apache.hop.vfs.azure.config.AzureConfigSingleton;
+import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
@@ -34,6 +35,8 @@ import org.mockito.Mockito;
 
 class AzureFileNameParserTest {
 
+  private static MockedStatic<AzureConfigSingleton> azureConfigSingleton;
+
   private AzureFileNameParser parser;
 
   @BeforeAll
@@ -41,11 +44,18 @@ class AzureFileNameParserTest {
     AzureConfig azureConfig = new AzureConfig();
     azureConfig.setAccount("hopsa");
     azureConfig.setKey("aGVsbG93b3JsZA==");
-    MockedStatic<AzureConfigSingleton> azureConfigSingleton =
-        Mockito.mockStatic(AzureConfigSingleton.class);
+    azureConfigSingleton = Mockito.mockStatic(AzureConfigSingleton.class);
     
azureConfigSingleton.when(AzureConfigSingleton::getConfig).thenReturn(azureConfig);
   }
 
+  @AfterAll
+  static void tearDown() {
+    if (azureConfigSingleton != null) {
+      azureConfigSingleton.close();
+      azureConfigSingleton = null;
+    }
+  }
+
   @BeforeEach
   void setup() {
     parser = new AzureFileNameParser();
diff --git 
a/plugins/tech/azure/src/test/java/org/apache/hop/vfs/azure/AzureFileObjectSdkPathTest.java
 
b/plugins/tech/azure/src/test/java/org/apache/hop/vfs/azure/AzureFileObjectSdkPathTest.java
index a24bee0471..1e5ce893f4 100644
--- 
a/plugins/tech/azure/src/test/java/org/apache/hop/vfs/azure/AzureFileObjectSdkPathTest.java
+++ 
b/plugins/tech/azure/src/test/java/org/apache/hop/vfs/azure/AzureFileObjectSdkPathTest.java
@@ -23,6 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
 import org.apache.commons.vfs2.provider.VfsComponentContext;
 import org.apache.hop.vfs.azure.config.AzureConfig;
 import org.apache.hop.vfs.azure.config.AzureConfigSingleton;
+import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 import org.mockito.MockedStatic;
@@ -43,19 +44,23 @@ import org.mockito.Mockito;
  */
 class AzureFileObjectSdkPathTest {
 
+  private static MockedStatic<AzureConfigSingleton> mocked;
+
   @BeforeAll
   static void init() {
     AzureConfig azureConfig = new AzureConfig();
     // Obvious dummy values: account is a placeholder, key is base64 of 
"dummy-key".
     azureConfig.setAccount("dummy-account");
     azureConfig.setKey("ZHVtbXkta2V5");
-    try {
-      // Intentionally not closed - mirrors AzureFileNameParserTest, which 
leaks the same static
-      // mock for the JVM lifetime. We just need a config available when the 
parser asks.
-      MockedStatic<AzureConfigSingleton> mocked = 
Mockito.mockStatic(AzureConfigSingleton.class);
-      mocked.when(AzureConfigSingleton::getConfig).thenReturn(azureConfig);
-    } catch (org.mockito.exceptions.base.MockitoException alreadyRegistered) {
-      // Another test in this JVM already mocked it; reuse that registration.
+    mocked = Mockito.mockStatic(AzureConfigSingleton.class);
+    mocked.when(AzureConfigSingleton::getConfig).thenReturn(azureConfig);
+  }
+
+  @AfterAll
+  static void tearDown() {
+    if (mocked != null) {
+      mocked.close();
+      mocked = null;
     }
   }
 

Reply via email to