1

I have application with PicketLink included as maven dependency. I have written arquillian test case that does not involve PicketLink in any way, but test is failing because of CDI in picketlink.

@RunWith(Arquillian.class)
public class WebServiceTest {

    @Deployment
    public static WebArchive deployment() {     
        return ShrinkWrap.create(WebArchive.class, "test.war")
                .addAsManifestResource(new File("test/beans.xml"));
    }

    @Test
    public void testMath() {
        Assert.assertEquals(2, 1+1);
    }
}

When I run JUnit test, i get this error:

Unsatisfied dependencies for type [DefaultLoginCredentials] with qualifiers [@Default] 
at injection point [[field] @Inject private org.picketlink.internal.AbstractIdentity.loginCredential]

Which is wierd, considering I'm not including picketlink into WebArchive at all. I tought arquillian should isolate test case from the rest of my application. Moreover, I'm excluding picketlink in beans.xml that I'm including into WebArchive:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
    version="1.1" bean-discovery-mode="all">

    <scan>
        <exclude name="org.picketlink.**" />
    </scan>
</beans>

Similar problem was also reported on developer.jboss, but without any resolution. Any help would be appreciated.

4

1 回答 1

0

替换焊接依赖

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

有管理的野蝇

<dependency>
    <groupId>org.wildfly</groupId>
    <artifactId>wildfly-arquillian-container-managed</artifactId>
    <version>${wildfly.version}</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.jboss.arquillian.protocol</groupId>
    <artifactId>arquillian-protocol-servlet</artifactId>
    <scope>test</scope>
</dependency>

解决了我的问题。请注意,您必须添加JBOSS_HOME环境。变量,当使用托管 Wildfly 时。可以在 IDE 中添加环境变量来更改运行配置。

于 2015-01-09T22:52:42.127 回答