3

私はこのテストを機能させようとしています:

@RunWith(Arquillian.class)
@RunAsClient
public class AnnotatedEchoServletTestCase {
    @Deployment(testable = false)
    public static WebArchive getTestArchive() {
        return ShrinkWrap.create(WebArchive.class, "servlet-test.war").addClass(EchoServlet.class);
    }

    @ArquillianResource
    URL deploymentUrl;

    @Test
    public void shouldBeAbleToInvokeServletInDeployedWebApp() throws Exception {
        String requestUrl = deploymentUrl + EchoServlet.URL_PATTERN.substring(1) + "?" + EchoServlet.MESSAGE_PARAM + "=hello";
        String body = StreamReaderUtil.readAllAndClose(new URL(requestUrl).openStream());
        Assert.assertEquals("Verify that the servlet was deployed and returns expected result", "hello", body);
    }
}

ただし、次のエラーが発生します。

Provider for type class java.net.URL returned a null value

@ArquillianResource URLコードからを削除すると、テストはエラーなしでパスします。

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

    <container qualifier="jbossas-managed" default="true">
        <configuration>
            <!-- If you want to use an existing JBoss AS installation, change the value of this property to that path -->
            <!-- If you've already set the JBOSS_HOME environment variable, you can remove this configuration block -->
            <property name="jbossHome">target/jboss-as-7.1.1.Final</property>
            <property name="outputToConsole">true</property>
        </configuration>
    </container>

</arquillian>
4

0 に答える 0