2016-03-15 49 views
1

我正在嘗試Arquallian,並遇到一些麻煩。Arquillian Jersey ClientHandlerException

我簡單的測試代碼,

@RunWith(Arquillian.class) 
public class Tests { 

@Deployment 
public static Archive<?> createDeployment() { 
    return ShrinkWrap.create(WebArchive.class, "test.war") 
      .addClass(Query.class) 
      .addAsResource("test-persistence.xml", "META-INF/persistence.xml") 
      .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); 
    } 


    @Test 
    public void testMeth() { 

    } 
} 

我獲得以下錯誤信息:

com.sun.jersey.api.client.ClientHandlerException: com.sun.jersey.api.client.ClientHandlerException: A message body writer for Java type, class com.sun.jersey.multipart.FormDataMultiPart,and MIME media type, multipart/form-data, was not found 
Caused by: com.sun.jersey.api.client.ClientHandlerException: A message body writer for Java type, class com.sun.jersey.multipart.FormDataMultiPart, and MIME media type, multipart/form-data, was not found 
在萬無一失的報告

在下面寫

org.jboss.arquillian.container.test.impl.client.deployment.ValidationException:DeploymentScenario contains a target (_DEFAULT_) not matching any defined Container in the registry. 
Please include at least 1 Deployable Container on your Classpath. 

項目的pom.xml

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 

    <modelVersion>4.0.0</modelVersion> 
    <groupId>eu.enda.backend</groupId> 
    <artifactId>enda-jpa-library</artifactId> 
    <version>0.2</version> 
    <packaging>jar</packaging> 

    <name>enda-jpa-api</name> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>2.3.2</version> 
       <configuration> 
        <source>1.8</source> 
        <target>1.8</target> 
       </configuration> 
      </plugin> 
      <plugin> 
       <artifactId>maven-surefire-plugin</artifactId> 
       <version>2.19.1</version> 
      </plugin> 
     </plugins> 
    </build> 

    <dependencies> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.8.1</version> 
      <scope>test</scope> 
     </dependency> 

     <dependency> 
      <groupId>org.jboss.arquillian.junit</groupId> 
      <artifactId>arquillian-junit-container</artifactId> 
      <!--<version>1.1.11.Final</version>--> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.eclipse.persistence</groupId> 
      <artifactId>eclipselink</artifactId> 
      <version>2.6.2</version> 
      <scope>test</scope> 
      <type>jar</type> 
     </dependency> 
     <dependency> 
      <groupId>javax.transaction</groupId> 
      <artifactId>javax.transaction-api</artifactId> 
      <version>1.2</version> 
      <scope>test</scope> 
      <type>jar</type> 
     </dependency> 
     <dependency> 
      <groupId>org.jboss.spec.javax.ejb</groupId> 
      <artifactId>jboss-ejb-api_3.1_spec</artifactId> 
      <version>1.0.2.Final</version> 
      <scope>test</scope> 
      <type>jar</type> 
     </dependency> 

     <dependency> 
      <groupId>org.eclipse.persistence</groupId> 
      <artifactId>eclipselink</artifactId> 
      <version>2.6.2</version> 
     </dependency> 
     <dependency> 
      <groupId>org.eclipse.persistence</groupId> 
      <artifactId>javax.persistence</artifactId> 
      <version>2.1.1</version> 
      <type>jar</type> 
     </dependency> 
     <dependency> 
      <groupId>javax.ejb</groupId> 
      <artifactId>javax.ejb-api</artifactId> 
      <version>3.2</version> 
     </dependency> 
     <dependency> 
      <groupId>javax.inject</groupId> 
      <artifactId>javax.inject</artifactId> 
      <version>1</version> 
      <type>jar</type> 
     </dependency> 
     <dependency> 
      <groupId>eu.enda</groupId> 
      <artifactId>commons</artifactId> 
      <version>0.2</version> 
     </dependency> 
     <dependency> 
      <groupId>eu.enda.vaadin</groupId> 
      <artifactId>enda-vaadin-library</artifactId> 
      <version>0.4.1.1</version> 
     </dependency> 
     <dependency> 
      <groupId>org.glassfish</groupId> 
      <artifactId>javax.json</artifactId> 
      <version>1.0.4</version> 
     </dependency>   
     <dependency> 
      <groupId>eu.enda.querytool.backend</groupId> 
      <artifactId>mavenproject1</artifactId> 
      <version>0.1</version>    
     </dependency> 
    </dependencies> 
    <dependencyManagement> 
     <dependencies> 
      <dependency> 
       <groupId>org.jboss.arquillian</groupId> 
       <artifactId>arquillian-bom</artifactId> 
       <version>1.0.0.Final</version> 
       <scope>import</scope> 
       <type>pom</type> 
      </dependency> 
     </dependencies> 
    </dependencyManagement> 
    <profiles> 
     <profile> 
      <id>arquillian-glassfish-remote</id> 
      <dependencies> 
       <dependency> 
        <groupId>org.jboss.spec</groupId> 
        <artifactId>jboss-javaee-7.0</artifactId> 
        <version>1.0.3.Final</version> 
        <type>pom</type> 
        <scope>provided</scope> 
       </dependency> 
       <dependency> 
        <groupId>org.jboss.weld</groupId> 
        <artifactId>weld-api</artifactId> 
        <version>2.3.Final</version> 
        <scope>test</scope> 
       </dependency> 
       <dependency> 
        <groupId>org.jboss.arquillian.container</groupId> 
        <artifactId>arquillian-glassfish-remote-3.1</artifactId> 
        <version>1.0.0.CR4</version> 
        <scope>test</scope> 
       </dependency> 
      </dependencies> 
     </profile> 
    </profiles> 
</project> 

雖然我嘗試運行測試GlassfishServer 4.1正在運行。

我有一個測試項目arquillian與幾乎相同的設置和它工作正常我檢查,如果我忘記了東西,但沒有遺漏。 maven配置文件已正確設置。 test-persistence.xmlsrc/test/resources之下。

回答

0

在我的版本的Arquilian文檔(法語)的,以測試遠程GlassFish服務器pom.xml中看起來不同,因爲這裏面除了在GlassFish中遠程配置文件:

<dependency> 
    <groupId>com.sun.jersey</groupId> 
    <artifactId>jersey-bundle</artifactId> 
    <version>1.19.1</version> 
    <scope>test</scope> 
    <exclusions> 
    <exclusion> 
     <groupId>javax.ws.rs</groupId> 
     <artifactId>jsr311-api</artifactId> 
    </exclusion> 
    </exclusions> 
</dependency> 
<dependency> 
    <groupId>com.sun.jersey.contribs</groupId> 
    <artifactId>jersey-multipart</artifactId> 
    <version>1.18</version> 
    <scope>test</scope> 
</dependency> 

由於文件解釋說, Glassfish適配器需要Jersey Rest來與容器進行通信。

第二個錯誤只是說,由於arquilian未能使用有效容器,因此無法運行測試。 我有確切的錯誤,所以我真的對這個問題的答案感興趣。

更新:正如我經歷了一些其他的答案,似乎澤西multipart和澤西捆綁版本需要是1.10。 Source