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

Croway pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git

commit 38bb1e183e117bdd8896b8b74fbbb67321175858
Author: croway <[email protected]>
AuthorDate: Thu Nov 12 12:23:04 2026 +0100

    CAMEL-26776: camel-state-store-starter - align tests with namespaced keys 
on shared backends
    
    Since CAMEL-26776 the state-store component stores keys on a shared
    KeyValueRepository (auto-discovered or backend=#ref) under
    statestore:<storeName>:<key>. The tests that read the raw key from the
    shared repository now expect the namespaced key, and a new test checks
    that camel.component.state-store.namespaced=false keeps the un-namespaced
    keys written by Camel 4.23.
---
 ...SpringCacheStateStoreAutoConfigurationTest.java | 32 ++++++++++++++++++++--
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git 
a/components-starter/camel-state-store-starter/src/test/java/org/apache/camel/component/statestore/springboot/cache/SpringCacheStateStoreAutoConfigurationTest.java
 
b/components-starter/camel-state-store-starter/src/test/java/org/apache/camel/component/statestore/springboot/cache/SpringCacheStateStoreAutoConfigurationTest.java
index 15b86585c46..781972374b9 100644
--- 
a/components-starter/camel-state-store-starter/src/test/java/org/apache/camel/component/statestore/springboot/cache/SpringCacheStateStoreAutoConfigurationTest.java
+++ 
b/components-starter/camel-state-store-starter/src/test/java/org/apache/camel/component/statestore/springboot/cache/SpringCacheStateStoreAutoConfigurationTest.java
@@ -219,8 +219,10 @@ class SpringCacheStateStoreAutoConfigurationTest {
 
                         
assertThat(ctx.getBean(CacheManager.class).getCache("orders").get("1").get())
                                 .isEqualTo("o1");
-                        assertThat(ctx.getBean("camelRepo", 
MemoryKeyValueRepository.class).get("1"))
-                                .isEqualTo("s1");
+                        // backend=#camelRepo is a shared repository, so the 
store keys are namespaced
+                        MemoryKeyValueRepository camelRepo = 
ctx.getBean("camelRepo", MemoryKeyValueRepository.class);
+                        
assertThat(camelRepo.get("statestore:sessions:1")).isEqualTo("s1");
+                        assertThat(camelRepo.get("1")).isNull();
                         
assertThat(ctx.getBean(CacheManager.class).getCache("sessions").get("1")).isNull();
                     } finally {
                         template.stop();
@@ -236,13 +238,37 @@ class SpringCacheStateStoreAutoConfigurationTest {
                 template.sendBodyAndHeader("state-store:orders?operation=put", 
"o1",
                         StateStoreConstants.KEY, "1");
 
-                assertThat(ctx.getBean("camelRepo", 
MemoryKeyValueRepository.class).get("1")).isEqualTo("o1");
+                // the auto-discovered camelRepo is a shared repository, so 
the store keys are namespaced
+                MemoryKeyValueRepository camelRepo = ctx.getBean("camelRepo", 
MemoryKeyValueRepository.class);
+                
assertThat(camelRepo.get("statestore:orders:1")).isEqualTo("o1");
+                assertThat(camelRepo.get("1")).isNull();
+                
assertThat(template.requestBodyAndHeader("state-store:orders?operation=get", 
null,
+                        StateStoreConstants.KEY, "1")).isEqualTo("o1");
             } finally {
                 template.stop();
             }
         });
     }
 
+    @Test
+    void camelRepositoryKeysAreNotNamespacedWhenNamespacedIsDisabled() {
+        mixedBackendRunner
+                
.withPropertyValues("camel.component.state-store.namespaced=false")
+                .run(ctx -> {
+                    ProducerTemplate template = 
ctx.getBean(CamelContext.class).createProducerTemplate();
+                    try {
+                        
template.sendBodyAndHeader("state-store:orders?operation=put", "o1",
+                                StateStoreConstants.KEY, "1");
+
+                        MemoryKeyValueRepository camelRepo = 
ctx.getBean("camelRepo", MemoryKeyValueRepository.class);
+                        assertThat(camelRepo.get("1")).isEqualTo("o1");
+                        
assertThat(camelRepo.get("statestore:orders:1")).isNull();
+                    } finally {
+                        template.stop();
+                    }
+                });
+    }
+
     @Test
     void optimisticLockingAggregatorStartsWhenFactoryEnabled() {
         camelRunner

Reply via email to