How to test classes with StreamBridge in Spring Cloud Stream?

Viewed 1317

I have a class which injects StreamBridge to send sometimes some events. Tests which uses this class fails, because no bean exists. I've tried to

@MockBean StreamBridge streamBridge

it with Mockito, but it fails, because of some static content. Tried to use

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-stream</artifactId>
    <version>${spring.cloud.stream.version}</version>
    <type>test-jar</type>
    <scope>test</scope>
    <classifier>test-binder</classifier>
</dependency>

but didn't help. I've tried also

@ImportAutoConfiguration(TestChannelBinderConfiguration.class)

but TestChannelBinderConfiguration doesn't exists too.

Any idea how can I make this StreamBridge be available for tests?

1 Answers
Related