如何使用JUnit轻松测试EJB [英] How to easily test a EJB using JUnit

查看:164
本文介绍了如何使用JUnit轻松测试EJB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用JUnit测试企业Java bean(应该稍后部署到JBoss服务器)。但是我不知道如何使用这些工具。由于缺少EJB容器,并且导致缺少所需的注入,平原JUnit失败。



Googling一点点导致我进入一个名为JBoss EJB嵌入式容器的库,但似乎它已经过时了。我也找不到任何源文件或二进制文件下载。



所以请帮忙,什么是简单的方法来本地生成一个能够运行的mock容器企业bean的JUnit测试?



问候

解决方案

我建议您查看 Arquillian


Arquillian使您可以在远程或嵌入式容器中测试业务逻辑。或者,它可以将存档部署到容器,以便测试可以作为远程客户端进行交互。


仍然有一个生活嵌入式JBoss AS Seam Framework 还提供了一个带有嵌入式JBoss的测试环境,以运行应用程序的组件测试(带有TestNG)。 p>

I want to test an enterprise java bean (that should later be deployed to a JBoss server) using JUnit. But I don't exactly know how tools I can use for this. Plain JUnit fails because of the missing EJB Container and the caused lack of needed injections.

Googling a bit around lead me to a library called JBoss EJB embedded container, but it seems that it is obsolete. I also couldn't find any source or binary files to download.

So please help, what's a easy way to locally generate a "mock" container that is able to run the JUnit tests on the enterprise beans?

Greetings Ben

解决方案

I suggest you to have a look at Arquillian:

Arquillian enables you to test your business logic in a remote or embedded container. Alternatively, it can deploy an archive to the container so the test can interact as a remote client.

There is still a living Embedded JBoss AS. The Seam Framework also provides a testing environment with an embedded JBoss to run component tests (with TestNG) of your application.

这篇关于如何使用JUnit轻松测试EJB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆