Since Spring Cloud Stream has not an annotation for sending a new message to a stream (@SendTo only works when @StreamListener is declared), I tried to use Spring Integratio
Since you use a @Publisher annotation in your ExampleService, it is proxied for that publishing stuff.
Only the way to overcome the issue is to expose an interface for your ExampleService and inject already that one into your test class:
public interface ExampleServiceInterface {
String sendMessage(String message);
}
...
public class ExampleService implements ExampleServiceInterface {
...
@Autowired
private ExampleServiceInterface exampleService;
On the other hand it looks like your ExampleService.sendMessage() does nothing with the message, so you may consider to use a @MessagingGateway on some interface instead: https://docs.spring.io/spring-integration/reference/html/messaging-endpoints-chapter.html#gateway