3

当我尝试在远程 Wildfly 8.1.0 上运行 Arquillian 测试时,我在测试结果文件中得到以下堆栈跟踪:

-------------------------------------------------------------------------------

Test set: com.tellyo.rtc.test.SimpleTest

-------------------------------------------------------------------------------

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 61.214 sec <<< FAILURE!

testApplication(com.tellyo.rtc.test.SimpleTest)  Time elapsed: 1.38 sec  <<< ERROR!

java.lang.IllegalStateException: Error launching test com.tellyo.rtc.test.SimpleTest public void com.tellyo.rtc.test.SimpleTest.testApplication()

at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.invoke(ServletMethodExecutor.java:103)

at org.jboss.arquillian.container.test.impl.execution.RemoteTestExecuter.execute(RemoteTestExecuter.java:109)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145)

at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116)

at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)

at org.jboss.arquillian.container.test.impl.execution.ClientTestExecuter.execute(ClientTestExecuter.java:57)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createContext(ContainerEventController.java:142)

at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createTestContext(ContainerEventController.java:129)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:102)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:84)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:65)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145)

at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:111)

at org.jboss.arquillian.junit.Arquillian$6.evaluate(Arquillian.java:294)

at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:269)

at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)

at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)

at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)

at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)

at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)

at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)

at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:193)

at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:345)

at org.jboss.arquillian.junit.Arquillian.access$200(Arquillian.java:49)

at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:207)

at org.junit.runners.ParentRunner.run(ParentRunner.java:309)

at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:155)

at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)

at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)

at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)

at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)

at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)

at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)

at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)

Caused by: java.lang.IllegalStateException: Error launching request at http://0.0.0.0:7080/test/ArquillianServletRunner?outputMode=serializedObject&className=com.tellyo.rtc.test.SimpleTest&methodName=testApplication. No result returned

at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.executeWithRetry(ServletMethodExecutor.java:139)

at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.invoke(ServletMethodExecutor.java:99)

... 78 more

我关注了一些教程和论坛主题,但我找不到任何解决该问题的方法,我相信我正在做我应该做的一切。我的项目由两个 ejb 模块和一个 web 模块组成。我正在附加主 ejb 模块的 pom 文件、SImpleTest.java 测试类以及我的 arquillian.xml 文件。不过,我不确定项目的结构是否与此有关。

arquillian.xml

<?xml version="1.0" encoding="UTF-8"?>
<!-- JBoss, Home of Professional Open Source Copyright 2013, Red Hat, Inc. 
    and/or its affiliates, and individual contributors by the @authors tag. See 
    the copyright.txt in the distribution for a full listing of individual contributors. 
    Licensed under the Apache License, Version 2.0 (the "License"); you may not 
    use this file except in compliance with the License. You may obtain a copy 
    of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required 
    by applicable law or agreed to in writing, software distributed under the 
    License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 
    OF ANY KIND, either express or implied. See the License for the specific 
    language governing permissions and limitations under the License. -->
<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">

    <!-- Uncomment to have test archives exported to the file system for inspection -->
    <!-- <engine> -->
    <!-- <property name="deploymentExportPath">target/</property> -->
    <!-- </engine> -->

    <!-- Force the use of the Servlet 3.0 protocol with all containers, as it 
        is the most mature -->
    <defaultProtocol type="Servlet 3.0" />

    <!-- Example configuration for a remote JBoss Enterprise Application Platform 
        6 or AS 7 instance -->
    <container qualifier="wildfly" default="true">
        <!-- By default, arquillian will use the JBOSS_HOME environment variable. 
            Alternatively, the configuration below can be uncommented. -->
        <configuration>
            <property name="managementAddress">xxx</property>
            <property name="managementPort">0000</property>
            <property name="username">xxx</property>
            <property name="password">tellyxxxoadmin</property>
        </configuration>
    </container>

</arquillian>

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<!-- JBoss, Home of Professional Open Source Copyright 2013, Red Hat, Inc. 
    and/or its affiliates, and individual contributors by the @authors tag. See 
    the copyright.txt in the distribution for a full listing of individual contributors. 
    Licensed under the Apache License, Version 2.0 (the "License"); you may not 
    use this file except in compliance with the License. You may obtain a copy 
    of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required 
    by applicable law or agreed to in writing, software distributed under the 
    License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 
    OF ANY KIND, either express or implied. See the License for the specific 
    language governing permissions and limitations under the License. -->
<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>

    <parent>
        <artifactId>tellyo-rtc</artifactId>
        <groupId>com.tellyo.rtc</groupId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>

    <artifactId>tellyo-rtc-ejb</artifactId>
    <packaging>ejb</packaging>

    <name>tellyo-rtc - ejb</name>

    <url>http://jboss.org/jbossas</url>
    <licenses>
        <license>
            <name>Apache License, Version 2.0</name>
            <distribution>repo</distribution>
            <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
        </license>
    </licenses>

    <properties>
        <jclouds.version>1.7.2</jclouds.version>
        <arq.version>1.1.5.Final</arq.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>com.tellyo.rtc</groupId>
            <artifactId>tellyo-rtc-properties</artifactId>
            <type>ejb</type>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.4.0</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.4.0</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>2.4.0</version>
        </dependency>

        <dependency>
            <groupId>com.tellyo.stm</groupId>
            <artifactId>tellyo-stm-core</artifactId>
            <version>0.0.11</version>
        </dependency>

        <!-- Declare the APIs we depend on and need for compilation. All of them 
            are provided by JBoss AS 7 -->

        <!-- Import the EJB API, we use provided scope as the API is included in 
            JBoss AS 7 -->
        <dependency>
            <groupId>org.jboss.spec.javax.ejb</groupId>
            <artifactId>jboss-ejb-api_3.2_spec</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Import the CDI API, we use provided scope as the API is included in 
            JBoss AS 7 -->
        <dependency>
            <groupId>javax.enterprise</groupId>
            <artifactId>cdi-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Import the JPA API, we use provided scope as the API is included in 
            JBoss AS 7 -->
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.1-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- JSR-303 (Bean Validation) Implementation -->
        <!-- Provides portable constraints such as @Email -->
        <!-- Hibernate Validator is shipped in JBoss AS 7 -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Test scope dependencies -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
            <version>4.11</version>
        </dependency>

        <!-- Optional, but highly recommended -->
        <!-- Arquillian allows you to test enterprise code such as EJBs and Transactional(JTA) 
            JPA from JUnit/TestNG -->
        <dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
            <version>${arq.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.arquillian.protocol</groupId>
            <artifactId>arquillian-protocol-servlet</artifactId>
            <version>${arq.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.arquillian.container</groupId>
            <artifactId>arquillian-container-spi</artifactId>
            <version>${arq.version}</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.arquillian.core</groupId>
            <artifactId>arquillian-core-api</artifactId>
            <version>1.1.5.Final</version>
        </dependency>


        <dependency>
            <groupId>org.jboss.arquillian.test</groupId>
            <artifactId>arquillian-test-spi</artifactId>
            <version>${arq.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.twitter4j</groupId>
            <artifactId>twitter4j-core</artifactId>
            <version>4.0.1</version>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.spec.javax.json</groupId>
            <artifactId>jboss-json-api_1.0_spec</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.3.3</version>
        </dependency>

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.4</version>
        </dependency>

        <dependency>
            <groupId>com.restfb</groupId>
            <artifactId>restfb</artifactId>
            <version>1.6.14</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.spec.javax.jms</groupId>
            <artifactId>jboss-jms-api_2.0_spec</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.google.api-client</groupId>
            <artifactId>google-api-client</artifactId>
            <version>1.18.0-rc</version>
        </dependency>

        <!-- jclouds dependencies -->
        <dependency>
            <groupId>org.apache.jclouds.driver</groupId>
            <artifactId>jclouds-slf4j</artifactId>
            <version>${jclouds.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.jclouds.driver</groupId>
            <artifactId>jclouds-sshj</artifactId>
            <version>${jclouds.version}</version>
        </dependency>
        <!-- Rackspace UK dependencies -->
        <dependency>
            <groupId>org.apache.jclouds.provider</groupId>
            <artifactId>rackspace-cloudservers-uk</artifactId>
            <version>${jclouds.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.jclouds.labs</groupId>
            <artifactId>rackspace-cloudfiles-uk</artifactId>
            <version>${jclouds.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.jclouds.provider</groupId>
            <artifactId>rackspace-cloudblockstorage-uk</artifactId>
            <version>${jclouds.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.jclouds.provider</groupId>
            <artifactId>rackspace-clouddatabases-uk</artifactId>
            <version>${jclouds.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.jclouds.labs</groupId>
            <artifactId>rackspace-cloudqueues-uk</artifactId>
            <version>${jclouds.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.jclouds.labs</groupId>
            <artifactId>rackspace-autoscale-us</artifactId>
            <version>${jclouds.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.jclouds.provider</groupId>
            <artifactId>rackspace-cloudloadbalancers-uk</artifactId>
            <version>${jclouds.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.jclouds.provider</groupId>
            <artifactId>rackspace-clouddns-uk</artifactId>
            <version>${jclouds.version}</version>
        </dependency>
        <!-- JDOM -->
        <dependency>
            <groupId>org.jdom</groupId>
            <artifactId>jdom2</artifactId>
            <version>2.0.5</version>
        </dependency>
    </dependencies>

    <build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-ejb-plugin</artifactId>
                <version>${version.ejb.plugin}</version>
                <configuration>
                    <!-- Tell Maven we are using EJB 3.2 -->
                    <ejbVersion>3.2</ejbVersion>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <!-- The default profile skips all tests, though you can tune it to run 
                just unit tests based on a custom pattern -->
            <!-- Seperate profiles are provided for running all tests, including Arquillian 
                tests that execute in the specified container -->
            <id>default</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>${version.surefire.plugin}</version>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>arq-wildfly-remote</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.wildfly</groupId>
                    <artifactId>wildfly-arquillian-container-remote</artifactId>
                    <version>8.1.0.Final</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>

        <profile>
            <id>arq-wildfly-managed</id>
            <dependencies>
                <dependency>
                    <groupId>org.wildfly</groupId>
                    <artifactId>wildfly-arquillian-container-managed</artifactId>
                    <version>8.1.0.Final</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>


    </profiles>

</project>

简单测试.java

package com.tellyo.rtc.test;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(Arquillian.class)
public class SimpleTest {
    @Deployment
    public static JavaArchive createTestArchive() {

        JavaArchive ear = ShrinkWrap.create(JavaArchive.class, "mytest.jar")
                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
        ear.addClasses(SimpleTest.class);

        System.out.println(ear.toString(true));
        return ear;
    }

    @Test
    public void testApplication() {
        Assert.assertNotNull(null);
    }
}

我不太明白的是为什么上面异常中的请求是在 0.0.0.0 启动的。

我可以在服务器日志中看到测试应用程序确实已部署:

2014-08-05 17:00:26,831 INFO  [org.jboss.as.repository] (management-handler-thread - 1) JBAS014900: Content added at location /opt/wildfly/standalone/data/content/f6/1fe7d564c3ef44a17443920a1b8a201787eb19/content

2014-08-05 17:00:26,848 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "test.war" (runtime-name: "test.war")

2014-08-05 17:00:27,236 INFO  [org.jboss.weld.deployer] (MSC service thread 1-1) JBAS016002: Processing weld deployment test.war

2014-08-05 17:00:27,492 INFO  [org.jboss.weld.deployer] (MSC service thread 1-2) JBAS016005: Starting Services for CDI deployment: test.war

2014-08-05 17:00:27,585 INFO  [org.jboss.weld.deployer] (MSC service thread 1-2) JBAS016008: Starting weld service for deployment test.war

2014-08-05 17:00:30,595 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-2) JBAS017534: Registered web context: /test

2014-08-05 17:00:30,812 INFO  [org.jboss.as.server] (management-handler-thread - 1) JBAS018559: Deployed "test.war" (runtime-name : "test.war")

2014-08-05 17:01:14,637 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) JBAS017535: Unregistered web context: /test

2014-08-05 17:01:14,674 INFO  [org.jboss.weld.deployer] (MSC service thread 1-1) JBAS016009: Stopping weld service for deployment test.war

2014-08-05 17:01:14,769 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015877: Stopped deployment test.war (runtime-name: test.war) in 139ms

2014-08-05 17:01:15,008 INFO  [org.jboss.as.repository] (management-handler-thread - 1) JBAS014901: Content removed from location /opt/wildfly/standalone/data/content/f6/1fe7d564c3ef44a17443920a1b8a201787eb19/content

2014-08-05 17:01:15,014 INFO  [org.jboss.as.server] (management-handler-thread - 1) JBAS018558: Undeployed "test.war" (runtime-name: "test.war")

但是,我不知道为什么将它部署为 test.war,即使我在 SimpleTest 类的 ShrinkWrap.create 方法中指定了不同的名称。

日志文件中的另一个可疑之处是:

2014-08-05 16:38:08,561 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-2) JBAS017519: Undertow HTTP listener default listening on /0.0.0.0:7080

为什么没有为 Undertow 分配正确的 IP 地址?这是它应该的方式吗?

任何帮助,将不胜感激!

4

1 回答 1

5

我建议您使用 Arquillian BOM 来管理您的依赖项。我已经使用以下配置执行了您的 Arquillian 测试,并且适用于托管和远程 WildFly。

为方便起见,您可以在此arquillian-wildfly-example GitHub 存储库中找到代码。确保在 POM xml 中激活远程 WidlFly 配置文件(默认情况下托管是活动的),并在arquillian.xml中将 wildfly-remote 容器配置设为默认值 (default="true") 。此外从arquillian.xml中的wildfly 管理的容器配置中删除default="true"

pom.xml

<?xml version="1.0"?>
<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>org.jboss.aerogear</groupId>
    <artifactId>arquillian-wildfly-example</artifactId>
    <packaging>jar</packaging>
    <version>0.0.1</version>

    <licenses>
        <license>
            <name>Apache License, Version 2.0</name>
            <distribution>repo</distribution>
            <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
        </license>
    </licenses>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <version.org.jboss.arquillian>1.1.5.Final</version.org.jboss.arquillian>
        <version.org.wildfly>8.1.0.Final</version.org.wildfly>
        <version.junit>4.11</version.junit>
    </properties>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.17</version>
                </plugin>
                <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>
                                            org.apache.maven.plugins
                                        </groupId>
                                        <artifactId>
                                            maven-dependency-plugin
                                        </artifactId>
                                        <versionRange>
                                            [2.1,)
                                        </versionRange>
                                        <goals>
                                            <goal>unpack</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <dependencyManagement>
        <dependencies>

            <!-- Arquillian BOM (Bill Of Materials). -->
            <dependency>
                <groupId>org.jboss.arquillian</groupId>
                <artifactId>arquillian-bom</artifactId>
                <version>${version.org.jboss.arquillian}</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>

            <!-- JUnit regression testing framework. -->
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>${version.junit}</version>
            </dependency>

        </dependencies>
    </dependencyManagement>

    <profiles>

        <!-- Arquillian WildFly managed profile -->
        <profile>
            <id>arq-wildfly-managed</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.wildfly</groupId>
                    <artifactId>wildfly-arquillian-container-managed</artifactId>
                    <version>${version.org.wildfly}</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
            <build>
                <testResources>
                    <testResource>
                        <directory>src/test/resources</directory>
                    </testResource>
                </testResources>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <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>${version.org.wildfly}</version>
                                            <type>zip</type>
                                            <overWrite>false</overWrite>
                                            <outputDirectory>${project.build.directory}</outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- Arquillian WildFly remote profile -->
        <profile>
            <id>arq-widlfly-remote</id>
            <dependencies>
                <dependency>
                    <groupId>org.wildfly</groupId>
                    <artifactId>wildfly-arquillian-container-remote</artifactId>
                    <version>${version.org.wildfly}</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>

    </profiles>

    <dependencies>

        <!-- JUnit regression testing framework. -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
        </dependency>

        <!-- JUnit Container Implementation for the Arquillian Project -->
        <dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.arquillian.protocol</groupId>
            <artifactId>arquillian-protocol-servlet</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

</project>

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">

        <!-- Sets the protocol which is how Arquillian talks and executes the tests inside the container -->
        <defaultProtocol type="Servlet 3.0" />

        <!-- Configuration to be used when the WidlFly remote profile is active -->
        <container qualifier="widlfly-remote">
            <configuration>
                <property name="managementAddress">X.X.X.X</property>
                <property name="managementPort">9990</property>
                <property name="username">admin</property>
                <property name="password">admin</property>
            </configuration>
        </container>

        <!-- Configuration to be used when the WildFly managed profile is active -->
        <container qualifier="widlfly-managed" default="true">
            <configuration>
                <property name="jbossHome">${jbossHome:target/wildfly-8.1.0.Final}</property>
            </configuration>
        </container>

    </arquillian>
于 2014-08-07T09:10:39.407 回答