小编ste*_*man的帖子

具有多项测试的 OuputCapture

我正在使用 org.springframework.boot.test.OutputCapture 来测试记录某些内容的注释。

它对于单个测试非常有效,并且当单独运行测试时,如果源文件中存在使用输出捕获的多个测试,但是当多个测试一起运行时,只有第一个测试运行获取捕获的输出,其他测试运行获取空字符串。

有什么办法可以避免这种情况,我看不到任何配置的可能性吗?

这是一个简化的测试,说明了 import static org.hamcrest.Matchers 问题。; 导入静态 org.junit.Assert。;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.FixMethodOrder;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.springframework.boot.test.OutputCapture;

/** 
 * Simplest implementation that illustrates my problem using {@link OutputCapture}. 
 * <p>
 * If both tests are run, the second test run will not have any output captured so fails. 
 * If tests are run individually they both pass.
 * <p>
 * It is somehow related to …
Run Code Online (Sandbox Code Playgroud)

testing spring-boot

8
推荐指数
1
解决办法
5221
查看次数

如何增加消息头

Spring Integration Java DSL 有没有办法修改现有的消息头?

我正在使用 SI Java DSL 重新实现下载重试机制,并且希望在发生失败时增加保存下载尝试的消息标头,然后根据与限制相比的尝试次数路由消息。

我的路由基于 SI 中包含的 RouterTests 运行良好。使用 HeaderEnrichers 我可以轻松添加标头,但我看不到修改现有标头的方法。

谢谢

/**
 * Unit test of {@link RetryRouter}.
 * 
 * Based on {@link RouterTests#testMethodInvokingRouter2()}.
 */
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@DirtiesContext
public class RetryRouterTests {

    /** Failed download attempts are sent to this channel to be routed by {@link ContextConfiguration#failedDownloadRouting( ) } */
    @Autowired
    @Qualifier("failed")
    private MessageChannel failed;

    /** Retry attempts for failed downloads are sent to this channel by {@link ContextConfiguration#failedDownloadRouting( ) }*/
    @Autowired
    @Qualifier("retry-channel") …
Run Code Online (Sandbox Code Playgroud)

dsl spring-integration

5
推荐指数
1
解决办法
2556
查看次数

哪些版本的gradle,sonarqube和jacoco插件兼容

我正在建立一个新的多模块gradle项目,将在jenkins中构建,并试图让sonarqube分析它,但我遇到了一些我无法解决的不兼容问题.

我正在寻找使用

  1. sonarqube插件因为我们现有的项目得到关于声纳 - 跑步者弃用的警告:'sonar-runner'插件已被弃用,并计划在Gradle 3.0中删除.请使用SonarQube的官方插件(文档).
  2. gradle 3
  3. 从sonarqube这个简单的例子https://github.com/SonarSource/sonar-examples/blob/master/projects/languages/java/gradle/java-gradle-simple/build.gradle

如果我使用gradle 3,我会收到此错误:org.gradle.internal.jvm.Jvm.getRuntimeJar()Ljava/io/File;

如果我使用gradle这个2.14我得到这个错误:产生java.io.IOException:由造成不兼容的版本1007这个错误在过去已经引起jacoco和sonarqube插件不兼容看到JaCoCo SonarQube不兼容的版本1007.

我应该使用哪些版本?

gradle jacoco sonarqube sonarqube-scan

5
推荐指数
1
解决办法
2142
查看次数