Arquillian:得到302(找到)

时间:2016-11-22 08:22:24

标签: java spring junit wildfly jboss-arquillian

我正在尝试使用JUnit和Arquillian在我的Web应用程序中测试服务但是当我启动测试时,控制台显示以下错误:

  

java.lang.IllegalStateException: Error launching test at http://127.0.0.1:8080/avisoLegalTest/ArquillianServletRunner?outputMode=serializedObject&className=es.dia.altatienda.service.AvisoLegalServiceTest&methodName=findActivo&cmd=event. Got 302 (Found)

我的代码:

JUnit测试:

@RunWith(Arquillian.class)
@SpringWebConfiguration
public class AvisoLegalServiceTest {

    @Autowired
    AvisoLegalService avisoLegalService;

    /**
     * <p>
     * Creates the test deployment.
     * </p>
     *
     * @return the test deployment
     */
    @Deployment
    @OverProtocol("Servlet 3.0")
    public static WebArchive createTestArchive() {
    System.setProperty(
        MavenSettingsBuilder.ALT_GLOBAL_SETTINGS_XML_LOCATION,
        "C:\\DEVELOPMENT_ENV\\TOOLS\\MAVEN\\apache-maven-3.3.9\\conf\\settings.xml");
    System.setProperty(MavenSettingsBuilder.ALT_USER_SETTINGS_XML_LOCATION,
        "C:\\DEVELOPMENT_ENV\\TOOLS\\MAVEN\\apache-maven-3.3.9\\conf\\settings.xml");
    return Deployments.createDeployment();
    }

    @Test
    public void findActivo() {
    try {
        AvisoLegal avisoLegal = avisoLegalService.findActivo();
        assertNotNull(avisoLegal);
    } catch (IOException e) {
        assertFalse(e.getMessage(), Boolean.FALSE);
    }
    }
}

我的arquillian.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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">

    <defaultProtocol type="Servlet 3.0"/>

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

        <protocol type="Servlet 3.0">
            <property name="host">127.0.0.1</property>
            <property name="port">8080</property>
        </protocol>
    </container>
</arquillian>

我的pom依赖项:

<dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
            <version>1.1.11.Final</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.core</groupId>
            <artifactId>arquillian-core-api</artifactId>
            <version>1.1.11.Final</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.extension</groupId>
            <artifactId>arquillian-service-deployer-spring-3</artifactId>
            <version>1.0.0.Beta3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.extension</groupId>
            <artifactId>arquillian-service-integration-spring-javaconfig</artifactId>
            <version>1.0.0.Beta3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wildfly</groupId>
            <artifactId>wildfly-arquillian-container-remote</artifactId>
            <version>8.2.1.Final</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <artifactId>jboss-logging</artifactId>
                    <groupId>org.jboss.logging</groupId>
                </exclusion>
            </exclusions>
        </dependency>       
        <dependency>
            <groupId>org.wildfly</groupId>
            <artifactId>wildfly-server</artifactId>
            <version>8.2.1.Final</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <artifactId>jboss-logging</artifactId>
                    <groupId>org.jboss.logging</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
            <version>2.11.0</version>
            <scope>test</scope>
        </dependency>   
        <dependency>
            <groupId>org.jboss.arquillian.extension</groupId>
            <artifactId>arquillian-service-integration-spring-inject</artifactId>
            <version>1.0.0.Beta3</version>
        </dependency>

我需要使用Arquillian测试服务,因为我的Wildfly服务器上有activeMQ配置(队列)。

我的项目使用:Spring 4.1.4.RELEASE(基于Java的配置),Java 1.8和Wildfly 10.1.0。

有关这方面的任何想法都可能发生吗?提前致谢。

0 个答案:

没有答案