我正在使用带有arquillian的wildfly容器进行集成测试。 在某些情况下,我想使用JMS和standalone-full.xml,并在服务器启动时加载一些自定义配置。 因此,对于我的int测试,我想通过将它放在src / test / resources中来加载这个standalone-full.xml。
我该怎么做?
我不能放下以下行,因为它是默认的jboss文件而不是我的overrided standalone-full.xml文件。
<property name="serverConfig">standalone-full.xml</property>
当我指定文件路径(在资源中)时,它不起作用。
<property name="serverConfig">src/test/resources/standalone-full.xml</property>
<property name="serverConfig">/src/test/resources/standalone-full.xml</property>
<property name="serverConfig">${project.basedir}/src/test/resources/standalone-full.xml</property>
[编辑]
当我把maven变量放在surefire-plugin中时这样:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<reuseForks>true</reuseForks>
<systemPropertyVariables>
<server.standalone.config.path>${project.basedir}/src/test/resources/standalone-full.xml</server.standalone.config.path>
</systemPropertyVariables>
<redirectTestOutputToFile>false</redirectTestOutputToFile>
</configuration>
</plugin>
并在arquillian.xml中使用它
<property name="serverConfig">${server.standalone.config.path}</property>
我有这个错误:
java.lang.IllegalStateException: WFLYCTL0214: Could not get main file:
D:\my_project_path\int-tests/src/test/resources/standalone-full.xml. Specified
files must be relative to the configuration dir: D:\wildfly_path\wildfly-
10.1.0.Final\standalone\configuration
答案 0 :(得分:2)
我们使用以下配置:
<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
<testResource>
<directory>src/test/resources-wildfly-embedded</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${version.surefire}</version>
<configuration>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<!-- the maven dependency plugin will have already downloaded the server on /target -->
<jboss.home>${dir.wildfly.home}</jboss.home>
<module.path>${dir.wildfly.modules}</module.path>
<!-- Do not use ./test/resources-wildfly/configuration because jboss will write to the
config directory and we don't want these files to change -->
<jboss.server.config.dir>${project.build.directory}/test-classes/configuration</jboss.server.config.dir>
<org.apache.deltaspike.ProjectStage>UnitTest</org.apache.deltaspike.ProjectStage>
<server-config>standalone.xml</server-config>
</systemPropertyVariables>
<redirectTestOutputToFile>false</redirectTestOutputToFile>
</configuration>
</plugin>
</plugins>
</build>
在src / test / resources-wildfly-embedded / configuration中,我们有:
您似乎需要所有这些文件才能启动,但是没有办法将standalone.xml放在与配置其余部分不同的目录中。