具有application-test.properties的自动装配Bean

时间:2018-07-16 10:12:06

标签: java spring spring-boot properties-file spring-camel

我有以下Test类,并且我的bean总是根据我的 src路径中的application.properties自动接线。

简单属性已正确自动连接(queueFrom,queueTo ...),但属性 camelContext 已与主体 application.properties 文件自动连接

我想通过测试路径

中的特定属性文件自动连接Bean

这是我的Test类的标题:

@RunWith(CamelSpringBootRunner.class)
@SpringBootTest
@EnableAutoConfiguration
@TestPropertySource(locations = "classpath:application-north-connector-test.properties")
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
public class LifeRouteITTest extends CamelTestSupport {

  private NotifyBuilder notify;

  @Value("${route.lifefrom}")
  private String queueFrom;
  @Value("${route.lifeto}")
  private String queueTo;
  @Value("${expected.liferoute.file.path}/")
  private String expectedFilePath;
  @Value("${input.liferoute.file.path}/")
  private String inputFilePath;

  @Autowired
  private CamelContext camelContext;
}

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

您只需要将测试属性放在application.properties文件中,然后将其放在src/test/resources中即可。测试属性将从那里自动加载。

相关问题