|
1 |
| -package io.micronaut.nats.docs.consumer.custom.annotation |
2 |
| - |
3 |
| -import io.micronaut.nats.AbstractNatsTest |
4 |
| - |
5 |
| -class SIDSpec extends AbstractNatsTest { |
6 |
| - |
7 |
| - void "test using a custom annotation binder"() { |
8 |
| - startContext() |
9 |
| - |
10 |
| - when: |
11 |
| -// tag::producer[] |
12 |
| -def productClient = applicationContext.getBean(ProductClient) |
13 |
| -productClient.send("body".getBytes()) |
14 |
| -productClient.send("body2".getBytes()) |
15 |
| -productClient.send("body3".getBytes()) |
16 |
| -// end::producer[] |
17 |
| - |
18 |
| - ProductListener productListener = applicationContext.getBean(ProductListener) |
19 |
| - |
20 |
| - then: |
21 |
| - waitFor { |
22 |
| - productListener.messages.size() == 3 |
23 |
| - } |
24 |
| - |
25 |
| - cleanup: |
26 |
| - sleep 200 |
27 |
| - } |
28 |
| -} |
| 1 | +package io.micronaut.nats.docs.consumer.custom.annotation |
| 2 | + |
| 3 | +import io.micronaut.context.annotation.Property |
| 4 | +import io.micronaut.test.extensions.spock.annotation.MicronautTest |
| 5 | +import jakarta.inject.Inject |
| 6 | +import spock.lang.Specification |
| 7 | + |
| 8 | +import static java.util.concurrent.TimeUnit.SECONDS |
| 9 | +import static org.awaitility.Awaitility.await |
| 10 | + |
| 11 | +@MicronautTest |
| 12 | +@Property(name = "spec.name", value = "SIDSpec") |
| 13 | +class SIDSpec extends Specification { |
| 14 | + @Inject ProductClient productClient |
| 15 | + @Inject ProductListener productListener |
| 16 | + |
| 17 | + |
| 18 | + void "test using a custom annotation binder"() { |
| 19 | + when: |
| 20 | +// tag::producer[] |
| 21 | +productClient.send("body".getBytes()) |
| 22 | +productClient.send("body2".getBytes()) |
| 23 | +productClient.send("body3".getBytes()) |
| 24 | +// end::producer[] |
| 25 | + |
| 26 | + then: |
| 27 | + await().atMost(10, SECONDS).until { |
| 28 | + productListener.messages.size() == 3 |
| 29 | + } |
| 30 | + |
| 31 | + cleanup: |
| 32 | + sleep 200 |
| 33 | + } |
| 34 | +} |
0 commit comments