如何使用arquillian使用@webserviceref注释测试EJB调用Web服务

时间:2015-11-12 16:36:32

标签: jboss-arquillian

我尝试使用arquillian通过@WebServiceRef注释使用webservice测试EJB的一个方法

在我@Deployment装饰的方法中,我声明了资源

 @Deployment
    public static JavaArchive createDeployment() {
        return ShrinkWrap.create(JavaArchive.class)
                .addPackages(true, ....  PortType.class.getPackage())
                .addAsResource("test-my.wsdl","my.wsdl")
                .addAsManifestResource("META-INF/beans.xml", "beans.xml").addAsManifestResource("META-INF/test-persistence.xml", "persistence.xml");

    }

然后我将bean编码为以下

@Stateless
@LocalBean
public class WSBean {

    @WebServiceRef(wsdlLocation = "/my.wsdl")
    PortType portType;

    public void test() throws Exception{
        portType.lireAdresseClient(null, null);
    }
}

和测试

@RunWith(Arquillian.class)
public class WSintegrationTest extends DefaultServicesIntegrationTest {

@Deployment
....

    @Inject
    private WSBean wsBean;

    @Test
    public void testAppel() throws Exception {
        System.out.println("TEST APPEL");
        wsBean.test();
    }
}

我可以用Arquillian做到吗? 我该如何解决?

由于 此致

1 个答案:

答案 0 :(得分:1)

此外,如果您需要,可以查看https://github.com/javaee-samples/javaee7-samples/tree/master/jaxws,您将找到JAXWS及其Arquillian测试的示例。

相关问题