From 2b8d9725495716b82fefbd6c6a830ee720086743 Mon Sep 17 00:00:00 2001 From: Joachim Grimm Date: Wed, 25 Oct 2023 15:07:01 +0200 Subject: [PATCH] adds mirroring test for kv --- .../nats/jetstream/KeyValueSpec.groovy | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/nats/src/test/groovy/io/micronaut/nats/jetstream/KeyValueSpec.groovy b/nats/src/test/groovy/io/micronaut/nats/jetstream/KeyValueSpec.groovy index 77a8d34c..ab4fbe47 100644 --- a/nats/src/test/groovy/io/micronaut/nats/jetstream/KeyValueSpec.groovy +++ b/nats/src/test/groovy/io/micronaut/nats/jetstream/KeyValueSpec.groovy @@ -99,12 +99,38 @@ class KeyValueSpec extends AbstractJetstreamTest { applicationContext.close() } + void "mirroring key value"() { + given: + ApplicationContext context = startContext([ + "nats.default.jetstream.keyvalue.m-examplebucket.storage-type": "Memory", + "nats.default.jetstream.keyvalue.m-examplebucket.mirror.name": "examplebucket", + ]) + KeyValueManagement kvm = context.getBean(KeyValueManagement, Qualifiers.byName(NatsConnection.DEFAULT_CONNECTION)) + KeyValueHolder kvHolder = context.getBean(KeyValueHolder) + + when: + kvHolder.keyValueBucket.put("hello", "world") + + then: + kvHolder.mirror.get("hello").valueAsString == "world" + + cleanup: + kvm.delete("examplebucket") + kvm.delete("m-examplebucket") + context.close() + } + + @Requires(property = 'spec.name', value = 'KeyValueSpec') @Singleton static class KeyValueHolder { @Inject @KeyValueStore('examplebucket') - KeyValue keyValueBucket; + KeyValue keyValueBucket + + @Inject + @KeyValueStore('m-examplebucket') + KeyValue mirror; } }