Java 对onApplicationEvent使用mockito进行Spring引导单元测试(WebServerInitializedEvent事件)
有谁能帮我用Mockito实现一个单元测试吗?多谢各位Java 对onApplicationEvent使用mockito进行Spring引导单元测试(WebServerInitializedEvent事件),java,spring-boot,junit,mockito,Java,Spring Boot,Junit,Mockito,有谁能帮我用Mockito实现一个单元测试吗?多谢各位 @Component public class StartUp implements ApplicationListener<WebServerInitializedEvent> { @Override public void onApplicationEvent(WebServerInitializedEvent event) { String baseUrl = "http://
@Component
public class StartUp implements ApplicationListener<WebServerInitializedEvent> {
@Override
public void onApplicationEvent(WebServerInitializedEvent event) {
String baseUrl = "http://"+getHostAddress()+":"+event.getWebServer().getPort();
boolean status = executeRestCall(url);
} }
@组件
公共类启动实现ApplicationListener{
@凌驾
ApplicationEvent上的公共无效(WebServerInitializedEvent事件){
String baseUrl=“http://”+getHostAddress()+:“+event.getWebServer().getPort();
布尔状态=ExecuterTestCall(url);
} }