arquillian 不支持 ServerConfig

ServerConfig is unsupported by arquillian

使用 arquillian 对 Wilfly 8 应用服务器中的 EJB 进行单元测试和集成测试。 Arquillian 无法识别 属性 "serverConfig" 来选择服务器启动配置并且它在支持的 属性 名称中缺失,因此它总是以 "standalone.xml" 配置开始但我需要到 运行 和 "standalone-full.xml",下面是开始测试时的警告捕获并提供 pom.xml 和 arquillian.xml,是否缺少任何依赖项来克服这个问题?

WARNING [org.jboss.arquillian.container.impl.MapObject] Configuration contain properties not supported by the backing object org.jboss.as.arquillian.container.embedded.EmbeddedContainerConfiguration
Unused property entries: {serverConfig=standalone-full.xml}
Supported property names: [managementAddress, modulePath, password, bundlePath, managementPort, jbossHome, managementProtocol, cleanServerBaseDir, username]

arquillian.xml

<arquillian xmlns="http://jboss.org/schema/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="
    http://jboss.org/schema/arquillian
    http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<container qualifier="wildfly" default="true">
    <configuration>
        <property name="jbossHome">D:/wildfly-8.1.0.Final</property>
        <property name="modulePath">D:/wildfly-8.1.0.Final/modules</property>
        <property name="serverConfig">standalone-full.xml</property>
    </configuration>
</container>

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.mycompany</groupId>
<artifactId>EJBTest</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>ejb</packaging>

<name>EJBTest</name>

<properties>
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <junit-version>4.11</junit-version>
    <arquillian-version>1.1.4.Final</arquillian-version>
    <arquillian-wildfly-version>8.1.0.CR2</arquillian-wildfly-version>
    <arquillian-transaction-version>1.0.1.Final</arquillian-transaction-version>
</properties>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>${javaee-api-version}</version>
        </dependency>
        <!-- -JUNIT-->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit-version}</version>
        </dependency>
        <!-- rquillian itself-->
        <dependency>
            <groupId>org.jboss.arquillian</groupId>
            <artifactId>arquillian-bom</artifactId>
            <version>${arquillian-version}</version>
            <scope>import</scope>
            <type>pom</type>
        </dependency>
        <!-- this is in an extention to arquillian it is optional-->
        <dependency>
            <groupId>org.jboss.arquillian.extension</groupId>
            <artifactId>arquillian-transaction-bom</artifactId>
            <version>${arquillian-transaction-version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <!-- this is container adapter for wildfly-->
        <dependency>
            <groupId>org.wildfly</groupId>
            <artifactId>wildfly-arquillian-container-embedded</artifactId>
            <version>${arquillian-wildfly-version}</version>
        </dependency>

        <!-- this is the wildfly emb.container - BUT eventually it is not a fully blown emb.container-->
        <dependency>
            <groupId>org.wildfly</groupId>
            <artifactId>wildfly-embedded</artifactId>                
            <version>${arquillian-wildfly-version}</version>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.10</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.jboss.arquillian.junit</groupId>
        <artifactId>arquillian-junit-container</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.wildfly</groupId>
        <artifactId>wildfly-arquillian-container-embedded</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.wildfly</groupId>
        <artifactId>wildfly-embedded</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.jboss.arquillian.extension</groupId>
        <artifactId>arquillian-transaction-jta</artifactId>
        <scope>test</scope>
    </dependency>



</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
                <compilerArguments>
                    <endorseddirs>${endorsed.dir}</endorseddirs>
                </compilerArguments>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ejb-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <ejbVersion>3.1</ejbVersion>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${endorsed.dir}</outputDirectory>
                        <silent>true</silent>
                        <artifactItems>
                            <artifactItem>
                                <groupId>javax</groupId>
                                <artifactId>javaee-endorsed-api</artifactId>
                                <version>7.0</version>
                                <type>jar</type>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>unpack</id>
                    <phase>process-test-classes</phase>
                    <goals>
                        <goal>unpack</goal>
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>org.wildfly</groupId>
                                <artifactId>wildfly-dist</artifactId>
                                <version>8.1.0.Final</version>
                                <type>zip</type>
                                <overWrite>false</overWrite>
                                <outputDirectory>target</outputDirectory>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <!-- Fork every test because it will launch a separate AS instance -->
                <forkMode>always</forkMode>
                <systemPropertyVariables>
                    <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                    <!--
                    <jboss.home>${project.basedir}/target/wildfly-8.1.0.Final</jboss.home>
                    <module.path>${project.basedir}/target/wildfly-8.1.0.Final/modules</module.path>
                    -->
                </systemPropertyVariables>
                <redirectTestOutputToFile>false</redirectTestOutputToFile>
            </configuration>
        </plugin>
    </plugins>
</build>

解决方案

已替换依赖项目 ID

<artifactId>wildfly-arquillian-container-embedded</artifactId>

<artifactId>wildfly-arquillian-container-managed</artifactId>

仔细检查,您使用的是嵌入式 wildfly:

       <!-- this is container adapter for wildfly-->
    <dependency>
        <groupId>org.wildfly</groupId>
        <artifactId>wildfly-arquillian-container-embedded</artifactId>
        <version>${arquillian-wildfly-version}</version>
    </dependency>

    <!-- this is the wildfly emb.container - BUT eventually it is not a fully blown emb.container-->
    <dependency>
        <groupId>org.wildfly</groupId>
        <artifactId>wildfly-embedded</artifactId>                
        <version>${arquillian-wildfly-version}</version>
    </dependency>

如果您想使用完整配置文件,您应该使用托管或远程。