我有一个位于文件夹src/test/java/resources/framework.properties
中的资源文件,其中包含以下内容:
felix.auto.start.1=\
"file:${test.archive.directory}/agenda.test-1.0.0.jar"
我使用(或假装使用)maven-surefire-plugin
将该变量(${test.archive.directory}
)替换为正确的值,请参阅示例ballow:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>${skipTests}</skipTests>
<systemPropertyVariables>
<test.archive.directory>${project.build.directory}</test.archive.directory>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
它只是失败了,测试会返回此消息错误:
java.io.FileNotFoundException: ${test.archive.directory}\testbundle.test-1.0.0.jar (The system cannot find the path specified))
显然maven-surefire-plugin
没有取代属性值。我在互联网上挖掘,找不到合适的答案,对我做错了什么的想法?
更新
还要考虑我为 Arquillian OSGi 测试用例运行此代码。上面要替换的参数是 Arquillian 找到运行测试所需的bundle,因此必须在框架启动之前替换参数。
答案 0 :(得分:0)
<test.archive.directory>${project.build.directory}</test.archive.directory>
可用作Java进程的System属性,它可以通过
读取它们System.getProperty("test.archive.directory");
在您的Java类中,您不能指望它在属性文件
中神奇地替换它