2016-05-29 75 views
0

我嘗試使用Arquillian和WildFly 8.1.0 Final版進行測試。作爲測試容器的服務器啓動,bean被加載,但測試(即使是最簡單的)也不會通過。Arquillian with Wildfly

這是控制檯日誌:

ERROR [io.undertow.request] UT005023: Exception handling request to /test/ArquillianServletRunner: java.lang.NoSuchMethodError: org.jboss.arquillian.test.spi.TestResult.setEnd(J)V 
at org.jboss.arquillian.junit.container.JUnitTestRunner.execute(JUnitTestRunner.java:84) [arquillian-junit.jar:] 
at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.executeTest(ServletTestRunner.java:160) [arquillian-protocol.jar:] 
at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.execute(ServletTestRunner.java:126) [arquillian-protocol.jar:] 
at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.doGet(ServletTestRunner.java:90) [arquillian-protocol.jar:] 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final] 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final] 
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final] 
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final] 
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final] 
at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78) 
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final] 
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:113) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final] 
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final] 
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final] 
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45) [undertow-core-1.0.15.Final.jar:1.0.15.Final] 
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:61) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final] 
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) [undertow-core-1.0.15.Final.jar:1.0.15.Final] 
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final] 
at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) [undertow-core-1.0.15.Final.jar:1.0.15.Final] 
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final] 
at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61) 
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final] 
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final] 
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:240) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final] 
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final] 
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final] 
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final] 
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:177) [undertow-core-1.0.15.Final.jar:1.0.15.Final] 
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:727) [undertow-core-1.0.15.Final.jar:1.0.15.Final] 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_91] 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_91] 
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_91] 

我的測試:

@RunWith(Arquillian.class) 
public class GeneratorTest { 

public GeneratorTest() { 
} 

@Deployment 
public static Archive<?> createDeployment(){ 
     WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war"); 
     war.addClass(SessionHandler.class) 
     .addClass(Generator.class) 
     .addClass(TestResult.class); 
    return war; 
    } 

@Inject 
SessionHandler sessionHandler; 

@Inject 
Generator Generator; 

@Test 
public void testGenerateValue() { 
    assertTrue(true); 
} 
} 

的pom.xml:

<properties> 
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
</properties> 

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

<dependencies> 
    <dependency> 
     <groupId>org.eclipse.persistence</groupId> 
     <artifactId>eclipselink</artifactId> 
     <version>2.5.2</version> 
    </dependency> 

    <dependency> 
     <groupId>org.eclipse.persistence</groupId> 
     <artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId> 
     <version>2.5.2</version> 
     <scope>provided</scope> 
    </dependency> 

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

    <dependency> 
     <groupId>com.fasterxml.jackson.core</groupId> 
     <artifactId>jackson-databind</artifactId> 
     <version>2.7.4</version> 
    </dependency> 

    <dependency> 
     <groupId>com.fasterxml.jackson.core</groupId> 
     <artifactId>jackson-core</artifactId> 
     <version>2.7.4</version> 
    </dependency> 

    <dependency> 
     <groupId>com.fasterxml.jackson.core</groupId> 
     <artifactId>jackson-annotations</artifactId> 
     <version>2.7.4</version> 
    </dependency> 

    <dependency> 
     <groupId>com.google.guava</groupId> 
     <artifactId>guava</artifactId> 
     <version>19.0</version> 
    </dependency> 

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

    <dependency> 
     <groupId>org.wildfly</groupId> 
     <artifactId>wildfly-arquillian-container-embedded</artifactId> 
     <version>8.1.0.Final</version> 
    </dependency> 

    <dependency> 
     <groupId>org.wildfly</groupId> 
     <artifactId>wildfly-embedded</artifactId> 
     <version>8.1.0.Final</version> 
    </dependency> 

    <dependency> 
     <groupId>org.jboss.arquillian.core</groupId> 
     <artifactId>arquillian-core-impl-base</artifactId> 
     <version>1.1.11.Final</version> 
     <scope>test</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.jboss.arquillian.junit</groupId> 
     <artifactId>arquillian-junit-container</artifactId> 
     <version>1.1.3.Final</version> 
     <scope>test</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.jboss.spec</groupId> 
     <artifactId>jboss-javaee-6.0</artifactId> 
     <version>1.0.0.Final</version> 
     <type>pom</type> 
     <scope>provided</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.jboss.arquillian.core</groupId> 
     <artifactId>arquillian-core-api</artifactId> 
     <version>1.1.4.Final</version> 
     <scope>test</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.jboss.arquillian.extension</groupId> 
     <artifactId>arquillian-drone-bom</artifactId> 
     <type>pom</type> 
     <version>1.1.0.Final</version> 
    </dependency> 

    <dependency> 
     <groupId>org.jboss.arquillian.test</groupId> 
     <artifactId>arquillian-test-impl-base</artifactId> 
     <version>1.1.11.Final</version> 
    </dependency> 

    <dependency> 
     <groupId>org.jboss.arquillian.test</groupId> 
     <artifactId>arquillian-test-spi</artifactId> 
     <version>1.1.11.Final</version> 
    </dependency> 

    <dependency> 
    <groupId>org.jboss.arquillian.container</groupId> 
    <artifactId>arquillian-container-spi</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.jboss.arquillian.container</groupId> 
     <artifactId>arquillian-container-test-spi</artifactId> 
    </dependency> 

</dependencies> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>3.1</version> 
      <configuration> 
       <source>1.7</source> 
       <target>1.7</target> 
       <compilerArguments> 
        <endorseddirs>${endorsed.dir}</endorseddirs> 
       </compilerArguments> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.3</version> 
      <configuration> 
       <failOnMissingWebXml>false</failOnMissingWebXml> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-dependency-plugin</artifactId> 
      <version>2.6</version> 
      <executions> 
       <execution> 
        <phase>validate</phase> 
        <goals> 
         <goal>copy</goal> 
        </goals> 
        <configuration> 
         <outputDirectory>${endorsed.dir}</outputDirectory> 
         <silent>true</silent> 
         <artifactItems> 
          <artifactItem> 
           <groupId>javax</groupId> 
           <artifactId>javaee-endorsed-api</artifactId> 
           <version>7.0</version> 
           <type>jar</type> 
          </artifactItem> 
         </artifactItems> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin>--> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-dependency-plugin</artifactId> 
      <version>2.8</version> 
      <executions> 
       <execution> 
        <id>unpack</id> 
         <phase>process-test-classes</phase> 
         <goals> 
          <goal>unpack</goal> 
         </goals> 
         <configuration> 
          <artifactItems> 
           <artifactItem> 
            <groupId>org.wildfly</groupId> 
            <artifactId>wildfly-dist</artifactId> 
            <version>8.1.0.Final</version> 
            <type>zip</type> 
            <overWrite>false</overWrite> 
            <outputDirectory>target</outputDirectory> 
           </artifactItem> 
          </artifactItems> 
         </configuration> 
        </execution> 
       </executions> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <version>2.17</version> 
      <configuration> 
       <!-- Fork every test because it will launch a separate AS instance --> 
       <forkMode>always</forkMode> 
       <systemPropertyVariables> 
        <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> 
         <!-- the maven dependency plugin will have already downloaded the server on /target --> 
        <jboss.home>${project.basedir}/target/wildfly-8.1.0.Final</jboss.home> 
        <module.path>${project.basedir}/target/wildfly-8.1.0.Final/modules</module.path> 
       </systemPropertyVariables> 
       <redirectTestOutputToFile>false</redirectTestOutputToFile> 
       <enableAssertions>true</enableAssertions> 
      </configuration> 
     </plugin>   
    </plugins> 
</build> 

<profiles> 
      <profile> 
         <id>arquillian-jbossas-managed</id> 
         <dependencies> 
          <dependency> 
            <groupId>org.jboss.arquillian.junit</groupId> 
            <artifactId>arquillian-junit-container</artifactId> 
            <scope>test</scope> 
          </dependency> 
          <dependency> 
            <groupId>org.jboss.spec</groupId> 
            <artifactId>jboss-javaee-6.0</artifactId> 
            <version>1.0.0.Final</version> 
            <type>pom</type> 
            <scope>provided</scope> 
          </dependency> 
          <dependency> 
            <groupId>org.jboss.as</groupId> 
            <artifactId>jboss-as-arquillian-container-managed</artifactId> 
            <version>7.1.1.Final</version> 
            <scope>test</scope> 
           </dependency> 
           <dependency> 
            <groupId>org.jboss.arquillian.protocol</groupId> 
            <artifactId>arquillian-protocol-servlet</artifactId> 
            <scope>test</scope> 
           </dependency> 
        </dependencies> 
      </profile> 

回答

1

你的依賴是所有的地方。

  • 您的pom文件正在利用arquillian 1.0.4,1.1.3,1.1.4,1.1.11。請僅使用一個,最好是1.1.11作爲更新,更多的錯誤修復。
  • Wildfly 8是EE7忽略現有評論
+0

WildFly 8是一個Java EE 7容器。 –

+0

@ JamesR.Perkins是嗎?認爲發生在9,我的壞:-) –

+0

是的:) WildFly 8是第一個Java EE 7認證的容器。 9和10都是Java EE 7。 –

相關問題