Closed twinkybot closed 3 months ago
Could you add a reproducer project with your test?
You are right about adding the smallrye-in-memory
to the test configuration. The switch to in-memory trick won't work for Quarkus tests.
Then you need to inject InMemoryConnector
using a CDI qualifier,@Any
should do it as there is only one of that type.
When using the injected connector, you need to get a source
or sink
from the in-memory connector for a channel that exists in your application. As far as I see "prices" does not exist in the application.
That leads me to say that we need to add more context to that example in the doc. That example is for an application like :
@Incoming("prices")
@Outgoing("processed-prices")
int process(int price) {
return price;
}
So that you'd get the source of the incoming channel "prices" and send messages, and get the sink of the outgoing channel "processed-prices" to check that the channel produced messages.
Lastly, in the reproducer you sent, Outgoing
and Incoming
channels are both called "source". This means two streams will be linked in-memory, without using connector channels. You probably do not want that.
Hope this helps.
You are right about adding the
smallrye-in-memory
to the test configuration. The switch to in-memory trick won't work for Quarkus tests.Then you need to inject
InMemoryConnector
using a CDI qualifier,@Any
should do it as there is only one of that type.@Incoming("prices") @Outgoing("processed-prices") int process(int price) { return price; }
So that you'd get the source of the incoming channel "prices" and send messages, and get the sink of the outgoing channel "processed-prices" to check that the channel produced messages.
@ozangunalp Updated the project but I cannot get it to run, as the Connector is Null without the QuarkusTest annotation. Would you mind to change it so that it works, if you have time?
Lastly, in the reproducer you sent,
Outgoing
andIncoming
channels are both called "source". This means two streams will be linked in-memory, without using connector channels. You probably do not want that.
And the naming 'source' of the channel is from another example. I removed it not to confuse issues.
Hello
I could not get the InMemmoryConnector Example from the documentation https://smallrye.io/smallrye-reactive-messaging/smallrye-reactive-messaging/3.3/testing/testing.html running. Did I do something wrong or is the documentation not complete?
Steps to reprodice:
Got a new Quarkus Project from https://smallrye.io/smallrye-reactive-messaging/3.18.0/getting-started/
went to https://smallrye.io/smallrye-reactive-messaging/3.18.0/concepts/testing/ and followed steps there.
Which lead to:
pointing to the InMemoryConnector, which imo cannot be injected.
Well as I am new and totally confused what to do, I would very much appreciate some hints on how to get the test running. Maybe also in regards to the production class ReactiveMessagingExample which is provided in the Quarkus example.