Arquillian与托管Tomcat 7

时间:2014-04-15 10:06:45

标签: tomcat7 integration-testing jboss-arquillian

是否有人使用托管Tomcat 7为Aquillian提供工作配置? Arquillian在使用以下行启动Tomcat之后总是失败

Apr 15, 2014 12:04:39 PM org.apache.catalina.startup.Catalina start
Information: Server startup in 1165 ms
Tests run: 4, Failures: 1, Errors: 0, Skipped: 3, Time elapsed: 3.453 sec <<< FAILURE!
arquillianBeforeSuite(net.sweblog.jerseyplayground.simple.HelloResourceIT)  Time elapsed: 3.328 sec  <<< FAILURE!
org.jboss.arquillian.container.spi.client.container.LifecycleException: Could not start container

1 个答案:

答案 0 :(得分:1)

要将托管Tomcat 7与Arquillian一起使用,您需要将原始tomcat-users.xml替换为自定义版本,如下所示:

<tomcat-users>
    <role rolename="manager-gui"/>
    <role rolename="manager-jmx"/>
    <role rolename="manager-script"/>
    <user username="tomcat" password="tomcat" 
          roles="manager-script, manager-jmx, manager-gui"/>
    <user username="masterofdesaster" password="letmein" 
          roles="manager-script"/>
</tomcat-users>

对于设置而言,重要的是倒数第二行,我使用自己的密码定义了用户masterofdesaster

此外,您必须通过arquillian.xml配置Arquillian。我的一个看起来像这样,并使用用户masterofdesaster在我的测试期间执行部署:

<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="tomcat7" default="true">
        <configuration>
            <property name="catalinaHome">/path/to/tomcat7</property>

            <property name="jmxPort">8089</property>
            <property name="bindHttpPort">8080</property>

            <property name="user">masterofdesaster</property>
            <property name="pass">letmein</property>
            <property name="serverConfig">server.xml</property>
        </configuration>
    </container>
</arquillian>