java - Mock JMS MessageSource -
i have set of messagesources (in fact jmsdestinationpollingsources) polled regularly. under hood oracle aq database persists queue items.
@bean @inboundchanneladapter(value = "queuesourcechannel", poller = @poller(fixeddelay = "1000")) public messagesource queuesource() { return jms .inboundadapter(connectionfactory) .configurejmstemplate(t -> t.deliverypersistent(true) .jmsmessageconverter(jacksonjmsmessageconverter) ).destination(queuename).get(); } however, now, make @springboottest without oracle persistence of course.
the way did now, mocking (mockito) above bean:
@mockbean(name = "queuesource") private messagesource queuesource; this way, test class can run, without having worry messagesource polled.
however, mentioned, have multiple messagesource's , i'd disable polling way.
the way i'm doing stupid:
@mockbean(name = "queuesource") private messagesource queuesource; @mockbean(name = "queuesource2") private messagesource queuesource2; @mockbean(name = "queuesource3") private messagesource queuesource3; .. , on i tried mock messagesources, or jmsdestinationpollingsource's seems hard (i read powermockito didn't try out yet because think can done differently).
i thought should possible disable poller in test scope. suppose there more solutions problem didn't think of. appreciated!
starting version 5.0 spring integration provides testing framework mocks on matter well.
there @springintegrationtest property:
/** * specify simple matching patterns ("xxx*", "*xxx", "*xxx*" or "xxx*yyy") * {@link org.springframework.integration.endpoint.abstractendpoint} * bean names mark them {@code autostartup = false} * during context initialization. * @return endpoints name patterns stop during context initialization * @see integrationendpointsinitializer * @see org.springframework.util.patternmatchutils */ string[] noautostartup() default {}; that how can useful use-case.
another option can done @profile when don't create beans if profile test example.
otherwise don't have choice unless stop sourcepollingchanneladapter beans type or names in beginning of test.
Comments
Post a Comment