samedi 13 janvier 2018

Testing Spring-Integration with subscriber channel

I have the following:

Direct-Channel => Splitter => PublishSubscribeChannel

I would like to send data to the direct-channel and test the outcome in the publish-subscribe-channel

What I have so far partly taken from Spring.io (and it works only if I step through debug mode) is:

DirectChannel incomeChannel
PublishSubscribeChannel subscriberChannel

@Test
public void test() {
    final AtomicInteger count  = new AtomicInteger()

    assert true == subscriberChannel.subscribe(new MessageHandler() {
        void handleMessage(Message<?> message) throws MessagingException {
            count.getAndIncrement();
            Entity response = message.getPayload()
            assert response != null
            // assertions ...
        }
    })

    def request = MessageBuilder.withPayload(entities).build()
    assert incomeChannel.send(request) == true
    assert 0 < count.get()
}

Aucun commentaire:

Enregistrer un commentaire