如何使用Arquillian远程容器配置Tomcat 7用户。

时间:2014-08-04 13:15:45

标签: java tomcat testing gradle jboss-arquillian

我正在尝试在arquillian tomcat 7远程容器中配置并运行简单的Hello World测试,但我得到了

ConfigurationException: Unable to connect to Tomcat manager. The server command (/text /deploy?path=%2Ftest) failed with responseCode (401) and responseMessage (Unauthorized).

我知道我应该在arquillian.xml中配置它,所以我按照以下方式进行了配置:

 <?xml version="1.0"?>
 <arquillian
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://jboss.org/schema/arquillian"
    xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">

<container qualifier="tomcat" default="true">
    <configuration>
        <property name="jmxPort">8089</property>
        <property name="host">localhost</property>
        <property name="port">8080</property>
        <property name="user">arquillian</property>
        <property name="pass">arquillian</property>
    </configuration>
</container>

并将其放在./src/test/resources/arquillian.xml

当然我在tomcat-users.xml中指定了用户:

 <role rolename="manager-gui"/>
 <role rolename="manager-script"/>
 <role rolename="manager-jmx"/>
 <role rolename="manager-status"/>
 <role rolename="admin-gui"/>
 <role rolename="admin-script"/>

 <user username="admin" password="admin" roles="manager-gui, manager-script, manager-jmx, manager-status, admin-gui, admin-script"/>
 <user username="arquillian" password="arquillian" roles="manager-gui, manager-script, manager-jmx, manager-status, admin-gui, admin-script"/>
 <user username="null" password="null" roles="manager-gui, manager-script, manager-jmx, manager-status, admin-gui, admin-script"/>
 </tomcat-users>

我使用的gradle构建脚本几乎是默认的:

dependencies {  
 compile group: 'javax', name: 'javaee-api', version: libraryVersions.javaee
 testCompile group: 'junit', name: 'junit', version: libraryVersions.junit
 testCompile group: 'org.jboss.arquillian.junit', name: 'arquillian-junit-container', version: libraryVersions.arquillian
 testCompile group: 'org.jboss.arquillian.protocol', name: 'arquillian-protocol-servlet', version: libraryVersions.arquillian
 testCompile group: 'org.jboss.shrinkwrap.resolver', name: 'shrinkwrap-resolver-gradle-depchain', version: libraryVersions.shrinkWrapResolverGradle
 testCompile "org.jboss.arquillian.container:arquillian-tomcat-remote-7:1.0.0.CR7"
 testCompile(group:'org.jboss.arquillian.container',name:'arquillian-container-test-api',version:'1.1.4.Final')

}  

sourceSets {
 main {
     compileClasspath = configurations.compile + configurations.compile
 }
 test {
     resources {
         srcDir "src/test/resources"
     }
 }
}

 task inContainerTest(type: Test) {
 } 

我做错了什么?

0 个答案:

没有答案