JUnit-testing a Spring @Async void service method

后端 未结 4 1674
情话喂你
情话喂你 2020-12-29 03:15

I have a Spring service:

@Service
@Transactional
public class SomeService {

    @Async
    public void asyncMethod(Foo foo) {
        // processing takes si         


        
4条回答
  •  心在旅途
    2020-12-29 03:37

    In case your method returns CompletableFuture use join method - documentation CompletableFuture::join.

    This method waits for the async method to finish and returns the result. Any encountered exception is rethrown in the main thread.

提交回复
热议问题