@ArquillianResource returns空URL

@ArquillianResource returns null URL

我正在尝试测试一个非常简单的 REST Web 服务:


我的测试class使用了@ArquillianResource注解:

public class ResourceTest extends Arquillian {

  @ArquillianResource URL baseURL;

  @Deployment
  public static WebArchive create() {
    return ShrinkWrap.create(WebArchive.class)
                     .addClasses(Resource.class, Application.class);
  }

  @Test public void get() { /* test Resource here */ }
}

我试过@Deployment(testable = false)@Deployment(Testable = true),我也试过在测试方法中添加@RunAsClient注解。

但我总是遇到同样的异常:

java.lang.RuntimeException: Could not lookup value for field java.net.URL com.assylias.test.arquillian.ResourceTest.baseURL

at org.jboss.arquillian.test.impl.enricher.resource.ArquillianResourceTestEnricher.enrich(ArquillianResourceTestEnricher.java:71)
at org.jboss.arquillian.test.impl.TestInstanceEnricher.enrich(TestInstanceEnricher.java:55)
at org.jboss.arquillian.container.test.impl.ClientTestInstanceEnricher.enrich(ClientTestInstanceEnricher.java:51)

[...]

Caused by: java.lang.RuntimeException: Provider for type class java.net.URL returned a null value: org.jboss.arquillian.container.test.impl.enricher.resource.URLResourceProvider@babafc2
at org.jboss.arquillian.test.impl.enricher.resource.ArquillianResourceTestEnricher.lookup(ArquillianResourceTestEnricher.java:133)
at org.jboss.arquillian.test.impl.enricher.resource.ArquillianResourceTestEnricher.enrich(ArquillianResourceTestEnricher.java:67)

供参考,pom.xml:

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.jboss.arquillian</groupId>
      <artifactId>arquillian-bom</artifactId>
      <version>1.1.11.Final</version>
      <scope>import</scope>
      <type>pom</type>
    </dependency>
  </dependencies>
</dependencyManagement>

<dependencies>
  <dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-api</artifactId>
    <version>7.0</version>
    <scope>provided</scope>
  </dependency>

  <dependency>
    <groupId>org.jboss.arquillian.container</groupId>
    <artifactId>arquillian-weld-ee-embedded-1.1</artifactId>
    <version>1.0.0.CR9</version>
    <scope>test</scope>
  </dependency>
  <dependency>
    <groupId>org.jboss.arquillian.testng</groupId>
    <artifactId>arquillian-testng-container</artifactId>
    <scope>test</scope>
  </dependency>
  <dependency>
    <groupId>org.jboss.weld</groupId>
    <artifactId>weld-core</artifactId>
    <version>2.2.16.Final</version>
    <scope>test</scope>
  </dependency>

  <dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <scope>test</scope>
  </dependency>
</dependencies>

同样的事情适用于:

<dependency>
  <groupId>org.wildfly.arquillian</groupId>
  <artifactId>wildfly-arquillian-container-remote</artifactId>
  <version>2.0.0.Final</version>
  <scope>test</scope>
</dependency>

问题似乎是嵌入式配置文件不支持该功能。