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

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


The following commit(s) were added to refs/heads/main by this push:
     new 25bc9bb94bd3 CAMEL-27539: Fix flaky 
AzureStorageBlobCloudEventDataTypeTransformerRouteTest
25bc9bb94bd3 is described below

commit 25bc9bb94bd3e5ef0ef209386508208b0a0b1eef
Author: AurĂ©lien Pupier <[email protected]>
AuthorDate: Wed Nov 25 11:02:09 2026 +0100

    CAMEL-27539: Fix flaky 
AzureStorageBlobCloudEventDataTypeTransformerRouteTest
    
    Avoid dynamically creating and stubbing Mockito mocks inside the thenAnswer
    callback during consumer execution, which caused Mockito state corruption
    when tests run concurrently. Preconfigure the BlobClient mock in 
setupResources.
    
    Co-authored-by: IBM Bob 2.2.1
    Signed-off-by: AurĂ©lien Pupier <[email protected]>
---
 ...torageBlobCloudEventDataTypeTransformerRouteTest.java | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git 
a/components/camel-azure/camel-azure-storage-blob/src/test/java/org/apache/camel/component/azure/storage/blob/transform/AzureStorageBlobCloudEventDataTypeTransformerRouteTest.java
 
b/components/camel-azure/camel-azure-storage-blob/src/test/java/org/apache/camel/component/azure/storage/blob/transform/AzureStorageBlobCloudEventDataTypeTransformerRouteTest.java
index d123f6e47945..384ce0c97621 100644
--- 
a/components/camel-azure/camel-azure-storage-blob/src/test/java/org/apache/camel/component/azure/storage/blob/transform/AzureStorageBlobCloudEventDataTypeTransformerRouteTest.java
+++ 
b/components/camel-azure/camel-azure-storage-blob/src/test/java/org/apache/camel/component/azure/storage/blob/transform/AzureStorageBlobCloudEventDataTypeTransformerRouteTest.java
@@ -55,7 +55,7 @@ class AzureStorageBlobCloudEventDataTypeTransformerRouteTest 
extends CamelTestSu
     private final BlobServiceClient serviceClient = 
mock(BlobServiceClient.class);
 
     @Override
-    protected void doPreSetup() throws Exception {
+    protected void setupResources() throws Exception {
         BlobContainerClient containerClient = mock(BlobContainerClient.class);
         
when(serviceClient.getBlobContainerClient("invoices")).thenReturn(containerClient);
         AtomicBoolean listed = new AtomicBoolean();
@@ -67,14 +67,12 @@ class 
AzureStorageBlobCloudEventDataTypeTransformerRouteTest extends CamelTestSu
                             : List.of(new BlobItem().setName("a.txt"), new 
BlobItem().setName("b.txt"));
                     return new PagedIterable<>(() -> new 
PagedResponseBase<Void, BlobItem>(null, 200, null, items, null, null));
                 });
-        when(containerClient.getBlobClient(anyString())).thenAnswer(i -> {
-            BlobClient blobClient = mock(BlobClient.class);
-            BlobInputStream stream = mock(BlobInputStream.class);
-            
when(stream.getProperties()).thenReturn(mock(BlobProperties.class));
-            when(blobClient.openInputStream(nullable(BlobRange.class), 
nullable(BlobRequestConditions.class)))
-                    .thenReturn(stream);
-            return blobClient;
-        });
+        BlobClient blobClient = mock(BlobClient.class);
+        BlobInputStream stream = mock(BlobInputStream.class);
+        when(stream.getProperties()).thenReturn(mock(BlobProperties.class));
+        when(blobClient.openInputStream(nullable(BlobRange.class), 
nullable(BlobRequestConditions.class)))
+                .thenReturn(stream);
+        
when(containerClient.getBlobClient(anyString())).thenReturn(blobClient);
     }
 
     @Test

Reply via email to