jbossHome' null'必须存在

时间:2015-03-01 18:47:40

标签: java maven testing junit jboss-arquillian

我正在获得jbossHome' null'尝试运行单元测试时必须存在错误。我创建了一个简单的测试类来配置arquillian:

@RunWith(Arquillian.class)
public class EmpresaResourceTest {

@Deployment @OverProtocol("Servlet 3.0")
public static JavaArchive createDeployment() {
    System.out.println("entrou");
    return ShrinkWrap.create(JavaArchive.class)
            .addClass(
                    EmpresaResource.class
                    )
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}
//TESTES BASICOS//

@Test
public void teste() {
    System.out.println("entrou");
    Assert.assertTrue(true);
}
}

我已经设置了JBOSS_HOME变量,并尝试在arquillian.xml文件中配置它,我已将其放在主程序包的META-INF文件夹中。

这是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">E:\arquivos\wildfly-8.2.0.Final</property>
    </configuration>
</container>

这是我的pom.xml:

<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/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>br.com.logtec</groupId>
<artifactId>WebDeliveryService</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>WebDeliveryService</name>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.jboss.arquillian</groupId>
            <artifactId>arquillian-bom</artifactId>
            <version>${arquilian-bom.version}</version>
            <scope>import</scope>
            <type>pom</type>
        </dependency>
    </dependencies>
</dependencyManagement>

<build>
    <finalName>WebDeliveryService</finalName>
    <plugins>
       <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
            <configuration>
                <source>${maven-compiler.version}</source>
                <target>${maven-compiler.version}</target>
            </configuration>
        </plugin>

        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${maven-surefire.version}</version>

            <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>
                      <!-- the maven dependency plugin will have already downloaded the server on /target -->
                    <jboss.home>${jboss.home}</jboss.home>
                    <module.path>${jboss.home}</module.path>
                </systemPropertyVariables>
                <redirectTestOutputToFile>false</redirectTestOutputToFile>
            </configuration>

        </plugin>
    </plugins>
</build>

<dependencies>

    <!-- QBEasy -->
    <dependency>
        <groupId>br.com.boilerplatecorp</groupId>
        <artifactId>qbeasy</artifactId>
        <version>${br.com.boilerplatecorp.qbeasy.version}</version>
    </dependency>

    <!-- JUnit -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit.junit.version}</version>
        <scope>test</scope>
    </dependency>

    <!-- Arquillian -->
    <dependency>
        <groupId>org.jboss.arquillian.junit</groupId>
        <artifactId>arquillian-junit-container</artifactId>
        <scope>test</scope>
    </dependency>

    <!-- PoDam -->
    <dependency>
        <groupId>uk.co.jemos.podam</groupId>
        <artifactId>podam</artifactId>
        <version>${uk.co.jemos.podam.podam.version}</version>
    </dependency>

    <!-- Model Mapper -->
    <dependency>
      <groupId>org.modelmapper</groupId>
      <artifactId>modelmapper</artifactId>
      <version>${org.modelmapper.modelmapper.version}</version>
    </dependency>

    <!-- Gson -->
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.3.1</version>
        <scope>test</scope>
    </dependency>

</dependencies>

<profiles>
    <profile>
        <id>wildfly8.2-embutido</id>

        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>

        <dependencies>

            <!-- Java EE 7 -->
            <dependency>
                <groupId>javax</groupId>
                <artifactId>javaee-api</artifactId>
                <version>${javaee-api.version}</version>
                <scope>provided</scope>
            </dependency>

            <!-- Arquillian Adapter -->
            <dependency>
                <groupId>org.wildfly</groupId>
                <artifactId>wildfly-arquillian-container-embedded</artifactId>
                <version>${wildfly.version}</version>
            </dependency>

            <dependency>
                <groupId>org.wildfly</groupId>
                <artifactId>wildfly-embedded</artifactId>
                <version>${wildfly.version}</version>
                <exclusions>
                    <exclusion>
                        <artifactId>jconsole</artifactId>
                        <groupId>sun.jdk</groupId>
                    </exclusion>
                </exclusions>
            </dependency>

            <!-- Protocolo para execução de testes -->
            <dependency>  
                <groupId>org.jboss.arquillian.protocol</groupId>  
                <artifactId>arquillian-protocol-servlet</artifactId>  
                <scope>test</scope>  
            </dependency>

        </dependencies>
    </profile>
</profiles>

<properties>
    <!-- Bills of Materials -->
    <arquilian-bom.version>1.1.7.Final</arquilian-bom.version>

    <!-- Plugins -->    
    <maven-compiler.version>1.8</maven-compiler.version>
    <maven-surefire.version>2.17</maven-surefire.version>

    <!-- Dependencies -->
    <javaee-api.version>7.0</javaee-api.version>
    <br.com.boilerplatecorp.qbeasy.version>1.0</br.com.boilerplatecorp.qbeasy.version>
    <junit.junit.version>4.12</junit.junit.version>
    <uk.co.jemos.podam.podam.version>4.7.3.RELEASE</uk.co.jemos.podam.podam.version>
    <wildfly.version>8.2.0.Final</wildfly.version>
    <org.slf4j.slf4j-log4j.version>1.7.10</org.slf4j.slf4j-log4j.version>
    <org.modelmapper.modelmapper.version>0.7.3</org.modelmapper.modelmapper.version>

    <!-- Configuracoes -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <jboss.home>E:\arquivos\wildfly-8.2.0.Final</jboss.home>
</properties>

1 个答案:

答案 0 :(得分:6)

arquillian.xml应该在src / test / resources